/* Naisho site: shared foundation.
   Tokens ported VERBATIM from apps/naisho/design-system/colors_and_type.css
   (the single source of truth, mirrored by ios/DesignTokens.generated.swift).
   Every value is a literal, never `--x: var(--y)`, so nothing freezes across
   the theme boundary (see the css-var alias gotcha). The splash keeps its own
   page-local styles inline; this file carries what every page shares: fonts,
   tokens, base, nav, prose, cards, footer, the theme FAB. */

@font-face { font-family: 'General Sans'; src: url('../fonts/GeneralSans-Semibold.woff2') format('woff2'); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('../fonts/Inter-Regular.woff2') format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('../fonts/Inter-Medium.woff2') format('woff2'); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('../fonts/Inter-SemiBold.woff2') format('woff2'); font-weight: 600; font-style: normal; font-display: swap; }

.theme-dark, .theme-light {
  --font-display: 'General Sans', Inter, -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-body: Inter, -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --ease-standard: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-emphasized: cubic-bezier(0.22, 0.9, 0.3, 1);
  --brand-pink: #F90565;
}

.theme-dark {
  --bg: #060C17; --bg-elevated: #101724; --surface: #0C121C; --surface-tint: #121A28;
  --ink: #F5F5F7; --ink-soft: #8E8E93; --ink-faint: #48484A;
  --line: rgba(255,255,255,0.09); --line-strong: rgba(255,255,255,0.18);
  --accent: #409CFF; --accent-deep: #0A84FF; --accent-contrast: #FFFFFF;
  --accent-ink: #66B2FF;
  --partner: #FF6482; --partner-deep: #FF375F; --partner-ink: #FF8299;
  --gold: #FFD60A; --gold-ink: #FFD60A; --danger: #FF453A; --success: #30D158;
  --scrim: rgba(0,0,0,0.60); --secret: #C9B8FF;
  --fab-border: rgba(255,255,255,0.35); --fab-ink: var(--ink-soft);
}

.theme-light {
  --bg: #EEF3FA; --bg-elevated: #FFFFFF; --surface: #FFFFFF; --surface-tint: #F6F6F9;
  --ink: #0A0A0C; --ink-soft: #6B6B72; --ink-faint: #B0B0B8;
  --line: rgba(10,10,12,0.08); --line-strong: rgba(10,10,12,0.14);
  --accent: #0A84FF; --accent-deep: #0070E0; --accent-contrast: #FFFFFF;
  --accent-ink: #0A66CC;
  --partner: #FF375F; --partner-deep: #E0224B; --partner-ink: #C01945;
  --gold: #FFB340; --gold-ink: #8A5A00; --danger: #FF453A; --success: #30D158;
  --scrim: rgba(0,0,0,0.38); --secret: #7C6BD0;
  --fab-border: rgba(10,10,12,0.14); --fab-ink: var(--ink-soft);
}

