/* ============================================================
   CoffeaFab™ — Industrial Engineering & Investor Site
   Design System: x.com dark theme + dashboard data discipline
   Author: Coda ⚡
   ============================================================ */

:root {
  /* Base surfaces */
  --bg-base: #000000;
  --bg-canvas: #050506;
  --bg-elevated: #16181c;
  --bg-elevated-2: #1c1f24;
  --bg-hover: #1d1f23;
  --bg-inset: #0a0a0c;

  /* Borders */
  --border-subtle: #2f3336;
  --border-default: #3d4146;
  --border-strong: #536471;

  /* Text */
  --text-primary: #e7e9ea;
  --text-secondary: #9099a2;
  --text-tertiary: #71767b;
  --text-faint: #4b5560;

  /* Brand */
  --accent: #1d9bf0;
  --accent-hover: #1a8cd8;
  --accent-soft: rgba(29, 155, 240, 0.12);
  --accent-line: rgba(29, 155, 240, 0.35);

  /* Data series (Western investor dashboard) */
  --series-1: #1d9bf0;   /* blue   */
  --series-2: #8b5cf6;   /* violet */
  --series-3: #f59e0b;   /* amber  */
  --series-4: #10b981;   /* emerald (savings/positive) */
  --series-5: #ef4444;   /* red    */
  --series-6: #06b6d4;   /* cyan   */

  /* Status */
  --ok: #10b981;
  --warn: #f59e0b;
  --risk: #ef4444;

  /* Radii */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 22px;
  --r-pill: 9999px;

  /* Shadows */
  --shadow-card: 0 1px 2px rgba(0,0,0,0.5), 0 0 0 1px var(--border-subtle);
  --shadow-float: 0 8px 32px rgba(0,0,0,0.65);

  /* Type */
  --font-sans: "Inter", "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "SF Mono", "JetBrains Mono", "Fira Code", ui-monospace, Menlo, Consolas, monospace;

  /* Layout */
  --nav-h: 64px;
  --max-w: 1180px;
  --gutter: 24px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "ss01", "cv01", "cv11";
  letter-spacing: -0.01em;
}

a { color: var(--accent); text-decoration: none; transition: color .15s; }
a:hover { color: var(--accent-hover); }

::selection { background: var(--accent-soft); color: var(--text-primary); }

img { max-width: 100%; display: block; }

/* ---------- Typography ---------- */
h1, h2, h3, h4 { font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; color: #fff; }
h1 { font-size: clamp(2.1rem, 4.5vw, 3.25rem); }
h2 { font-size: clamp(1.6rem, 3vw, 2.25rem); }
h3 { font-size: clamp(1.2rem, 2vw, 1.5rem); }
h4 { font-size: 1.05rem; }

p { color: var(--text-secondary); }
strong { color: var(--text-primary); font-weight: 600; }

.eyebrow {
  font-size: .72rem; font-weight: 600; letter-spacing: .14em; text-transform: uppercase;
  color: var(--accent); display: inline-block; margin-bottom: 14px;
}
.lead { font-size: 1.12rem; color: var(--text-secondary); line-height: 1.7; }
.mono { font-family: var(--font-mono); }
.text-accent { color: var(--accent); }
.text-ok { color: var(--ok); }
.text-warn { color: var(--warn); }
.text-risk { color: var(--risk); }
.text-sec { color: var(--text-secondary); }
.text-faint { color: var(--text-tertiary); }

/* ---------- Layout primitives ---------- */
.wrap { max-width: var(--max-w); margin: 0 auto; padding: 0 var(--gutter); }
.wrap-wide { max-width: 1320px; margin: 0 auto; padding: 0 var(--gutter); }

.section { padding: 88px 0; border-top: 1px solid var(--border-subtle); }
.section--tight { padding: 56px 0; }
.section-head { margin-bottom: 44px; }
.section-head .num { font-family: var(--font-mono); color: var(--text-faint); font-size: .8rem; }
.section-head h2 { margin: 8px 0 14px; }
.section-head p { max-width: 720px; }

.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- Cards ---------- */
.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-lg);
  padding: 28px;
  transition: border-color .18s, transform .18s;
}
.card:hover { border-color: var(--border-default); }
.card--flush { padding: 0; overflow: hidden; }
.card--accent { border-color: var(--accent-line); background: linear-gradient(180deg, rgba(29,155,240,0.05), var(--bg-elevated)); }

.card-tag {
  font-size: .68rem; font-weight: 600; letter-spacing: .1em; text-transform: uppercase;
  color: var(--accent); margin-bottom: 12px;
}

