/* Typography utility classes — the only 4 sizes and 2 colors in the system.
   See "UX & Design System Guidelines.md" before adding anything here. */

.text-hero {
  font-size: var(--font-size-hero);
  font-weight: var(--font-weight-light);
  letter-spacing: var(--letter-spacing-tight);
  line-height: 1.02;
}

.text-project-title {
  font-size: var(--font-size-project-title);
  font-weight: var(--font-weight-light);
  letter-spacing: var(--letter-spacing-tight);
  line-height: 1.05;
}

.text-card-title {
  font-size: var(--font-size-card-title);
  font-weight: var(--font-weight-light);
  letter-spacing: var(--letter-spacing-snug);
  line-height: 1.2;
}

.text-section-title {
  font-size: var(--font-size-section-title);
  font-weight: var(--font-weight-semibold);
}

.text-body {
  font-size: var(--font-size-body);
}

.text-caption {
  font-size: var(--font-size-caption);
}

.text-primary {
  color: var(--color-text-primary);
}

.text-secondary {
  color: var(--color-text-secondary);
}

/* ==========================================================================
   Page transition — every page simply fades in on load. This is the only
   transition between pages; no JS and no view-transition machinery.
   ========================================================================== */

@keyframes page-fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.page {
  animation: page-fade-in 400ms ease both;
}

@media (prefers-reduced-motion: reduce) {
  .page {
    animation: none;
  }
}

/* ==========================================================================
   Page layout — Home
   ========================================================================== */

body {
  background: var(--color-bg-page);
}

.content {
  width: var(--content-width);
  margin: 0 auto;
  padding-block: 40px 96px;
}

/* Nav — simple underline tab bar. On scroll, a soft radial drop-shadow
   fades in beneath it (strong at the center, feathering out toward the
   edges) so page content reads as passing into a slot in the page material. */

.nav {
  display: flex;
  align-items: center;
  gap: 28px;
  width: 100%;
  margin-top: 32px;
  /* left inset matches the corner radius so the first tab starts where the
     curve finishes (and lines up with the cards' own content padding) */
  /* no bottom padding: the active tab's underline sits directly on the bar's
     bottom edge, so it meets the opening's top stroke without a gap or overlap */
  padding: 25px 0 0 var(--card-radius);
  background: var(--color-bg-page);
  position: sticky;
  top: 0;
  z-index: 10;
  transition: padding-top 0.35s cubic-bezier(0.33, 1, 0.68, 1);
}

/* Inverted (concave) bottom corners. Rather than the bar itself rounding off,
   page-colored fills sit just below its left and right edges with a quarter
   circle cut out of each — so the opening reads as the top corners of the
   card passing underneath, curving inward instead of away. */
.nav__opening {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  height: var(--card-radius);
  pointer-events: none;
  /* 1px top edge spanning between the two arcs, so the outline runs
     continuously across the whole opening instead of only on the curves */
  background: linear-gradient(var(--color-card-border), var(--color-card-border))
    center top / calc(100% - var(--card-radius) * 2) 1px no-repeat;
  /* hidden at rest — with nothing scrolled under the bar yet, the arcs would
     otherwise float over empty background above the first card. Kept short so
     the outline is gone before the gap between two cards reaches the bar. */
  opacity: 0;
  transition: opacity 0.15s ease;
}

/* Each corner clips a circle of exactly the card's radius: the circle's own
   1px border draws the arc and its spread shadow fills the rest of the square
   with the page colour. Curving with a real border-radius rather than a
   radial-gradient hard stop keeps the stroke crisp and an even 1px the whole
   way round, so it meets the card's vertical border without stepping. */
.nav__opening i {
  position: absolute;
  top: 0;
  width: var(--card-radius);
  height: var(--card-radius);
  overflow: hidden;
}

.nav__opening i:first-child {
  left: 0;
}

.nav__opening i:last-child {
  right: 0;
}

