/* Troy landing: layout, panels, sections, cards, buttons, chips, FAQ. No animation lives here. */

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--paper);
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p, ul, ol, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
img, svg { display: block; }

h1, h2 {
  font-family: var(--font-serif);
  font-weight: 400;
  line-height: var(--lh-head);
  letter-spacing: -0.01em;
  text-wrap: balance;
}
h2 { font-size: var(--fs-h2); }
h3 { font-size: var(--fs-h3); font-weight: 600; line-height: 1.3; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }
#hero :focus-visible, #footer :focus-visible { outline-color: var(--white); }

/* ---------- The painting layer ---------- */

#sky {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  height: 100lvh;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}
#sky img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* The plaza paintings: the statue fills the left 17%, Bovard's tower ends 88.5% across, and the picture is 2.33
     times as wide as it is tall. Centered while that shows the whole tower; on squarer screens the tower's right
     side is held 28px inside the right edge instead (the statue comes into frame from about 1.8:1). */
  object-position: min(0px, max(100vw - 233.01vh, min(50vw - 116.5vh, 100vw - 206.2vh - 28px))) 50%;
  object-position: min(0px, max(100vw - 233.01lvh, min(50vw - 116.5lvh, 100vw - 206.2lvh - 28px))) 50%;
}
#sky-golden, #sky-night { opacity: 0; }

/* Phones: the tower stands to the right of Troy, with the palms and jacaranda around it. */
@media (max-width: 767px) {
  #sky img { object-position: 86% 50%; }
}

main, #footer { position: relative; z-index: 1; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 0 30px;
  border-radius: var(--r-pill);
  background: var(--cardinal);
  color: var(--white);
  font-size: var(--fs-body);
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
}
.btn[aria-disabled="true"] {
  background: var(--stone);
  cursor: default;
}

/* ---------- Hero ---------- */

#hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  min-height: 100svh;
  padding: clamp(32px, 5vh, 72px) 16px var(--panel-gap);
  text-align: center;
  overflow-x: clip;
}

/* The soft dark patch behind white text on the painting */
.on-painting {
  position: relative;
  color: var(--white);
}
.on-painting::before {
  content: "";
  position: absolute;
  inset: -56px -72px;
  z-index: -1;
  /* The least that keeps white text at 4.5:1 over the brightest cloud, blurred wide so it has no edge. */
  background: rgba(var(--ink-rgb), var(--scrim, 0.54));
  border-radius: 96px;
  filter: blur(36px);
}

/* The hero sits on the calm morning sky of the plaza painting, so its headline is ink with no dark patch:
   the darkest brushstroke behind it needs a paper haze of 0.17 for ink to reach 4.5:1 (measured at 1440 and 390 wide); 0.22 covers the soft edge. */
#hero .on-painting { color: var(--ink); }
#hero .on-painting::before { background: rgba(var(--paper-rgb), var(--scrim, 0.22)); }
/* Between phone and desktop widths the subline can reach the palms beside the tower, so the haze is stronger there. */
@media (min-width: 768px) and (max-width: 1199px) {
  #hero { --scrim: 0.45; }
}

#hero h1 { font-size: var(--fs-hero); line-height: 1; }
.hero-sub {
  margin-top: 16px;
  font-size: clamp(1.0625rem, 1.5vw, 1.25rem);
  font-weight: 500;
}

.hero-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 28px;
}

#qr {
  width: 76px;
  height: 76px;
  padding: 6px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 14px;
}
#qr[hidden] { display: none; }
@media (max-width: 767px) {
  #qr { display: none; }
}

.hero-phone {
  position: relative;
  margin-top: 126px;
}
/* The hero phone is as tall as the first screen allows, so its input bar is in view (429px sits above it and 16px below).
   480px is the least that shows scenario 1 in full without the list scrolling. */
#hero .phone { height: clamp(480px, calc(100vh - 429px), 640px); height: clamp(480px, calc(100svh - 429px), 640px); }
/* Troy sits on top of the hero phone. Positioned without transform so a script is free to animate transform. */
#troy-hero {
  position: absolute;
  left: calc(50% - 70px);
  bottom: 100%;
  width: 140px;
  margin-bottom: -10px;
  z-index: 1;
}
#troy-hero svg { width: 100%; height: auto; overflow: visible; }

