/* SWC Partnership: WHISKAS x Channel 4 case study
   One family (Bricolage Grotesque), one palette (WHISKAS plum and friends),
   one motion moment (the split-flap 8 to 9). */

:root {
  --plum: #4C0348;
  --plum-deep: #2A0128;
  --magenta: #9B2F8F;
  --lilac: #D38ABA;
  --lilac-pale: #F3DFEE;
  --paper: #F8F1F6;
  --paper-2: #EEDFEA;
  --ink: #26102A;
  --ink-soft: #5E4360;
  --white: #FFFFFF;
  --tile: #FFFFFF;
  --tile-2: #F1E4EE;

  --font: "Bricolage Grotesque", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --wrap: 1280px;
  --gutter: clamp(1.25rem, 4vw, 3rem);
  --header-h: 4rem;
  --radius: 1.25rem;
  --focus: var(--magenta);
  --ease: cubic-bezier(.2, .7, .2, 1);
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: calc(var(--header-h) + 1rem);
}
html[data-motion="on"] { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  font-optical-sizing: auto;
  font-size: 1.0625rem;
  line-height: 1.55;
  color: var(--ink);
  background: var(--paper);
  overflow-x: hidden;
}

img, video, svg { display: block; max-width: 100%; }
video { width: 100%; height: auto; }
a { color: inherit; }
p { margin: 0 0 1em; }
h1, h2, h3 { margin: 0; font-weight: 800; letter-spacing: -0.02em; line-height: 1.02; }
sup { line-height: 0; font-size: .6em; }
sup a { text-decoration: none; color: var(--magenta); font-weight: 700; }
sup a:hover { text-decoration: underline; }
.hero sup a, .result sup a, .contact sup a { color: var(--lilac); }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 4px; }

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

.skip-link {
  position: absolute; left: 1rem; top: -4rem; z-index: 100;
  background: var(--white); color: var(--plum); padding: .6rem 1rem;
  border-radius: 999px; font-weight: 700; text-decoration: none;
}
.skip-link:focus { top: 1rem; }

.wrap {
  width: min(100% - 2 * var(--gutter), var(--wrap));
  margin-inline: auto;
}

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

.btn {
  display: inline-flex; align-items: center; gap: .55rem;
  padding: .85rem 1.4rem; border-radius: 999px;
  font: inherit; font-weight: 700; line-height: 1.1; text-decoration: none;
  border: 2px solid transparent; cursor: pointer;
  transition: background-color .2s var(--ease), color .2s var(--ease), border-color .2s var(--ease);
}
.btn-primary { background: var(--magenta); color: var(--white); border-color: var(--magenta); }
.btn-primary:hover { background: var(--plum); border-color: var(--plum); }
.btn-light { background: var(--white); color: var(--plum); border-color: var(--white); }
.btn-light:hover { background: var(--lilac-pale); border-color: var(--lilac-pale); }
.btn-ghost { background: transparent; color: var(--plum); border-color: var(--plum); }
.btn-ghost:hover { background: var(--plum); color: var(--white); }
.btn-ghost-light { background: transparent; color: var(--white); border-color: var(--lilac); }
.btn-ghost-light:hover { background: var(--lilac); color: var(--plum); }
.btn svg { width: 1.1em; height: 1.1em; flex: none; }

/* ---------- Header ---------- */