.nav__opening i::before {
  content: '';
  position: absolute;
  top: 0;
  box-sizing: border-box;
  width: calc(var(--card-radius) * 2);
  height: calc(var(--card-radius) * 2);
  border: 1px solid var(--color-card-border);
  border-radius: 50%;
  box-shadow: 0 0 0 100vmax var(--color-bg-page);
}

/* centre the circle on the square's inner bottom corner, so the quarter that
   falls inside the square is the one curving away from the bar */
.nav__opening i:first-child::before {
  left: 0;
}

.nav__opening i:last-child::before {
  right: 0;
}

/* Kept a modest step up from the resting 25px: the taller stuck state is what
   animates on every scroll direction change, so a smaller delta (and an eased
   curve below) keeps that from reading as a bounce when scrolling up quickly. */
.nav--scrolled {
  padding-top: 44px;
}

.nav::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  height: 140px;
  /* Held wide on purpose: the alpha stays close to its peak well past the
     halfway mark so the darkness spreads across the bar rather than pooling
     in the middle, then falls off quickly enough to reach zero exactly at the
     left/right edges (rx is 50% = half the width) and avoid a visible seam.
     Kept light — roughly half the peak alpha over a taller falloff — so it
     reads as the page material catching light, not as a hard cast shadow. */
  background: radial-gradient(
    ellipse 50% 100% at center top,
    rgba(0, 0, 0, 0.16),
    rgba(0, 0, 0, 0.148) 30%,
    rgba(0, 0, 0, 0.125) 50%,
    rgba(0, 0, 0, 0.08) 70%,
    rgba(0, 0, 0, 0.036) 85%,
    rgba(0, 0, 0, 0.011) 94%,
    transparent 100%
  );
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

/* The opening's outline only reads correctly while a card is actually passing
   under the bar — over bare background there is no card edge to continue, so
   it stays hidden. The shadow is independent, tied to the scrolled state. */
.nav--over-card .nav__opening,
.nav--shadow::after {
  opacity: 1;
}

/* Experiments page: the bar stays flat, with no shadow at any scroll position. */
.nav--no-shadow::after {
  display: none;
}

.nav__item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding-bottom: 8px;
  font-size: var(--font-size-section-title);
  font-weight: var(--font-weight-regular);
  color: var(--color-text-secondary);
  border-bottom: 2px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.nav__icon {
  flex-shrink: 0;
}

.nav__item:not(.nav__item--active):hover {
  color: var(--color-text-primary);
}

.nav__item--active {
  font-weight: var(--font-weight-medium);
  color: var(--color-text-primary);
  border-bottom-color: var(--color-text-primary);
}

/* Card shell — shared by the timeline card, project cards, and the link card */

.card {
  display: flex;
  background: var(--color-card-bg);
  border: 1px solid var(--color-card-border);
  border-radius: var(--card-radius);
  margin-top: var(--card-gap);
  overflow: clip;
}

/* All cards below the timeline share one fixed height */
.card--project,
.card--link {
  height: var(--card-height);
}

.card__content {
  flex: 1;
  min-width: 0;
  padding: var(--card-padding);
  display: flex;
  flex-direction: column;
}

.card__desc {
  margin-top: 4px;
  max-width: 305px;
}

