/* /projects: three expanding slabs. Tokens live in style.css. */

.is-projects .page { height: auto; min-height: 100svh; }

.work {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
  max-width: 1200px;
  padding-top: 16px;
}

/* ---------- Header ---------- */
.work-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--ink);
  padding-bottom: 12px;
}

.work-title {
  font-weight: 900;
  font-stretch: 125%;
  text-transform: uppercase;
  font-size: 38px;
  line-height: 0.86;
  letter-spacing: -0.03em;
}

.work-hint { display: none; font-size: 13px; font-weight: 500; color: var(--muted); white-space: nowrap; }
.hint-mouse { display: none; }
@media (hover: hover) and (pointer: fine) {
  .hint-mouse { display: inline; }
  .hint-touch { display: none; }
}

/* ---------- Slabs (mobile: stacked accordion) ---------- */
.slabs { display: flex; flex-direction: column; gap: 8px; }

.slab {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  transition: background-color 400ms ease, border-color 400ms ease, color 400ms ease;
}
.slab:not(.is-open):hover { border-color: var(--coral-strong); }
.slab.is-open { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }

.slab-tab {
  all: unset;
  box-sizing: border-box;
  position: relative;
  z-index: 1;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px;
  cursor: pointer;
}
.slab-tab:focus-visible { outline: 2px solid var(--coral-strong); outline-offset: -4px; border-radius: var(--r-card); }

.slab-num {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.is-open .slab-num { color: var(--on-ink-muted); }

.slab-name {
  font-weight: 900;
  font-stretch: 125%;
  text-transform: uppercase;
  font-size: 22px;
  line-height: 1;
  letter-spacing: -0.02em;
  min-width: 0;
  text-wrap: balance;
  transition: color 150ms ease;
}
.slab:not(.is-open):hover .slab-name { color: var(--coral-strong); }

.slab-plus {
  margin-left: auto;
  width: 18px;
  height: 18px;
  flex: none;
  color: var(--muted);
  transition: transform 400ms cubic-bezier(.7, 0, .2, 1), color 150ms ease;
}
.slab:not(.is-open):hover .slab-plus { color: var(--coral-strong); transform: rotate(90deg); }
.is-open .slab-plus { transform: rotate(45deg); color: var(--coral); }

/* Height animates with the 0fr → 1fr grid trick. */
.slab-body {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 500ms cubic-bezier(.7, 0, .2, 1);
}
.is-open .slab-body { grid-template-rows: 1fr; }

.slab-inner {
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 0 18px;
  transition: padding 500ms cubic-bezier(.7, 0, .2, 1);
}
.is-open .slab-inner { padding-bottom: 18px; }

.slab-copy { display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }

.slab-meta {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--on-ink-muted);
}

/* On phones the tab already shows the name. */
.slab-title { display: none; }

.slab-pitch { font-size: 15px; line-height: 1.5; color: var(--on-ink); text-wrap: pretty; max-width: 440px; }

.tags { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.tags li {
  font-size: 11px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: var(--r-pill);
  border: 1px solid var(--muted);
  color: var(--on-ink-muted);
}

.cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  padding: 12px 18px;
  border-radius: var(--r-pill);
  background: var(--coral);
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  transition: background-color 150ms ease;
}
.cta:hover { background: var(--on-ink); color: var(--ink); }
.cta:focus-visible { outline-color: var(--on-ink); }
.cta svg { width: 14px; height: 14px; transition: transform 200ms ease; }
.cta:hover svg { transform: translate(2px, -2px); }

/* Faux browser: replace .window-body's text with an <img> once there are screenshots. */
.window {
  border: 1px solid var(--muted);
  border-radius: var(--r-tile);
  overflow: hidden;
  background: var(--ink);
}
.window-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--muted);
}
.window-bar i { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.window-bar span { margin-left: 8px; font-size: 10px; color: var(--on-ink-muted); }
.window-body {
  aspect-ratio: 16 / 10;
  display: grid;
  place-items: center;
  background: var(--ink-hover);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--on-ink-muted);
}
.window-body img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Results panel for projects without screenshots: stat, bars, pipeline. */
.viz {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 18px;
  border: 1px solid var(--muted);
  border-radius: var(--r-tile);
}
.viz-stat { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 14px; }
.viz-big {
  font-weight: 900;
  font-stretch: 125%;
  font-size: 48px;
  line-height: 0.8;
  letter-spacing: -0.03em;
}
.viz-cap { font-size: 12px; line-height: 1.4; color: var(--on-ink-muted); max-width: 220px; text-wrap: pretty; }

.viz-bars { display: flex; flex-direction: column; gap: 10px; }
.bar {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "label val" "track track";
  row-gap: 6px;
  font-size: 12px;
  color: var(--on-ink-muted);
}
.bar-label { grid-area: label; }
.bar-val { grid-area: val; font-variant-numeric: tabular-nums; }
.bar-track { grid-area: track; height: 10px; border-radius: var(--r-pill); background: var(--ink-hover); overflow: hidden; }
.bar-fill {
  display: block;
  height: 100%;
  width: calc(var(--v) * 100%);
  border-radius: inherit;
  background: var(--on-ink-muted);
  transform-origin: left;
  transform: scaleX(0);
  transition: transform 900ms cubic-bezier(.2, .8, .2, 1) 450ms;
}
.is-open .bar-fill { transform: scaleX(1); }
.bar.is-ours { color: var(--on-ink); font-weight: 600; }
.bar.is-ours .bar-fill { background: var(--coral); transition-delay: 600ms; }
.viz-unit { font-size: 10px; font-weight: 600; letter-spacing: 0.08em; color: var(--on-ink-muted); }

