/* ══════════════════════════════════════════════════════════════════════
   shared/styles.css — Design tokens & reusable component styles
   Import: <link rel="stylesheet" href="/shared/styles.css">
   ══════════════════════════════════════════════════════════════════════ */

/* ── Reset ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Design Tokens ─────────────────────────────────────────────────── */
:root {
  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
  --font-serif: 'Georgia', 'Times New Roman', serif;

  --text-xs: 0.65rem;
  --text-sm: 0.78rem;
  --text-base: 0.875rem;
  --text-md: 0.95rem;
  --text-lg: 1.1rem;
  --text-xl: 1.35rem;
  --text-2xl: 1.75rem;

  /* Surfaces */
  --bg: #ffffff;
  --surface: #f8f9fa;
  --surface-alt: #f1f3f5;
  --border: #e9ecef;
  --border-light: #f3f4f6;
  --text: #1a1a1a;
  --text-secondary: #4b5563;
  --muted: #6c757d;
  --faint: #9ca3af;

  /* Semantic — colour-blind safe (blue/amber, NO red, NO green) */
  --positive: #0d6efd;
  --positive-bg: #dbeafe;
  --positive-text: #1e40af;
  --negative: #e67700;
  --negative-bg: #fff3cd;
  --negative-text: #92400e;
  --warning: #d97706;
  --warning-bg: #fef9c3;
  --warning-text: #854d0e;
  --info: #0d6efd;
  --info-bg: #dbeafe;
  --info-text: #1e40af;
  --neutral: #6c757d;
  --neutral-bg: #f3f4f6;
  --neutral-text: #4b5563;
  --accent: #7c3aed;
  --accent-bg: #f3e8ff;
  --accent-text: #7e22ce;

  /* Amber (kept for backward compat where amber is semantically correct) */
  --amber: #d97706;
  --amber-bg: #fef9c3;
  --amber-text: #854d0e;

  /* Blue alias */
  --blue: #0d6efd;
  --blue-bg: #dbeafe;
  --blue-text: #1e40af;

  /* Spacing */
  --sp-xs: 0.25rem;
  --sp-sm: 0.5rem;
  --sp-md: 1rem;
  --sp-lg: 1.5rem;
  --sp-xl: 2rem;

  /* Radius */
  --radius-sm: 4px;
  --radius-md: 7px;
  --radius-pill: 99px;
}

/* ── Base ──────────────────────────────────────────────────────────── */
body {
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }

/* ── Layout ────────────────────────────────────────────────────────── */
.page { max-width: 1200px; margin: 0 auto; padding: 2rem 2rem 4rem; }
.page-narrow { max-width: 720px; margin: 0 auto; padding: 3rem 2rem 4rem; }
.page-wide { max-width: 1120px; margin: 0 auto; padding: 0 28px; }

/* ── Nav ───────────────────────────────────────────────────────────── */
nav, .site-nav {
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
  display: flex;
  align-items: center;
  gap: 2rem;
  height: 52px;
}
.nav-brand { font-weight: 700; font-size: 0.95rem; letter-spacing: -0.02em; color: var(--text); text-decoration: none; }
.nav-links { display: flex; gap: 1.5rem; }
.nav-links a { font-size: 0.875rem; color: var(--muted); font-weight: 500; transition: color 0.12s; text-decoration: none; }
.nav-links a:hover { color: var(--text); }
.nav-links a.active { color: var(--text); font-weight: 600; }
.lock-icon { font-size: 0.7rem; margin-left: 2px; opacity: 0.5; }
.nav-right { margin-left: auto; display: flex; align-items: center; gap: 1rem; }
.btn-logout, .nav-logout { font-size: 0.8rem; color: var(--muted); cursor: pointer; background: none; border: none; font-family: inherit; }
.btn-logout:hover, .nav-logout:hover { color: var(--text); }

