/* Project pages. Loaded after styles.css, which holds the tokens, nav, links, buttons and reveals. */

/* ---------- hero ---------- */
.p-hero { padding-top: calc(var(--nav-h) + clamp(16px, 4vh, 40px)); }
.p-back {
  display: inline-flex; align-items: center; gap: 0.5em; min-height: 44px;
  font: 500 0.8125rem/1 var(--mono); text-transform: uppercase; letter-spacing: 0.08em; text-decoration: none;
}
.p-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 24px 48px; align-items: end; margin-top: clamp(12px, 3vh, 32px); }
.p-head .eyebrow { grid-column: 1 / -1; }
.p-title {
  grid-column: 1 / -1; margin: 0;
  font: 700 clamp(3.75rem, 12.5vw, 14rem)/0.86 var(--display); font-stretch: 75%; text-transform: uppercase; letter-spacing: -0.01em;
}
.p-lede { max-width: 30ch; font-size: clamp(1.25rem, 2vw, 1.75rem); line-height: 1.3; }
.p-actions { display: flex; flex-wrap: wrap; gap: 12px; }

.p-panel {
  position: relative; margin-top: clamp(28px, 5vh, 56px); height: min(76svh, 760px);
  border-radius: 12px; overflow: hidden; background: var(--c); color: var(--fg);
  view-transition-name: hero;
}
.p-phones {
  position: absolute; inset: 0; display: flex; justify-content: center; align-items: flex-start;
  gap: clamp(16px, 3vw, 48px); padding-top: clamp(36px, 7vh, 80px);
}
.p-phones > div { width: clamp(150px, 16vw, 250px); }
.p-phones > div:nth-child(2) { margin-top: clamp(40px, 8vh, 90px); }

/* phone frame */
.phone {
  --pad: clamp(4px, 0.45vw, 8px);
  position: relative; aspect-ratio: 9 / 19.5; padding: var(--pad);
  border-radius: clamp(16px, 2vw, 30px); background: #0b0b0b;
}
.phone img {
  display: block; width: 100%; height: 100%; object-fit: cover; object-position: top;
  border-radius: calc(clamp(16px, 2vw, 30px) - var(--pad));
}
html.js [data-rise] { transform: translate3d(0, 30%, 0); opacity: 0; transition: transform 1.2s var(--ease-out), opacity 0.6s ease; transition-delay: calc(var(--i, 0) * 110ms + 0.35s); }
html.js.is-loaded [data-rise] { transform: none; opacity: 1; }