/* ---- Base ---------------------------------------------------------------- */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
html, body { min-height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font-body); font-size: 16.5px; line-height: 1.6;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
a { color: inherit; }
:focus-visible { outline: 2px solid var(--brand-pink); outline-offset: 3px; border-radius: 4px; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

/* ---- Nav ------------------------------------------------------------------ */
/* Quiet top bar. On the splash it sits absolute over the hero; on subpages it
   is normal flow. Links are ink-soft, warming to ink on hover; the current
   page's link is ink. No underlines, no borders, restraint is the aesthetic. */
.nav {
  position: relative; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; max-width: 960px; margin: 0 auto;
  padding: 22px 32px;
}
/* Centered via auto margins, NOT a translateX: the splash's .rise animation
   ends on a transform of its own, and an animation's fill transform replaces
   a rule-level one (that override centered the brand and shoved the links
   off-viewport when this used left:50% + translateX). */
.nav.nav-overlay { position: absolute; top: 0; left: 0; right: 0; margin: 0 auto; }
.nav-brand {
  display: flex; align-items: center; gap: 11px;
  font-family: var(--font-display); font-weight: 600; font-size: 17px;
  letter-spacing: -0.02em; color: var(--ink); text-decoration: none;
}
.nav-brand img { width: 28px; height: 28px; display: block; }
/* The brand slot carries the composed app-icon tile (per Grant 2026-08-13:
   "use tile everywhere for now"), theme-swapped like the hero jewel. */
.theme-dark .brand-light, .theme-light .brand-dark { display: none; }
.nav-links { display: flex; align-items: center; gap: 26px; }
.nav-links a {
  font-size: 14.5px; font-weight: 500; letter-spacing: -0.005em;
  color: var(--ink-soft); text-decoration: none;
  transition: color 160ms var(--ease-standard);
}
.nav-links a:hover { color: var(--ink); }
.nav-links a[aria-current="page"] { color: var(--ink); }
@media (max-width: 560px) {
  .nav { padding: 18px 22px; }
  .nav-links { gap: 18px; }
  .nav-links a { font-size: 13.5px; }
}

/* ---- Page scaffold (subpages) ---------------------------------------------- */
.page {
  width: 100%; max-width: 680px; margin: 0 auto;
  padding: 34px 32px 96px;
}
.page-title {
  margin: 0 0 10px; font-family: var(--font-display);
  font-size: clamp(30px, 5.4vw, 40px); font-weight: 600;
  letter-spacing: -0.022em; line-height: 1.08;
}
.page-title .kw { color: var(--brand-pink); letter-spacing: -0.03em; }
.page-lede { margin: 0 0 46px; font-size: 17.5px; color: var(--ink-soft); }
/* Post created date: sits between a post's title and lede. */
.page-date {
  margin: -4px 0 14px; font-size: 12.5px; font-weight: 600;
  letter-spacing: -0.005em; color: var(--ink-soft);
}

/* ---- Prose ----------------------------------------------------------------- */
.prose h2 {
  margin: 52px 0 14px; font-family: var(--font-display);
  font-size: 24px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.2;
}
.prose h3 {
  margin: 34px 0 8px; font-family: var(--font-body);
  font-size: 17px; font-weight: 600; letter-spacing: -0.01em;
}
.prose p { margin: 0 0 18px; color: var(--ink); }
.prose p.soft, .prose li.soft { color: var(--ink-soft); }
.prose ul { margin: 0 0 18px; padding-left: 22px; }
.prose li { margin-bottom: 8px; }
.prose a { color: var(--accent-ink); text-decoration: none; }
.prose a:hover { text-decoration: underline; text-underline-offset: 3px; }
.prose hr { border: none; border-top: 0.5px solid var(--line); margin: 44px 0; }
.prose strong { font-weight: 600; }

/* ---- Cards ----------------------------------------------------------------- */
/* The app's real card grammar: r16, 0.5px hairline, elevated surface. */
.card {
  display: block; border: 0.5px solid var(--line); border-radius: 16px;
  background: var(--surface); padding: 22px 24px;
  text-decoration: none; color: inherit;
  transition: border-color 160ms var(--ease-standard), transform 160ms var(--ease-standard);
}
/* Clickable cards react as one surface: the outline firms up and the tile
   lifts slightly. Draft tiles stay div.card and stay inert; the reaction is
   the affordance, so it belongs only where a click goes somewhere. */
a.card:hover { border-color: var(--line-strong); transform: translateY(-2px); }
a.card:active { transform: translateY(-1px) scale(0.995); }
@media (prefers-reduced-motion: reduce) { a.card:hover, a.card:active { transform: none; } }
.card + .card { margin-top: 14px; }
.card h3 {
  margin: 0 0 6px; font-family: var(--font-display);
  font-size: 18.5px; font-weight: 600; letter-spacing: -0.015em; line-height: 1.25;
}
.card p { margin: 0; font-size: 15px; color: var(--ink-soft); line-height: 1.55; }
.card .meta {
  display: block; margin-bottom: 10px;
  font-size: 12.5px; font-weight: 600; letter-spacing: -0.005em; color: var(--ink-soft);
}
.card .meta .draft { color: var(--gold-ink); }

/* ---- Footer ----------------------------------------------------------------- */
.footer {
  width: 100%; max-width: 960px; margin: 0 auto;
  padding: 40px 32px 44px;
  display: grid; gap: 14px; justify-items: center; text-align: center;
  border-top: 0.5px solid var(--line);
}
.footer .patent { font-size: 14px; font-weight: 500; letter-spacing: -0.005em; color: var(--ink); }
.footer-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 20px; }
.footer-links a {
  font-size: 13.5px; font-weight: 500; color: var(--ink-soft); text-decoration: none;
}
.footer-links a:hover { color: var(--ink); }
.footer .fine { font-size: 12.5px; color: var(--ink-soft); }
/* Social placeholders: present but quiet until the accounts exist. Anchors
   carry no href yet; they warm up and become real links when wired. */