.card__stats {
  display: flex;
  gap: 40px;
  margin-top: auto;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.card__visual {
  flex-shrink: 0;
  width: var(--card-visual-width);
  height: var(--card-height);
  align-self: stretch;
  object-fit: cover;
}

/* Same placeholder convention the project pages use: a bare <div> stands in
   for a preview image that hasn't been added yet and renders as a grey box. */
div.card__visual {
  background: var(--color-placeholder-bg);
}

/* Timeline card */

.card--timeline {
  flex-direction: column;
  padding: var(--card-padding) 0;
}

.timeline-row {
  display: grid;
  grid-template-columns: 100px 260px 1fr;
  gap: 24px;
  padding: 6px var(--card-padding);
}

.timeline-col {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.timeline-desc {
  max-width: 200px;
}

a.card {
  text-decoration: none;
}

/* ==========================================================================
   Page layout — Experiments
   ========================================================================== */

/* Two equal columns; row height is driven by each card's square image + text. */
/* The headline and tab bar sit in their own column here, with the wider grid
   following it, so the column drops its bottom padding and the grid sets the
   gap below the tab bar. */
.content--header {
  padding-bottom: 0;
}

.experiments-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  width: var(--experiments-width);
  margin: 32px auto 96px;
}

.experiment-card {
  display: flex;
  flex-direction: column;
  background: var(--color-card-bg);
  border: 1px solid var(--color-card-border);
  border-radius: var(--card-radius);
  overflow: clip;
}

.experiment-card__image {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
}

.experiment-card__body {
  padding: var(--card-padding);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* ==========================================================================
   Page layout — Project pages
   ========================================================================== */

.project-page {
  padding-block: 40px 96px;
}

.project-header {
  width: var(--project-text-width);
  margin: 0 auto;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
  color: var(--color-text-secondary);
  text-decoration: none;
}

.project-header .text-project-title {
  margin-top: 8px;
}

/* Narrow cards: overview, narrative text, and the closing learnings card.
   All share the base .card shell (white bg, border, radius) but lay out
   as a column instead of the row layout project cards use. */
.card--overview,
.card--text,
.card--learnings {
  flex-direction: column;
  align-items: stretch;
  width: var(--project-text-width);
  height: auto;
  margin-inline: auto;
  padding: var(--card-padding);
}

/* Base rhythm between blocks (sections, paragraphs, lists) */
.card--overview > * + *,
.card--text > * + *,
.card--learnings > * + * {
  margin-top: 32px;
}

/* Tighter gap specifically between a header and the body text right after it */
.card--text > .text-section-title + *,
.card--learnings > .text-section-title + * {
  margin-top: 16px;
}

.project-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.project-section p + p {
  margin-top: 16px;
}

.text-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-left: 20px;
  list-style: disc;
}

/* Wide cards: media galleries. Support a white and a black variant. */
.card--media {
  flex-direction: column;
  align-items: center;
  width: var(--project-media-width);
  height: auto;
  margin-inline: auto;
  padding: var(--card-padding);
  gap: 16px;
}

.card--media-dark {
  background: var(--color-card-bg-dark);
  border-color: var(--color-card-border-dark);
}

.card--media-dark .media-caption,
.card--media-dark .media-caption-row .media-caption,
.card--media-dark .media-caption-heading,
.card--media-dark .media-caption-ol li {
  color: var(--color-text-on-dark-secondary);
}

.card--media-dark .media-placeholder {
  background: transparent;
}

/* True placeholders (no image asset yet) still render as a visible grey
   box, per the placeholder convention. Only applies to bare <div> stand-ins;
   real <img> elements stay transparent so the card's own background shows
   through any transparency in the asset itself. */
.card--media-dark div.media-placeholder {
  background: rgba(255, 255, 255, 0.12);
}

/* Embedded presentation: a live 16:9 deck in an iframe, wider than the media
   measure so its slides stay legible. The card's overflow: clip rounds it. */
.card--deck {
  width: var(--project-deck-width);
  aspect-ratio: 16 / 9;
  margin-inline: auto;
}

.deck-frame {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

/* Containerless media block: a centered image with a caption below,
   no card background/border. Used when a media item shouldn't read as
   a boxed card among the others. */
.media-bare {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: var(--project-media-width);
  margin-inline: auto;
  margin-top: 64px;
  margin-bottom: 64px;
  gap: 16px;
}

.media-row {
  display: flex;
  gap: 16px;
  width: 100%;
}

.media-placeholder {
  flex: 1;
  min-width: 0;
  min-height: 0;
  width: 100%;
  aspect-ratio: var(--placeholder-aspect, 16 / 10);
  background: transparent;
  border-radius: var(--placeholder-radius);
  object-fit: cover;
}

div.media-placeholder {
  background: var(--color-placeholder-bg);
}

.media-caption {
  max-width: 480px;
  text-align: center;
}

.media-caption-row {
  display: flex;
  gap: 16px;
  width: 100%;
}

.media-caption-row .media-caption {
  flex: 1;
  max-width: none;
}

/* Numbered caption list — used under a single tall collage image with several
   sequential callouts, instead of one caption per image in a row. */
.media-caption-list {
  width: 100%;
  max-width: 480px;
  text-align: left;
}

.media-caption-heading {
  font-weight: var(--font-weight-semibold);
  margin-bottom: 8px;
}

.media-caption-ol {
  list-style: decimal;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Lightbox: click any project image to view it enlarged. */
img.media-placeholder {
  cursor: zoom-in;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
  background: var(--color-card-bg-dark);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease;
  /* Scopes repaint to this layer only, so pinch/trackpad zoom doesn't
     force the browser to repaint the whole page underneath. */
  contain: layout paint;
}

.lightbox.is-open {
  opacity: 1;
  visibility: visible;
}

.lightbox.lightbox--light {
  background: var(--color-card-bg);
}

.lightbox-image {
  max-width: 100%;
  max-height: 100%;
  border-radius: var(--placeholder-radius);
  /* Promote to its own compositing layer: on a plain matching background
     there's nothing else to repaint, so zoom stays smooth. */
  will-change: transform;
  cursor: zoom-in;
  transition: transform 0.2s ease;
}

.lightbox-image.is-zoomed {
  max-width: none;
  max-height: none;
  width: auto;
  height: 100%;
  transform: scale(1.2);
  cursor: zoom-out;
}

.lightbox--light .lightbox-image {
  box-shadow: 0px 4px 16px rgba(0, 0, 0, 0.15);
}

.lightbox-close {
  position: absolute;
  top: 24px;
  right: 32px;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

.lightbox--light .lightbox-close {
  background: rgba(0, 0, 0, 0.06);
  color: #000000;
}

.lightbox--light .lightbox-close:hover {
  background: rgba(0, 0, 0, 0.12);
}

body.lightbox-open {
  overflow: hidden;
}

/* ==========================================================================
   Responsive — Mobile
   ========================================================================== */

@media (max-width: 680px) {
  :root {
    --font-size-hero: 44px;
    --font-size-project-title: 34px;
    --font-size-card-title: 24px;

    /* Fixed desktop measures become fluid; horizontal room comes from
       padding on .content / .project-page instead. */
    --content-width: 100%;
    --project-text-width: 100%;
    --project-media-width: 100%;
    --project-deck-width: 100%;
    --experiments-width: 100%;
  }

  .content {
    padding-inline: 20px;
  }

  .project-page {
    padding-inline: 20px;
  }

  /* Single column — matches how project cards stack on the home page. */
  .experiments-grid {
    grid-template-columns: 1fr;
    padding-inline: 20px;
  }

  /* Nav: same pill, smaller items so all four fit one row. */
  .nav {
    gap: 2px;
    padding: 3px;
  }

  .nav__item {
    padding: 6px 10px;
    gap: 4px;
    font-size: var(--font-size-caption);
  }

  .nav__icon {
    width: 12px;
    height: 12px;
  }

  /* Project/link cards: stack image below content instead of side by side. */
  .card--project,
  .card--link {
    flex-direction: column;
    height: auto;
  }

  .card__desc {
    max-width: none;
  }

  .card__visual {
    width: 100%;
    height: 200px;
  }

  /* Timeline: one column per row instead of a fixed 3-column grid. */
  .timeline-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .timeline-desc {
    max-width: none;
  }

  /* Lightbox: less padding so small screens keep the image large. */
  .lightbox {
    padding: 16px;
  }

  .lightbox-close {
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
  }
}

/* Work-in-progress marker: a small outlined pill above a card or project title. */
.wip-badge {
  display: block;
  width: fit-content;
  margin-bottom: 8px;
  padding: 2px 8px;
  border: 1px solid var(--color-card-border);
  border-radius: 999px;
  font-size: var(--font-size-caption);
  font-weight: var(--font-weight-medium);
  letter-spacing: 0.04em;
  line-height: 1.5;
  color: var(--color-text-secondary);
}
.project-header .wip-badge { margin-top: 16px; margin-bottom: 0; }
