/* The site's look (ticket 26: midnight blue, white words and light blue
   buttons, chosen 2026-10-26 after the first "deep wine and gold"; font, ticket 27),
   shared by every page: the landing page, the calculator and the privacy page.
   Change the look here. Colours meet WCAG AA (4.5:1) for text on --surface. */

/* Tenor Sans, self-hosted so visitors aren't sent to Google. Licence: fonts/tenor-sans-OFL.txt */
@font-face {
  font-family: 'Tenor Sans';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/tenor-sans-latin.woff2') format('woff2');
}

:root {
  /* Palette */
  --base: #070e1c;
  --bloom-1: rgba(18, 72, 112, 0.8); /* teal-blue, top left */
  --bloom-2: rgba(28, 38, 96, 0.8); /* indigo, right */
  --bloom-3: rgba(110, 160, 220, 0.18); /* soft blue, bottom */
  --surface: rgba(10, 22, 44, 0.82);
  --ground: #0b1830; /* opaque, for sticky table headings */
  --field: rgba(0, 0, 0, 0.18);
  --panel: rgba(220, 232, 250, 0.07);
  --line: rgba(156, 201, 242, 0.22);
  --ink: #f5f7fa;
  --muted: #c3cad6;
  --heading: #ffffff;
  --backdrop-strength: 0.4; /* how strongly the chart shows behind every page but the home screen */
  --quiet: #9aa6b8; /* blue-grey, for the home screen's small italic line */

  /* States. The accent (light blue) fills buttons, the selected tab and the Starting Figure */
  --accent: #9cc9f2;
  --accent-hover: #bcdcf8;
  --on-accent: #0a1224;
  --worked: rgba(129, 140, 248, 0.3); /* indigo with a glow, ticket 37 */
  --flash: rgba(165, 180, 252, 0.85); /* bright indigo, the moment a figure is worked out */
  --error: #ffb3a7;
  --error-bg: rgba(255, 120, 100, 0.12);
  --note-bg: rgba(156, 201, 242, 0.1);
  --note-line: rgba(156, 201, 242, 0.5);
  --good: #8af5bf; /* soft mint, ticket 34 */
  --good-bg: rgba(70, 230, 150, 0.22);
  --good-line: var(--good); /* border round the "lowest" cells, ticket 35 */
  --good-glow: inset 0 0 0 transparent;
  --starting-line: #ffffff; /* border round the Starting Figure: white with a glow, ticket 36 */
  --starting-glow: 0 0 14px rgba(156, 201, 242, 0.75);
  --on-worked: var(--ink); /* text in Worked-out Figures */
  --worked-line: #a5b4fc;
  --worked-glow: 0 0 12px rgba(129, 140, 248, 0.6);

  /* Type: Tenor Sans for words, a plain sans with lined-up digits for figures */
  --words: 'Tenor Sans', Optima, Candara, 'Segoe UI', sans-serif;
  --figures: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;

  color-scheme: dark;
  font-family: var(--words);
  color: var(--ink);
  background: var(--base);
  line-height: 1.5;
}

* { box-sizing: border-box; }
body { margin: 0; }

/* The colour bleed: still, CSS only, on its own fixed layer so scrolling stays cheap */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(55rem 38rem at 0% 0%, var(--bloom-1), transparent 65%),
    radial-gradient(45rem 40rem at 100% 45%, var(--bloom-2), transparent 65%),
    radial-gradient(50rem 30rem at 30% 100%, var(--bloom-3), transparent 70%),
    var(--base);
}

h1, h2, h3 { font-weight: 400; color: var(--heading); text-wrap: balance; }
a { color: var(--heading); }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* Printing: dark on white, no background, so it doesn't use up ink */
@media print {
  :root {
    --base: #fff; --surface: #fff; --ground: #fff; --field: #fff; --panel: #f4f4f4; --line: #ccc;
    --ink: #111; --muted: #444; --heading: #111;
    --accent: #111; --on-accent: #fff; --worked: #fff; --error: #b42318; --error-bg: #fff;
    --note-bg: #fff; --note-line: #999; --good: #067647; --good-bg: #fff;
    --good-line: #067647; --good-glow: inset 0 0 0 transparent; --starting-line: #111; --starting-glow: none;
    --on-worked: #111; --worked-line: transparent; --worked-glow: none;
    color-scheme: light;
  }
  body::before { display: none; }
}

/* The shell every page shares (scripts/shell.mjs): a top bar with the menu
   button and Home button, and a sidebar that stays open until the Borrower
   hides it. Without JavaScript the sidebar is simply always shown. */
body { display: flex; flex-direction: column; min-height: 100vh; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; padding: 0.6rem 1rem; background: var(--surface); border-bottom: 1px solid var(--line); }
.icon-button { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 2.75rem; height: 2.75rem; padding: 0; border: 0; border-radius: 0.5rem; background: transparent; color: var(--ink); cursor: pointer; }
.icon-button[hidden] { display: none; }
.icon-button:hover { background: var(--panel); }
.home-button { border: 1px solid var(--line); }

/* Without JavaScript there is no menu button, and the Home button stays on the right */
.home-button { margin-left: auto; }

/* The chart behind every page (ticket 66), on a fixed layer like the colour
   bleed. Dulled and faint here so words stay easy to read; the home screen
   shows it at full strength (src/landing.css) */
.backdrop { position: fixed; inset: 0; z-index: -1; width: 100%; height: 100%; pointer-events: none; opacity: var(--backdrop-strength); filter: saturate(0.35); }

.shell-body { flex: 1; display: flex; align-items: stretch; min-width: 0; }
.shell-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.shell-main > * { width: 100%; }

.sidebar { flex: none; width: 16.5rem; padding: 1rem 1rem 1.5rem; background: var(--ground); border-right: 1px solid var(--line); }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; min-height: 2.75rem; }
.sidebar-name { font-size: 1.1rem; color: var(--heading); white-space: nowrap; }
.sidebar nav { display: grid; gap: 0.25rem; margin-top: 0.5rem; }
.sidebar nav a { display: flex; align-items: center; min-height: 3rem; padding: 0 0.9rem; border-radius: 0.5rem; color: var(--ink); font-size: 1.05rem; text-decoration: none; }
.sidebar nav a[hidden] { display: none; }
.sidebar nav a:hover { background: var(--panel); }
.sidebar nav a[aria-current='page'] { background: var(--accent); color: var(--on-accent); }
.js[data-menu='closed'] .sidebar { display: none; }
.scrim { display: none; }

/* Phones and narrow windows: the sidebar slides over the page instead of
   sitting beside it (without JavaScript it sits above the page) */
@media (max-width: 56.24rem) {
  .shell-body { flex-direction: column; }
  .sidebar { width: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .js .sidebar { position: fixed; top: 0; left: 0; bottom: 0; z-index: 20; width: min(17.5rem, 85%); border-right: 1px solid var(--line); border-bottom: 0; overflow: auto; }
  .js[data-menu='open'] .scrim { display: block; position: fixed; inset: 0; z-index: 10; width: 100%; height: 100%; padding: 0; border: 0; background: rgba(0, 0, 0, 0.55); }
}

@media print {
  .topbar, .sidebar, .scrim, .backdrop { display: none !important; }
}
