/* Peats website: theme tokens and shared styles.
   Colour values come from docs/brand/BRAND.md and the Peats design system (tokens.json), so the
   site and the phone mock-ups use exactly the app's colours.

   In the built site the root <html> carries .pt-site. Its theme:
     - follows the visitor's system setting (the dark set below, under prefers-color-scheme);
     - is overridden by the header button, whose choice is remembered as "peats-theme" and applied
       before first paint (inline script in each page's head) as .pt-light or .pt-dark.
   Everything from the design's site.css is unchanged except where "Build additions" says otherwise. */

.pt-site {
  --bg: #F4F5FB;            /* Paper */
  --surface: #FFFFFF;
  --sunken: #E8EAF6;        /* surface-variant */
  --hint: #E1E4F2;          /* surface-container-highest: overlap hints */
  --line: #DDE0EE;          /* outline-variant: dividers */
  --outline: #C5C9E0;
  --ink: #0F1230;
  --ink2: #5A5F7A;          /* 5.8:1 on Paper */
  --primary: #2F4BFF;
  --on-primary: #FFFFFF;
  --pc: #DDE1FF;            /* primary-container: Spending tiles */
  --on-pc: #0A1A8C;
  --tc: #FFF1CC;            /* tertiary-container: Insurance tiles */
  --on-tc: #4A3200;
  --bc: #D5F5EA;            /* building-container: Savings tiles */
  --on-bc: #086B50;
  --build: #12B886;
  --paid: #0A7D5E;
  --due: #7A4B00;
  --due-c: #FFF1CC;
  --over: #C8323F;
  --link: #2F4BFF;
  --link-hover: #0A1A8C;
  --focus: #2F4BFF;
  --band: #0F1230;          /* privacy band, closing band, footer */
  --band-line: #2F3568;
  --on-band: #F4F5FB;
  --on-band2: #A4A8C2;
  --bezel: #0F1230;
  --shadow: 0 30px 60px -24px rgba(15, 18, 48, 0.35);
  color-scheme: light;
}

.pt-site.pt-dark {
  --bg: #0F1230;            /* Ink */
  --surface: #191D45;
  --sunken: #242A5C;
  --hint: #282E68;
  --line: #2F3568;
  --outline: #3A4078;
  --ink: #F4F5FB;
  --ink2: #A4A8C2;          /* 7.8:1 on Ink */
  --primary: #A3AEFF;
  --on-primary: #0F1230;
  --pc: #1F2FA8;
  --on-pc: #DDE1FF;
  --tc: #3A3320;
  --on-tc: #FFE9A8;
  --bc: #123D33;
  --on-bc: #4FE0B0;
  --build: #4FE0B0;
  --paid: #4FE0B0;
  --due: #FFC83D;
  --due-c: #3A3320;
  --over: #FF8A8A;
  --link: #A3AEFF;
  --link-hover: #DDE1FF;
  --focus: #A3AEFF;
  --band: #191D45;
  --band-line: #3A4078;
  --on-band: #F4F5FB;
  --on-band2: #A4A8C2;
  --bezel: #3A4078;
  --shadow: 0 30px 60px -24px rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}
/* Dark set, system setting: the same values as .pt-dark above, used when the visitor has not chosen. */
@media (prefers-color-scheme: dark) {
  .pt-site:not(.pt-light) {
  --bg: #0F1230;            /* Ink */
  --surface: #191D45;
  --sunken: #242A5C;
  --hint: #282E68;
  --line: #2F3568;
  --outline: #3A4078;
  --ink: #F4F5FB;
  --ink2: #A4A8C2;          /* 7.8:1 on Ink */
  --primary: #A3AEFF;
  --on-primary: #0F1230;
  --pc: #1F2FA8;
  --on-pc: #DDE1FF;
  --tc: #3A3320;
  --on-tc: #FFE9A8;
  --bc: #123D33;
  --on-bc: #4FE0B0;
  --build: #4FE0B0;
  --paid: #4FE0B0;
  --due: #FFC83D;
  --due-c: #3A3320;
  --over: #FF8A8A;
  --link: #A3AEFF;
  --link-hover: #DDE1FF;
  --focus: #A3AEFF;
  --band: #191D45;
  --band-line: #3A4078;
  --on-band: #F4F5FB;
  --on-band2: #A4A8C2;
  --bezel: #3A4078;
  --shadow: 0 30px 60px -24px rgba(0, 0, 0, 0.6);
  color-scheme: dark;
  }
}

.pt-site a { color: var(--link); }
.pt-site a:hover { color: var(--link-hover); }
.pt-site button { font: inherit; cursor: pointer; }
.pt-site a:focus-visible,
.pt-site button:focus-visible,
.pt-site summary:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 12px; }

