/* CLOSE design tokens — from the Claude Design handoff (DESIGN_TOKENS.md).
   Shared brand/status/peak in :root; Command Center surface tokens scoped to
   .cc; full dark remap under html[data-theme="dark"]. The rep app uses the
   :root surface tokens, the Command Center overrides them inside .cc. */

@import url("https://fonts.googleapis.com/css2?family=Hanken+Grotesk:ital,wght@0,300..800;1,400..700&display=swap");

:root {
  --font: "Hanken Grotesk", -apple-system, system-ui, "SF Pro Display", sans-serif;

  /* brand (shared) */
  --brand: #10A0B0;
  --brand-deep: #004050;
  --peak-1: #2EB6CD;
  --peak-2: #0E8FBF;
  --peak-3: #2A5798;
  --peak-4: #1F3D6E;

  /* status (shared) — --warn darkened from #B57305 for WCAG AA on white */
  --good: #0F8C5D;
  --warn: #8A5A00;
  --bad:  #C53030;
  --gold: #B58210;
  --good-bg: #E4F4ED;
  --warn-bg: #FBF0DC;
  --bad-bg:  #FBE7E7;

  /* rep-app surfaces (default) — --dim darkened from #6B7A8A for WCAG AA on white */
  --ink: #0C2030;
  --ink-soft: #2A3F50;
  --dim: #5B6B7B;
  --line: #D6DFE6;
  --bg: #FFFFFF;
  --bg-2: #F3F6FA;
  --bg-alt: #F3F6FA;
  --sand: #F1F9FC;
  --card: #FFFFFF;
  --card-2: #EDF2F7;
  --ring-track: #E3EBF1;
  --glass: rgba(255,255,255,.72);
  --frame-bg: #E7ECF1;
  --num: #063C49;

  /* shadows (light) */
  --shadow-sm: 0 1px 2px rgba(12,32,48,.05), 0 4px 16px rgba(12,32,48,.06);
  --shadow-md: 0 2px 6px rgba(12,32,48,.07), 0 12px 34px rgba(12,32,48,.09);
  --shadow-card: 0 1px 2px rgba(12,32,48,.05), 0 6px 22px rgba(12,32,48,.07);
  --shadow-sheet: 0 -8px 40px rgba(8,28,40,.20);
  --shadow-pop: 0 10px 34px rgba(8,28,40,.22);
}

/* Command Center surface overrides */
.cc {
  --ink-soft: #2A3F50;
  --dim: #5B6B7B;
  --line: #E2E9EF;
  --cc-bg: #F4F7FA;
  --panel: #FFFFFF;
  --panel-2: #F7FAFC;
  --sand: #EFF7FA;
  --num: #063C49;
  --sidebar: #072530;
  --sidebar-ink: #CFE0E6;
  --sidebar-dim: #6E8C97;
  --sidebar-active: #10A0B0;
  --chrome: #DFE6EC;
  --chrome-ink: #5A6A78;
  --desk: #D4DCE3;
}

/* ---- DARK — rep app / shared ---- */
html[data-theme="dark"] {
  --brand: #2EB6CD;
  --brand-deep: #0a5564;
  --peak-1: #3CC6DD;
  --peak-2: #2BA4D6;
  --peak-3: #5C84C8;
  --peak-4: #6E88C0;
  --good: #2BB47C;
  --warn: #D89A33;
  --bad:  #E76860;
  --gold: #D7A53A;
  --good-bg: #0E2E25;
  --warn-bg: #2E2310;
  --bad-bg:  #301414;

  --ink: #EAF3F6;
  --ink-soft: #B6C8D1;
  --dim: #7E96A4;
  --line: #1C3742;
  --bg: #07171D;
  --bg-2: #0B222B;
  --bg-alt: #0B222B;
  --sand: #0E2A33;
  --card: #0E2630;
  --card-2: #143039;
  --ring-track: #143039;
  --glass: rgba(14,38,48,.74);
  --frame-bg: #04141A;
  --num: #D7EEF3;

  --shadow-sm: 0 1px 2px rgba(0,0,0,.4), 0 4px 20px rgba(0,0,0,.42);
  --shadow-md: 0 2px 8px rgba(0,0,0,.5), 0 16px 40px rgba(0,0,0,.55);
  --shadow-card: 0 1px 2px rgba(0,0,0,.4), 0 6px 24px rgba(0,0,0,.45);
  --shadow-sheet: 0 -8px 44px rgba(0,0,0,.6);
  --shadow-pop: 0 12px 40px rgba(0,0,0,.6);
}

/* ---- DARK — Command Center overrides ---- */
html[data-theme="dark"] .cc {
  --ink-soft: #AFC3CD;
  --dim: #7A93A0;
  --line: #1B3640;
  --cc-bg: #06161C;
  --panel: #0C2530;
  --panel-2: #10303B;
  --sand: #0E2A33;
  --num: #D7EEF3;
  --sidebar: #04141A;
  --sidebar-dim: #5E7C87;
  --sidebar-active: #2EB6CD;
  --chrome: #0A1E26;
  --chrome-ink: #7F97A2;
  --desk: #031015;
}

