/**
 * foundation.css — shared design tokens + component primitives for Rosebud Terminal.
 *
 * Source of truth: /foundation/index.html (foundation v0.3, May 2026).
 *
 * Every page in terminal/ must load this file BEFORE any per-page styles.
 * No off-brand hex codes allowed in this file. The audit (2026-05-20)
 * flagged 185+ stray off-brand colors across 11 pages + 4 overlays —
 * this module is the single source of truth that ends that drift.
 *
 * Forbidden hex (never re-introduce — listed in foundation.js OFFENDERS):
 *   legacy GitHub dark surfaces (0d, 16, 21 ramps)
 *   GitHub blues (58, 79, 1f ramps)
 *   GitHub greens, reds, yellows
 *   off-brand orange, pink, purple
 * See terminal/shared/foundation.js for the literal list.
 *
 * Load with: <link rel="stylesheet" href="/shared/foundation.css?v=YYYYMMDD">
 */

@import url("https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,500;0,600;0,700;0,800;0,900;1,400;1,500&family=Source+Serif+Pro:ital,wght@0,400;0,500;0,600;1,400;1,500&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap");

/* ============================================================
   TOKENS — foundation v0.3
   ============================================================ */
:root {
  /* Surfaces — warm cream/paper, editorial. Anchored on --card #fdfcfa. */
  --bg: #f4f3f0;
  --surface: #ffffff;
  --surface-2: #faf9f6;
  --surface-3: #efece6;
  --card: #fdfcfa;
  --card-2: #f6f4ef;
  --border: #e3ded4;
  --border-soft: #ece8e0;
  --border-hair: #f1eee7;

  /* Ink ramp */
  --text: #1d1a17;
  --text-2: #57514a;
  --text-3: #847d73;
  --text-4: #9b948a;

  /* Brand accent — Rosebud coral (THE only brand color) */
  --accent: #e8836b;
  --accent-hi: #f29d86;
  --accent-lo: #d4654d;
  --accent-tint: rgba(232, 131, 107, 0.08);
  --accent-tint-2: rgba(232, 131, 107, 0.16);
  --accent-glow: rgba(232, 131, 107, 0.35);

  /* Semantic — muted, never brand-loud */
  --pos: #6bb38a;
  --pos-tint: rgba(107, 179, 138, 0.1);
  --warn: #d4a45a;
  --warn-tint: rgba(212, 164, 90, 0.1);
  --neg: #c47262;
  --neg-tint: rgba(196, 114, 98, 0.1);
  --info: #6b8cce;
  --info-tint: rgba(107, 140, 206, 0.1);

  /* Typography families */
  --serif: 'Playfair Display', 'Georgia', 'Times New Roman', serif;
  --editorial: 'Source Serif Pro', 'Playfair Display', Georgia, serif;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --mono: 'JetBrains Mono', 'SF Mono', Menlo, Consolas, monospace;

  /* Type scale */
  --fs-xs: 11px;
  --fs-sm: 12px;
  --fs-base: 13px;
  --fs-md: 15px;
  --fs-lg: 17px;
  --fs-xl: 21px;
  --fs-2xl: 28px;
  --fs-3xl: 40px;

  /* Spacing — 8 steps */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
  --sp-7: 48px;
  --sp-8: 64px;

  /* Radius */
  --r-1: 4px;
  --r-2: 6px;
  --r-3: 10px;
  --r-4: 14px;
  --r-pill: 999px;

  /* Shadows */
  --shadow-card: 0 1px 2px rgba(29, 26, 23, 0.04), 0 0 0 1px var(--border-hair);
  --shadow-hover: 0 4px 12px rgba(29, 26, 23, 0.07), 0 0 0 1px var(--border);
  --shadow-modal: 0 24px 48px rgba(29, 26, 23, 0.14), 0 0 0 1px var(--border);
  --shadow-cta: 0 1px 0 rgba(255, 255, 255, 0.4) inset, 0 4px 14px var(--accent-glow);

  /* Motion */
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --t-fast: 120ms var(--ease);
  --t-base: 180ms var(--ease);
}