.footer-social { display: flex; justify-content: center; gap: 20px; }
.footer-social a {
  font-size: 13.5px; font-weight: 500; color: var(--ink-soft);
  text-decoration: none; cursor: default;
}
.footer-social a[href] { color: var(--ink-soft); cursor: pointer; }
.footer-social a[href]:hover { color: var(--ink); }

/* ---- Theme FAB ---------------------------------------------------------------- */
/* Fixed on every page: the site's switch between its two co-equal themes.
   Shows the mode you will switch TO: sun in dark, moon in light. */
.fab {
  position: fixed; left: 28px; bottom: 28px; z-index: 20;
  width: 49px; height: 49px; border-radius: 50%; padding: 0;
  display: grid; place-items: center; background: var(--bg);
  border: 0.5px solid var(--fab-border); color: var(--fab-ink); cursor: pointer;
}
.fab { bottom: calc(28px + env(safe-area-inset-bottom)); }
.theme-dark .fab-moon, .theme-light .fab-sun { display: none; }

/* ---- Mobile header ------------------------------------------------------------ */
/* On narrow viewports the subpage header stays pinned and stable. The splash
   keeps its absolute overlay nav. */
@media (max-width: 900px) {
  .nav:not(.nav-overlay) {
    position: sticky; top: 0; background: var(--bg);
    border-bottom: 0.5px solid var(--line);
  }
}
/* Hamburger appears where the inline links stop fitting comfortably. */
.nav-menu-btn {
  display: none; width: 40px; height: 40px; margin: -8px -10px -8px 0;
  place-items: center; background: none; border: none; padding: 0;
  color: var(--ink); cursor: pointer;
}
@media (max-width: 640px) {
  .nav-links { display: none; }
  .nav-menu-btn { display: grid; }
  .fab {
    top: calc(14px + env(safe-area-inset-top)); right: 64px; bottom: auto; left: auto;
    width: 40px; height: 40px;
  }
}

/* ---- Drawer (mobile site index) ------------------------------------------------ */
/* Drawer ground sits just above the page bg (surface, not bg-elevated):
   the panel meets the unscrimmed page at a full-height seam, so an elevated
   tone reads as a glowing slab in dark mode (Grant 2026-08-16). */
.nav-drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 40;
  width: min(78vw, 320px); background: var(--surface);
  border-left: 0.5px solid var(--line);
  transform: translateX(102%); transition: transform 280ms var(--ease-emphasized);
  display: flex; flex-direction: column;
  padding: calc(14px + env(safe-area-inset-top)) 26px calc(24px + env(safe-area-inset-bottom));
  visibility: hidden;
}
.nav-drawer.open { transform: translateX(0); visibility: visible; }
.nav-drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px;
}
.nav-drawer-head .drawer-title {
  font-family: var(--font-display); font-weight: 600; font-size: 17px;
  letter-spacing: -0.02em; color: var(--ink);
}
.nav-drawer-close {
  width: 40px; height: 40px; margin-right: -10px;
  display: grid; place-items: center; background: none; border: none; padding: 0;
  color: var(--ink-soft); cursor: pointer;
}
.nav-drawer-links { display: flex; flex-direction: column; }
.nav-drawer-links a {
  font-family: var(--font-display); font-size: 19px; font-weight: 600;
  letter-spacing: -0.015em; color: var(--ink-soft); text-decoration: none;
  padding: 15px 0; border-top: 0.5px solid var(--line);
}
.nav-drawer-links a:first-child { border-top: none; }
.nav-drawer-links a[aria-current="page"] { color: var(--ink); }

