@layer reset, tokens, base, layout, components, motion, utilities;

@font-face { font-family: "Bricolage Grotesque"; src: url("/hq/fonts/bricolage-grotesque-latin.woff2") format("woff2"); font-style: normal; font-weight: 200 800; font-stretch: 75% 100%; font-display: swap; }
@font-face { font-family: "Hanken Grotesk"; src: url("/hq/fonts/hanken-grotesk-latin.woff2") format("woff2"); font-style: normal; font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Commit Mono"; src: url("/hq/fonts/commit-mono-regular.woff2") format("woff2"); font-style: normal; font-weight: 400; font-display: swap; }

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  html { color-scheme: light; }
  body, h1, h2, h3, p { margin: 0; }
  button, input, textarea { font: inherit; }
}

@layer tokens {
  :root {
    --display: "Bricolage Grotesque", "Arial Narrow", sans-serif;
    --text: "Hanken Grotesk", system-ui, sans-serif;
    --mono: "Commit Mono", ui-monospace, monospace;
    --bg: oklch(0.97 0.012 85);
    --surface: oklch(0.995 0.008 85);
    --ink: oklch(0.20 0.02 275);
    --ink-2: oklch(0.42 0.03 275);
    --line: oklch(0.88 0.015 85);
    --accent: oklch(0.70 0.17 55);
    --accent-ink: oklch(0.16 0.03 55);
    --ok: oklch(0.64 0.15 150);
    --warn: oklch(0.75 0.15 85);
    --danger: oklch(0.60 0.20 25);
    --info: oklch(0.65 0.12 230);
    --highlight: oklch(0.84 0.16 120);
    --star: oklch(1 0 0 / .72);
    --surface-glass: color-mix(in oklch, var(--surface) 78%, transparent);
    --surface-solid: var(--surface);
    --muted: var(--ink-2);
    --accent-soft: color-mix(in oklch, var(--accent) 20%, var(--surface));
    --lime: var(--highlight);
    --blue: var(--info);
    --success: var(--ok);
    --warning: var(--warn);
    --shadow: 0 18px 50px color-mix(in oklch, var(--ink) 9%, transparent);
    --radius: 24px;
    --rail: 216px;
    --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
    --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
    --ease-sheet: cubic-bezier(0.32, 0.72, 0, 1);
    --duration-press: 120ms;
    --duration-popover: 150ms;
    --duration-dropdown: 200ms;
    --duration-sheet: 360ms;
  }

  :root[data-theme="night"] {
    --bg: oklch(0.14 0.015 275);
    --surface: oklch(0.18 0.018 275);
    --ink: oklch(0.93 0.012 85);
    --ink-2: oklch(0.72 0.02 275);
    --line: oklch(0.28 0.02 275);
    --accent: oklch(0.75 0.16 55);
    --ok: oklch(0.70 0.15 150);
    --warn: oklch(0.81 0.15 85);
    --danger: oklch(0.66 0.20 25);
    --info: oklch(0.71 0.12 230);
    --surface-glass: color-mix(in oklch, var(--surface) 78%, transparent);
    --shadow: 0 22px 70px color-mix(in oklch, var(--ink) 10%, transparent);
  }
}

@layer base {
  html { min-height: 100%; background: var(--bg); }
  :root[data-theme="night"] { color-scheme: dark; }
  body {
    min-height: 100vh;
    background: var(--bg);
    color: var(--ink);
    font: 500 16px/1.5 var(--text);
    overflow-x: hidden;
  }
  a { color: inherit; text-decoration: none; }
  button { color: inherit; }
  :focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }
  h1, h2, h3 { font-family: var(--display); line-height: .98; letter-spacing: -.045em; }
  h1 { font-size: clamp(2.6rem, 8vw, 6.7rem); max-width: 11ch; }
  h2 { font-size: clamp(1.45rem, 3vw, 2.25rem); }
  .mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
}