.site-header {
  position: sticky; top: 0; z-index: 50;
  background: var(--plum); color: var(--white);
  --focus: var(--lilac);
}
.header-inner {
  display: flex; align-items: center; gap: 1rem;
  min-height: var(--header-h);
}
.wordmark {
  display: block;
  flex-shrink: 0;
}
.wordmark img {
  width: auto;
  height: var(--header-h);
}
.site-nav { margin-inline: auto; }
.site-nav ul { list-style: none; margin: 0; padding: 0; display: flex; gap: .25rem; }
.site-nav a {
  display: block; padding: .55rem .9rem; border-radius: 999px;
  text-decoration: none; font-weight: 600; font-size: .98rem; white-space: nowrap;
  transition: background-color .2s var(--ease);
}
.site-nav a:hover { background: rgba(255,255,255,.12); }
.menu-toggle, .motion-toggle {
  display: inline-flex; align-items: center; gap: .5rem;
  font: inherit; font-weight: 700; font-size: .95rem; white-space: nowrap;
  color: var(--white); background: transparent;
  border: 2px solid rgba(255,255,255,.35); border-radius: 999px;
  padding: .5rem .95rem; cursor: pointer;
  transition: border-color .2s var(--ease), background-color .2s var(--ease);
}
.menu-toggle:hover, .motion-toggle:hover { border-color: var(--white); background: rgba(255,255,255,.08); }
.motion-toggle svg { width: 1rem; height: 1rem; fill: currentColor; }
.motion-toggle .icon-play, html[data-motion="off"] .motion-toggle .icon-pause { display: none; }
html[data-motion="off"] .motion-toggle .icon-play { display: block; }
.menu-toggle { display: none; margin-left: auto; }

@media (max-width: 1023px) {
  .menu-toggle { display: inline-flex; }
  .site-nav {
    position: absolute; left: 0; right: 0; top: 100%;
    background: var(--plum-deep); margin: 0;
    padding: .5rem var(--gutter) 1rem;
    border-top: 1px solid rgba(255,255,255,.15);
  }
  .site-nav ul { flex-direction: column; gap: .1rem; }
  .site-nav a { padding: .8rem .75rem; font-size: 1.05rem; }
  .js .site-nav { display: none; }
  .js .site-header.is-open .site-nav { display: block; }
  .motion-toggle span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .motion-toggle { padding: .55rem .7rem; }
}

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

.hero {
  background: var(--plum); color: var(--white);
  --focus: var(--lilac);
  padding-block: clamp(2.5rem, 6vw, 5.5rem) clamp(2.5rem, 6vw, 5rem);
  overflow: hidden;
}
.hero-grid {
  display: grid; gap: clamp(2rem, 5vw, 4rem);
  align-items: center;
}
@media (min-width: 900px) {
  .hero-grid { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); }
}

.claim {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: .12em .28em;
  font-size: clamp(3.2rem, 8.5vw, 7.5rem);
  font-weight: 800; line-height: 1; letter-spacing: -0.035em;
  margin: 0 0 .32em;
}
.hero-title {
  font-size: clamp(1.75rem, 3.6vw, 3.1rem);
  max-width: 22ch; margin-bottom: .6em;
  text-wrap: balance;
}
.hero-dek {
  font-size: clamp(1.05rem, 1.4vw, 1.25rem);
  max-width: 34em; color: var(--lilac-pale);
}
.hero-tag {
  font-stretch: 85%; font-weight: 600; color: var(--lilac);
  margin: 1.5rem 0 0; font-size: .95rem;
}

.hero-media {
  width: auto; max-width: 100%;
  aspect-ratio: 600 / 867;
  max-height: min(78vh, 760px);
  margin-inline: auto;
  border-radius: var(--radius); overflow: hidden;
  background: var(--plum-deep);
  box-shadow: 0 30px 60px -30px rgba(0,0,0,.6);
}
.hero-media video, .hero-media img { width: 100%; height: 100%; object-fit: cover; }
@media (min-width: 900px) { .hero-media { margin-inline: 0 auto; justify-self: end; } }
@media (max-width: 899px) { .hero-media { max-height: 70vh; } }

/* ---------- Split-flap tile ---------- */

