/* Shared base for the home page and project pages, modelled on despacio/index.html: a dark room, full-bleed footage between a single
   readable column, one panel carrying the numbers. Each project sets its own --accent / --accent-2. */
:root {
  --bg: #07080c;
  --panel: #0e1118;
  --line: #1e2430;
  --fg: #e4e8ee;
  --muted: #8b95a6;
  --accent: #8fd0ff;      /* title highlight and numbers */
  --accent-2: #c8a26a;    /* eyebrows */
  --display: "Big Shoulders Display", "Arial Narrow", "Helvetica Neue", sans-serif;
  --body: "Instrument Sans", "Segoe UI", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --col: 42rem;
  --wide: 76rem;
  color-scheme: dark;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--body); font-size: 1.0625rem; line-height: 1.65; padding-inline: 16px; padding-block: 0 4rem; }
a { color: var(--accent); text-underline-offset: 3px; }
a:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }
img, video { display: block; max-width: 100%; height: auto; }
h1, h2 { font-family: var(--display); font-weight: 800; text-transform: uppercase; letter-spacing: 0.01em; line-height: 0.95; text-wrap: balance; margin: 0; }
h2 { font-size: clamp(2.2rem, 5vw, 3.4rem); }
p { margin: 0; }
p, dd, figcaption { text-wrap: pretty; }
.eyebrow { font-family: var(--mono); font-size: 0.75rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent-2); }
.col { max-width: var(--col); margin-inline: auto; display: grid; gap: 1.1rem; }
.wide { max-width: var(--wide); margin-inline: auto; }

/* back to the portfolio */
.sitebar { max-width: var(--wide); margin-inline: auto; display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding-block: 1rem 0.25rem; font-family: var(--mono); font-size: 0.75rem; letter-spacing: 0.12em; text-transform: uppercase; }
.sitebar a { color: var(--muted); text-decoration: none; }
.sitebar a:hover { color: var(--fg); }
.sitebar .home { color: var(--fg); }

