/* ============================================================
   components.css — nav, buttons, cards, lightbox, meta, pager, figures
   ============================================================ */

/* ---------- Nav ---------- */
.nav {
  position: relative;
  z-index: 20;
  height: var(--nav-h);
  padding: 0 var(--gutter);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-5);
}
.nav.is-hidden { visibility: hidden; }

.wordmark {
  font-size: var(--t-2);
  line-height: 1;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.wordmark__first { font-weight: 700; color: var(--black); }
.wordmark__last { font-weight: 700; color: var(--gray); }

.tabs {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--s-6);
}
.tab {
  position: relative;
  display: inline-block;
  padding: 10px var(--s-4);
  font-size: var(--t-1);
  line-height: 1;
  font-weight: 500;
  color: var(--gray-text);
  transition: color var(--d-fast) var(--ease-out);
  white-space: nowrap;
}
.tab:hover { color: var(--black); }
.tab.is-active { color: var(--black); font-weight: 600; }
.tabs__ink {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 1px;
  width: 0;
  background: var(--black);
  opacity: 0;
  transition: left 320ms var(--ease-out), width 320ms var(--ease-out), opacity var(--d-fast);
}
.tabs__ink.is-ready { opacity: 1; }

/* ---------- Buttons ---------- */
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 15px 18px;
  border-radius: var(--radius-btn);
  background: var(--black);
  color: var(--white);
  font-size: var(--t-1);
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.005em;
  overflow: hidden;
  isolation: isolate;
  transition: background-color var(--d-fast) var(--ease-out), transform var(--d-fast) var(--ease-out);
  -webkit-tap-highlight-color: transparent;
}
.btn svg { width: 16px; height: 16px; flex: none; }
/* Optical centring: trim the label box to cap height so the flex
   centre lands on the caps, not on the font's line box. */
.btn__label { display: block; line-height: 1; text-box: trim-both cap alphabetic; }
@supports not (text-box: trim-both cap alphabetic) {
  .btn__label { transform: translateY(-0.08em); }
}
.btn:hover { background: var(--btn-hover); }
.btn:active { transform: translateY(1px); }
.btn::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(105deg,
    transparent 30%,
    rgba(255, 255, 255, 0.10) 44%,
    rgba(255, 255, 255, 0.34) 50%,
    rgba(255, 255, 255, 0.10) 56%,
    transparent 70%);
  transform: translateX(-130%);
  pointer-events: none;
}
.btn:hover::after, .btn:focus-visible::after { animation: shimmer 760ms var(--ease-out) forwards; }
.btn:focus-visible { outline-offset: 4px; }

/* text links (back, pager) */
.textlink {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--t-1);
  font-weight: 500;
  color: var(--gray-text);
  transition: color var(--d-fast) var(--ease-out), transform var(--d-base) var(--ease-out);
}
.textlink svg { width: 12px; height: 12px; flex: none; transition: transform var(--d-base) var(--spring-soft); }
.textlink:hover { color: var(--black); }
.textlink:hover .chev-left { transform: translateX(-3px); }
.textlink:hover .chev-right { transform: translateX(3px); }

/* ---------- Cards (Projects two-over-three, Fun Zone 2×2) ---------- */
.stage {
  position: relative;
  min-height: calc(100dvh - var(--nav-h));
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s-5) var(--gutter) var(--s-8);
}
.cards { display: flex; flex-direction: column; gap: var(--card-row-gap); width: 100%; }
.cards__row { display: flex; justify-content: center; gap: var(--card-gap); }
.cards[data-rows="2-3"] .cards__row:last-child { gap: var(--card-gap-wide); }