/* ============================================================
   THEME (optional, light is default — keep dark slot reserved)
   ============================================================ */
[data-theme="dark"] {
  /* Reserved for a future inverted theme. Foundation v0.3 ships light only. */
  --bg: #1d1a17;
  --card: #25211d;
  --text: #f4f3f0;
  --text-2: #c8c1b5;
  --text-3: #9b948a;
  --border: #3b362f;
  --border-soft: #2e2925;
  --border-hair: #28231f;
}

/* ============================================================
   BASE — minimal page reset; only applies inside .foundation-root
   so we don't clobber legacy pages that have their own resets.
   ============================================================ */
.foundation-root,
.foundation-root * {
  box-sizing: border-box;
}
.foundation-root {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: var(--fs-base);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
.foundation-root a { color: inherit; text-decoration: none; }

/* ============================================================
   BRAND MARKS — p: (PitchPerfect) and r: (Rosebud) lockups
   Heavy serif glyph + coral colon. Both single-letter, mirrored.
   ============================================================ */
.brand-mark {
  font-family: var(--serif);
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.045em;
  color: var(--text);
  font-style: normal;
  display: inline-flex;
  align-items: baseline;
}
.brand-mark__colon { color: var(--accent); margin-left: 0.04em; }
.brand-mark--pp { font-size: 30px; }
.brand-mark--r  { font-size: 30px; }

/* Reversed on dark ink — uses --accent-hi for the colon */
.brand-mark--inverse { color: var(--card); }
.brand-mark--inverse .brand-mark__colon { color: var(--accent-hi); }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn,
.btn-primary,
.btn-secondary,
.btn-ghost,
.btn-link,
.btn-danger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--r-2);
  font-family: var(--sans);
  font-size: var(--fs-sm);
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: all var(--t-fast);
  border: 1px solid transparent;
  text-decoration: none;
}
.btn-primary { background: var(--accent); color: #1a1108; box-shadow: var(--shadow-cta); }
.btn-primary:hover { background: var(--accent-hi); transform: translateY(-1px); }

.btn-secondary { background: transparent; color: var(--accent-lo); border-color: var(--accent); }
.btn-secondary:hover { background: var(--accent-tint); color: var(--accent-lo); }

.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--text-4); }

.btn-link { background: transparent; color: var(--accent-lo); padding: 4px 0; }
.btn-link:hover { color: var(--accent); text-decoration: underline; }

.btn-danger { background: var(--neg-tint); color: var(--neg); border-color: var(--neg); }
.btn-danger:hover { background: var(--neg); color: var(--card); }

/* ============================================================
   PILLS / BADGES — status, tier, tag chips
   ============================================================ */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--r-pill);
  font-family: var(--sans);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.02em;
  border: 1px solid transparent;
  background: var(--surface-3);
  color: var(--text-3);
}
.pill--accent   { background: var(--accent-tint);  color: var(--accent-lo); border-color: var(--accent-tint-2); }
.pill--pos      { background: var(--pos-tint);     color: var(--pos); }
.pill--warn     { background: var(--warn-tint);    color: var(--warn); }
.pill--neg      { background: var(--neg-tint);     color: var(--neg); }
.pill--info     { background: var(--info-tint);    color: var(--info); }
.pill--filled   { background: var(--accent);       color: #1a1108; }
.pill--outline  { background: transparent;         color: var(--text-3); border-color: var(--border); }

/* ============================================================
   DB-BAR — header row above any db-grid (title + search + count + actions)
   ============================================================ */
.db-bar {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-5);
  background: var(--card);
  border: 1px solid var(--border-hair);
  border-radius: var(--r-3);
  margin-bottom: var(--sp-4);
}
.db-bar__title {
  font-family: var(--serif);
  font-size: var(--fs-xl);
  font-weight: 500;
  letter-spacing: -0.015em;
  color: var(--text);
}
.db-bar__search {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-2);
  padding: 8px 12px;
  font-family: var(--sans);
  font-size: var(--fs-base);
  color: var(--text);
  width: 100%;
  max-width: 320px;
  justify-self: end;
  transition: all var(--t-fast);
}
.db-bar__search:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }
.db-bar__count {
  font-family: var(--mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-4);
}
.db-bar__actions { display: inline-flex; gap: var(--sp-2); }