@layer layout {
  .shell { min-height: 100vh; }
  .rail {
    position: fixed; inset: 0 auto 0 0; z-index: 20;
    width: var(--rail); padding: 28px 20px;
    border-right: 1px solid var(--line); background: var(--bg);
    display: flex; flex-direction: column;
  }
  .brand { display: flex; align-items: center; gap: 11px; font-family: var(--display); font-size: 1.15rem; font-weight: 750; }
  .brand-mark { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; background: var(--ink); color: var(--bg); }
  .nav { display: grid; gap: 7px; margin-top: 44px; }
  .nav a, .bottom-nav a { min-height: 46px; display: flex; align-items: center; gap: 11px; border-radius: 14px; padding: 0 13px; color: var(--muted); transition: transform var(--duration-press) var(--ease-out), opacity var(--duration-popover) var(--ease-out); }
  .nav a[aria-current="page"], .bottom-nav a[aria-current="page"] { color: var(--ink); background: var(--surface-solid); box-shadow: 0 8px 24px color-mix(in oklch, var(--ink) 6%, transparent); }
  .rail-foot { margin-top: auto; display: grid; gap: 10px; }
  .main { margin-left: var(--rail); min-height: 100vh; padding: 34px clamp(24px, 5vw, 72px) 80px; position: relative; z-index: 1; }
  .topbar { min-height: 48px; display: flex; justify-content: space-between; align-items: center; gap: 18px; margin-bottom: clamp(40px, 8vw, 88px); }
  .status { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font: 600 .77rem/1 var(--mono); text-transform: uppercase; letter-spacing: .08em; }
  .status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 5px color-mix(in srgb, var(--success) 16%, transparent); }
  .actions { display: flex; align-items: center; gap: 8px; }
  .grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 16px; margin-top: 36px; }
  .span-4 { grid-column: span 4; }
  .span-5 { grid-column: span 5; }
  .span-7 { grid-column: span 7; }
  .span-8 { grid-column: span 8; }
  .span-12 { grid-column: 1 / -1; }
  .bottom-nav { display: none; }
}

@layer components {
  .context-line { color: var(--accent); font: 700 .76rem/1 var(--mono); letter-spacing: .12em; text-transform: uppercase; margin-bottom: 16px; }
  .lede { color: var(--muted); max-width: 56ch; font-size: clamp(1rem, 2vw, 1.2rem); margin-top: 22px; }
  .hero { position: relative; }
  .card { border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius); padding: clamp(20px, 3vw, 30px); box-shadow: var(--shadow); min-width: 0; }
  .card-head { display: flex; align-items: start; justify-content: space-between; gap: 16px; margin-bottom: 26px; }
  .card-label { color: var(--muted); font: 650 .72rem/1 var(--mono); text-transform: uppercase; letter-spacing: .09em; }
  .metric { font-family: var(--display); font-size: clamp(2.5rem, 5vw, 4.8rem); line-height: .86; letter-spacing: -.06em; }
  .metric-label { color: var(--muted); margin-top: 14px; }
  .list { list-style: none; padding: 0; margin: 0; display: grid; }
  .list li { min-height: 52px; display: grid; grid-template-columns: 12px 1fr auto; align-items: center; gap: 12px; border-top: 1px solid var(--line); }
  .list li:first-child { border-top: 0; }
  .bullet { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
  .meta { color: var(--muted); font: 500 .75rem/1.2 var(--mono); }
  .chip { display: inline-flex; min-height: 28px; align-items: center; border: 1px solid var(--line); border-radius: 99px; padding: 0 10px; color: var(--muted); font: 600 .7rem/1 var(--mono); }
  .chip.disabled { opacity: .48; cursor: not-allowed; }
  .button { min-height: 44px; border: 1px solid var(--line); border-radius: 14px; padding: 0 15px; background: var(--surface-solid); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: transform var(--duration-press) var(--ease-out), opacity var(--duration-popover) var(--ease-out); }
  .button:active, .nav a:active, .bottom-nav a:active, .palette-links a:active, .capture-types label:active span { transform: scale(.97); }
  .icon-button { width: 44px; padding: 0; }
  .icon { width: 20px; height: 20px; display: block; }
  .quest-bar { height: 9px; border-radius: 99px; background: var(--line); overflow: hidden; margin-top: 18px; }
  .quest-bar span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent), var(--lime)); }
  .freshness { display: flex; justify-content: space-between; align-items: center; gap: 12px; border-top: 1px solid var(--line); padding-top: 18px; margin-top: 22px; color: var(--muted); font-size: .82rem; }
  .freshness [data-level="stale"] { color: var(--accent); }
  .freshness [data-level="aging"] { color: var(--warning); }
  .system-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 18px; padding: 17px 0; border-top: 1px solid var(--line); }
  .system-row:first-of-type { border-top: 0; }
  .health { display: inline-flex; align-items: center; gap: 8px; font: 650 .72rem/1 var(--mono); text-transform: uppercase; color: var(--success); }
  .health::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
  .capture { min-height: 360px; display: grid; align-content: center; position: relative; overflow: hidden; }
  .capture textarea { width: 100%; min-height: 136px; resize: vertical; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: transparent; color: var(--ink); font: 600 clamp(1.35rem, 4vw, 2.6rem)/1.16 var(--display); padding: 12px 0; }
  .capture textarea::placeholder { color: color-mix(in srgb, var(--muted) 62%, transparent); }
  .capture-actions { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 14px; margin-top: 20px; }
  .capture-types { display: flex; flex-wrap: wrap; gap: 7px; }
  .capture-types label { cursor: pointer; }
  .capture-types input { position: absolute; opacity: 0; pointer-events: none; }
  .capture-types span { min-height: 38px; display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 99px; padding: 0 13px; color: var(--muted); font: 650 .72rem/1 var(--mono); transition: transform var(--duration-press) var(--ease-out), opacity var(--duration-popover) var(--ease-out); }
  .capture-types input:checked + span { background: var(--ink); color: var(--bg); border-color: var(--ink); }
  .notice { border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; color: var(--muted); font-size: .82rem; background: var(--surface); }
  .empty { color: var(--muted); padding: 22px 0; }
  .palette { width: min(520px, calc(100% - 28px)); border: 1px solid var(--line); border-radius: var(--radius); padding: 26px; background: var(--surface); color: var(--ink); box-shadow: var(--shadow); transition: transform var(--duration-sheet) var(--ease-sheet), opacity var(--duration-dropdown) var(--ease-out); }
  .palette::backdrop { background: color-mix(in oklch, var(--ink) 42%, transparent); }
  .palette form { margin: 0; }
  .palette-links { display: grid; }
  .palette-links a { min-height: 58px; display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--line); transition: transform var(--duration-press) var(--ease-out), opacity var(--duration-popover) var(--ease-out); }
  .palette-links a:first-child { border-top: 0; }
}

