/* ========== Thesis prototype — shared styles ==========
   The tokens below are the single source of truth for the visual system.
   Rules for using them (allowed colors / fonts / radii, banned patterns)
   live in DESIGN.md at the repo root. Read it before adding new styles.
   ======================================================== */

:root {
  /* Type */
  --font-sans: 'Inter Tight', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', Menlo, Consolas, monospace;
  --font-serif: 'Source Serif 4', 'Source Serif Pro', 'Charter', Georgia, serif;

  /* Light theme — warm off-white prosumer */
  --bg: #f6f3ec;
  --bg-2: #ede9df;
  --bg-3: #e3dfd2;
  --surface: #fbf9f3;
  --ink: #1a1410;
  --ink-2: #3a302a;
  --ink-3: #6a6055;
  --ink-4: #948a7a;
  --line: #ddd6c5;
  --line-2: #c8bfac;
  --accent: #b8451f;
  --accent-fg: #fdfaf3;
  --accent-soft: #f4d8c2;
  --pos: #3d6e2c;
  --neg: #b8451f;
  --warn: #b07f1c;
  --hl: #f0c64a;

  /* Density (overridden in compact) */
  --d-card-pad: 20px;
  --d-row-h: 44px;
  --d-gap: 16px;
  --d-text: 15px;
  --d-text-sm: 13px;
  --d-text-xs: 11.5px;
  --d-radius: 6px;
  --d-radius-lg: 10px;
}

[data-theme='dark'] {
  --bg: #14110d;
  --bg-2: #1d1914;
  --bg-3: #26211a;
  --surface: #1a1611;
  --ink: #f3ecdb;
  --ink-2: #d8d0bf;
  --ink-3: #9a9182;
  --ink-4: #6a6253;
  --line: #2c2620;
  --line-2: #3a342c;
  --accent: #e87a4a;
  --accent-fg: #14110d;
  --accent-soft: #3a2418;
  --pos: #87b76e;
  --neg: #e87a4a;
  --warn: #e4b85a;
  --hl: #f0c64a;
}

[data-density='compact'] {
  --d-card-pad: 14px;
  --d-row-h: 36px;
  --d-gap: 10px;
  --d-text: 13.5px;
  --d-text-sm: 12px;
  --d-text-xs: 10.5px;
  --d-radius: 4px;
  --d-radius-lg: 8px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--d-text);
  line-height: 1.5;
  font-feature-settings: 'ss01', 'cv11';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button { font-family: inherit; }
input, textarea { font-family: inherit; color: inherit; }

::selection { background: var(--ink); color: var(--bg); }

/* ========== Primitives ========== */