@media (max-width: 720px) {
  .db-bar { grid-template-columns: 1fr; }
  .db-bar__search { max-width: none; justify-self: stretch; }
}

/* ============================================================
   DB-GRID — responsive card grid; auto-fill minmax(280px, 1fr)
   ============================================================ */
.db-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--sp-4);
}
.db-grid--narrow { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.db-grid--wide   { grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); }
.db-grid__empty {
  grid-column: 1 / -1;
  padding: var(--sp-7);
  text-align: center;
  color: var(--text-3);
  font-family: var(--serif);
  font-style: italic;
  background: var(--card);
  border: 1px dashed var(--border);
  border-radius: var(--r-3);
}

/* ============================================================
   CARDS — generic shells used by db-grid, modals, sections
   ============================================================ */
.card {
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-4);
  padding: var(--sp-5);
  transition: all var(--t-base);
}
.card--hover:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }
.card--feat { box-shadow: var(--shadow-card); border-color: var(--border); }

/* ============================================================
   JOURNALIST CARD (.j-card) — canonical per journalist_card_spec.md
   360px fixed · Source Serif Pro name · SVG turbulence noise substrate
   ============================================================ */
.j-card {
  width: 360px;
  background-color: #fdfcfa;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 240 240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.62' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.42  0 0 0 0 0.36  0 0 0 0 0.3  0 0 0 0.3 0'/></filter><rect width='240' height='240' filter='url(%23n)'/></svg>");
  background-size: 240px 240px;
  background-repeat: repeat;
  border: 0.5px solid rgba(0, 0, 0, 0.15);
  border-radius: 12px;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  font-family: var(--sans);
  color: #1a1a1a;
}
.j-header-row { display: flex; align-items: center; justify-content: space-between; }
.j-tier { display: inline-flex; align-items: center; font-size: 10px; letter-spacing: 0.14em; color: rgba(0, 0, 0, 0.65); border: 0.5px solid rgba(0, 0, 0, 0.15); padding: 3px 9px; border-radius: 999px; }
.j-pub-pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px 3px 5px; border-radius: 999px; text-decoration: none; transition: filter 0.15s; background: var(--pub-pill-bg, #e8f5ee); }
.j-pub-pill:hover { filter: brightness(0.96); }
.j-pub-mark { width: 13px; height: 13px; border-radius: 3px; display: inline-flex; align-items: center; justify-content: center; color: #fff; font-size: 8px; font-weight: 500; line-height: 1; background: var(--pub-brand, #0f9d58); }
.j-pub-label { font-size: 11px; font-weight: 500; letter-spacing: -0.01em; color: var(--pub-pill-text, #0b6e3f); }
.j-identity-row { display: flex; align-items: flex-start; gap: 14px; }
.j-identity { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; }
.j-name { font-family: var(--editorial); font-size: 28px; font-weight: 500; line-height: 1.05; letter-spacing: -0.01em; margin: 14px 0 6px; color: #1a1a1a; }
.j-role { font-family: var(--editorial); font-style: italic; font-size: 13px; color: rgba(0, 0, 0, 0.65); text-decoration: none; }
.j-photo-stack { display: flex; flex-direction: column; align-items: center; gap: 10px; flex-shrink: 0; }
.j-photo { width: 72px; height: 72px; border-radius: 50%; object-fit: cover; display: flex; align-items: center; justify-content: center; background: #efece6; font-family: var(--editorial); font-size: 20px; color: rgba(0, 0, 0, 0.65); font-weight: 500; overflow: hidden; }
.j-photo img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.j-rule { height: 1px; background: #1a1a1a; width: 28px; margin: 18px 0 14px; opacity: 0.85; }
.j-label { font-family: var(--editorial); font-style: italic; font-size: 11px; color: rgba(0, 0, 0, 0.45); letter-spacing: 0.06em; margin-bottom: 8px; }
.j-quote { font-family: var(--editorial); font-size: 15px; line-height: 1.4; color: #1a1a1a; margin-bottom: 6px; display: block; text-decoration: none; }
.j-meta { font-size: 11px; color: rgba(0, 0, 0, 0.45); }

/* ============================================================
   PUBLICATION CARD (.p-card) — 220px, real logo, monogram fallback,
   AI Pick + tier + picked states. Same SVG-noise substrate as .j-card.
   ============================================================ */
.p-card {
  width: 220px;
  background-color: #fdfcfa;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 240 240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.62' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.42  0 0 0 0 0.36  0 0 0 0 0.3  0 0 0 0.3 0'/></filter><rect width='240' height='240' filter='url(%23n)'/></svg>");
  background-size: 240px 240px;
  border: 0.5px solid rgba(0, 0, 0, 0.15);
  border-radius: 12px;
  padding: 18px 18px 16px;
  position: relative;
  transition: all var(--t-base);
  cursor: pointer;
  font-family: var(--sans);
  color: #1a1a1a;
}
.p-card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(29, 26, 23, 0.07); }
.p-card.is-aipick { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent-tint-2); }
.p-card .p-aipick { position: absolute; top: -10px; left: 14px; background: var(--accent); color: #1a1108; font-family: var(--sans); font-size: 10px; font-weight: 700; letter-spacing: 0.08em; padding: 3px 9px; border-radius: 999px; }
.p-card .p-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.p-card .p-mark { width: 36px; height: 36px; border-radius: 8px; display: flex; align-items: center; justify-content: center; background: #ffffff; border: 0.5px solid rgba(0, 0, 0, 0.08); flex-shrink: 0; overflow: hidden; }
.p-card .p-mark img { width: 100%; height: 100%; object-fit: contain; padding: 4px; display: block; }
.p-card .p-mark.is-fallback { background: var(--pub-brand, #847d73); border: none; color: #fff; font-family: var(--serif); font-weight: 600; font-size: 14px; }
.p-card .p-name { font-family: var(--editorial); font-size: 17px; font-weight: 500; letter-spacing: -0.01em; color: #1a1a1a; line-height: 1.15; }
.p-card .p-meta { font-family: var(--mono); font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: rgba(0, 0, 0, 0.45); margin-top: 4px; }
.p-card .p-tagline { font-family: var(--editorial); font-style: italic; font-size: 12px; color: rgba(0, 0, 0, 0.65); line-height: 1.4; margin: 10px 0 14px; }
.p-card .p-stats { display: flex; gap: 14px; padding-top: 12px; border-top: 0.5px dashed rgba(0, 0, 0, 0.15); }
.p-card .p-stat { display: flex; flex-direction: column; gap: 2px; }
.p-card .p-stat-k { font-family: var(--mono); font-size: 9px; letter-spacing: 0.12em; text-transform: uppercase; color: rgba(0, 0, 0, 0.45); }
.p-card .p-stat-v { font-family: var(--editorial); font-size: 16px; font-weight: 500; color: #1a1a1a; font-variant-numeric: tabular-nums; }
.p-card .p-stat-v.match { color: var(--pub-brand, var(--accent)); }

/* ============================================================
   INPUTS — text, select, textarea
   ============================================================ */
.fld {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: var(--sp-4);
}
.fld label {
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--text-3);
  font-weight: 600;
}
.fld input,
.fld select,
.fld textarea {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-2);
  padding: 10px 14px;
  font-family: var(--sans);
  font-size: var(--fs-base);
  color: var(--text);
  transition: all var(--t-fast);
}
.fld input:focus,
.fld select:focus,
.fld textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}
.fld textarea { resize: vertical; min-height: 90px; line-height: 1.55; }
.fld .help { font-family: var(--sans); font-size: var(--fs-sm); color: var(--text-3); }
