/* ─────────────────────────────────────────────
   Compass · base.css
   Design tokens, layout, typography, sidebar
   ───────────────────────────────────────────── */

:root {
  /* Type */
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
               "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-serif: ui-serif, "New York", "Iowan Old Style", "Apple Garamond", Georgia, serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* Warm-neutral surface palette (light mode) */
  --bg-0: #f3efe9;             /* page wash, warm sand */
  --bg-1: #ece6dd;             /* deeper warm wash for gradient */
  --bg-2: #e2dccf;             /* edge of gradient */
  --surface: rgba(255, 254, 252, 0.78);
  --surface-strong: rgba(255, 254, 252, 0.94);
  --surface-sunk: rgba(0, 0, 0, 0.025);
  --hairline: rgba(20, 20, 30, 0.08);
  --hairline-strong: rgba(20, 20, 30, 0.14);

  /* Ink */
  --ink-0: #19181a;            /* primary text */
  --ink-1: #44434a;            /* secondary text */
  --ink-2: #6e6c75;            /* tertiary text */
  --ink-3: #9c98a3;            /* muted */

  /* Brand & accents */
  --accent: #3a4a6b;           /* slate-blue, considered & calm */
  --accent-ink: #ffffff;
  --accent-soft: rgba(58, 74, 107, 0.08);
  --accent-softer: rgba(58, 74, 107, 0.04);
  --warm: #d77a5a;             /* peach for progress/energy */
  --warm-soft: rgba(215, 122, 90, 0.10);
  --good: #4a7c59;             /* sage for success */
  --good-soft: rgba(74, 124, 89, 0.10);
  --warn: #b48a3c;             /* amber */
  --warn-soft: rgba(180, 138, 60, 0.10);
  --bad:  #a3504a;             /* muted red */
  --bad-soft: rgba(163, 80, 74, 0.10);

  /* Shadows — layered, subtle */
  --shadow-sm: 0 1px 2px rgba(20, 20, 30, 0.04), 0 1px 1px rgba(20, 20, 30, 0.03);
  --shadow-md: 0 6px 24px -8px rgba(20, 20, 30, 0.10), 0 2px 6px rgba(20, 20, 30, 0.04);
  --shadow-lg: 0 24px 60px -20px rgba(20, 20, 30, 0.18), 0 8px 24px -8px rgba(20, 20, 30, 0.06);

  /* Radii */
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 26px;

  /* Transitions */
  --t-fast: 120ms cubic-bezier(.2,.7,.3,1);
  --t-med:  220ms cubic-bezier(.2,.7,.3,1);
  --t-slow: 380ms cubic-bezier(.2,.7,.3,1);

  /* Layout */
  --sidebar-w: 232px;
  --content-max: 1080px;
}

/* Dark-mode tokens are scaffolded so Phase 2 can flip a class. */
:root[data-theme="dark"] {
  --bg-0: #14141a;
  --bg-1: #1a1a22;
  --bg-2: #20202a;
  --surface: rgba(34, 34, 42, 0.72);
  --surface-strong: rgba(34, 34, 42, 0.92);
  --surface-sunk: rgba(255, 255, 255, 0.04);
  --hairline: rgba(255, 255, 255, 0.08);
  --hairline-strong: rgba(255, 255, 255, 0.14);
  --ink-0: #f1eee9;
  --ink-1: #c9c4bc;
  --ink-2: #9a958d;
  --ink-3: #6c6862;
  --accent: #8da3c9;
  --accent-ink: #14141a;
  --accent-soft: rgba(141, 163, 201, 0.14);
  --accent-softer: rgba(141, 163, 201, 0.07);
}

/* ── Reset-ish ─────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink-0);
  background: var(--bg-0);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "ss01", "cv11", "kern";
  letter-spacing: -0.005em;
  overflow: hidden; /* main scrolls inside */
}

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
input, textarea, select { font: inherit; color: inherit; }

::selection { background: var(--accent-soft); color: var(--ink-0); }

