/* Homepage chapters. Each section carries its own style's tokens, so it renders
   correctly with no JavaScript. morph.js adds the page-level effect on top:
   the .armed class (on each chapter) arms the entrance animations, .is-in plays them, html[data-style]
   switches nav and page colours (tokens.css). Only transform, opacity, clip-path
   and colours are animated. */

/* Every homepage section paints its own background, so text always sits on it. */
main > section[data-style] {
  position: relative;
  isolation: isolate;
  overflow-x: clip; /* scroll-linked drift must never cause sideways scrolling */
}
main > section[data-style]::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--bg);
}

.chapter {
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--t-1);
  line-height: 1.55;
}
.chapter-label {
  font-size: var(--t-0);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--label);
}
.chapter-note {
  font-size: var(--t-0);
  color: var(--muted);
}

/* ---------- Style 01: Swiss ---------- */
.chapter-swiss {
  --font-head: "Archivo", "Archivo fallback", Arial, sans-serif;
  --font-body: "Archivo", "Archivo fallback", Arial, sans-serif;
  --head-weight: 700;
  --head-variation: normal;

  --t-0: 0.75rem;    /* 12 */
  --t-1: 1rem;       /* 16 */
  --t-2: 1.3125rem;  /* 21 */
  --t-3: 1.75rem;    /* 28 */
  --t-4: 2.375rem;   /* 38 */
  --t-5: 3.125rem;   /* 50 */
  --t-6: clamp(4.1875rem, 2rem + 4.5vw, 6rem); /* 67 → 96 */

  --s-1: 0.5rem;  /* 8 */
  --s-2: 1rem;    /* 16 */
  --s-3: 1.5rem;  /* 24 */
  --s-4: 2rem;    /* 32 */
  --s-5: 3rem;    /* 48 */
  --s-6: 4rem;    /* 64 */
  --s-7: 6rem;    /* 96 */

  --bg: #FFFFFF;
  --ink: #000000;
  --muted: #595959;
  --accent: #D0201A;
  --label: #D0201A;
  --focus: #D0201A;
  --rule: #000000;
  --btn-bg: #000000;
  --btn-fg: #FFFFFF;
  --btn-hover-bg: #D0201A;
  --radius: 0;

  padding-block: var(--s-6);
}
.sw-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  column-gap: var(--s-2);
}
.sw-grid > * { grid-column: 1 / -1; }
.chapter-swiss h2 {
  margin-top: var(--s-2);
  font-size: var(--t-5);
  line-height: 0.95;
  letter-spacing: -0.03em;
}
.sw-intro {
  margin-top: var(--s-4);
  font-size: var(--t-2);
  line-height: 1.35;
}
.sw-parts {
  list-style: none;
  padding: 0;
  margin-top: var(--s-6);
}
.sw-parts li,
.sw-prices {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  column-gap: var(--s-2);
  padding-block: var(--s-3);
}
/* Hairlines are separate elements so they can draw in with scaleX. */
.sw-parts li::before,
.sw-prices::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 1px;
  background: var(--rule);
  transform-origin: left;
}
.sw-num {
  grid-row: span 2;
  font-size: var(--t-3);
  font-weight: 700;
  line-height: 1;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.sw-parts h3 {
  grid-column: 2 / -1;
  font-size: var(--t-2);
  line-height: 1.2;
}
.sw-parts p {
  grid-column: 2 / -1;
  margin-top: var(--s-1);
}
.sw-prices {
  margin-top: var(--s-5);
  row-gap: var(--s-3);
}
.sw-prices > div { grid-column: 1 / -1; }
.sw-prices dt {
  font-size: var(--t-0);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.sw-prices dd { margin-top: var(--s-1); }
.sw-figure {
  font-size: var(--t-5);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.03em;
}
.sw-small { font-size: var(--t-1); }
.sw-after { margin-top: var(--s-3); }
.sw-after p + p { margin-top: var(--s-1); }
.sw-after a { font-weight: 700; }
.chapter-swiss .chapter-note { margin-top: var(--s-6); }

@media (min-width: 48rem) {
  .chapter-swiss { padding-block: var(--s-7); }
  .sw-grid,
  .sw-parts li,
  .sw-prices {
    grid-template-columns: repeat(12, minmax(0, 1fr));
    column-gap: var(--s-3);
  }
  .chapter-swiss .chapter-label { grid-column: 1 / 4; grid-row: 1; padding-top: var(--s-2); }
  .chapter-swiss h2 { grid-column: 4 / -1; grid-row: 1; margin-top: 0; font-size: var(--t-6); }
  .sw-intro { grid-column: 4 / span 6; }
  .sw-num { grid-column: 1 / 4; grid-row: auto; font-size: var(--t-4); }
  .sw-parts h3 { grid-column: 4 / 8; }
  .sw-parts p { grid-column: 8 / -1; margin-top: 0; }
  .sw-prices > div:first-child { grid-column: 4 / 8; }
  .sw-prices > div:last-child { grid-column: 8 / -1; }
  .sw-after { grid-column: 4 / -1; }
  .sw-figure { font-size: var(--t-6); }
  .chapter-swiss .chapter-note { grid-column: 4 / -1; }
}

/* ---------- Style 02: Editorial ---------- */
.chapter-editorial {
  --font-head: "Newsreader", "Newsreader fallback", Georgia, serif;
  --font-body: "Newsreader", "Newsreader fallback", Georgia, serif;
  --head-weight: 300;
  --head-variation: normal;

  --t-0: 0.8125rem;  /* 13 */
  --t-1: 1.125rem;   /* 18 */
  --t-2: 1.5625rem;  /* 25 */
  --t-3: 2.25rem;    /* 36 */
  --t-4: 3.1875rem;  /* 51 */
  --t-5: 4.5rem;     /* 72 */
  --t-6: clamp(4.5rem, 1.5rem + 6vw, 6.5rem); /* 72 → 104 */

  --s-1: 0.4375rem;  /* 7 */
  --s-2: 0.875rem;   /* 14 */
  --s-3: 1.75rem;    /* 28: the baseline */
  --s-4: 3.5rem;     /* 56 */
  --s-5: 5.25rem;    /* 84 */
  --s-6: 7rem;       /* 112 */

  --bg: #1B1815;
  --ink: #F1EADB;
  --muted: #BDB3A1;
  --accent: #E0A846;
  --label: #E0A846;
  --focus: #E0A846;
  --rule: #5C544A;
  --btn-bg: #F1EADB;
  --btn-fg: #1B1815;
  --btn-hover-bg: #E0A846;
  --radius: 0;

  line-height: 1.5556; /* 28px on 18px */
  padding-block: var(--s-5);
}
.ed-grid > * + * { margin-top: var(--s-3); }
.chapter-editorial h2 {
  margin-top: var(--s-3);
  font-size: var(--t-3);
  line-height: 1.1;
  max-width: 22ch;
}
.chapter-editorial h2 + p { margin-top: var(--s-4); }
.ed-grid > p:not(.chapter-label, .chapter-note, .ed-pull) { max-width: 34rem; }
.ed-first::first-letter {
  float: left;
  margin: var(--s-1) var(--s-2) 0 0;
  font-size: var(--t-5);
  line-height: 0.8;
  color: var(--accent);
}
@supports (initial-letter: 3) {
  .ed-first::first-letter {
    float: none;
    margin: 0 var(--s-2) 0 0;
    font-size: inherit;
    line-height: inherit;
    initial-letter: 3;
  }
}
.ed-pull {
  padding-block: var(--s-3);
  border-block: 1px solid var(--accent);
  font-size: var(--t-2);
  line-height: 1.12;
  color: var(--accent);
  text-wrap: balance;
}
.chapter-editorial .chapter-note {
  padding-top: var(--s-3);
  border-top: 1px solid var(--rule);
}
.chapter-editorial a { color: var(--accent); }

@media (min-width: 48rem) {
  .chapter-editorial { padding-block: var(--s-6); }
  .ed-grid {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    column-gap: var(--s-3);
    align-items: start;
  }
  .ed-grid > * { grid-column: 3 / span 6; }
  .ed-grid > * + * { margin-top: 0; }
  .ed-grid > p:not(.chapter-label) { margin-bottom: var(--s-3); }
  .chapter-editorial .chapter-label { grid-column: 1 / -1; margin-bottom: var(--s-3); }
  .chapter-editorial h2 { grid-column: 1 / 11; margin: 0 0 var(--s-4); font-size: var(--t-5); }
  .chapter-editorial h2 + p { margin-top: 0; }
  .ed-pull { grid-column: 9 / -1; grid-row: span 3; font-size: var(--t-3); }
  .chapter-editorial .chapter-note { grid-column: 3 / -1; margin-top: var(--s-3); }
}

/* ---------- Style 03: Brutalist ---------- */
.chapter-brutalist {
  --font-head: "Archivo", "Archivo fallback", Arial, sans-serif;
  --font-body: "Archivo", "Archivo fallback", Arial, sans-serif;
  --head-weight: 900;
  --head-variation: normal;

  --t-0: 0.8125rem;  /* 13 */
  --t-1: 1.0625rem;  /* 17 */
  --t-2: 1.625rem;   /* 26 */
  --t-3: 2.375rem;   /* 38 */
  --t-4: 3.5625rem;  /* 57 */
  --t-5: 5.375rem;   /* 86 */
  --t-6: clamp(5.375rem, 1rem + 8vw, 8rem); /* 86 → 128 */

  --s-1: 0.5rem;  /* 8 */
  --s-2: 1rem;    /* 16 */
  --s-3: 2rem;    /* 32 */
  --s-4: 4rem;    /* 64 */
  --s-5: 8rem;    /* 128 */
  --border: 4px;
  --border-thick: 8px;

  --bg: #FFE14D;
  --ink: #000000;
  --muted: #000000;
  --accent: #000000;
  --label: #FFE14D;
  --focus: #000000;
  --rule: #000000;
  --btn-bg: #000000;
  --btn-fg: #FFE14D;
  --btn-hover-bg: #FF5A1F;
  --radius: 0;

  font-stretch: 112%;
  padding-block: var(--s-4);
  border-block: var(--border-thick) solid var(--ink);
}
.chapter-brutalist .chapter-label {
  display: inline-block;
  padding: var(--s-1) var(--s-2);
  background: var(--ink);
  letter-spacing: 0.04em;
}
.br-clip {
  margin-top: var(--s-3);
  overflow: clip;
}
.chapter-brutalist h2,
.chapter-brutalist h3 {
  font-stretch: 125%;
  text-transform: uppercase;
  line-height: 0.95;
  letter-spacing: -0.01em;
}
.chapter-brutalist h2 { font-size: var(--t-3); }
.br-steps {
  list-style: none;
  padding: 0;
  margin-top: var(--s-3);
  display: grid;
  gap: var(--border);
  background: var(--ink);           /* the gaps are the visible grid lines */
  border: var(--border) solid var(--ink);
}
.br-step {
  overflow: clip;
  padding: var(--s-3) var(--s-2);
  background: var(--bg);
}
.br-step:nth-child(2) { background: #000000; color: #FFE14D; }
.br-step:nth-child(3) { background: #FF5A1F; }
.br-num {
  font-size: var(--t-0);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.br-step h3 {
  margin-top: var(--s-1);
  font-size: var(--t-2);
}
.br-step h3 + p { margin-top: var(--s-2); }
.chapter-brutalist .chapter-note {
  margin-top: var(--s-3);
  padding-top: var(--s-2);
  border-top: var(--border) solid var(--ink);
  font-weight: 700;
}

@media (min-width: 48rem) {
  .chapter-brutalist { padding-block: var(--s-5) var(--s-4); }
  .chapter-brutalist h2 { font-size: var(--t-5); }
  .br-steps { grid-template-columns: 1fr 1fr; margin-top: var(--s-4); }
  .br-step { padding: var(--s-3); }
  .br-step h3 { font-size: var(--t-3); }
}

/* ---------- Style 04: Warm ---------- */
.chapter-warm {
  --font-head: "Fraunces", "Fraunces fallback", Georgia, serif;
  --font-body: "Archivo", "Archivo fallback", Arial, sans-serif;
  --head-weight: 650;
  --head-variation: "SOFT" 100, "WONK" 1;

  --t-0: 0.875rem;   /* 14 */
  --t-1: 1.125rem;   /* 18 */
  --t-2: 1.4375rem;  /* 23 */
  --t-3: 1.75rem;    /* 28 */
  --t-4: 2.1875rem;  /* 35 */
  --t-5: 2.75rem;    /* 44 */
  --t-6: 3.4375rem;  /* 55 */

  --s-1: 0.5rem;     /* 8 */
  --s-2: 0.75rem;    /* 12 */
  --s-3: 1.25rem;    /* 20 */
  --s-4: 2rem;       /* 32 */
  --s-5: 3.25rem;    /* 52 */
  --s-6: 5.25rem;    /* 84 */

  --bg: #F2E4CF;
  --surface: #FBF4E8;
  --photo: #E7D3B6;
  --ink: #3B2A1D;
  --muted: #6B5644;
  --accent: #A0441F;
  --label: #4F5A2A;
  --focus: #A0441F;
  --btn-bg: #A0441F;
  --btn-fg: #FFF8EE;
  --btn-hover-bg: #86361A;
  --radius: 999px;
  --card-radius: 14px;
  --photo-radius: 20px;

  padding-block: var(--s-5);
}
.wm-grid {
  display: grid;
  gap: var(--s-4);
  grid-template-areas: "head" "big" "list" "small" "note";
}
.wm-head { grid-area: head; }
.wm-photo-big { grid-area: big; }
.wm-list { grid-area: list; }
.wm-small { grid-area: small; display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-3); }
.chapter-warm .chapter-note { grid-area: note; }

.chapter-warm h2 {
  margin-top: var(--s-2);
  font-size: var(--t-5);
  line-height: 1.05;
}
.wm-intro {
  margin-top: var(--s-3);
  font-size: var(--t-2);
  line-height: 1.4;
  color: var(--muted);
}
.wm-list {
  padding: var(--s-4) var(--s-3);
  border-radius: var(--card-radius);
  background: var(--surface);
}
.wm-list h3 { font-size: var(--t-3); line-height: 1.15; }
.wm-list ul {
  list-style: none;
  padding: 0;
  margin-top: var(--s-3);
  display: grid;
  gap: var(--s-2);
}
.wm-list li {
  position: relative;
  padding-left: var(--s-4);
}
.wm-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.45em;
  width: var(--s-2);
  height: var(--s-2);
  border-radius: 50%;
  background: var(--label);
}
.wm-photo {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  padding: var(--s-3);
  border: 2px dashed var(--muted);
  border-radius: var(--photo-radius);
  background: var(--photo);
  font-size: var(--t-0);
  text-align: center;
}
.wm-photo-big { aspect-ratio: 4 / 3; }

@media (min-width: 48rem) {
  .chapter-warm { padding-block: var(--s-6); }
  .wm-grid {
    grid-template-columns: 5fr 6fr;
    grid-template-areas: "head big" "list small" "note note";
    column-gap: var(--s-5);
    row-gap: var(--s-4);
    align-items: start;
  }
  .chapter-warm h2 { font-size: var(--t-6); }
  .wm-list { padding: var(--s-4); }
}

/* ---------- Closing (home style) ---------- */
.chapter-home { font-size: var(--t-1); }

/* ---------- Entrances: only when morph.js has armed them ---------- */
.chapter.armed:not(.is-in) .chapter-inner { opacity: 0; }

/* Swiss: hard left-to-right wipe, then hairlines draw in. */
.chapter-swiss.armed:not(.is-in)::before { clip-path: inset(0 100% 0 0); }
.chapter-swiss.is-in::before { animation: wipe-ltr 400ms cubic-bezier(0.77, 0, 0.18, 1) both; }
.chapter-swiss.is-in .chapter-inner { animation: fade-in 200ms 380ms linear both; }
.chapter-swiss.is-in .sw-parts li::before,
.chapter-swiss.is-in .sw-prices::before { animation: draw 450ms 380ms cubic-bezier(0.77, 0, 0.18, 1) both; }
.chapter-swiss.is-in .sw-parts li:nth-child(2)::before { animation-delay: 440ms; }
.chapter-swiss.is-in .sw-parts li:nth-child(3)::before { animation-delay: 500ms; }
.chapter-swiss.is-in .sw-parts li:nth-child(4)::before { animation-delay: 560ms; }
.chapter-swiss.is-in .sw-prices::before { animation-delay: 620ms; }

/* Editorial: the lights go down, then the type fades up. */
.chapter-editorial.armed:not(.is-in)::before { opacity: 0; }
.chapter-editorial.is-in::before { animation: fade-in 700ms ease both; }
.chapter-editorial.is-in .chapter-inner { animation: fade-up 500ms 650ms ease-out both; }

/* Brutalist: hard cut, then each block slams up into place. */
.chapter-brutalist.armed:not(.is-in)::before { opacity: 0; }
.chapter-brutalist.armed:not(.is-in) .chapter-inner { opacity: 1; }
.chapter-brutalist.armed:not(.is-in) .br-clip > h2,
.chapter-brutalist.armed:not(.is-in) .br-body,
.chapter-brutalist.armed:not(.is-in) .chapter-label,
.chapter-brutalist.armed:not(.is-in) .chapter-note { transform: translateY(110%); opacity: 0; }
.chapter-brutalist.is-in .chapter-label,
.chapter-brutalist.is-in .br-clip > h2,
.chapter-brutalist.is-in .br-body,
.chapter-brutalist.is-in .chapter-note { animation: slam 250ms cubic-bezier(0.2, 0.9, 0.1, 1) both; }
.chapter-brutalist.is-in .br-clip > h2 { animation-delay: 60ms; }
.chapter-brutalist.is-in .br-step:nth-child(1) .br-body { animation-delay: 140ms; }
.chapter-brutalist.is-in .br-step:nth-child(2) .br-body { animation-delay: 200ms; }
.chapter-brutalist.is-in .br-step:nth-child(3) .br-body { animation-delay: 260ms; }
.chapter-brutalist.is-in .br-step:nth-child(4) .br-body { animation-delay: 320ms; }
.chapter-brutalist.is-in .chapter-note { animation-delay: 380ms; }

/* Warm: a soft circle opens from the big photo, then the pieces rise. */
.chapter-warm.armed:not(.is-in)::before { clip-path: circle(0 at 75% 30%); }
.chapter-warm.is-in::before { animation: open-circle 600ms ease-out both; }
.chapter-warm.is-in .chapter-inner { animation: fade-in 1ms 380ms both; }
.chapter-warm.is-in .wm-grid > * { animation: rise 500ms 380ms ease-out both; }
.chapter-warm.is-in .wm-photo-big { animation-delay: 440ms; }
.chapter-warm.is-in .wm-list { animation-delay: 500ms; }
.chapter-warm.is-in .wm-small { animation-delay: 560ms; }
.chapter-warm.is-in .chapter-note { animation-delay: 620ms; }

/* Back home: a calm upward wipe. */
.chapter-home.armed:not(.is-in)::before { clip-path: inset(100% 0 0 0); }
.chapter-home.is-in::before { animation: wipe-up 500ms cubic-bezier(0.33, 1, 0.68, 1) both; }
.chapter-home.is-in .chapter-inner { animation: fade-in 300ms 420ms ease both; }

@keyframes wipe-ltr { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0); } }
@keyframes wipe-up { from { clip-path: inset(100% 0 0 0); } to { clip-path: inset(0); } }
@keyframes open-circle { from { clip-path: circle(0 at 75% 30%); } to { clip-path: circle(150% at 75% 30%); } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes fade-up { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes draw { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes slam { from { opacity: 1; transform: translateY(110%); } to { opacity: 1; transform: none; } }
@keyframes rise { from { opacity: 0; transform: translateY(var(--s-3)); } to { opacity: 1; transform: none; } }

/* Progressive enhancement: gentle scroll-linked drift where supported. */
@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    .ed-pull { animation: drift-y linear both; animation-timeline: view(); }
  }
  @media (prefers-reduced-motion: no-preference) and (min-width: 48rem) {
    .br-clip { animation: drift-x linear both; animation-timeline: view(); }
  }
}
@keyframes drift-y { from { transform: translateY(var(--s-3)); } to { transform: translateY(calc(var(--s-3) * -1)); } }
@keyframes drift-x { from { transform: translateX(var(--s-3)); } to { transform: translateX(calc(var(--s-3) * -1)); } }

@media (prefers-reduced-motion: reduce) {
  .chapter *, .chapter::before { animation: none !important; }
}