/* ---------- intro ---------- */
.p-intro__grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: 24px; align-items: start; }
.p-facts { grid-column: 1 / span 4; margin: 0; border-top: 1px solid var(--line); }
.p-facts div { display: grid; grid-template-columns: 6.5rem 1fr; gap: 16px; padding-block: 14px; border-bottom: 1px solid var(--line); }
.p-facts dt { font: 500 0.75rem/1.7 var(--mono); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.p-facts dd { margin: 0; }
.p-facts a { text-decoration-thickness: 1px; text-underline-offset: 3px; }
.p-copy { grid-column: 6 / -1; }
.p-big { max-width: 30ch; margin-bottom: 1em; font-size: clamp(1.375rem, 2.3vw, 2.125rem); line-height: 1.25; letter-spacing: -0.01em; }
.p-copy > p:not(.p-big) { max-width: 58ch; color: var(--muted); }

.features { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 32px; margin: 48px 0 0; padding: 0; list-style: none; }
.features li { padding-block: 22px; border-top: 1px solid var(--line); }
.features h3 { margin: 0 0 0.35em; font: 700 1.5rem/1 var(--display); font-stretch: 75%; text-transform: uppercase; }
.features p { color: var(--muted); font-size: 0.9375rem; }

/* ---------- stats (counters) ---------- */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-block: 1px solid var(--line); margin: 0; }
.stat { padding: 28px 16px 28px 0; }
.stat + .stat { padding-left: 16px; border-left: 1px solid var(--line); }
.stat__v { display: block; font: 700 clamp(2.75rem, 6vw, 5.5rem)/1 var(--display); font-stretch: 75%; font-variant-numeric: tabular-nums; }
.stat__k { display: block; margin-top: 10px; font: 500 0.75rem/1.4 var(--mono); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.note { margin-top: 14px; font: 500 0.75rem/1.5 var(--mono); color: var(--muted); }

/* ---------- pinned horizontal gallery ---------- */
.hs { position: relative; }
.hs__sticky {
  position: sticky; top: var(--nav-h); height: calc(100svh - var(--nav-h));
  display: flex; flex-direction: column; justify-content: center; gap: clamp(20px, 4vh, 40px); overflow: hidden;
}
.hs__head { display: flex; justify-content: space-between; align-items: end; gap: 24px; }
.hs__head .h2 { margin: 0; }
.hs__track { position: relative; display: flex; gap: clamp(28px, 5vw, 80px); width: max-content; padding-inline: var(--gutter); will-change: transform; }
.hs__item { flex: none; width: min(19vw, calc((100svh - var(--nav-h) - 240px) / 2.17)); min-width: 150px; }
.hs__item .phone { transform: scale(var(--s, 1)); transition: transform 0.2s linear; }
.hs__label { display: block; margin-bottom: 14px; font: 500 0.75rem/1 var(--mono); text-transform: uppercase; letter-spacing: 0.08em; }

/* ---------- theme wipe ---------- */
.wipe { position: relative; height: 260vh; }
.wipe__sticky { position: sticky; top: var(--nav-h); height: calc(100svh - var(--nav-h)); display: flex; flex-direction: column; justify-content: center; gap: clamp(20px, 4vh, 36px); }
.wipe__head { display: flex; justify-content: space-between; align-items: end; gap: 24px; }
.wipe__head .h2 { margin: 0; }
.wipe__legend { display: flex; white-space: nowrap; gap: 20px; font: 500 0.75rem/1 var(--mono); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.wipe__phones { display: flex; justify-content: center; gap: clamp(24px, 6vw, 96px); }
.wipe .phone { width: min(18vw, calc((100svh - var(--nav-h) - 220px) / 2.17)); min-width: 140px; }
.wipe .phone .over {
  position: absolute; left: var(--pad); top: var(--pad);
  width: calc(100% - 2 * var(--pad)); height: calc(100% - 2 * var(--pad));
  clip-path: inset(0 calc((1 - var(--p, 0)) * 100%) 0 0);
}
.wipe .phone .seam {
  position: absolute; top: 2%; bottom: 2%; width: 2px; margin-left: -1px; background: var(--accent);
  left: calc(var(--pad) + var(--p, 0) * (100% - 2 * var(--pad)));
  opacity: calc(min(var(--p, 0) * 20, 1) * min((1 - var(--p, 0)) * 20, 1));
}

/* ---------- card deal ---------- */
.deal { position: relative; height: clamp(420px, 58vw, 700px); }
.deal__card {
  --w: clamp(130px, 17vw, 240px);
  position: absolute; left: 50%; top: 4%; width: var(--w); margin-left: calc(var(--w) / -2);
  transform: translate3d(0, 6%, 0) rotate(0deg);
  transition: transform 1s var(--ease-out); transition-delay: calc(var(--i) * 90ms);
}
.deal.is-in .deal__card { transform: translate3d(calc(var(--x) * 100%), var(--y), 0) rotate(var(--r)); }
@media (hover: hover) and (pointer: fine) {
  .deal.is-in .deal__card:hover { z-index: 5; transform: translate3d(calc(var(--x) * 100%), calc(var(--y) - 4%), 0) rotate(0deg); transition-duration: 0.4s; transition-delay: 0s; }
}

/* ---------- data flow (server) ---------- */
.flow {
  position: absolute; inset: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr) minmax(0, 1fr);
  align-items: center; padding: clamp(24px, 4vw, 64px);
}
.flow svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.flow path { fill: none; stroke: currentColor; stroke-opacity: 0.35; stroke-width: 1.5; }
.flow .packet { fill: var(--accent); }
.node { position: relative; z-index: 1; padding: 16px 18px; border: 1px solid currentColor; border-radius: 8px; background: var(--c); }
.node__t { margin: 0 0 0.3em; font: 700 clamp(1.25rem, 2vw, 1.75rem)/1 var(--display); font-stretch: 75%; text-transform: uppercase; }
.node p:not(.node__t) { font: 400 0.8125rem/1.5 var(--mono); opacity: 0.85; }
.flow__pi { grid-column: 1; }
.flow__count { display: block; margin-top: 12px; font: 600 0.8125rem/1 var(--mono); font-variant-numeric: tabular-nums; }
.flow__clients { grid-column: 3; display: grid; gap: clamp(14px, 4vh, 36px); }
.flow__pause {
  position: absolute; right: clamp(16px, 2vw, 28px); bottom: clamp(16px, 2vw, 28px); z-index: 2;
  min-height: 44px; padding: 0 16px; border: 1px solid currentColor; border-radius: 4px; background: transparent; color: inherit;
  font: 500 0.75rem/1 var(--mono); text-transform: uppercase; letter-spacing: 0.08em; cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease, transform 0.16s var(--ease-out);
}
.flow__pause:active { transform: scale(0.97); }
@media (hover: hover) and (pointer: fine) { .flow__pause:hover { background: var(--fg); color: var(--c); } }
.flow__pause:focus-visible { outline-color: currentColor; }

/* ---------- terminal ---------- */
.term {
  margin: 0; padding: clamp(20px, 3vw, 36px); border-radius: 12px; background: var(--ink); color: #e9e2d4;
  font: 400 clamp(0.75rem, 1.05vw, 0.9375rem)/1.75 var(--mono); overflow-x: auto;
}
.term .t { display: block; white-space: pre; }
.term .t--cmd { color: var(--accent); }
html.js .term .t { clip-path: inset(0 100% 0 0); }
html.js .term.is-in .t { animation: type calc(var(--n, 20) * 10ms) steps(var(--n, 20)) forwards; animation-delay: var(--d, 0s); }
@keyframes type { to { clip-path: inset(0 0 0 0); } }

/* ---------- peg board ---------- */
.peg-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: clamp(32px, 5vw, 72px); align-items: center; }
.peg { position: relative; aspect-ratio: 1 / 0.92; border-radius: 12px; background: var(--ink); }
.hole {
  position: absolute; width: 14%; aspect-ratio: 1; padding: 0; border: 0; border-radius: 50%;
  transform: translate(-50%, -50%); background: rgba(239, 233, 223, 0.1); cursor: pointer;
}
.hole:disabled { cursor: default; }
.hole .dot { position: absolute; inset: 9%; border-radius: 50%; background: var(--paper); transition: background-color 0.2s ease; }
.hole.is-empty .dot { display: none; }
.hole.is-from .dot { background: var(--accent); }
.hole.is-to { box-shadow: inset 0 0 0 2px var(--accent); }
.hole:focus-visible { outline: 2px solid var(--paper); outline-offset: 3px; }
@media (hover: hover) and (pointer: fine) { .peg.is-choosing .hole:hover { box-shadow: inset 0 0 0 2px var(--paper); } }
.peg-status { margin: 20px 0 24px; font: 500 0.8125rem/1.6 var(--mono); font-variant-numeric: tabular-nums; }
.peg-controls { display: flex; flex-wrap: wrap; gap: 10px; }
.btn--ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.btn:disabled { opacity: 0.4; cursor: default; transform: none; }
@media (hover: hover) and (pointer: fine) { .btn--ghost:hover { background: rgba(22, 19, 15, 0.06); } }

