/* 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; } }

@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; }