/* ── Auth Screen ───────────────────────────────────────────────────── */
#authScreen { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 2rem; }
#app { display: none; }
.auth-card { width: 100%; max-width: 360px; }
.auth-card h1 { font-size: 1.4rem; font-weight: 700; letter-spacing: -0.03em; margin-bottom: 0.25rem; }
.auth-card p { color: var(--muted); font-size: 0.85rem; margin-bottom: 1.5rem; }
.btn-google { width: 100%; padding: 0.7rem 1rem; background: #fff; color: var(--text); border: 1px solid var(--border); border-radius: 8px; font-family: inherit; font-size: 0.9rem; font-weight: 600; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 0.6rem; transition: background 0.15s, box-shadow 0.15s; }
.btn-google:hover { background: var(--surface); box-shadow: 0 1px 3px rgba(0,0,0,0.08); }

/* ── Cards ──────────────────────────────────────────────────────────── */
.card { border: 1px solid var(--border); border-radius: 10px; padding: 1.5rem; margin-bottom: 1.5rem; }
.card-title { font-size: var(--text-xs); font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); margin-bottom: 1.25rem; }

/* ── Tables ─────────────────────────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.data-table th {
  padding: 0.5rem 0.75rem; text-align: left;
  font-size: var(--text-xs); font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--muted);
  border-bottom: 1px solid var(--border); background: var(--surface);
}
.data-table td { padding: 0.55rem 0.75rem; border-bottom: 1px solid var(--border); }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--surface); }
.data-table th.sortable { cursor: pointer; user-select: none; }
.data-table th.sortable:hover { color: var(--text); }

/* ── Tabs ───────────────────────────────────────────────────────────── */
.tabs { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 1.25rem; gap: 0; }
.tab {
  padding: 0.6rem 1rem; font-size: 0.85rem; font-weight: 500;
  color: var(--muted); background: none; border: none;
  border-bottom: 2px solid transparent; cursor: pointer;
  font-family: inherit; white-space: nowrap;
}
.tab.active { color: var(--text); border-bottom-color: var(--text); font-weight: 600; }
.tab:hover { color: var(--text); }
.tab .count {
  font-size: 0.65rem; background: var(--text); color: #fff;
  padding: 0.1rem 0.4rem; border-radius: 99px; margin-left: 0.4rem;
  vertical-align: middle;
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Pills ──────────────────────────────────────────────────────────── */
.pills { display: flex; gap: 0.35rem; margin-bottom: 1rem; }
.pill {
  padding: 0.3rem 0.75rem; font-size: 0.75rem; font-weight: 600;
  border: 1px solid var(--border); border-radius: 99px;
  background: var(--bg); color: var(--muted); cursor: pointer; font-family: inherit;
}
.pill.active { background: var(--text); color: #fff; border-color: var(--text); }
.pill:hover:not(.active) { background: var(--surface); color: var(--text); }

/* ── Buttons ───────────────────────────────────────────────────────── */
.btn {
  padding: 0.55rem 1.1rem; border-radius: var(--radius-md); font-family: var(--font-sans);
  font-size: 0.85rem; font-weight: 600; cursor: pointer;
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
  display: inline-flex; align-items: center; gap: 0.4rem; transition: opacity 0.15s;
}
.btn:hover { background: var(--surface); }
.btn-dark { background: var(--text); color: #fff; border-color: var(--text); }
.btn-dark:hover { opacity: 0.85; background: var(--text); }
.btn-sm { padding: 0.3rem 0.75rem; font-size: 0.78rem; }
.btn-positive { background: var(--positive-bg); color: var(--positive-text); border-color: var(--positive-bg); }
.btn-negative { background: var(--negative-bg); color: var(--negative-text); border-color: var(--negative-bg); }
.btn-warning { background: var(--warning-bg); color: var(--warning-text); border-color: var(--warning-bg); }
.btn-info { background: var(--info-bg); color: var(--info-text); border-color: var(--info-bg); }
.btn-accent { background: var(--accent-bg); color: var(--accent-text); border-color: var(--accent-bg); }
.btn-blue { background: var(--blue-bg); color: var(--blue-text); border-color: var(--blue-bg); }
.btn-amber { background: var(--amber-bg); color: var(--amber-text); border-color: var(--amber-bg); }

/* ── Stat Grid / Summary Strip ─────────────────────────────────────── */
.stat-grid {
  display: grid; gap: 1px; background: var(--border);
  border: 1px solid var(--border); border-radius: 10px;
  overflow: hidden; margin-bottom: 1.5rem;
}
.stat-grid-3 { grid-template-columns: repeat(3, 1fr); }
.stat-grid-4 { grid-template-columns: repeat(4, 1fr); }
.stat-grid-5 { grid-template-columns: repeat(5, 1fr); }
.stat-cell { background: var(--bg); padding: 1rem 1.25rem; }
.stat-cell label {
  font-size: var(--text-xs); font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.07em; color: var(--muted); display: block; margin-bottom: 0.3rem;
}
.stat-cell .val { font-size: 1.35rem; font-weight: 700; letter-spacing: -0.03em; }
.stat-cell .sub { font-size: 0.75rem; color: var(--muted); margin-top: 0.15rem; }

/* ── Forms ──────────────────────────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.form-grid-2 { grid-template-columns: 1fr 1fr; }
.form-grid-4 { grid-template-columns: repeat(4, 1fr); }
.field label {
  font-size: var(--text-xs); font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--muted); display: block; margin-bottom: 0.35rem;
}
.field input, .field select, .field textarea {
  width: 100%; padding: 0.55rem 0.8rem; border: 1px solid var(--border);
  border-radius: var(--radius-md); font-family: inherit; font-size: 0.88rem;
  outline: none; background: var(--bg); color: var(--text);
}
.field textarea { resize: vertical; min-height: 60px; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--text); }

/* ── Section Headers ───────────────────────────────────────────────── */
.section-eyebrow {
  font-size: var(--text-xs); font-weight: 600;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--faint); margin-bottom: 22px;
}
.page-header { margin-bottom: 2rem; }
.page-header h1 { font-size: var(--text-xl); font-weight: 700; letter-spacing: -0.03em; }
.page-header p { color: var(--muted); font-size: 0.9rem; margin-top: 0.35rem; }

/* ── Semantic Value Classes ────────────────────────────────────────── */
.val-positive { color: var(--positive); }
.val-negative { color: var(--negative); }
.val-warning { color: var(--warning); }
.val-muted { color: var(--muted); }
.pnl-pos { color: var(--positive); font-weight: 600; }
.pnl-neg { color: var(--negative); font-weight: 600; }

/* ── Grade Badges (A–F) ─── monochrome scale ───────────────────────── */
.grade-badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.56rem;
  font-weight: 600;
  padding: 1px 4px;
  margin-left: 3px;
  vertical-align: middle;
  line-height: 1.2;
}
.grade-A { background: #1a1a1a; color: #fff; }
.grade-B { background: #444;    color: #fff; }
.grade-C { background: #888;    color: #fff; }
.grade-D { background: #ccc;    color: #1a1a1a; }
.grade-F { background: #fff;    color: #1a1a1a; border: 1px solid #aaa; }

/* ── Score Chips (numeric 0–10) ────────────────────────────────────── */
.score-chip {
  display: inline-block;
  padding: 0.18rem 0.55rem;
  border-radius: var(--radius-pill);
  font-size: 0.82rem;
  font-weight: 700;
  min-width: 2.4rem;
  text-align: center;
}
.chip-positive { background: var(--positive-bg); color: var(--positive-text); }
.chip-warning  { background: var(--warning-bg);  color: var(--warning-text); }
.chip-negative { background: var(--negative-bg); color: var(--negative-text); }
.chip-amber    { background: var(--amber-bg);    color: var(--amber-text); }
.chip-null     { color: var(--muted); font-size: 0.82rem; font-weight: 400; }

/* ── Conviction Badges ─────────────────────────────────────────────── */
.conviction-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-pill);
  text-transform: capitalize;
}
.conv-high     { background: var(--positive-bg); color: var(--positive-text); }
.conv-medium   { background: var(--amber-bg);    color: var(--amber-text); }
.conv-moderate { background: var(--amber-bg);    color: var(--amber-text); }
.conv-low      { background: var(--surface);     color: var(--muted); }
.conv-unscored { background: var(--surface);     color: var(--muted); }

/* ── Signal Badges (position actions) ──────────────────────────────── */
.signal-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 14px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  white-space: nowrap;
}
/* Portfolio signals */
.signal-badge.exit       { background: #e5e7eb; color: #1a1a1a; }
.signal-badge.trim       { background: var(--warning-bg); color: var(--warning-text); }
.signal-badge.accumulate { background: var(--positive-bg); color: var(--positive-text); }
.signal-badge.review     { background: var(--warning-bg); color: var(--warning-text); }
.signal-badge.rebalance  { background: var(--positive-bg); color: var(--positive-text); }
.signal-badge.hold       { background: var(--neutral-bg); color: var(--neutral-text); }
/* Watchlist signals */
.signal-badge.enter              { background: var(--positive-bg); color: var(--positive-text); }
.signal-badge.getting-interesting { background: var(--warning-bg); color: var(--warning-text); }
.signal-badge.wait               { background: var(--neutral-bg); color: var(--neutral-text); }
.signal-badge.avoid              { background: #e5e7eb; color: #1a1a1a; }

/* ── Action Pills (composite decision) ─────────────────────────────── */
.action-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.68rem;
  font-weight: 700;
  margin-left: 5px;
  vertical-align: middle;
}
.action-pill.buy          { background: #1e40af; color: #fff; }
.action-pill.prepare      { background: #3730a3; color: #fff; }
.action-pill.watch        { background: #e0e7ff; color: #3730a3; }
.action-pill.consider     { background: var(--warning-bg); color: var(--warning-text); }
.action-pill.low-priority { background: var(--neutral-bg); color: var(--neutral-text); }
.action-pill.pass         { background: var(--neutral-bg); color: var(--faint); }
.action-pill.avoid        { background: #e5e7eb; color: #1a1a1a; }
.action-pill.na           { background: var(--neutral-bg); color: var(--faint); font-style: italic; }

/* ── Bear Signal Status Badges ─────────────────────────────────────── */
.badge {
  font-size: 0.62rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 3px;
  letter-spacing: .06em;
  white-space: nowrap;
}
.b-met   { background: var(--positive-bg); color: var(--positive-text); border: 1px solid #93c5fd; }
.b-close { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.b-no    { background: #f9fafb; color: #9ca3af; border: 1px solid #e5e7eb; }
.b-data  { background: #fff;    color: #9ca3af; border: 1px dashed #d1d5db; }

/* ── Tags ──────────────────────────────────────────────────────────── */
.tag {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.72rem;
  font-weight: 600;
}
.tag-positive { background: var(--positive-bg); color: var(--positive-text); }
.tag-negative { background: var(--negative-bg); color: var(--negative-text); }
.tag-warning  { background: var(--warning-bg);  color: var(--warning-text); }
.tag-amber    { background: var(--amber-bg);    color: var(--amber-text); }
.tag-blue     { background: var(--blue-bg);     color: var(--blue-text); }
.tag-neutral  { background: var(--neutral-bg);  color: var(--neutral-text); }
.tag-dark     { background: #e5e7eb;            color: #1a1a1a; }

/* ── Trend Arrows ──────────────────────────────────────────────────── */
.trend-arrow { font-size: 0.6rem; margin-left: 1px; }
.trend-up    { color: var(--text); font-weight: 700; }
.trend-down  { color: #888; font-weight: 400; text-decoration: underline; }
.trend-flat  { color: #bbb; font-weight: 400; }

/* ══════════════════════════════════════════════════════════════════════
   READING MODE — editorial/blog layout
   Used by: blog posts, book reviews, essays, about, now
   Applied via .reading class on <body> or a wrapper <div>
   ══════════════════════════════════════════════════════════════════════ */

.reading .page,
.page-reading {
  max-width: 680px;
  margin: 0 auto;
  padding: 3rem 2rem 5rem;
}

.reading body,
.page-reading {
  font-size: 1.05rem;
  line-height: 1.75;
  color: #2d2d2d;
  -webkit-font-smoothing: antialiased;
}

.essay-title {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1.15;
  margin-bottom: 0.5rem;
  color: var(--text);
}

.essay-meta {
  font-size: 0.82rem;
  color: var(--faint);
  margin-bottom: 2rem;
  font-weight: 500;
}

.essay-hero {
  width: 100%;
  margin-bottom: 2.5rem;
  border-radius: 4px;
}

.reading p,
.essay-body p {
  margin-bottom: 1.5rem;
  font-size: 1.05rem;
  line-height: 1.75;
}

.reading h2,
.essay-body h2 {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-top: 3rem;
  margin-bottom: 1rem;
  color: var(--text);
}

.reading h3,
.essay-body h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-top: 2rem;
  margin-bottom: 0.75rem;
}

.reading blockquote,
.essay-body blockquote {
  border-left: 3px solid var(--border);
  padding: 0.25rem 0 0.25rem 1.5rem;
  margin: 2rem 0;
  color: var(--text-secondary);
  font-style: italic;
  font-size: 1rem;
  line-height: 1.7;
}

.reading a,
.essay-body a {
  color: var(--text);
  text-decoration: underline;
  text-decoration-color: var(--border);
  text-underline-offset: 3px;
  transition: text-decoration-color 0.15s;
}
.reading a:hover,
.essay-body a:hover {
  text-decoration-color: var(--text);
}

.book-cover {
  max-width: 188px;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  margin-bottom: 1.5rem;
}

.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 1.5rem;
  margin-top: 2rem;
}
.book-grid a { display: block; transition: transform 0.15s; }
.book-grid a:hover { transform: translateY(-2px); }
.book-grid img {
  width: 100%;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.post-card {
  border-bottom: 1px solid var(--border-light);
  padding: 2rem 0;
}
.post-card:first-of-type { padding-top: 0; }
.post-card:last-of-type { border-bottom: none; }
.post-date {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--faint);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.5rem;
}
.post-title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.4rem;
}
.post-title a:hover { color: var(--text-secondary); }
.post-excerpt {
  font-size: 0.92rem;
  color: var(--text-secondary);
  line-height: 1.65;
  margin-bottom: 0.75rem;
}
.post-read { font-size: 0.82rem; font-weight: 600; color: var(--text); }
.post-read:hover { color: var(--muted); }

.section-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--faint);
  margin-top: 2.5rem;
  margin-bottom: 1.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}
.section-label:first-of-type { margin-top: 0; }

.newsletter-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.5rem 2rem;
  margin: 3rem 0;
  text-align: center;
}
.newsletter-box p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 1rem;
}
.newsletter-box input[type="email"] {
  padding: 0.6rem 1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.9rem;
  width: 260px;
  max-width: 100%;
  margin-right: 0.5rem;
}
.newsletter-box button {
  padding: 0.6rem 1.2rem;
  background: var(--text);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.about-portrait {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  object-fit: cover;
  margin-bottom: 1.5rem;
}

.now-updated {
  font-size: 0.82rem;
  color: var(--faint);
  font-style: italic;
  margin-bottom: 2rem;
}

.reading del {
  color: var(--muted);
  text-decoration: line-through;
}

@media (max-width: 768px) {
  .reading .page,
  .page-reading {
    padding: 1.5rem 1rem 3rem;
  }
  .essay-title { font-size: 1.5rem; }
  .book-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 1rem; }
  .newsletter-box input[type="email"] { width: 100%; margin-right: 0; margin-bottom: 0.5rem; }
  .newsletter-box button { width: 100%; }
}