/* ---------- Stat / KPI ---------- */
.kpi { background: var(--bg-elevated); border: 1px solid var(--border-subtle); border-radius: var(--r-md); padding: 22px 24px; }
.kpi .label { font-size: .72rem; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: .08em; }
.kpi .value { font-size: 2.1rem; font-weight: 800; color: #fff; letter-spacing: -0.03em; margin-top: 6px; line-height: 1; }
.kpi .value .unit { font-size: 1rem; font-weight: 600; color: var(--text-secondary); margin-left: 4px; }
.kpi .delta { font-size: .82rem; color: var(--text-secondary); margin-top: 10px; }
.kpi .delta b { color: var(--ok); }

/* ---------- Navbar ---------- */
.nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--nav-h);
  backdrop-filter: blur(18px) saturate(160%);
  background: rgba(0,0,0,0.72);
  border-bottom: 1px solid var(--border-subtle);
}
.nav__inner { max-width: 1320px; margin: 0 auto; height: 100%; display: flex; align-items: center; justify-content: space-between; padding: 0 var(--gutter); }
.nav__brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.05rem; color: #fff; letter-spacing: -0.02em; }
.nav__brand .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 12px var(--accent); }
.nav__brand .tm { font-size: .6rem; vertical-align: super; color: var(--text-tertiary); font-weight: 500; }

.nav__links { display: flex; align-items: center; gap: 4px; }
.nav__item { position: relative; }
.nav__link {
  display: flex; align-items: center; gap: 5px;
  padding: 8px 14px; border-radius: var(--r-pill);
  font-size: .9rem; font-weight: 500; color: var(--text-secondary);
  cursor: pointer; transition: background .15s, color .15s;
}
.nav__link:hover, .nav__item:hover > .nav__link { background: var(--bg-elevated); color: var(--text-primary); }
.nav__link.active { color: #fff; }
.nav__link .caret { font-size: .65rem; opacity: .6; transition: transform .18s; }
.nav__item:hover > .nav__link .caret { transform: rotate(180deg); }
.nav__link.active::after {
  content: ""; position: absolute; bottom: -4px; left: 14px; right: 14px;
  height: 2px; background: var(--accent); border-radius: 2px;
}

/* dropdown */
.nav__dropdown {
  position: absolute; top: calc(100% + 10px); left: 50%; transform: translateX(-50%) translateY(-6px);
  min-width: 230px; background: var(--bg-elevated-2);
  border: 1px solid var(--border-default); border-radius: var(--r-md);
  box-shadow: var(--shadow-float);
  padding: 8px; opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity .18s, transform .18s;
}
.nav__item:hover .nav__dropdown { opacity: 1; visibility: visible; pointer-events: auto; transform: translateX(-50%) translateY(0); }
.nav__dropdown a {
  display: flex; flex-direction: column; gap: 2px;
  padding: 10px 12px; border-radius: var(--r-sm);
  color: var(--text-secondary);
}
.nav__dropdown a:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav__dropdown a b { color: var(--text-primary); font-size: .9rem; }
.nav__dropdown a span { font-size: .76rem; color: var(--text-tertiary); }

.nav__cta {
  padding: 8px 16px; border-radius: var(--r-pill);
  background: var(--accent); color: #fff; font-weight: 600; font-size: .88rem;
  transition: background .15s;
}
.nav__cta:hover { background: var(--accent-hover); color: #fff; }

.nav__burger { display: none; background: none; border: none; color: var(--text-primary); font-size: 1.4rem; cursor: pointer; }

@media (max-width: 820px) {
  .nav__links { display: none; }
  .nav__burger { display: block; }
  .nav__links.open {
    display: flex; flex-direction: column; position: absolute; top: var(--nav-h); left: 0; right: 0;
    background: var(--bg-elevated-2); border-bottom: 1px solid var(--border-subtle);
    padding: 12px; gap: 4px; box-shadow: var(--shadow-float);
  }
  .nav__links.open .nav__dropdown { position: static; transform: none; opacity: 1; visibility: visible; pointer-events: auto; min-width: 0; box-shadow: none; background: var(--bg-elevated); }
}

/* ---------- Hero ---------- */
.hero {
  position: relative; padding: calc(var(--nav-h) + 70px) 0 64px;
  border-bottom: 1px solid var(--border-subtle);
  background:
    radial-gradient(900px 500px at 80% -10%, rgba(29,155,240,0.10), transparent 60%),
    radial-gradient(700px 400px at 0% 20%, rgba(139,92,246,0.07), transparent 55%),
    var(--bg-base);
  overflow: hidden;
}
.hero__grid-bg {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.018) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, #000 40%, transparent 100%);
  pointer-events: none;
}
.hero__inner { position: relative; }
.hero__pills { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 26px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: var(--r-pill);
  font-size: .74rem; font-weight: 600;
  background: var(--bg-elevated); border: 1px solid var(--border-subtle); color: var(--text-secondary);
}
.pill--accent { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); }
.pill .led { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 8px var(--accent); }

.hero h1 { max-width: 16ch; }
.hero__sub { font-size: 1.2rem; color: var(--text-secondary); max-width: 60ch; margin-top: 22px; }
.hero__meta { display: flex; flex-wrap: wrap; gap: 28px; margin-top: 34px; padding-top: 30px; border-top: 1px solid var(--border-subtle); }
.hero__meta div { display: flex; flex-direction: column; gap: 2px; }
.hero__meta .k { font-size: .72rem; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: .08em; }
.hero__meta .v { font-size: 1.25rem; font-weight: 700; color: #fff; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 22px; border-radius: var(--r-pill);
  font-weight: 600; font-size: .92rem; cursor: pointer; border: 1px solid transparent;
  transition: background .15s, border-color .15s, transform .12s;
}
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-hover); }
.btn--ghost { background: transparent; border-color: var(--border-strong); color: var(--text-primary); }
.btn--ghost:hover { background: var(--bg-elevated); border-color: var(--text-secondary); }