.flap {
  position: relative; display: inline-grid;
  height: 1.18em; line-height: 1.18em;
  perspective: 900px;
  color: var(--plum);
  font-variant-numeric: tabular-nums;
  vertical-align: baseline;
}
.flap-size { visibility: hidden; padding: 0 .16em; white-space: nowrap; }
.flap-half {
  position: absolute; left: 0; width: 100%; height: 50%;
  overflow: hidden; background: var(--tile);
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
}
.flap-top { top: 0; border-radius: .1em .1em 0 0; transform-origin: 50% 100%; z-index: 1; }
.flap-bottom { bottom: 0; border-radius: 0 0 .1em .1em; transform-origin: 50% 0; background: var(--tile-2); z-index: 1; }
.flap-half > span {
  position: absolute; left: 0; width: 100%; height: 200%;
  display: flex; align-items: center; justify-content: center;
  padding: 0 .16em; white-space: nowrap;
}
.flap-top > span { top: 0; }
.flap-bottom > span { bottom: 0; }
.flap-leaf { z-index: 3; }
.flap::after {
  content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 2px;
  margin-top: -1px; background: rgba(76, 3, 72, .35); z-index: 4;
}

/* Resting state (no JS, motion off, or reduced motion): show the new number. */
.flap-cur { visibility: hidden; }

/* Motion on: show the old number, keep the new bottom leaf edge-on until the flip.
   The data-motion attribute is set by a tiny inline script in <head>, so there is no flash. */
html[data-motion="on"] .flap .flap-cur { visibility: visible; }
html[data-motion="on"] .flap .flap-bottom.flap-leaf { transform: rotateX(90deg); }
html[data-motion="on"] .flap.is-flipped .flap-top.flap-leaf { animation: flap-down .34s ease-in forwards; }
html[data-motion="on"] .flap.is-flipped .flap-bottom.flap-leaf { animation: flap-up .34s ease-out .3s forwards; }
html[data-motion="on"] .flap.is-flipped .flap-bottom.flap-cur { animation: flap-hide 0s linear .64s forwards; }

@keyframes flap-down { from { transform: rotateX(0deg); } to { transform: rotateX(-90deg); } }
@keyframes flap-up { from { transform: rotateX(90deg); } to { transform: rotateX(0deg); } }
@keyframes flap-hide { to { visibility: hidden; } }

/* ---------- Sections ---------- */

.section { padding-block: clamp(3.5rem, 8vw, 7rem); }
.section-title {
  font-size: clamp(1.9rem, 3.6vw, 3.1rem);
  max-width: 18ch;
}
.lede { font-size: clamp(1.1rem, 1.5vw, 1.3rem); max-width: 34em; }
.measure { max-width: 34em; }

/* Story */
.story-grid { display: grid; gap: 2rem; }
@media (min-width: 900px) {
  .story-grid { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 4rem; align-items: start; }
}
.story-grid .section-title { color: var(--plum); }

/* Speech bubble: the cats do the talking */
.meow {
  position: relative; margin: 1.5rem 0 2rem;
  background: var(--plum); color: var(--white);
  border-radius: var(--radius); padding: 1.1rem 1.4rem;
  font-weight: 600; font-size: 1.1rem; line-height: 1.35;
  max-width: 30em;
}
.meow p { margin: 0; }
.meow::after {
  content: ""; position: absolute; left: 2rem; bottom: -.7rem;
  width: 1.4rem; height: 1.4rem; background: var(--plum);
  transform: rotate(45deg); border-radius: 0 0 .25rem 0;
}
.meow cite { display: block; font-style: normal; font-weight: 500; font-size: .85rem; color: var(--lilac); margin-top: .5rem; font-stretch: 85%; }
.meow-big {
  font-size: clamp(1.35rem, 2.3vw, 2rem); font-weight: 700; letter-spacing: -0.01em;
  padding: 1.5rem 2rem; max-width: 24em; margin-top: 2.5rem;
}

/* ---------- Emails ---------- */

.emails { background: var(--paper-2); }
.emails-head { margin-bottom: clamp(2rem, 4vw, 3.5rem); }
.emails-head .section-title { color: var(--plum); margin-bottom: .5rem; }
.emails-layout { display: grid; gap: 2.5rem; }
@media (min-width: 1024px) {
  .emails-layout { grid-template-columns: 300px minmax(0, 1fr); gap: 3.5rem; }
  .inbox-wrap { position: sticky; top: calc(var(--header-h) + 1.5rem); align-self: start; }
}