/* ---------- Panels ---------- */

main > section:not(#hero) {
  padding: 0 clamp(12px, 8.33vw, 120px);
  margin-bottom: var(--panel-gap);
}

.panel {
  max-width: var(--panel-max);
  margin: 0 auto;
  padding: clamp(48px, 7vw, 88px) clamp(20px, 5vw, 72px);
  background: rgba(var(--paper-rgb), var(--panel-alpha));
  border-radius: var(--r-panel);
  text-align: center;
}

.panel > h2 { max-width: 26ch; margin: 0 auto; }
/* A headline of two sentences breaks between them. */
h2 .s { display: inline-block; }

.sub {
  max-width: 34em;
  margin: 20px auto 0;
  text-wrap: balance;
}

.lead {
  font-family: var(--font-serif);
  font-size: var(--fs-lead);
  line-height: 1.15;
  text-wrap: balance;
}

.note {
  max-width: 34em;
  margin: 32px auto 0;
  text-wrap: balance;
}

/* ---------- Circle icons ---------- */

.icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 56px;
  height: 56px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--paper);
  color: var(--ink);
}
.icon svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon svg .dot { fill: currentColor; stroke: none; }

/* ---------- Problem ---------- */

.pairs {
  display: grid;
  gap: 20px;
  max-width: 800px;
  margin: 48px auto;
}
.pair {
  display: grid;
  grid-template-columns: 1fr 112px 1fr;
  align-items: center;
}
.pair-card {
  padding: 20px 24px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-soft);
  text-wrap: balance;
}
/* Dotted line with a gap in the middle: it never connects. */
.pair-line {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 2px;
}
.pair-line::before,
.pair-line::after {
  content: "";
  width: 38%;
  border-top: 2px dotted var(--stone);
}

@media (max-width: 767px) {
  main > section:not(#hero) { padding: 0 12px; }
  /* The pairs stay side by side with the line running across between them, only smaller. */
  .pairs { gap: 16px; margin: 40px auto; }
  .pair { grid-template-columns: 1fr 32px 1fr; }
  .pair-card {
    padding: 12px;
    border-radius: 20px;
    font-size: 0.875rem;
    line-height: 1.35;
  }
}

/* ---------- Two-screen sections ---------- */

.stage {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: clamp(40px, 7vw, 96px);
  margin-top: 48px;
}
.convo {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: clamp(40px, 7vw, 96px);
}
.stage .convo .phone[data-phone="left"] { order: 1; }
.stage .convo .phone[data-phone="right"] { order: 3; }
/* The small arrow between stacked screens on phones */
.stage .convo::before {
  content: "\2192";
  order: 2;
  display: none;
  font-size: 24px;
  line-height: 44px;
  color: var(--stone);
}

/* Free food: phone and map */
.map-figure {
  flex: 0 1 420px;
  min-width: 0;
}
#food-map {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1 / 1;
  padding: 24px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  overflow: hidden;
}
.map-figure figcaption {
  margin-top: 16px;
  font-size: var(--fs-small);
}

/* Broken things: Reported, On it, Fixed between the phones */
.stage.has-steps .convo { gap: 220px; }
.repair-steps {
  position: absolute;
  left: calc(50% - 70px);
  top: calc(50% - 72px);
  width: 140px;
  display: grid;
  gap: 28px;
  text-align: left;
}
.repair-steps li {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 32px;
  font-size: var(--fs-small);
  font-weight: 600;
}
/* The joining line */
.repair-steps li + li::after {
  content: "";
  position: absolute;
  left: 15px;
  bottom: 100%;
  width: 1px;
  height: 28px;
  background: var(--stone);
}
/* The round marker. Done is laurel. */
.repair-steps li::before {
  content: "";
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--laurel);
  border: 1px solid var(--laurel);
}

/* Under each pair: chip and replay */
.pair-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 28px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: var(--tap);
  padding: 8px 18px 8px 14px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  font-size: var(--fs-small);
  font-weight: 500;
  line-height: 1.3;
  color: var(--ink);
  text-align: left;
}
.chip::before {
  content: "";
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--gold);
}
.replay {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--tap);
  height: var(--tap);
  padding: 0;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink);
  cursor: pointer;
}
.replay svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* States that scripts drive. With motion allowed, chips wait for .is-shown and repair steps wait for .is-done.
   With reduced motion or no JavaScript, everything shows in its finished state and replay is hidden. */