.mono { font-family: var(--font-mono); font-feature-settings: 'zero', 'ss01'; letter-spacing: -0.01em; }
.serif { font-family: var(--font-serif); font-feature-settings: 'ss01', 'liga'; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--d-radius);
  border: 1px solid var(--line-2);
  background: var(--surface);
  color: var(--ink);
  font-size: var(--d-text-sm);
  font-weight: 500;
  cursor: pointer;
  transition: background 120ms, border-color 120ms, transform 80ms;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { background: var(--bg-2); border-color: var(--ink-3); }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
}
.btn-primary:hover { background: color-mix(in oklch, var(--accent) 88%, black); border-color: color-mix(in oklch, var(--accent) 88%, black); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--bg-2); border-color: var(--line); }
.btn-sm { padding: 6px 10px; font-size: var(--d-text-xs); }
.btn-founder {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 16px;
  border-radius: var(--d-radius);
  border: 1px solid var(--line-2);
  background: var(--accent-soft);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: var(--d-text-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.kbd {
  font-family: var(--font-mono);
  font-size: 10.5px;
  padding: 2px 5px;
  border: 1px solid var(--line-2);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--bg);
  color: var(--ink-3);
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  background: var(--bg-2);
  font-size: var(--d-text-xs);
  color: var(--ink-3);
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.tag-dot { width: 6px; height: 6px; border-radius: 999px; background: var(--ink-3); }
.tag-pos .tag-dot { background: var(--pos); }
.tag-neg .tag-dot { background: var(--neg); }
.tag-warn .tag-dot { background: var(--warn); }

.divider {
  height: 1px;
  background: var(--line);
  width: 100%;
}

.label {
  font-family: var(--font-mono);
  font-size: var(--d-text-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-4);
}

/* ========== Disclaimer ========== */

.disclaimer {
  font-family: var(--font-mono);
  font-size: var(--d-text-xs);
  color: var(--ink-3);
  background: color-mix(in oklch, var(--hl) 18%, var(--bg));
  border-bottom: 1px solid color-mix(in oklch, var(--hl) 30%, var(--line));
  padding: 8px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.disclaimer-dot {
  width: 6px; height: 6px; border-radius: 999px;
  background: var(--warn);
  flex-shrink: 0;
}

/* Mock banner — make clear this is a non-functional prototype */
.mock-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 6px 14px;
  background: var(--ink);
  color: var(--bg);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.mock-banner-dot {
  width: 6px; height: 6px; border-radius: 999px;
  background: var(--hl);
}

/* ========== Card ========== */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--d-radius-lg);
  padding: var(--d-card-pad);
  transition: border-color 120ms, transform 120ms;
}
.card-hover:hover { border-color: var(--ink-3); cursor: pointer; }

/* ========== Score bar ========== */

.score-bar {
  position: relative;
  height: 4px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
}
.score-bar-fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: var(--accent);
  border-radius: 999px;
}

/* ========== Sparkline / chart placeholder ========== */

.spark {
  height: 36px;
  width: 100%;
  display: block;
}

/* ========== Profile form ========== */

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.field:last-child { border-bottom: none; }
.field-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  justify-content: space-between;
}
.field-label {
  font-family: var(--font-mono);
  font-size: var(--d-text-xs);
  color: var(--ink-4);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  width: 140px;
  flex-shrink: 0;
}
.field-value {
  flex: 1;
  font-size: var(--d-text);
  color: var(--ink);
  background: transparent;
  border: none;
  outline: none;
  padding: 2px 0;
  border-bottom: 1px dashed transparent;
}
.field-value:hover, .field-value:focus { border-bottom-color: var(--line-2); }
.field-rationale {
  font-size: var(--d-text-xs);
  color: var(--ink-4);
  margin-top: 2px;
  font-style: italic;
}

/* ========== Tab bar ========== */

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line);
}
.tab {
  padding: 10px 14px;
  font-size: var(--d-text-sm);
  color: var(--ink-3);
  border: none;
  background: transparent;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  font-family: inherit;
  font-weight: 500;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ========== Citation pill ========== */

.cite {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-3);
  text-decoration: none;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  margin: 0 2px;
  white-space: nowrap;
}
.cite:hover { background: var(--bg-3); color: var(--ink); }

/* ========== Scrollbars ========== */

.scroll-area::-webkit-scrollbar { width: 8px; height: 8px; }
.scroll-area::-webkit-scrollbar-track { background: transparent; }
.scroll-area::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 999px; }
.scroll-area::-webkit-scrollbar-thumb:hover { background: var(--ink-4); }

/* ========== Animation ========== */

@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
.fade-in { animation: fadeIn 240ms ease-out both; }

@keyframes pulseDot {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}
.pulse-dot { animation: pulseDot 1.4s ease-in-out infinite; }

@keyframes shimmer {
  0% { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}
.shimmer {
  background: linear-gradient(90deg, var(--bg-2) 0%, var(--bg-3) 50%, var(--bg-2) 100%);
  background-size: 800px 100%;
  animation: shimmer 1.6s infinite linear;
  border-radius: 4px;
}

/* ========== Layout ========== */

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 18px;
  letter-spacing: -0.01em;
}
.brand-mark {
  width: 22px;
  height: 22px;
  background: var(--accent);
  color: var(--accent-fg);
  border-radius: 5px;
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
}

.crumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: var(--d-text-xs);
  color: var(--ink-4);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.crumb-sep { opacity: 0.5; }
.crumb-active { color: var(--ink); }