.pt-display { font-family: 'Bricolage Grotesque', 'Inter', system-ui, sans-serif; font-weight: 700; letter-spacing: -0.02em; }
.pt-mono { font-family: 'JetBrains Mono', ui-monospace, Menlo, monospace; font-weight: 500; }
.pt-num { font-variant-numeric: tabular-nums; }

.pt-site summary { list-style: none; cursor: pointer; }
.pt-site summary::-webkit-details-marker { display: none; }
.pt-site details[open] .pt-chev { transform: rotate(45deg); }
.pt-chev { transition: transform 0.2s ease; }

/* Header: a floating pill. The links fold into a menu at phone width. */
.pt-navlinks { display: flex; }
.pt-navcta { display: inline-flex; }
.pt-navmenu { display: none; }
@media (max-width: 760px) {
  .pt-navlinks { display: none; }
  .pt-navlinks.pt-open { display: flex; position: absolute; left: 0; right: 0; top: 64px; z-index: 5; flex-direction: column; align-items: stretch; padding: 8px; border-radius: 24px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); }
  .pt-navcta { display: none; }
  .pt-navmenu { display: inline-grid; }
}

/* Bento: six columns on wide screens, one column on a phone. */
.pt-bento { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 16px; }
.pt-span-2 { grid-column: span 2; }
.pt-span-3 { grid-column: span 3; }
.pt-span-4 { grid-column: span 4; }
.pt-span-6 { grid-column: span 6; }
@media (max-width: 980px) {
  .pt-bento { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pt-span-2, .pt-span-3, .pt-span-4 { grid-column: span 1; }
  .pt-span-6 { grid-column: span 2; }
}
@media (max-width: 640px) {
  .pt-bento { grid-template-columns: minmax(0, 1fr); }
  .pt-span-2, .pt-span-3, .pt-span-4, .pt-span-6 { grid-column: auto; }
}

/* Hero stage: the cards around the phone show only when there is room for them.
   As the stage scrolls into view each card flies in from off the stage, spinning, and lands at
   its tilt; scrolling on, they drift up at different speeds, so they sit at different depths.
   Scroll-driven, so it plays back and forth with the scroll. Where the browser has no scroll
   timelines, or asks for reduced motion, the cards simply sit where they land. */
.pt-float { transform: rotate(var(--r, 0deg)); }
@media (max-width: 980px) { .pt-float { display: none !important; } }
@supports (animation-timeline: view()) {
  .pt-float {
    animation: ptFly linear both, ptDrift linear both;
    animation-timeline: view(), view();
    animation-range: entry 20% cover 45%, cover 50% exit 100%;
  }
}
@keyframes ptFly {
  from { opacity: 0; transform: translate(var(--fx, 0), var(--fy, 0)) rotate(var(--fr, 0deg)) scale(0.8); }
  60% { opacity: 1; }
  to { opacity: 1; transform: translate(0, 0) rotate(var(--r, 0deg)) scale(1); }
}
@keyframes ptDrift { from { translate: 0 0; } to { translate: 0 var(--dy, -80px); } }

/* Hero phone: as the page scrolls past it, the list on the screen scrolls too, like a thumb
   flicking down Home. The bottom bar and the add button stay put. Without scroll timelines, on
   the canvas, or with reduced motion, the screen stays at the top. */
@supports (animation-timeline: view()) {
  .pt-phone { view-timeline-name: --pt-phone; }
  .pt-screen { animation: ptScreen linear both; animation-timeline: --pt-phone; animation-range: cover 38% cover 78%; }
}
@keyframes ptScreen { from { transform: translateY(0); } to { transform: translateY(-320px); } }

/* The privacy receipt: a dotted leader between label and value. */
.pt-leader { flex: 1; min-width: 16px; border-bottom: 2px dotted var(--outline); transform: translateY(-5px); }

/* The signature: when Rent is marked paid, the dot goes once round the loop on the week card
   (an SVG animateMotion in HeroPhone). These swap Rent to Paid at the same moment. Every swapped
   element's resting style is its final state, so reduced motion shows the end, still. */
.pt-before { opacity: 0; animation: ptOut 1ms linear 1.8s both; }
.pt-after { opacity: 1; animation: ptIn 1ms linear 1.8s both; }
@keyframes ptOut { from { opacity: 1; } to { opacity: 0; } }
@keyframes ptIn { from { opacity: 0; } to { opacity: 1; } }

/* "Three questions" bento: the tiles rise in one after another, then each mock-up builds itself as
   it scrolls into view. Tile 1: the card slides up out of its tray, then the 30-day total and the
   button follow. Tile 2: the Family music bar lands, the three people pop in, Maya's turn lights
   last, then the real cost. Tile 3: the split bar fills cobalt, sun, mint, then the savings bar
   fills to 62%. Scroll-driven like the hero cards, so it plays back and forth with the scroll and
   never loops. Every element's resting style is its drawn state, so a browser without scroll
   timelines, or reduced motion, shows the tiles exactly as designed. Nothing here changes a figure. */
@supports (animation-timeline: view()) {
  /* Each mock-up tray is the timeline its own parts follow, so they play as the tray comes into view. */
  .pt-q1 { view-timeline-name: --pt-q1; overflow: clip; } /* clip: the card slides up out of the tray */
  .pt-q2 { view-timeline-name: --pt-q2; }
  .pt-q3 { view-timeline-name: --pt-q3; }

  /* The tiles, staggered along the row. */
  .pt-rise { animation: ptRise linear both; animation-timeline: view(); animation-range: entry 0% entry 60%; }
  .pt-r2 { animation-range: entry 10% entry 70%; }
  .pt-r3 { animation-range: entry 20% entry 80%; }

  /* 1. Which card pays for it? */
  .pt-a1 { animation: ptSlideUp linear both; animation-timeline: --pt-q1; animation-range: entry 0% entry 40%; }
  .pt-a2 { animation: ptFadeUp linear both; animation-timeline: --pt-q1; animation-range: entry 30% entry 60%; }
  .pt-a3 { animation: ptFadeUp linear both; animation-timeline: --pt-q1; animation-range: entry 50% entry 80%; }

  /* 2. What is my real share? Ends on Maya's turn, as drawn. */
  .pt-b-bar { animation: ptFadeUp linear both; animation-timeline: --pt-q2; animation-range: entry 0% entry 25%; }
  .pt-b-box { animation: ptFadeUp linear both; animation-timeline: --pt-q2; animation-range: entry 10% entry 35%; }
  .pt-b-maya { animation: ptPop linear both, ptHi linear both; animation-timeline: --pt-q2, --pt-q2; animation-range: entry 25% entry 42%, entry 58% entry 78%; }
  .pt-b-you { animation: ptPop linear both; animation-timeline: --pt-q2; animation-range: entry 33% entry 50%; }
  .pt-b-tobi { animation: ptPop linear both; animation-timeline: --pt-q2; animation-range: entry 41% entry 58%; }
  .pt-b-cost { animation: ptFadeUp linear both; animation-timeline: --pt-q2; animation-range: entry 68% entry 90%; }

  /* 3. Spent, or building something? Each segment starts where the one before it ends. */
  .pt-c-total { animation: ptFadeUp linear both; animation-timeline: --pt-q3; animation-range: entry 0% entry 30%; }
  .pt-c-s1 { animation: ptGrow linear both; animation-timeline: --pt-q3; animation-range: entry 22% entry 50%; }
  .pt-c-s2 { animation: ptGrow linear both; animation-timeline: --pt-q3; animation-range: entry 46% entry 60%; }
  .pt-c-s3 { animation: ptGrow linear both; animation-timeline: --pt-q3; animation-range: entry 56% entry 72%; }
  .pt-c-legend { animation: ptFadeUp linear both; animation-timeline: --pt-q3; animation-range: entry 50% entry 75%; }
  .pt-c-fund { animation: ptFadeUp linear both; animation-timeline: --pt-q3; animation-range: entry 56% entry 80%; }
  .pt-c-fill { animation: ptGrow linear both; animation-timeline: --pt-q3; animation-range: entry 74% entry 96%; }
}
@keyframes ptRise { from { opacity: 0; translate: 0 28px; } }
@keyframes ptSlideUp { from { opacity: 0; translate: 0 44px; } }
@keyframes ptFadeUp { from { opacity: 0; translate: 0 14px; } }
@keyframes ptPop { from { opacity: 0; scale: 0.8; translate: 0 8px; } }
@keyframes ptHi { from { background-color: var(--bg); color: var(--ink); } }
@keyframes ptGrow { from { clip-path: inset(0 100% 0 0 round 999px); } to { clip-path: inset(0 0 0 0 round 999px); } }

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

/* ---- Build additions (not in the design's site.css) ---- */

body { margin: 0; }
html.pt-site { background: var(--bg); }

/* The header's theme button shows the sun in dark, the moon in light (the design's two <sc-if> branches). */
.pt-ico-sun { display: none; }
.pt-site.pt-dark .pt-ico-sun { display: block; }
.pt-site.pt-dark .pt-ico-moon { display: none; }
@media (prefers-color-scheme: dark) {
  .pt-site:not(.pt-light) .pt-ico-sun { display: block; }
  .pt-site:not(.pt-light) .pt-ico-moon { display: none; }
}

/* The paid moment waits until the hero phone is first seen: site.js adds .pt-go then, and begins the dot.
   Without it (no script) the phone simply shows Home before Rent is marked paid. */
.pt-phone .pt-before, .pt-phone .pt-after { animation-play-state: paused; }
.pt-phone.pt-go .pt-before, .pt-phone.pt-go .pt-after { animation-play-state: running; }