@media (prefers-reduced-motion: no-preference) {
  .chip:not(.is-shown) { opacity: 0; }
  .repair-steps li:not(.is-done)::before {
    background: var(--paper);
    border-color: var(--stone);
  }
}
@media (prefers-reduced-motion: reduce) {
  .replay { display: none; }
}

@media (max-width: 767px) {
  .stage { flex-direction: column; gap: 8px; }
  .convo { flex-direction: column; align-items: center; gap: 0; }
  .stage .convo::before { display: block; }
  .stage.has-map .convo::before { content: "\2192"; }
  .map-figure { flex: none; width: 100%; max-width: 420px; }

  .stage.has-steps .convo { gap: 0; }
  .stage.has-steps .convo::before { margin-top: 64px; }
  /* The replay button comes first, so the room kept for the chip is at the bottom and never reads as a hole. */
  .pair-foot { flex-direction: column-reverse; }
  .repair-steps {
    left: 0;
    right: 0;
    top: 512px;           /* label space 36 + phone 460 + 16 */
    width: auto;
    grid-auto-flow: column;
    justify-content: center;
    gap: 28px;
  }
  .repair-steps li { gap: 8px; }
  @media (prefers-reduced-motion: reduce) {
    .repair-steps { top: 612px; }   /* label space 36 + phone 560 + 16 */
  }
  .repair-steps li + li::after {
    left: -22px;
    bottom: 50%;
    width: 16px;
    height: 1px;
  }
}

/* ---------- Why Troy stands out ---------- */

.why-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 40px;
  margin-top: 56px;
}
.why-grid li {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.why-grid h3 { margin-top: 20px; }
.why-grid p { margin-top: 8px; max-width: 20em; }

/* ---------- Engine ---------- */

.engine-steps {
  position: relative;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
  margin-top: 56px;
  padding-bottom: 84px;   /* room for the example under a step */
}
/* The thin line joining the five circles */
.engine-steps::before {
  content: "";
  position: absolute;
  top: 32px;
  left: 10%;
  right: 10%;
  height: 1px;
  background: var(--stone);
}
.engine-step {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.engine-circle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  padding: 0;
  background: var(--paper);
  border: 1px solid var(--stone);
  border-radius: 50%;
  font-family: var(--font-serif);
  font-size: 30px;
  line-height: 1;
  color: var(--ink);
}
button.engine-circle { cursor: pointer; }
/* The title and the line under it read as one sentence: the title in the display font, the rest in body text. */
.engine-step h3 {
  margin-top: 20px;
  font-family: var(--font-serif);
  font-weight: var(--display-weight);
  font-size: 1.5rem;
  letter-spacing: var(--display-tracking);
  line-height: 1.15;
}
.engine-step p { margin-top: 4px; font-size: 1.0625rem; line-height: 1.4; text-wrap: balance; }
.engine-step p.engine-example { margin-top: 12px; font-size: var(--fs-small); }
/* The tiny example. On wide screens it shows just under its step, in room the row keeps free for it. */
.engine-example {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  opacity: 0;
  pointer-events: none;
}
.engine-step:hover .engine-example,
.engine-step:focus-within .engine-example,
.engine-step.is-open .engine-example {
  opacity: 1;
}
.engine-after { margin: 24px auto 0; max-width: 36em; text-wrap: balance; }
/* The five steps are numbered I to V. The digit in the markup stays for screen readers; the numeral is drawn here. */
#engine .engine-circle { font-size: 0; }
#engine .engine-circle::after {
  font-size: 26px;
  letter-spacing: 0.02em;
}
#engine .engine-step:nth-child(1) .engine-circle::after { content: "I"; content: "I" / ""; }
#engine .engine-step:nth-child(2) .engine-circle::after { content: "II"; content: "II" / ""; }
#engine .engine-step:nth-child(3) .engine-circle::after { content: "III"; content: "III" / ""; }
#engine .engine-step:nth-child(4) .engine-circle::after { content: "IV"; content: "IV" / ""; }
#engine .engine-step:nth-child(5) .engine-circle::after { content: "V"; content: "V" / ""; }
@media (max-width: 767px) {
  #engine .engine-circle::after { font-size: 20px; }
}