/* hero */
.hero { max-width: var(--wide); margin-inline: auto; padding-top: 1.5rem; display: grid; gap: 1.6rem; }
.frame { position: relative; border-radius: 4px; overflow: hidden; background: #000; aspect-ratio: 16 / 9; max-width: 100%; }
.frame video, .frame img { width: 100%; height: 100%; object-fit: cover; }
.frame video[controls] { object-fit: contain; }
.hero h1 { font-size: clamp(3.4rem, 11vw, 8.5rem); }
.hero h1 span { color: var(--accent); }
.lede { font-size: clamp(1.15rem, 2.2vw, 1.4rem); line-height: 1.5; max-width: 46rem; }
.meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); gap: 1rem 2rem; margin: 0; border-top: 1px solid var(--line); padding-top: 1rem; }
.meta div { display: grid; gap: 0.15rem; min-width: 0; align-content: start; }
.meta dt { font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.meta dd { margin: 0; font-size: 0.95rem; }

/* the numbers */
.plate { max-width: var(--wide); margin: 4.5rem auto 0; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: clamp(1.2rem, 3vw, 2rem); }
.specs { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: 1.2rem 1.6rem; margin: 0; }
.spec { display: flex; flex-direction: column-reverse; justify-content: flex-end; gap: 0.1rem; min-width: 0; }
.spec dd { margin: 0; font-family: var(--display); font-weight: 800; font-size: 2.6rem; line-height: 1; color: var(--accent); font-variant-numeric: tabular-nums; text-shadow: 0 0 18px color-mix(in srgb, var(--accent) 35%, transparent); }
.spec dt { font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }

/* chapters */
section.chapter { margin-top: 6rem; display: grid; grid-template-columns: minmax(0, 1fr); gap: 2rem; }
.pair { max-width: var(--wide); margin-inline: auto; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.8rem; width: 100%; }
figure { margin: 0; display: grid; gap: 0.45rem; min-width: 0; }
figcaption { font-family: var(--mono); font-size: 0.75rem; color: var(--muted); line-height: 1.5; }
.pair img { border-radius: 4px; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
figure.wide { width: 100%; }

/* app screens in phone frames (one row, scaling down on small screens) */
.phones { max-width: var(--wide); width: 100%; margin-inline: auto; display: grid; grid-template-columns: repeat(var(--n, 2), minmax(0, 250px)); justify-content: center; gap: clamp(0.6rem, 2.5vw, 2rem); }
/* chapter screens big enough to read; two of them span the text column */
.phones:not(.hero-phones) { grid-template-columns: repeat(var(--n, 2), minmax(0, 320px)); gap: clamp(0.8rem, 3vw, 2rem); }
.phone { margin: 0; display: grid; gap: 0.6rem; align-content: start; }
.phone-screen { aspect-ratio: 390 / 844; padding: clamp(4px, 0.7vw, 7px); background: #05070b; border: 1px solid var(--line); border-radius: clamp(16px, 2.6vw, 28px); box-shadow: 0 30px 60px -30px rgba(0, 0, 0, 0.8); }
.phone-screen img, .phone-screen video { width: 100%; height: 100%; object-fit: cover; border-radius: clamp(12px, 2vw, 21px); }
.hero-phones {
  align-items: center; padding: clamp(1.5rem, 5vw, 3.5rem) clamp(0.6rem, 3vw, 2rem);
  border: 1px solid var(--line); border-radius: 4px;
  background: radial-gradient(60% 70% at 50% 45%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 70%), var(--panel);
}
.hero-phones .phone:nth-child(2):nth-last-child(2) { transform: translateY(-4%) scale(1.06); }
/* split hero (apps): title and lede on the left, three phones fanned on the right */
.hero-split { grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); align-items: center; column-gap: clamp(1.5rem, 4vw, 4rem); padding-top: clamp(1.5rem, 4vw, 3.5rem); }
.hero-split .hero-text { display: grid; gap: 1.2rem; align-content: center; }
.hero-split h1 { font-size: clamp(3.4rem, 8.5vw, 7.5rem); }
.hero-split .meta { grid-column: 1 / -1; margin-top: clamp(1rem, 3vw, 2.5rem); }
.app-icon { display: block; width: clamp(64px, 7vw, 92px); height: auto; aspect-ratio: 1; border-radius: 22%; margin-bottom: clamp(0.8rem, 2vw, 1.2rem); box-shadow: 0 0 0 1px var(--line), 0 18px 40px -12px color-mix(in srgb, var(--accent) 45%, transparent); }
.hero-phones.fanned { position: relative; isolation: isolate; grid-template-columns: repeat(3, minmax(0, 1fr)); max-width: 40rem; gap: 0; padding: clamp(1rem, 3vw, 2.5rem) 0; border: 0; background: none; align-items: center; }
.hero-phones.fanned::before { content: ""; position: absolute; inset: 8% 4%; z-index: -1; background: radial-gradient(closest-side, color-mix(in srgb, var(--accent) 24%, transparent), transparent); filter: blur(10px); }
.hero-phones.fanned .phone { transform: none; }
.hero-phones.fanned .phone:nth-child(1) { transform: translate(14%, 7%) rotate(-7deg) scale(0.9); }
.hero-phones.fanned .phone:nth-child(2) { position: relative; z-index: 2; transform: scale(1.06); }
.hero-phones.fanned .phone:nth-child(3) { transform: translate(-14%, 7%) rotate(7deg) scale(0.9); }
.hero-phones.fanned .phone:not(:nth-child(2)) .phone-screen { filter: brightness(0.82); }

/* cards in a row: numbered steps, or a features grid */
.cards { list-style: none; margin: 0 auto; padding: 0; max-width: var(--wide); width: 100%; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr)); gap: clamp(0.7rem, 1.6vw, 1rem); }
.cards li { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: clamp(1.1rem, 2.4vw, 1.6rem); display: grid; gap: 0.5rem; align-content: start; }
.cards h3 { margin: 0; font-family: var(--display); font-weight: 800; text-transform: uppercase; font-size: 1.55rem; line-height: 1; letter-spacing: 0.01em; }
.cards p { color: var(--muted); font-size: 0.98rem; line-height: 1.55; }
.cards .step { font-family: var(--mono); font-size: 0.75rem; letter-spacing: 0.14em; color: var(--accent); }
.cards.numbered li { border-top: 2px solid var(--accent); }
/* four cards: 2 by 2, or one row on wide screens (never three and an orphan) */
.cards.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 1280px) { .cards.four { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 600px) { .cards.four { grid-template-columns: minmax(0, 1fr); } }

/* a left-to-right diagram: inputs -> hub -> outputs */
.flow { max-width: var(--wide); width: 100%; margin-inline: auto; display: grid; grid-template-columns: minmax(0, 1fr) 2.5rem minmax(0, 1.1fr) 2.5rem minmax(0, 1fr); align-items: start; gap: 0.6rem; }
.flow-hub, .flow-arrow { align-self: center; }
.flow-label { font-family: var(--mono); font-size: 0.7rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent-2); margin-bottom: 0.6rem; }
.flow-col ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.4rem; }
.flow-col li { font-size: 0.92rem; border: 1px solid var(--line); border-radius: 4px; padding: 0.45rem 0.7rem; background: var(--panel); }
.flow-hub { border: 1px solid color-mix(in srgb, var(--accent) 55%, transparent); border-radius: 6px; padding: clamp(1rem, 2.4vw, 1.5rem); background: radial-gradient(90% 90% at 50% 0%, color-mix(in srgb, var(--accent) 14%, transparent), transparent), var(--panel); box-shadow: 0 0 40px -12px color-mix(in srgb, var(--accent) 50%, transparent); text-align: center; }
.flow-hub-name { font-family: var(--display); font-weight: 800; text-transform: uppercase; font-size: clamp(1.6rem, 2.6vw, 2.1rem); line-height: 1; color: var(--accent); }
.flow-hub-note { margin-top: 0.5rem; color: var(--muted); font-size: 0.92rem; line-height: 1.5; }
.flow-arrow { height: 2px; background: linear-gradient(90deg, var(--line), var(--accent)); position: relative; }
.flow-arrow::after { content: ""; position: absolute; right: -1px; top: 50%; width: 8px; height: 8px; border-top: 2px solid var(--accent); border-right: 2px solid var(--accent); transform: translateY(-50%) rotate(45deg); }