/* ---------- under the hood ---------- */
.stack { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 32px; margin: 0; padding: 0; list-style: none; }
.stack li { padding-block: 22px; border-top: 1px solid var(--line); }
.stack h3 { margin: 0 0 0.3em; font: 500 0.8125rem/1.4 var(--mono); text-transform: uppercase; letter-spacing: 0.08em; }
.stack p { color: var(--muted); font-size: 0.9375rem; }
.tree { margin: 40px 0 0; padding: 24px 28px; border: 1px solid var(--line); border-radius: 12px; font: 400 0.8125rem/1.7 var(--mono); overflow-x: auto; }

/* ---------- next project ---------- */
.p-next { border-top: 1px solid var(--line); }
.p-next__link {
  position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 24px;
  min-height: 60svh; padding-block: 48px; text-decoration: none; color: inherit;
}
.p-next__title {
  display: block; margin-top: 0.15em;
  font: 700 clamp(3.25rem, 10vw, 10rem)/0.88 var(--display); font-stretch: 75%; text-transform: uppercase;
  transition: transform 0.5s var(--ease-out);
}
.p-next__disc {
  display: grid; place-items: center; width: clamp(110px, 13vw, 190px); aspect-ratio: 1; border-radius: 50%;
  background: var(--accent); font: 700 clamp(2rem, 3vw, 3rem)/1 var(--display);
  transition: transform 0.4s var(--ease-out);
}
@media (hover: hover) and (pointer: fine) {
  .p-next__link:hover .p-next__title { transform: translateX(16px); }
}

/* ---------- small screens ---------- */
@media (max-width: 819px) {
  .p-head { grid-template-columns: 1fr; }
  .p-panel { height: min(68svh, 620px); }
  .p-phones > div { width: 40vw; }
  .p-phones > div:nth-child(3) { display: none; }
  .p-facts, .p-copy { grid-column: 1 / -1; }
  .p-facts { margin-bottom: 40px; }
  .features, .stack { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat:nth-child(3) { padding-left: 0; border-left: 0; }
  .stat:nth-child(n + 3) { border-top: 1px solid var(--line); }
  .hs__item { width: 46vw; }
  .wipe .phone { width: 38vw; min-width: 0; }
  .wipe__head { flex-direction: column; align-items: start; }
  .flow { grid-template-columns: 1fr; grid-template-rows: auto 1fr auto; align-items: stretch; gap: 0; }
  .flow__pi { grid-column: 1; grid-row: 1; }
  .flow__clients { grid-column: 1; grid-row: 3; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; padding-bottom: 56px; }
  .flow__clients .node { padding: 10px; }
  .flow__clients .node p:not(.node__t) { display: none; }
  .flow__clients .node__t { font-size: 1rem; }
  .peg-grid { grid-template-columns: 1fr; }
  .p-next__link { grid-template-columns: 1fr; min-height: 44svh; }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html.js [data-rise] { transform: none; transition: opacity 0.4s ease; }
  .hs { height: auto !important; }
  .hs__sticky { position: static; height: auto; padding-block: 64px; }
  .hs__track { transform: none !important; overflow-x: auto; max-width: 100%; }
  .wipe { height: auto; }
  .wipe__sticky { position: static; height: auto; padding-block: 64px; }
  [data-wipe] { --p: 0.5 !important; }
  .deal__card { transition: none; }
  html.js .term .t { clip-path: none; animation: none; }
  .p-next__title, .p-next__disc { transition: none; }
}