.inbox {
  list-style: none; margin: 0; padding: 0;
  background: var(--white); border-radius: var(--radius); overflow: hidden;
  border: 1px solid rgba(76, 3, 72, .12);
}
.inbox li + li { border-top: 1px solid var(--paper-2); }
.inbox a {
  display: grid; grid-template-columns: 1fr auto; gap: .1rem .75rem;
  padding: .95rem 1.1rem; text-decoration: none;
  transition: background-color .2s var(--ease), color .2s var(--ease);
}
.inbox a:hover { background: var(--paper); }
.inbox-from { font-weight: 800; font-size: .9rem; color: var(--plum); }
.inbox time { font-size: .85rem; font-stretch: 85%; font-weight: 600; color: var(--ink-soft); text-align: right; }
.inbox-subject { grid-column: 1 / -1; font-weight: 500; line-height: 1.3; }
.inbox a.is-active { background: var(--plum); color: var(--white); }
.inbox a.is-active .inbox-from, .inbox a.is-active time { color: var(--lilac); }
.inbox-note { font-size: .9rem; color: var(--ink-soft); margin: 1rem .25rem 0; }

.chapter {
  display: grid; gap: 2rem;
  padding-block: clamp(2.5rem, 4vw, 4rem);
  border-top: 2px solid var(--plum);
}
.chapter:first-of-type { border-top: 0; padding-top: 0; }
@media (min-width: 800px) {
  .chapter { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 3rem; align-items: start; }
}
.chapter-meta {
  display: flex; flex-wrap: wrap; gap: .25rem 1rem;
  font-stretch: 85%; font-weight: 700; color: var(--magenta); margin-bottom: .75rem;
}
.chapter-subject {
  font-size: clamp(1.6rem, 2.8vw, 2.4rem); color: var(--plum);
  margin-bottom: .75em; text-wrap: balance;
}
.chapter-text .meow { margin-top: 1.25rem; }
.chapter-text .btn { margin-top: .25rem; }

