/* =====================================================================
   theme.css : the token contract (creative brief v2, section 2)
   Dark is the default. html[data-theme] is set before first paint by the
   inline head script and managed by js/theme.js.
   .invert flips the theme inside any element (the early-access slab).
   ===================================================================== */

/* ---------- fixed brand tokens (never themed) ---------- */
:root {
  --amber: #F59E0B;
  --on-accent: #0A0F1E;
  --doc-mail-ink: #5C4300;
}

/* ---------- dark ---------- */
html[data-theme="dark"],
html[data-theme="light"] .invert,
.pui-window {
  color-scheme: dark;
  --bg: #070B16;
  --bg-alt: #0A1020;
  --surface: #0E1627;
  --surface-2: #131D33;
  --border: rgba(140, 170, 220, .16);
  --border-strong: rgba(140, 170, 220, .32);
  --heading: #F4F6FA;
  --text: #C9D2E0;
  --muted: #93A3C0;
  --link: #78B0F8;
  --line: rgba(120, 176, 248, .55);
  --focus: #78B0F8;
  --amber-hover: #F7AB2B;
  --amber-edge: transparent;
  --cta-shadow: 0 8px 28px -10px rgba(245, 158, 11, .55);
  --amber-text: #F59E0B;
  --gold-text: #FFCF40;
  --gold-line: #FFCF40;
  --ok: #34D399;
  --warn: #F59E0B;
  --error: #FCA5A5;
  --party-arranger: #B29BFB;
  --party-lender: #34D399;
  --party-borrower: #78B0F8;
  --pill-bg: rgba(120, 176, 248, .10);
  --input-bg: #0B1222;
  --input-border: rgba(147, 163, 192, .55);
  --nav-bg-scrolled: rgba(7, 11, 22, .82);
  --logo-word: #FFFFFF;
  --logo-sub: #F59E0B;
  --logo-folder-m: url(#tl-fa-m);
  --logo-folder-l: url(#tl-fa-l);
  --ph-line: rgba(147, 163, 192, .5);
  --shadow-card: none;
  --shadow-float: 0 30px 90px -30px rgba(0, 0, 0, .8);
  --scrim: rgba(5, 8, 15, .78);
  --light-key: rgba(214, 228, 255, .11);
  --light-navy: rgba(65, 108, 179, .30);
  --doc-pdf: #E5534B;
  --doc-xlsx: #1FA968;
  --doc-mail: #F2C230;
  --doc-docx: #4C8DF6;
  --doc-paper: #1A2540;
  --doc-edge: rgba(163, 178, 207, .6);
}

/* ---------- light ---------- */
html[data-theme="light"],
html[data-theme="dark"] .invert {
  color-scheme: light;
  --bg: #F4F6FA;
  --bg-alt: #EBEEF5;
  --surface: #FFFFFF;
  --surface-2: #F7F9FC;
  --border: #D5DBE6;
  --border-strong: #B4BECF;
  --heading: #0B1324;
  --text: #2A3447;
  --muted: #566178;
  --link: #2F56A0;
  --line: rgba(47, 86, 160, .5);
  --focus: #1D4ED8;
  --amber-hover: #E89206;
  --amber-edge: #C77D00;
  --cta-shadow: 0 1px 2px rgba(11, 19, 36, .18), 0 10px 24px -12px rgba(199, 125, 0, .6);
  --amber-text: #9A5B00;
  --gold-text: #8A6100;
  --gold-line: #A87A00;
  --ok: #047857;
  --warn: #9A5B00;
  --error: #B42318;
  --party-arranger: #6D28D9;
  --party-lender: #047857;
  --party-borrower: #2563EB;
  --pill-bg: #E6EBF4;
  --input-bg: #FFFFFF;
  --input-border: #7A879E;
  --nav-bg-scrolled: rgba(244, 246, 250, .86);
  --logo-word: #0B1324;
  --logo-sub: #416CB3;
  --logo-folder-m: url(#tl-fb-m);
  --logo-folder-l: url(#tl-fb-l);
  --ph-line: #9AA7BD;
  --shadow-card: 0 1px 2px rgba(11, 19, 36, .06), 0 1px 1px rgba(11, 19, 36, .04);
  --shadow-float: 0 24px 60px -28px rgba(27, 43, 77, .35);
  --scrim: rgba(235, 238, 245, .84);
  --light-key: rgba(255, 255, 255, .95);
  --light-navy: rgba(65, 108, 179, .13);
  --doc-pdf: #D0342C;
  --doc-xlsx: #12804F;
  --doc-mail: #E5B009;
  --doc-docx: #2563EB;
  --doc-paper: #FFFFFF;
  --doc-edge: #9AA7BD;
}

/* The hand-built product window is dark in both page themes. It re-asserts the
   dark values above (selector list), so it needs only its own surface/ink. */
.pui-window { color: var(--text); }

/* A flipped region paints its own surface. */
.invert { background: var(--bg); color: var(--text); }

/* ---------- theme-aware images ---------- */
html[data-theme="dark"] .only-light:not(.invert *),
html[data-theme="light"] .only-dark:not(.invert *),
html[data-theme="dark"] .invert .only-dark,
html[data-theme="light"] .invert .only-light { display: none !important; }

/* ---------- document-type icons ---------- */
.doc-ico { width: 28px; height: 33px; flex: none; display: inline-block; overflow: visible; }
.doc-ico--sm { width: 16px; height: 19px; --doc-label: transparent; }
.doc-ico--pdf { --doc-c: var(--doc-pdf); }
.doc-ico--xlsx { --doc-c: var(--doc-xlsx); }
.doc-ico--docx { --doc-c: var(--doc-docx); }
.doc-ico--mail { --doc-c: var(--doc-mail); }

/* ---------- background lights (2.2) ---------- */
/* Add class "lit" to the section (position:relative; isolation) and put
   <div class="lights" aria-hidden="true"> as its first child. Direct children
   other than .lights are lifted above it with .lit > :not(.lights). */
.lit { position: relative; isolation: isolate; }
.lit > :not(.lights) { position: relative; z-index: 1; }
.lights { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
.light {
  position: absolute; display: block;
  left: var(--x, 50%); top: var(--y, 50%);
  width: var(--w, 800px); height: var(--h, 500px);
  translate: -50% -50%;
  opacity: var(--o, 1);
  background: radial-gradient(closest-side, var(--light-navy), transparent);
}
.light--key { background: radial-gradient(closest-side, var(--light-key), transparent); }
.light--navy { background: radial-gradient(closest-side, var(--light-navy), transparent); }
@media (max-width: 820px) {
  .light { left: 50%; width: calc(var(--w, 800px) * .6); height: calc(var(--h, 500px) * .6); }
}

/* ---------- corner ticks (2.3): arranger card, security block, film frame only ---------- */
.ticks { position: relative; }
.ticks::before, .ticks::after {
  content: ""; position: absolute; width: 10px; height: 10px; pointer-events: none; z-index: 2;
}
.ticks::before { top: -1px; left: -1px; border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.ticks::after { bottom: -1px; right: -1px; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); }

/* ---------- theme switch transition (2.1) ---------- */
@media (prefers-reduced-motion: no-preference) {
  html.theme-switching *, html.theme-switching *::before, html.theme-switching *::after {
    transition: background-color .3s, border-color .3s, color .3s !important;
  }
}

/* ---------- reveal contract (2.3) ----------
   main.js adds .is-in once, when the element is ~45% visible
   (data-reveal-at="0.55" overrides). Each section writes its own pre-reveal
   state, ONLY inside:
     @media (prefers-reduced-motion: no-preference) { html.js [data-reveal]:not(.is-in) {...} }
   Without JS, or with reduced motion, nothing is hidden. */