/* ── App shell ─────────────────────────────── */
.app {
  position: relative;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh;
  height: 100dvh;
  background:
    radial-gradient(1100px 700px at 8% -10%, #ece1d2 0%, transparent 60%),
    radial-gradient(900px 600px at 100% 0%, #e5dec9 0%, transparent 55%),
    radial-gradient(700px 600px at 100% 100%, #e9dcd0 0%, transparent 60%),
    linear-gradient(180deg, var(--bg-0) 0%, var(--bg-1) 100%);
}

/* ── Sidebar ───────────────────────────────── */
.sidebar {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 22px 14px 18px;
  gap: 6px;
  border-right: 1px solid var(--hairline);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.42), rgba(255,255,255,0.18));
  backdrop-filter: saturate(140%) blur(14px);
  -webkit-backdrop-filter: saturate(140%) blur(14px);
}

.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px;
  margin-bottom: 12px;
  border-radius: 12px;
  color: inherit;
  cursor: pointer;
  transition: background var(--t-fast), transform var(--t-fast);
}
.brand:hover { background: rgba(0, 0, 0, 0.035); }
.brand:active { transform: translateY(1px); }
.brand:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--bg-0), 0 0 0 4px var(--accent);
}
.brand__mark {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: 11px;
  background: linear-gradient(160deg, #ffffff 0%, #efe7da 100%);
  border: 1px solid var(--hairline);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.5), var(--shadow-sm);
}
.brand__text { display: flex; flex-direction: column; line-height: 1.1; }
.brand__name {
  font-family: var(--font-serif);
  font-size: 18px; font-weight: 600;
  letter-spacing: -0.01em;
}
.brand__sub { font-size: 11px; color: var(--ink-2); margin-top: 2px; }

.nav { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; }
.sidebar__foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--hairline); }

.nav__item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  border-radius: var(--r-sm);
  color: var(--ink-1);
  font-size: 14px; font-weight: 500;
  transition: background var(--t-fast), color var(--t-fast), transform var(--t-fast);
  position: relative;
}
.nav__item:hover { background: rgba(0,0,0,.035); color: var(--ink-0); }
.nav__item:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--bg-0), 0 0 0 4px var(--accent);
}
.nav__item.is-active {
  background: var(--surface-strong);
  color: var(--ink-0);
  box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--hairline);
}
.nav__item.is-active::before {
  content: "";
  position: absolute; left: -14px; top: 8px; bottom: 8px; width: 3px;
  background: var(--accent); border-radius: 2px;
}
.nav__icon {
  width: 18px; height: 18px;
  fill: none; stroke: currentColor; stroke-width: 1.6;
  stroke-linecap: round; stroke-linejoin: round;
  opacity: .8;
}
.nav__item.is-active .nav__icon { opacity: 1; color: var(--accent); }
.nav__item--quiet { color: var(--ink-2); }
.nav__item--button {
  width: 100%;
  background: transparent;
  border: none;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.nav__item--button .kbd { font-size: 10px; }

/* ── Main / scroll container ───────────────── */
.main {
  position: relative;
  overflow-y: auto;
  overflow-x: hidden;
}
.main::-webkit-scrollbar { width: 10px; }
.main::-webkit-scrollbar-thumb { background: rgba(0,0,0,.10); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
.main::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,.18); border: 2px solid transparent; background-clip: padding-box; }

.view {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 40px 44px 96px;
  outline: none;
}

/* ── Mobile tab bar (hidden by default) ────── */
.tabbar { display: none; }

/* ── Generic typography ────────────────────── */
.eyebrow {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-2);
  font-weight: 600;
}
.h-display {
  font-family: var(--font-serif);
  font-size: clamp(28px, 3.3vw, 40px);
  line-height: 1.08;
  letter-spacing: -0.02em;
  font-weight: 600;
  color: var(--ink-0);
  margin: 0;
}
.h-section {
  font-family: var(--font-serif);
  font-size: 22px;
  letter-spacing: -0.01em;
  font-weight: 600;
  margin: 0;
}
.h-card {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.005em;
  margin: 0;
}
.muted { color: var(--ink-2); }
.dim   { color: var(--ink-3); }

/* ── View header (shared across pages) ─────── */
.view-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 24px; margin-bottom: 28px;
}
.view-head__left { min-width: 0; }
.view-head__title { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.view-head__sub { color: var(--ink-2); margin-top: 6px; font-size: 14px; }
.view-head__right { display: flex; gap: 8px; flex-shrink: 0; }

/* ── Responsive ────────────────────────────── */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .view { padding: 24px 20px 96px; }
  .tabbar {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    position: fixed;
    left: 12px; right: 12px; bottom: 12px;
    padding: 8px;
    background: var(--surface-strong);
    backdrop-filter: saturate(160%) blur(20px);
    -webkit-backdrop-filter: saturate(160%) blur(20px);
    border: 1px solid var(--hairline);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-lg);
    z-index: 50;
  }
  .tabbar__item {
    display: grid; place-items: center; gap: 4px;
    padding: 8px 6px;
    border-radius: 12px;
    font-size: 10.5px;
    color: var(--ink-2);
    transition: background var(--t-fast), color var(--t-fast);
  }
  .tabbar__item svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; opacity: .85; }
  .tabbar__item.is-active { color: var(--accent); background: var(--accent-soft); }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}