.chapter-media { display: grid; gap: 1rem; align-items: end; }
.media-duo { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
@media (max-width: 479px) { .media-duo { grid-template-columns: minmax(0, 1fr); } }
.creative {
  margin: 0; border-radius: var(--radius); overflow: hidden;
  background: var(--plum);
  box-shadow: 0 24px 48px -28px rgba(42, 1, 40, .5);
}
.creative video, .creative img { width: 100%; height: auto; }

/* ---------- Result ---------- */

.result { background: var(--plum); color: var(--white); --focus: var(--lilac); }
.result-grid { display: grid; gap: 2.5rem; align-items: center; }
@media (min-width: 900px) { .result-grid { grid-template-columns: minmax(0, 6fr) minmax(0, 6fr); gap: 4rem; } }
.result .section-title { margin-bottom: .6em; }
.result .lede { color: var(--lilac-pale); }
.donation { margin: 2rem 0 2.25rem; }
.donation .flap { font-size: clamp(2.4rem, 5.5vw, 4.5rem); font-weight: 800; letter-spacing: -0.03em; }
.donation-note { margin: .75rem 0 0; color: var(--lilac-pale); font-size: 1rem; }
.result-actions { display: flex; flex-wrap: wrap; gap: .75rem; }
.result .creative { box-shadow: 0 30px 60px -30px rgba(0,0,0,.6); }

/* ---------- Craft ---------- */

.craft-grid { display: grid; gap: 2.5rem; }
@media (min-width: 900px) { .craft-grid { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 4rem; align-items: start; } }
.craft .section-title { color: var(--plum); margin-bottom: .6em; }
.craft-credit { max-width: 32em; }
.craft-sign { max-width: 320px; margin-top: 1.5rem; }
.notes { list-style: none; margin: 0; padding: 0; display: grid; gap: 1.5rem; }
@media (min-width: 800px) { .notes { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.notes li { border-top: 3px solid var(--plum); padding-top: 1rem; }
.notes h3 { font-size: 1.25rem; color: var(--plum); margin-bottom: .5rem; letter-spacing: -0.01em; }
.notes p { margin: 0; font-size: 1rem; color: var(--ink-soft); }

/* ---------- Contact / footer ---------- */

.contact { background: var(--plum-deep); color: var(--white); --focus: var(--lilac); }
.contact-grid { display: grid; gap: 2rem; }
@media (min-width: 900px) { .contact-grid { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 4rem; align-items: end; } }
.contact .section-title { margin-bottom: .5em; }
.contact .lede { color: var(--lilac-pale); }
.contact-actions { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: 1.5rem; }
.footnotes { margin: 0; padding-left: 1.2rem; font-size: .875rem; line-height: 1.5; color: var(--lilac); }
.footnotes li + li { margin-top: .6rem; }
.footnotes a { color: inherit; }
.colophon {
  margin-top: clamp(2.5rem, 5vw, 4rem); padding-top: 1.5rem;
  border-top: 1px solid rgba(255,255,255,.15);
  font-size: .875rem; color: var(--lilac);
  display: flex; flex-wrap: wrap; gap: .5rem 2rem; justify-content: space-between;
}
.colophon p { margin: 0; }
.colophon a { color: var(--white); }

/* ---------- Email viewer dialog ---------- */

.email-dialog {
  width: min(720px, 100vw - 2rem);
  height: 92vh;
  height: min(92dvh, 1100px);
  max-width: none; max-height: none;
  padding: 0; border: 0; border-radius: var(--radius);
  background: var(--white); color: var(--ink);
  box-shadow: 0 40px 80px -30px rgba(0,0,0,.6);
  overflow: hidden;
}
.email-dialog::backdrop { background: rgba(42, 1, 40, .78); }
.email-dialog[open] { display: grid; grid-template-rows: auto minmax(0, 1fr); }
.dialog-head {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: .5rem 1rem; align-items: center;
  padding: 1rem 1.25rem; background: var(--plum); color: var(--white); --focus: var(--lilac);
}
.dialog-title { font-size: 1.15rem; line-height: 1.2; letter-spacing: -0.01em; }
.dialog-meta { margin: .15rem 0 0; font-size: .85rem; font-stretch: 85%; font-weight: 600; color: var(--lilac); }
.dialog-motion {
  font: inherit; font-weight: 700; font-size: .85rem; color: var(--white);
  background: transparent; border: 2px solid rgba(255,255,255,.35); border-radius: 999px;
  padding: .45rem .8rem; cursor: pointer;
}
.dialog-motion:hover { border-color: var(--white); }
.dialog-close {
  width: 2.5rem; height: 2.5rem; border-radius: 50%; border: 0;
  background: var(--white); color: var(--plum); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.dialog-close svg { width: 1.1rem; height: 1.1rem; }
.dialog-close:hover { background: var(--lilac-pale); }
.dialog-body { overflow: auto; background: var(--paper-2); -webkit-overflow-scrolling: touch; }
.dialog-body iframe { display: block; width: 100%; height: 100%; min-height: 100%; border: 0; background: var(--white); }
@media (max-width: 639px) {
  .email-dialog { width: 100vw; height: 100vh; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0; }
  .dialog-head { grid-template-columns: minmax(0, 1fr) auto; }
  .dialog-motion { grid-column: 1; justify-self: start; }
  .dialog-close { grid-column: 2; grid-row: 1; }
}

/* ---------- Motion off / reduced motion ---------- */

html[data-motion="off"] *, html[data-motion="off"] *::before, html[data-motion="off"] *::after {
  animation-play-state: paused !important;
}
@media (prefers-reduced-motion: reduce) {
  html:not([data-motion="on"]) { scroll-behavior: auto; }
  html:not([data-motion="on"]) * { transition-duration: 0s !important; }
}