/* ---------- Tables ---------- */
.tbl-wrap { overflow-x: auto; border: 1px solid var(--border-subtle); border-radius: var(--r-lg); }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
thead th {
  text-align: left; font-weight: 600; color: var(--text-tertiary);
  font-size: .74rem; text-transform: uppercase; letter-spacing: .06em;
  padding: 14px 18px; border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-inset);
}
tbody td { padding: 14px 18px; border-bottom: 1px solid var(--border-subtle); color: var(--text-secondary); vertical-align: top; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--bg-hover); color: var(--text-primary); }
td b, td strong { color: var(--text-primary); }
.t-total td { background: var(--bg-inset); font-weight: 700; color: #fff; border-top: 2px solid var(--accent-line); }
.t-num { font-family: var(--font-mono); color: var(--accent); }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: var(--r-pill);
  font-size: .72rem; font-weight: 600;
}
.badge--ok { background: rgba(16,185,129,0.12); color: var(--ok); }
.badge--warn { background: rgba(245,158,11,0.12); color: var(--warn); }
.badge--risk { background: rgba(239,68,68,0.12); color: var(--risk); }
.badge--accent { background: var(--accent-soft); color: var(--accent); }
.badge--neutral { background: var(--bg-elevated-2); color: var(--text-secondary); }

/* ---------- Stage / timeline ---------- */
.stage-list { display: flex; flex-direction: column; gap: 0; }
.stage {
  display: grid; grid-template-columns: 96px 1fr; gap: 0;
  border-left: 2px solid var(--border-subtle); position: relative;
}
.stage:last-child { border-left-color: transparent; }
.stage__node {
  position: relative; padding: 0 0 40px 24px;
}
.stage__node::before {
  content: ""; position: absolute; left: -7px; top: 4px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--bg-base); border: 2px solid var(--accent); box-shadow: 0 0 10px var(--accent-soft);
}
.stage__num { font-family: var(--font-mono); font-size: .72rem; color: var(--accent); font-weight: 700; }
.stage__title { font-size: 1.15rem; font-weight: 700; color: #fff; margin-top: 2px; }
.stage__body { padding: 0 0 40px 0; }

/* ---------- Code / ascii ---------- */
.code-block {
  background: var(--bg-inset); border: 1px solid var(--border-subtle); border-radius: var(--r-md);
  padding: 20px 22px; overflow-x: auto; font-family: var(--font-mono);
  font-size: .8rem; line-height: 1.55; color: var(--text-secondary); white-space: pre;
}

/* ---------- Footer ---------- */
.footer { border-top: 1px solid var(--border-subtle); padding: 56px 0 40px; background: var(--bg-canvas); }
.footer__top { display: flex; justify-content: space-between; align-items: flex-start; gap: 40px; flex-wrap: wrap; }
.footer__brand { max-width: 360px; }
.footer__brand p { font-size: .88rem; margin-top: 10px; }
.footer__cols { display: flex; gap: 48px; flex-wrap: wrap; }
.footer__col h5 { font-size: .76rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-tertiary); margin-bottom: 12px; }
.footer__col a { display: block; font-size: .9rem; color: var(--text-secondary); padding: 4px 0; }
.footer__col a:hover { color: var(--text-primary); }
.footer__bottom { margin-top: 40px; padding-top: 24px; border-top: 1px solid var(--border-subtle); display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.footer__bottom p { font-size: .8rem; color: var(--text-faint); }

/* ---------- Utilities ---------- */
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; } .mt-4 { margin-top: 32px; } .mt-5 { margin-top: 48px; }
.mb-0 { margin-bottom: 0; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; } .mb-4 { margin-bottom: 32px; }
.flex { display: flex; } .items-center { align-items: center; } .justify-between { justify-content: space-between; }
.gap-1 { gap: 8px; } .gap-2 { gap: 16px; } .gap-3 { gap: 24px; }
.wrap-balance { text-wrap: balance; }
.divider { height: 1px; background: var(--border-subtle); margin: 36px 0; border: none; }
.center { text-align: center; }
.chart-box { background: var(--bg-elevated); border: 1px solid var(--border-subtle); border-radius: var(--r-lg); padding: 24px; }
.chart-box canvas { max-height: 340px; }
.callout {
  border-left: 3px solid var(--accent); padding: 4px 0 4px 18px;
  color: var(--text-secondary); font-size: .95rem;
}
.icon-row { display: flex; align-items: center; gap: 12px; }
.tag-row { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- Scroll reveal ---------- */
.reveal { opacity: 0; transform: translateY(18px); transition: opacity .6s ease, transform .6s ease; }
.reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .reveal { opacity: 1; transform: none; transition: none; } }

/* page top spacer to clear fixed nav */
.page { padding-top: var(--nav-h); }