/* ---------- Safe by design ---------- */

.safe-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-top: 56px;
  text-align: left;
}
.safe-card {
  padding: 24px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-soft);
}
.safe-card h3 { margin-top: 16px; text-wrap: balance; }
.safe-card p { margin-top: 6px; font-size: 1.0625rem; }

/* ---------- Built on purpose: four quiet items on a paper panel ---------- */

#purpose > .panel { padding-block: clamp(40px, 4.5vw, 56px); box-shadow: var(--shadow-soft); }
.purpose-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 28px;
  margin-top: 36px;
  text-align: left;
}
.purpose-grid li { position: relative; padding-top: 22px; }
/* The small circle the page uses for its dots. */
.purpose-grid li::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 10px;
  height: 10px;
  background: var(--gold);
  border: 1px solid var(--stone);
  border-radius: 50%;
}
.purpose-grid h3 { font-size: 1.0625rem; text-wrap: balance; }
.purpose-grid p { margin-top: 6px; font-size: var(--fs-small); line-height: 1.45; color: var(--stone); }

/* ---------- What's next ---------- */

.next-rows {
  display: grid;
  gap: 32px;
  margin: 56px auto 0;
  max-width: 900px;
}
.next-rows h3 { font-size: var(--fs-small); }
.pills {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 12px;
}
.pills li {
  padding: 9px 18px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  font-size: 1.0625rem;
  line-height: 1.3;
}
#next .lead { margin-top: 56px; }
#problem .lead { margin-top: 0; }

/* ---------- FAQ ---------- */

.faq {
  max-width: 760px;
  margin: 40px auto 0;
  text-align: left;
  border-top: 1px solid var(--line);
}
.faq details { border-bottom: 1px solid var(--line); }
.faq summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 64px;
  padding: 14px 4px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: "";
  flex: none;
  width: 10px;
  height: 10px;
  margin-right: 6px;
  border-right: 2px solid var(--ink);
  border-bottom: 2px solid var(--ink);
  transform: translateY(-3px) rotate(45deg);
}
.faq details[open] summary::after { transform: translateY(2px) rotate(-135deg); }
.faq details p { padding: 0 4px 20px; max-width: 38em; }

.faq-more {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  margin-top: 56px;
}

/* ---------- Footer ---------- */

#footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 36px;
  min-height: 100vh;
  min-height: 100svh;
  padding: var(--panel-gap) 16px;
  text-align: center;
  overflow-x: clip;
  --scrim: 0.6;           /* the footer line can sit over the tower's lit windows: 0.54 measured at 390 wide */
}
/* On wide screens the line sits over the dark plaza, clear of the tower: 0.26 measured at 1440 wide. */
@media (min-width: 1200px) {
  #footer { --scrim: 0.32; }
}
.footer-line {
  font-family: var(--font-serif);
  font-size: var(--fs-h2);
  line-height: var(--lh-head);
  text-wrap: balance;
  max-width: 22ch;
}
/* Troy asleep on a chat bubble */
.footer-sleep {
  position: relative;
  width: 220px;
  padding-top: 118px;
}
#troy-sleep {
  position: absolute;
  left: calc(50% - 70px);
  top: 0;
  width: 140px;
  z-index: 1;
}
#troy-sleep svg { width: 100%; height: auto; overflow: visible; }
.sleep-bubble svg { width: 100%; height: auto; fill: var(--bubble-gray); }

/* ---------- Narrow screens ---------- */