.viz-flow {
  list-style: none;
  margin: 0;
  padding: 14px 0 0;
  border-top: 1px solid var(--muted);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 6px;
  font-size: 11px;
  font-weight: 500;
  color: var(--on-ink-muted);
}
.viz-flow li { display: flex; align-items: center; gap: 6px; }
.viz-flow li + li::before { content: ""; width: 8px; height: 1px; background: var(--muted); }
.viz-flow li:last-child { color: var(--on-ink); font-weight: 600; }

/* Real screenshot in a browser frame, with a caption underneath. */
.shot { margin: 0; display: flex; flex-direction: column; gap: 10px; }
.shot img { display: block; width: 100%; height: auto; }
a.window { display: block; transition: border-color 150ms ease; }
a.window:hover { border-color: var(--coral); }
.shot figcaption { font-size: 11px; line-height: 1.45; color: var(--on-ink-muted); text-wrap: pretty; }

/* Giant outlined-feel numeral behind the open slab. */
.slab-ghost {
  position: absolute;
  z-index: 0;
  right: -8px;
  top: -24px;
  font-weight: 900;
  font-stretch: 125%;
  font-size: 160px;
  line-height: 1;
  letter-spacing: -0.06em;
  color: var(--ink-hover);
  opacity: 0;
  pointer-events: none;
  transition: opacity 400ms ease;
}
.is-open .slab-ghost { opacity: 1; }

/* ---------- Desktop (≥ 900px): slabs side by side, open one widens ---------- */
@media (min-width: 900px) {
  .work { gap: 28px; padding-top: 28px; }
  .work-title { font-size: 96px; }
  .work-hint { display: block; }

  .slabs {
    container-type: inline-size;
    flex-direction: row;
    gap: 10px;
    height: clamp(400px, calc(100svh - 250px), 680px);
  }

  .slab {
    flex: 1 1 0;
    min-width: 0;
    transition:
      flex-grow 700ms cubic-bezier(.7, 0, .2, 1),
      background-color 400ms ease,
      border-color 400ms ease,
      color 400ms ease;
  }
  .slab.is-open { flex-grow: 8; }

  /* Collapsed: number on top, name running up the slab, plus at the bottom. */
  .slab-tab {
    position: absolute;
    inset: 0;
    flex-direction: column;
    justify-content: space-between;
    padding: 22px 0;
    container-type: size;
    transition: opacity 250ms ease 350ms;
  }
  .slab-num { font-size: 13px; }
  .slab-name {
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    /* Fit the name to the slab's height: --len is the name's character count. */
    white-space: nowrap;
    font-size: min(60px, 4.4vw, calc(82cqh / (var(--len, 8) * 0.92)));
  }
  .slab-plus { margin-left: 0; width: 20px; height: 20px; }
  .is-open .slab-tab { opacity: 0; pointer-events: none; transition-delay: 0ms; transition-duration: 150ms; }

  /* Open content is laid out at its final width, so it never reflows mid-animation. */
  .slab-body {
    position: absolute;
    inset: 0;
    display: block;
    opacity: 0;
    transition: opacity 200ms ease;
  }
  .is-open .slab-body { opacity: 1; transition: opacity 400ms ease 300ms; }

  .slab-inner,
  .is-open .slab-inner {
    width: calc((100cqw - 20px) * 0.8);
    height: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
    align-items: end;
    gap: 40px;
    padding: 36px;
  }

  .slab-copy { gap: 16px; }
  .slab-meta { font-size: 11px; }
  .slab-title {
    display: block;
    margin: 0;
    font-weight: 900;
    font-stretch: 125%;
    text-transform: uppercase;
    font-size: clamp(26px, 3cqw, 44px);
    line-height: 0.88;
    letter-spacing: -0.03em;
  }
  .slab-pitch { font-size: 17px; line-height: 1.55; color: var(--on-ink-muted); }

  .slab-media { transform: translateX(32px); transition: transform 700ms cubic-bezier(.2, .8, .2, 1) 250ms; }
  .is-open .slab-media { transform: none; }

  .viz { padding: 24px; gap: 22px; }
  .viz-big { font-size: clamp(56px, 7cqw, 96px); }
  .viz-cap { font-size: 13px; }
  .bar-track { height: 12px; }

  .slab-ghost { right: auto; left: 22px; top: -40px; font-size: clamp(200px, 26cqw, 340px); }
}

@media (prefers-reduced-motion: no-preference) {
  .slabs { animation-delay: 60ms; }
}

@media (prefers-reduced-motion: reduce) {
  .slab, .slab-body, .slab-inner, .slab-tab, .slab-media, .slab-plus, .bar-fill { transition: none !important; }
}

/* Short laptop screens: tighten the open slab so nothing is clipped. */
@media (min-width: 900px) and (max-height: 780px) {
  .work { gap: 20px; padding-top: 16px; }
  .work-title { font-size: 72px; }
  .slabs { height: clamp(440px, calc(100svh - 190px), 680px); }
  .slab-inner, .is-open .slab-inner { padding: 26px; gap: 28px; }
  .slab-copy { gap: 12px; }
  .slab-pitch { font-size: 15px; line-height: 1.5; }
  .viz { padding: 18px; gap: 14px; }
  .shot figcaption { display: none; }
}