@layer motion {
  .ambient { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 0; }
  body[data-view="today"] .aurora { position: absolute; width: 66vw; height: 66vw; right: -18vw; top: -26vw; border-radius: 50%; background: radial-gradient(circle at 35% 40%, color-mix(in srgb, var(--lime) 42%, transparent), transparent 58%), radial-gradient(circle at 65% 58%, color-mix(in srgb, var(--blue) 34%, transparent), transparent 60%); filter: blur(34px); opacity: .65; animation: drift 18s var(--ease-in-out) infinite alternate; }
  body[data-view="today"] .flame { position: absolute; width: 170px; height: 240px; right: 8vw; bottom: -100px; background: radial-gradient(ellipse at 50% 85%, var(--accent), transparent 66%); filter: blur(14px); opacity: .35; transform-origin: bottom; animation: breathe 6s var(--ease-in-out) infinite; }
  body[data-view="drop"] .dock-glow { position: absolute; inset: auto 16vw -18vw; height: 44vw; background: radial-gradient(ellipse, color-mix(in srgb, var(--accent) 34%, transparent), transparent 66%); filter: blur(30px); opacity: .48; animation: glow 8s var(--ease-in-out) infinite; }
  .stars { position: absolute; inset: 0; opacity: 0; background-image: radial-gradient(circle, var(--star) 0 1px, transparent 1.5px); background-size: 74px 74px; }
  :root[data-theme="night"] body[data-view="system"] .stars { opacity: .24; animation: star-drift 18s linear infinite; }
  .live-pulse { animation: pulse 2.4s var(--ease-in-out) infinite; }
  @keyframes drift { to { transform: translate3d(-5vw, 5vw, 0) scale(1.08); } }
  @keyframes breathe { 50% { opacity: .62; transform: scaleY(1.14) scaleX(.92); } }
  @keyframes glow { 50% { opacity: .68; transform: scale(1.04); } }
  @keyframes star-drift { to { transform: translate3d(8px, 4px, 0); } }
  @keyframes pulse { 50% { opacity: .42; } }
}

@layer utilities {
  .sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
  [hidden] { display: none !important; }
  @media (max-width: 900px) {
    .rail { display: none; }
    .main { margin-left: 0; padding: 22px 18px 104px; }
    .topbar { margin-bottom: 52px; }
    .grid { grid-template-columns: 1fr; }
    .span-4, .span-5, .span-7, .span-8, .span-12 { grid-column: 1; }
    .bottom-nav { position: fixed; display: grid; grid-template-columns: repeat(3, 1fr); inset: auto 12px 12px; z-index: 30; border: 1px solid var(--line); border-radius: 18px; padding: 6px; background: var(--surface-solid); box-shadow: var(--shadow); }
    .bottom-nav a { justify-content: center; min-height: 48px; padding: 0 8px; font-size: .78rem; }
    .bottom-nav a[href="/drop/"] { min-height: 58px; margin-top: -16px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); box-shadow: var(--shadow); }
  }
  @media (max-width: 520px) {
    .topbar .status span:last-child { max-width: 165px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .card { padding: 20px; border-radius: 18px; }
    .capture-actions { align-items: stretch; }
    .capture-actions .button { width: 100%; }
  }
  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  }
  @media (hover: hover) and (pointer: fine) { .button:hover { transform: translateY(-1px); } }
  :root[data-calm="true"] .aurora, :root[data-calm="true"] .flame, :root[data-calm="true"] .dock-glow, :root[data-calm="true"] .stars, :root[data-calm="true"] .live-pulse { animation: none; opacity: .12; }
}