@media (max-width: 1023px) {
  .safe-grid { grid-template-columns: repeat(2, 1fr); }
  .purpose-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 767px) {
  #hero { padding-top: 40px; }
  .hero-phone { margin-top: 122px; }
  /* 357px sits above the hero phone here. */
  #hero .phone { height: clamp(480px, calc(100vh - 365px), 640px); height: clamp(480px, calc(100svh - 365px), 640px); }

  /* Why: the three cards stack, so all of them are on the page with nothing hidden off to the side. */
  .why-grid {
    grid-template-columns: 1fr;
    gap: 12px;
    margin-top: 28px;
  }

  /* Engine: the five circles stay in one row on the line. The steps' boxes drop out of the layout so every
     title, line and example shares the same place under the row; only the chosen step's shows (the first
     until one is tapped). They are hidden with opacity only, so the room never jumps. */
  .engine-steps { gap: 0; margin-top: 40px; padding-bottom: 0; }
  .engine-steps::before { top: 24px; }
  .engine-step { display: contents; }
  .engine-circle {
    position: relative;
    grid-row: 1;
    justify-self: center;
    width: 48px;
    height: 48px;
    font-size: 24px;
    cursor: pointer;
  }
  .engine-step:nth-child(1) .engine-circle { grid-column: 1; }
  .engine-step:nth-child(2) .engine-circle { grid-column: 2; }
  .engine-step:nth-child(3) .engine-circle { grid-column: 3; }
  .engine-step:nth-child(4) .engine-circle { grid-column: 4; }
  .engine-step:nth-child(5) .engine-circle { grid-column: 5; }
  .engine-step h3,
  .engine-step p,
  .engine-step p.engine-example {
    grid-column: 1 / -1;
    justify-self: center;
    max-width: 22em;
    opacity: 0;
    pointer-events: none;
  }
  .engine-step h3 { grid-row: 2; margin-top: 24px; }
  .engine-step p { grid-row: 3; margin-top: 4px; }
  .engine-step p.engine-example { position: static; grid-row: 4; margin-top: 10px; }
  .engine-step:hover:not(.is-open):not(:focus-within) .engine-example { opacity: 0; }
  #engine .engine-step:hover:not(.is-open):not(:focus-within) .engine-circle {
    border-color: var(--line);
    color: var(--paper);
  }
  #engine .engine-step.is-open > :not(.engine-circle),
  #engine .engine-step:focus-within > :not(.engine-circle),
  #engine .engine-steps:not(:has(.is-open, :focus-within)) > .engine-step:first-child > :not(.engine-circle) {
    opacity: 1;
  }
  #engine .engine-steps:not(:has(.is-open, :focus-within)) > .engine-step:first-child .engine-circle {
    border-color: var(--gold);
    color: var(--gold);
  }
  .engine-after { margin-top: 32px; }

  /* Safe: two compact columns. */
  .safe-grid { gap: 12px; margin-top: 40px; }
  .safe-card { padding: 16px 14px; border-radius: 20px; }
  .safe-card .icon { width: 44px; height: 44px; }
  .safe-card .icon svg { width: 20px; height: 20px; }
  .safe-card h3 { margin-top: 12px; font-size: 1rem; }
  .safe-card p { margin-top: 4px; font-size: 0.875rem; line-height: 1.4; }
  .pills { gap: 8px; }

  /* Purpose: two by two, on a paper panel with a 16px gutter each side. */
  main > section#purpose { padding-left: 16px; padding-right: 16px; }
  #purpose > .panel { padding: 40px 18px; }
  .purpose-grid { gap: 20px 16px; margin-top: 28px; }
  .purpose-grid h3 { font-size: 1rem; }
  .purpose-grid p { font-size: 0.875rem; line-height: 1.4; }
}

/* ==========================================================================
   Bands. Each section gets one of five treatments so no two neighbors match:
     paper panel   #demos (and #lost-found, #concern, #food, #broken)
     open on scene #problem, #why, #safe   (content sits on the dimmed, blurred painting)
     ink panel     #engine
     cardinal band #next
     narrow paper  #faq
   Styled by section id only. Nothing here animates.
   ========================================================================== */

/* ---------- Shared: full-width bands (open on the scene, cardinal) ---------- */

#problem, #why, #safe, #next {
  position: relative;
  isolation: isolate;
}
#problem::before, #why::before, #safe::before, #next::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}
#problem > .panel, #why > .panel, #safe > .panel, #next > .panel {
  background: none;
  border-radius: 0;
  color: var(--paper);
}
#problem :focus-visible, #why :focus-visible, #safe :focus-visible,
#next :focus-visible, #engine :focus-visible { outline-color: var(--paper); }

/* ---------- Open on the scene ---------- */