/* ---- Shared scrim ---------------------------------------------------------------- */
.chrome-scrim {
  position: fixed; inset: 0; z-index: 35; background: var(--scrim);
  opacity: 0; pointer-events: none; transition: opacity 220ms var(--ease-standard);
}
.chrome-scrim.show { opacity: 1; pointer-events: auto; }

/* ---- On-this-page TOC ------------------------------------------------------------ */
/* Built by toc.js on pages that include it. Desktop: a fixed rail beside the
   680px column, active section highlighted. Narrow: a floating pill opening a
   bottom sheet (the app's sheet grammar: elevated surface, grabber, hairlines). */
.prose h2[id] { scroll-margin-top: 86px; }
.toc-rail {
  display: none; position: fixed; z-index: 5;
  top: 150px; left: calc(50% + 380px); width: 216px;
  max-height: calc(100vh - 220px); overflow-y: auto;
}
@media (min-width: 1220px) { .toc-rail { display: block; } }
.toc-label {
  font-size: 12.5px; font-weight: 600; letter-spacing: -0.005em;
  color: var(--ink-soft); margin: 0 0 8px;
}
.toc-rail a {
  display: block; padding: 5px 0 5px 14px;
  border-left: 1.5px solid var(--line);
  font-size: 13.5px; font-weight: 500; letter-spacing: -0.005em;
  color: var(--ink-soft); text-decoration: none;
  transition: color 160ms var(--ease-standard), border-color 160ms var(--ease-standard);
}
.toc-rail a:hover { color: var(--ink); }
.toc-rail a.active { color: var(--ink); border-left-color: var(--accent); }

.toc-pill {
  position: fixed; right: 22px; bottom: calc(26px + env(safe-area-inset-bottom));
  z-index: 20;
  display: flex; align-items: center; gap: 9px;
  padding: 13px 18px; border-radius: 999px;
  background: var(--bg); border: 0.5px solid var(--fab-border);
  color: var(--fab-ink); cursor: pointer;
  font-family: var(--font-body); font-size: 13.5px; font-weight: 500;
  letter-spacing: -0.005em;
}
@media (min-width: 1220px) { .toc-pill { display: none; } }

.toc-sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  background: var(--bg-elevated); border-top: 0.5px solid var(--line);
  border-radius: 18px 18px 0 0;
  transform: translateY(103%); transition: transform 300ms var(--ease-emphasized);
  padding: 10px 26px calc(26px + env(safe-area-inset-bottom));
  max-height: 70vh; overflow-y: auto; visibility: hidden;
}
.toc-sheet.open { transform: translateY(0); visibility: visible; }
.toc-sheet .grabber {
  width: 36px; height: 5px; border-radius: 3px;
  background: var(--line-strong); margin: 0 auto 16px;
}
.toc-sheet a {
  display: block; padding: 14px 0; border-top: 0.5px solid var(--line);
  font-size: 16.5px; font-weight: 500; letter-spacing: -0.01em;
  color: var(--ink-soft); text-decoration: none;
}
.toc-sheet .toc-label + a { border-top: none; }
.toc-sheet a.active { color: var(--ink); }

@media (max-width: 640px) {
  .toc-pill {
    top: calc(14px + env(safe-area-inset-top)); right: 112px; bottom: auto;
    width: 40px; height: 40px; padding: 0; justify-content: center;
  }
  .toc-pill span { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .nav-drawer, .chrome-scrim, .toc-sheet { transition: none; }
}