.tools { max-width: var(--col); margin-inline: auto; display: flex; flex-wrap: wrap; justify-content: center; gap: 0.5rem; }
.tools span { font-family: var(--mono); font-size: 0.78rem; border: 1px solid var(--line); border-radius: 999px; padding: 0.25rem 0.75rem; color: var(--fg); }
.cta { max-width: var(--col); margin-inline: auto; display: flex; flex-wrap: wrap; gap: 0.75rem; }
.cta a { font-family: var(--mono); font-size: 0.8rem; letter-spacing: 0.08em; text-transform: uppercase; text-decoration: none; color: var(--bg); background: var(--accent); border-radius: 999px; padding: 0.6rem 1.1rem; }
.cta a:hover { filter: brightness(1.1); }
.hero-cta { margin: 0.4rem 0 0; max-width: none; }

footer { max-width: var(--col); margin: 6rem auto 0; border-top: 1px solid var(--line); padding-top: 1.2rem; font-size: 0.85rem; color: var(--muted); display: grid; gap: 0.6rem; }
.next { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.next a { text-decoration: none; }
.next a:hover { text-decoration: underline; }

.not-found { max-width: var(--col); margin: 6rem auto 0; display: grid; gap: 1rem; }
.not-found h1 { font-size: clamp(2.6rem, 8vw, 4.5rem); }

/* placeholder when a media file is missing (see common.js) */
.ph { position: absolute; inset: 0; display: grid; place-items: center; background: var(--panel); }
.pair .ph, figure > .ph { position: relative; aspect-ratio: 16 / 9; border-radius: 4px; }
.ph-rec { display: none; }
.ph-label { display: flex; flex-direction: column; align-items: center; gap: 8px; color: var(--muted); font-family: var(--mono); font-size: 0.75rem; }

@media (max-width: 900px) {
  .hero-split { grid-template-columns: minmax(0, 1fr); }
  .hero-phones.fanned { max-width: 30rem; margin-top: -0.5rem; }
  .flow { grid-template-columns: minmax(0, 1fr); max-width: 28rem; }
  .flow-arrow { width: 2px; height: 1.6rem; justify-self: center; background: linear-gradient(180deg, var(--line), var(--accent)); }
  .flow-arrow::after { right: auto; left: 50%; top: auto; bottom: -1px; transform: translateX(-50%) rotate(135deg); }
}
@media (max-width: 760px) {
  .pair { grid-template-columns: minmax(0, 1fr); }
  section.chapter { margin-top: 4.5rem; }
  .specs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