/* The scrim: ink over the painting, softly blurred, fading out at the top and bottom so the band has no hard edge.
   0.7 keeps white text above 4.5:1 over the brightest cloud of the day painting. The blur sits on a layer that never animates. */
#problem::before, #why::before, #safe::before {
  background: rgba(var(--ink-rgb), 0.7);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 72px, #000 calc(100% - 72px), transparent);
  mask-image: linear-gradient(to bottom, transparent, #000 72px, #000 calc(100% - 72px), transparent);
}
#problem h2, #why h2, #safe h2, #problem .lead { color: var(--white); }

/* Problem: pinned paper notes on the scene */
#problem > .panel { padding-block: clamp(112px, 11vw, 168px); }
#problem .pair-card { color: var(--ink); }
#problem .pair:nth-child(4n+1) .pair-card:first-child { transform: rotate(-1.5deg); }
#problem .pair:nth-child(4n+1) .pair-card:last-child  { transform: rotate(1deg); }
#problem .pair:nth-child(4n+2) .pair-card:first-child { transform: rotate(1deg); }
#problem .pair:nth-child(4n+3) .pair-card:last-child  { transform: rotate(-1.5deg); }
#problem .pair:nth-child(4n+4) .pair-card:first-child { transform: rotate(-1deg); }
#problem .pair:nth-child(4n+4) .pair-card:last-child  { transform: rotate(2deg); }
#problem .pair-line::before,
#problem .pair-line::after { border-color: rgba(var(--paper-rgb), 0.75); }

/* Why: three dark glass cards, the outer two tilted */
#why > .panel { padding-block: clamp(96px, 9vw, 136px); }
#why .why-grid { gap: 24px; }
#why .why-grid li {
  padding: 32px 24px 36px;
  background: rgba(var(--ink-rgb), 0.42);
  border: 1px solid rgba(var(--paper-rgb), 0.28);
  border-radius: var(--r-card);
}
#why .why-grid li:first-child { transform: rotate(-1.5deg); }
#why .why-grid li:nth-child(2) { transform: translateY(14px); }
#why .why-grid li:last-child { transform: rotate(1.5deg); }
#why .why-grid h3 { color: var(--white); }

/* Safe: four paper cards on the night scene, a few tilted */
#safe > .panel { padding-block: clamp(104px, 10vw, 152px); }
#safe .safe-card { color: var(--ink); }
#safe .safe-card:nth-child(6n+1) { transform: rotate(-1deg); }
#safe .safe-card:nth-child(6n+3) { transform: rotate(1.5deg); }
#safe .safe-card:nth-child(4n+4) { transform: rotate(-1deg); }

/* ---------- Ink panel: the engine ---------- */

#engine > .panel {
  padding-block: clamp(64px, 8vw, 112px);
  background: rgba(var(--ink-rgb), 0.97);
  color: var(--paper);
}
#engine h2, #engine h3 { color: var(--white); }
#engine .engine-step p { color: var(--line); }
#engine .engine-steps::before,
#engine .engine-step:not(:last-child)::after { background: var(--stone); }
#engine .engine-circle {
  background: var(--ink);
  border-color: var(--line);
  color: var(--paper);
}
/* Gold only as the tiny highlight: the step being looked at, and its example. */
#engine .engine-step:hover .engine-circle,
#engine .engine-step:focus-within .engine-circle,
#engine .engine-step.is-open .engine-circle {
  border-color: var(--gold);
  color: var(--gold);
}
#engine .engine-step p.engine-example { color: var(--gold); }
#engine .engine-after { color: var(--paper); }

/* ---------- Cardinal band: what's next ---------- */

/* The page's one divider motif: a Greek key (meander). Classical world, modern tool.
   It is drawn once as a mask, so each use takes its color from the palette: gold on cardinal, line color on the dark scene.
   --key-up has its base line at the bottom, --key-down at the top, so the base always faces the edge it borders. */