* { box-sizing: border-box; }
html, body, #root { height: 100%; margin: 0; }
html { transition: background-color .45s ease; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  transition: background-color .45s ease, color .45s ease;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* tabular numerals on every metric/money/timestamp */
.num {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

/* ── accessibility ─────────────────────────────────────────────────────── */

/* Visible keyboard focus on every interactive element (components are
   inline-styled, so the shared ring lives here). */
button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
[role="button"]:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}
/* opt-in class for non-native interactive hosts */
.focus-ring:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* Expand small controls to a ≥44px touch target without changing visuals.
   Apply to any button whose painted size is under 44×44. */
.tap44 { position: relative; }
.tap44::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: max(100%, 44px);
  height: max(100%, 44px);
}

/* ── shared keyframes (kept here so prefers-reduced-motion governs them) ── */

/* Ring halo pulse on day close */
@keyframes ringHalo { 0% { transform: scale(1); opacity: .55; } 100% { transform: scale(1.22); opacity: 0; } }

/* AllDone end-state */
@keyframes fadeUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
@keyframes checkPop { from { opacity: 0; transform: scale(.5); } to { opacity: 1; transform: scale(1); } }

/* "why?" oracle tooltip */
@keyframes whyIn {
  from { opacity: 0; transform: translate(-50%, -100%) translateY(6px) scale(.96); }
  to   { opacity: 1; transform: translate(-50%, -100%) translateY(0) scale(1); }
}

/* brand splash */
@keyframes closeSplashIn { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes closeSplashOut { to { opacity: 0; transform: scale(1.03); } }

/* skeleton loading — breathing card placeholders */
@keyframes closeBreathe { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }
.skeleton-card {
  background: var(--card-2);
  border-radius: 20px;
  animation: closeBreathe 1.6s ease-in-out infinite;
}

/* Ask Andi thinking dots */
.andi-dot {
  width: 7px;
  height: 7px;
  border-radius: 9px;
  background: var(--brand);
  display: inline-block;
  animation: dotPulse 1s ease-in-out infinite;
}
@keyframes dotPulse { 0%, 100% { opacity: .25; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-3px); } }

/* Ask Andi streaming cursor — blinks at the end of the in-flight answer */
.andi-cursor {
  display: inline;
  color: var(--brand);
  animation: andiBlink 1.1s ease-in-out infinite;
}
@keyframes andiBlink { 0%, 55% { opacity: 1; } 56%, 100% { opacity: 0; } }

/* Command Center */
@keyframes cc-spin { to { transform: rotate(360deg); } }
@keyframes cc-rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes ccPageIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* CC table-loading shimmer (used by <TableSkeleton> in cc/ui.tsx) */
@keyframes ccShimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.cc .cc-skeleton-row {
  height: 36px;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--panel-2) 25%, var(--line) 40%, var(--panel-2) 60%);
  background-size: 300% 100%;
  animation: ccShimmer 1.4s ease infinite;
}

/* CC saved-row flash — brief green tint that fades */
@keyframes ccRowFlash {
  from { background-color: color-mix(in oklab, var(--good), transparent 78%); }
  to   { background-color: transparent; }
}
.cc .cc-row-flash { animation: ccRowFlash 1.2s ease forwards; }

/* ── CC responsive layout ──────────────────────────────────────────────── */

/* Sidebar + topbar search (fixed inline widths/padding moved here so media
   queries can win over them) */
.cc .cc-sidebar { width: 232px; flex-shrink: 0; padding: 18px 14px 14px; }
.cc .cc-topsearch { width: 220px; }

/* Page grids — fixed two/three-column layouts that reflow on small screens */
.cc .cc-cols-2    { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.cc .cc-cols-3    { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.cc .cc-cols-hero { display: grid; grid-template-columns: 1.15fr 1fr; gap: 16px; }
.cc .cc-cols-wide { display: grid; grid-template-columns: 1.5fr 1fr; gap: 16px; }
.cc .cc-cols-side { display: grid; grid-template-columns: minmax(220px, 280px) 1fr; gap: 16px; }
.cc .cc-cols-split { display: grid; grid-template-columns: 1fr 1.4fr; gap: 16px; }
.cc .cc-cols-rail { display: grid; grid-template-columns: 360px 1fr; gap: 16px; }

@media (max-width: 1024px) {
  /* Sidebar narrows to an icon rail: labels + kbd hints hide, icons stay */
  .cc .cc-sidebar { width: 64px; padding: 18px 10px 14px; }
  .cc .cc-nav-label { display: none; }
  .cc .cc-sidebar a { justify-content: center; }
}

@media (max-width: 768px) {
  .cc .cc-cols-2, .cc .cc-cols-3, .cc .cc-cols-hero, .cc .cc-cols-wide,
  .cc .cc-cols-side, .cc .cc-cols-split, .cc .cc-cols-rail {
    grid-template-columns: 1fr;
  }
  .cc .cc-topsearch { width: min(220px, 40vw); }
}

/* Sandbox: thinking dots + card pop-in (was an inline <style> tag) */
.sbx-bd {
  width: 9px;
  height: 9px;
  border-radius: 9px;
  background: var(--brand);
  display: inline-block;
  animation: sbxBdp 1s ease-in-out infinite;
}
@keyframes sbxBdp { 0%, 100% { opacity: .25; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-4px); } }
@keyframes sbxPop { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}