.card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-5);
  width: var(--card-w);
  padding: var(--s-5) var(--s-5) var(--s-6);
  background: var(--white);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  transform: scale(1);
  transition: transform var(--d-spring) var(--spring-bouncy), box-shadow var(--d-base) var(--ease-out);
  will-change: transform;
  -webkit-tap-highlight-color: transparent;
}
.card:hover, .card:focus-visible { transform: scale(var(--card-hover)); box-shadow: var(--card-shadow-hover); }
.card:focus-visible { outline: 2px solid var(--black); outline-offset: 4px; border-radius: var(--radius); }
.card__thumb {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  border-radius: 8px;
  overflow: hidden;
  background: #f2f2f2;
}
.card__thumb img { width: 100%; height: 100%; object-fit: cover; }
.card__thumb::after {
  content: "";
  position: absolute; inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px var(--hairline);
  pointer-events: none;
}
.card__title {
  display: block;
  font-size: var(--t-2);
  font-weight: 500;
  line-height: 1.15;
  text-align: center;
  text-wrap: balance;
  color: var(--black);
  margin-top: auto;
}

/* Mobile: compact nav, card grid */
@media (max-width: 720px) {
  .nav { gap: var(--s-3); }
  .wordmark { font-size: var(--t-1); }
  .tabs { gap: var(--s-1); }
  .tab { padding: 10px 8px; font-size: 15px; }
  .stage { min-height: 0; align-items: start; padding: var(--s-4) var(--margin) var(--s-9); }
  .cards, .cards__row { display: contents; }
  .cards { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-5); }
  .card { width: 100%; padding: var(--s-4) var(--s-4) var(--s-5); gap: var(--s-4); }
  .card__title { font-size: var(--t-1); }
  .card:hover, .card:focus-visible { transform: scale(1.02); }
}
@media (max-width: 400px) {
  .cards { grid-template-columns: 1fr; }
}

/* ---------- Morph layer ---------- */
#morph-layer {
  position: fixed; inset: 0; z-index: 40;
  pointer-events: none;
}
.morph {
  position: absolute;
  overflow: hidden;
  background: #f2f2f2;
  box-shadow: var(--card-shadow);
}
.morph > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

/* ---------- Lightbox ---------- */
.zoomable { cursor: zoom-in; }
.zoomable:focus-visible { outline-offset: -3px; }
.lightbox { position: fixed; inset: 0; z-index: 60; }
.lightbox__backdrop { position: absolute; inset: 0; background: rgba(255, 255, 255, 0.94); cursor: zoom-out; }
.lightbox__img {
  position: absolute;
  object-fit: cover;
  cursor: zoom-out;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 32px 64px -24px rgba(0, 0, 0, 0.35);
  background: #f2f2f2;
}
.lightbox__close {
  position: absolute;
  top: var(--s-5);
  right: var(--s-5);
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border-radius: 50%;
  color: var(--gray-text);
  background: transparent;
  transition: color var(--d-fast) var(--ease-out), background-color var(--d-fast) var(--ease-out);
}
.lightbox__close svg { width: 18px; height: 18px; }
.lightbox__close:hover { color: var(--black); background: rgba(36, 36, 36, 0.06); }
.lightbox__close:focus-visible { outline-offset: 2px; border-radius: 50%; }
@media (max-width: 720px) { .lightbox__close { top: var(--s-3); right: var(--s-3); } }

/* ---------- Meta list ---------- */
.meta { list-style: none; padding: 0; margin-top: var(--s-3); color: var(--gray-text); font-size: var(--t-1); line-height: 1.45; }
.meta li { max-width: 30ch; }

/* ---------- Figures ---------- */
.figure-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-5);
  margin: var(--s-6) 0 var(--s-7);
  max-width: min(100%, 1040px);
}
.figure-pair figure { max-width: none; }
.figure-pair img {
  width: 100%;
  height: auto;
  object-fit: cover;
  object-position: top left;
  border-radius: 12px;
  border: 1px solid var(--hairline);
  background: #fff;
}
.figure-pair figcaption { margin-top: var(--s-2); font-size: var(--t-0); color: var(--gray-text); }
@media (max-width: 720px) { .figure-pair { grid-template-columns: 1fr; } }

/* ---------- Pager ---------- */
.pager {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--s-5);
  margin-top: var(--s-9);
  padding-bottom: var(--s-9);
  max-width: none;
}
.pager .textlink { font-size: var(--t-1); }
.pager__next { margin-left: auto; text-align: right; }

/* ---------- Not found ---------- */
.notfound { padding: var(--s-8) var(--gutter) var(--s-9); }
.notfound h1 { font-size: var(--t-6); margin-bottom: var(--s-4); }