:root {
  --key-up: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 15 12'%3E%3Cpath d='M0 10.5H15M1.5 10.5V1.5H13.5V7.5H4.5V4.5H10.5' fill='none' stroke='%23000' stroke-width='1.5' stroke-linecap='square'/%3E%3C/svg%3E");
  --key-down: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 15 12'%3E%3Cpath d='M0 1.5H15M1.5 1.5V10.5H13.5V4.5H4.5V7.5H10.5' fill='none' stroke='%23000' stroke-width='1.5' stroke-linecap='square'/%3E%3C/svg%3E");
}
#next::before { background: var(--cardinal); }
/* Gold keys along the top and bottom of the cardinal band. */
#next::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: var(--gold);
  -webkit-mask:
    var(--key-down) 50% 14px / 20px 16px repeat-x,
    var(--key-up) 50% calc(100% - 14px) / 20px 16px repeat-x;
  mask:
    var(--key-down) 50% 14px / 20px 16px repeat-x,
    var(--key-up) 50% calc(100% - 14px) / 20px 16px repeat-x;
}
/* A thin key rule under the hero and above the footer, fading out at both ends. */
#hero { position: relative; }
#hero::after,
#footer::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  width: min(540px, 62vw);
  height: 12px;
  margin: 0 auto;
  pointer-events: none;
  background: var(--line);
  opacity: 0.9;
  -webkit-mask: var(--key-up) 50% 50% / 15px 12px repeat-x, linear-gradient(to right, transparent, #000 22%, #000 78%, transparent);
  -webkit-mask-composite: source-in;
  mask: var(--key-up) 50% 50% / 15px 12px repeat-x, linear-gradient(to right, transparent, #000 22%, #000 78%, transparent);
  mask-composite: intersect;
}
/* Under the hero it sits just inside the top of the next band, where the scene has started to dim. */
#hero::after { bottom: -46px; }
#footer::before { top: 0; }
#next > .panel { padding-block: clamp(112px, 12vw, 176px); }
#next h2, #next .lead { color: var(--white); }
/* Row labels in tight ink boxes */
#next .next-rows h3 {
  display: inline-block;
  padding: 5px 12px;
  background: var(--ink);
  border-radius: 8px;
  color: var(--paper);
  transform: rotate(-1deg);
}
#next .next-rows li:nth-child(even) > h3,
#next .next-rows > :nth-child(even) h3 { transform: rotate(1deg); }
#next .pills { margin-top: 16px; }
#next .pills li {
  background: none;
  border-color: rgba(var(--paper-rgb), 0.8);
  color: var(--paper);
  transform: none;
}

/* ---------- Paper panels ---------- */

/* Demo stage: the calm ground for the phones (the look from the first pass). */
#demos > .panel, #lost-found > .panel, #concern > .panel, #food > .panel, #broken > .panel {
  box-shadow: var(--shadow-soft);
}

/* FAQ: a narrow, quiet panel before the night footer */
#faq > .panel {
  max-width: 820px;
  padding-block: clamp(48px, 5vw, 64px);
  background: rgba(var(--paper-rgb), 0.97);
}
#faq .faq { margin-top: 32px; }
#faq .faq-more { margin-top: 40px; }

/* ---------- Bands on narrow screens: edge to edge, 18px gutters ---------- */

@media (max-width: 767px) {
  main > section#problem, main > section#why, main > section#safe, main > section#next,
  main > section#engine, main > section#faq, main > section#demos, main > section#lost-found,
  main > section#concern, main > section#food, main > section#broken { padding-left: 0; padding-right: 0; }
  #problem > .panel, #why > .panel, #safe > .panel, #next > .panel,
  #engine > .panel, #faq > .panel,
  #demos > .panel, #lost-found > .panel, #concern > .panel, #food > .panel, #broken > .panel {
    padding-left: 18px;
    padding-right: 18px;
  }
  #problem > .panel { padding-block: 104px; }
  #why > .panel { padding-block: 96px; }
  #safe > .panel { padding-block: 100px; }
  #next > .panel { padding-block: 108px; }
  #engine > .panel { padding-block: 64px; }
  /* Paper panels are not bands: they keep a 16px gutter and never touch the sides of the screen. */
  main > section#faq, main > section#purpose, main > section#demos { padding-left: 16px; padding-right: 16px; }

  /* Tilts stay small where a card is nearly as wide as the screen. */
  #problem .pair .pair-card:first-child { transform: rotate(-1deg); }
  #problem .pair .pair-card:last-child { transform: rotate(1deg); }
  #why .why-grid { gap: 12px; }
  #why .why-grid li { padding: 24px 18px 28px; }
  #why .why-grid li:first-child { transform: rotate(-1deg); }
  #why .why-grid li:nth-child(2) { transform: none; }
  #why .why-grid li:last-child { transform: rotate(1deg); }
  #safe .safe-card:nth-child(6n+3) { transform: rotate(1deg); }
  #next::after {
    -webkit-mask:
      var(--key-down) 50% 12px / 15px 12px repeat-x,
      var(--key-up) 50% calc(100% - 12px) / 15px 12px repeat-x;
    mask:
      var(--key-down) 50% 12px / 15px 12px repeat-x,
      var(--key-up) 50% calc(100% - 12px) / 15px 12px repeat-x;
  }
}

/* ==========================================================================
   Classical details. Three small things, used the same way everywhere:
     laurel sprigs   two mirrored sprigs above each section headline
     Roman numerals  the engine's five steps (see Engine above)
     double rule     a thin double rule with a small diamond, the quiet divider inside paper panels
   All drawn here as masks or backgrounds, in palette colors. Nothing animates.
   ========================================================================== */

:root {
  --sprigs: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 24'%3E%3Cdefs%3E%3Cpath id='l' d='M0 0Q3.6 -2.7 7.4 0Q3.6 2.7 0 0Z'/%3E%3Cg id='s'%3E%3Cpath d='M29 20Q14 20 5 6' fill='none' stroke='%23000' stroke-width='1.1' stroke-linecap='round'/%3E%3Cuse href='%23l' transform='translate(23.2 19.4) rotate(-134)'/%3E%3Cuse href='%23l' transform='translate(23.2 19.4) rotate(157)'/%3E%3Cuse href='%23l' transform='translate(18 17.8) rotate(-121)'/%3E%3Cuse href='%23l' transform='translate(18 17.8) rotate(169)'/%3E%3Cuse href='%23l' transform='translate(13.2 15) rotate(-109)'/%3E%3Cuse href='%23l' transform='translate(13.2 15) rotate(-179)'/%3E%3Cuse href='%23l' transform='translate(8.8 11) rotate(-97)'/%3E%3Cuse href='%23l' transform='translate(8.8 11) rotate(-167)'/%3E%3Cuse href='%23l' transform='translate(5.4 6.6) rotate(-123)'/%3E%3C/g%3E%3C/defs%3E%3Cuse href='%23s'/%3E%3Cuse href='%23s' transform='translate(64 0) scale(-1 1)'/%3E%3C/svg%3E");
  --diamond: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M6 1.2L10.8 6L6 10.8L1.2 6Z' fill='%23FFCC00' stroke='%2378716C' stroke-width='1'/%3E%3C/svg%3E");
}

/* Laurel: above each section's headline. Laurel green on paper, gold on the dark bands. */
.panel > h2::before {
  content: "";
  display: block;
  width: 58px;
  height: 22px;
  margin: 0 auto 18px;
  background: var(--laurel);
  -webkit-mask: var(--sprigs) 50% 50% / contain no-repeat;
  mask: var(--sprigs) 50% 50% / contain no-repeat;
}
#problem > .panel > h2::before, #why > .panel > h2::before, #safe > .panel > h2::before,
#engine > .panel > h2::before, #next > .panel > h2::before { background: var(--gold); }

/* Double rule with a diamond: between the FAQ's questions and its closing line. */
#faq .faq-more::before {
  content: "";
  align-self: center;
  width: min(320px, 72%);
  height: 12px;
  margin-bottom: 12px;
  background:
    var(--diamond) 50% 50% / 12px 12px no-repeat,
    linear-gradient(var(--stone), var(--stone)) 0 3px / calc(50% - 14px) 1px no-repeat,
    linear-gradient(var(--stone), var(--stone)) 0 8px / calc(50% - 14px) 1px no-repeat,
    linear-gradient(var(--stone), var(--stone)) 100% 3px / calc(50% - 14px) 1px no-repeat,
    linear-gradient(var(--stone), var(--stone)) 100% 8px / calc(50% - 14px) 1px no-repeat;
  opacity: 0.7;
}

@media (max-width: 767px) {
  .panel > h2::before { width: 50px; height: 19px; margin-bottom: 14px; }
}
