/* Cost Beacon — main stylesheet */
/* Design ref: handoff/design-guidelines.md */

:root {
  /* Surfaces — brand navy ladder */
  --bg-0: #0B1424;
  --bg-1: #0E1A2D;
  --bg-2: #122036;
  --bg-3: #16273F;
  --bg-4: #1C2F4A;

  /* Rules */
  --rule:     #1F2E45;
  --rule-2:   #2A3B54;
  --rule-dim: #152237;

  /* Text */
  --fg:       #ECEEF2;
  --fg-dim:   #A5AFC0;
  --fg-mute:  #6B7889;
  --fg-faint: #3A475C;

  /* Accents */
  --up:        #F2BC6A;  /* amber — positive / savings / accent */
  --up-soft:   #4A3520;
  --down:      #FF3636;  /* red — waste / loss / HIGH severity */
  --down-soft: #3D1818;
  --warn:      #FFD56B;

  /* Type */
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --font-ui:   'IBM Plex Sans', system-ui, -apple-system, sans-serif;

  /* Layout */
  --maxw: 1360px;
  --gutter: clamp(20px, 4vw, 56px);
}

/* ── Reset ── */
* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg-0);
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
body { overflow-x: hidden; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* ── Container ── */
.container {
  max-width: var(--maxw);
  margin: 0 auto;
  padding-inline: var(--gutter);
}

/* ── Mono label ── */
.mono-label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--fg-mute);
}
.mono-label.up { color: var(--up); }
.mono-label.down { color: var(--down); }

/* ── Headlines ── */
.h-display {
  font-family: var(--font-ui);
  font-weight: 500;
  font-size: clamp(48px, 7.5vw, 96px);
  line-height: 0.98;
  letter-spacing: -0.025em;
  color: var(--fg);
  margin: 0;
  text-wrap: balance;
}
.h-display .up { color: var(--up); }
.h-display .down { color: var(--down); }

.h-section {
  font-family: var(--font-ui);
  font-weight: 500;
  font-size: clamp(36px, 4.5vw, 60px);
  line-height: 1.02;
  letter-spacing: -0.022em;
  color: var(--fg);
  margin: 0;
  text-wrap: balance;
}
.h-section .up { color: var(--up); }

.lede {
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.55;
  color: var(--fg-dim);
  max-width: 56ch;
  text-wrap: pretty;
}

/* ── Section ── */
.section {
  padding-block: clamp(80px, 9vw, 140px);
  position: relative;
  border-top: 1px solid var(--rule);
}
.section--tight { padding-block: clamp(48px, 6vw, 88px); }

/* ── Section bracket label ── */
.bracket {
  font-family: var(--font-mono); font-size: 10.5px;
  letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--up);
  display: inline-flex; align-items: center; gap: 10px;
  font-weight: 600;
}
.bracket .rule {
  display: inline-block; width: 22px; height: 1px; background: var(--rule-2);
}
.bracket .num { color: var(--up); }
.bracket .sep { color: var(--fg-faint); font-weight: 400; }
.bracket .title { color: var(--fg-dim); }
.bracket .sub { color: var(--fg-mute); margin-left: 4px; letter-spacing: 0.08em; text-transform: none; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 12px 18px;
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 500;
  border: 1px solid transparent;
  background: transparent;
  color: var(--fg);
  transition: all 140ms ease;
  white-space: nowrap;
  cursor: pointer;
}
.btn-primary {
  background: var(--up);
  color: #082014;
  font-weight: 600;
}
.btn-primary:hover {
  filter: brightness(1.12);
  transform: translateY(-1px);
}
.btn-ghost {
  border-color: var(--rule-2);
  color: var(--fg-dim);
}
.btn-ghost:hover {
  border-color: var(--up);
  color: var(--up);
}

/* ── Panels ── */
.panel {
  background: var(--bg-2);
  border: 1px solid var(--rule);
  position: relative;
}
.panel--inset { background: var(--bg-3); }

.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--rule);
  background: var(--bg-3);
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--fg);
  font-weight: 500;
}
.panel-header .meta {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--fg-mute);
  font-weight: 500;
}
.panel-header .meta.up { color: var(--up); }
.panel-body { padding: 18px; }

/* ── Hairline ── */
.hairline { height: 1px; background: var(--rule); width: 100%; }

/* ── Live dot ── */
.live {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font-mono); font-size: 10.5px;
  letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--up);
}
.live::before {
  content: ""; width: 7px; height: 7px;
  background: var(--up); border-radius: 50%;
  animation: livePulse 1.6s ease-in-out infinite;
}
@keyframes livePulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.8); }
}

/* ── Stat cells ── */
.stat-cell {
  padding: 32px 24px;
  border-right: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  display: flex; flex-direction: column; gap: 10px;
  background: var(--bg-1);
}
.stat-cell:last-child { border-right: none; }
.stat-cell .v {
  font-family: var(--font-ui);
  font-weight: 500;
  font-size: clamp(40px, 4.5vw, 60px);
  line-height: 0.95;
  letter-spacing: -0.025em;
  color: var(--fg);
}
.stat-cell .v.up { color: var(--up); }
.stat-cell .l {
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--fg-dim);
  line-height: 1.5;
}

/* ── Severity pills ── */
.sev {
  font-family: var(--font-mono); font-size: 9.5px;
  letter-spacing: 0.14em; font-weight: 700;
  padding: 2px 6px; border-radius: 2px;
  display: inline-block;
}
.sev-high { background: var(--down-soft); color: var(--down); }
.sev-med  { background: rgba(255,213,107,0.12); color: var(--warn); }
.sev-low  { background: rgba(255,255,255,0.06); color: var(--fg-mute); }

/* ── Crosshair grid bg ── */
.grid-bg {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px);
  background-size: 60px 60px;
  pointer-events: none;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 30%, black 30%, transparent 80%);
  -webkit-mask-image: radial-gradient(ellipse 80% 60% at 50% 30%, black 30%, transparent 80%);
}

/* ── Placeholder ── */
.placeholder {
  background:
    repeating-linear-gradient(
      135deg,
      rgba(255,255,255,0.04) 0 8px,
      rgba(255,255,255,0.015) 8px 16px
    );
  border: 1px dashed var(--rule-2);
  display: flex; align-items: center; justify-content: center;
  color: var(--fg-mute);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

/* ── Forms ── */
.field {
  display: flex; flex-direction: column; gap: 6px;
}
.field label {
  font-family: var(--font-mono); font-size: 10px;
  letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--fg-mute);
}
.field input, .field textarea, .field select {
  background: var(--bg-3);
  border: 1px solid var(--rule);
  color: var(--fg);
  font-family: var(--font-ui);
  font-size: 15px;
  padding: 12px 14px;
  outline: none;
}
.field input:focus, .field textarea:focus {
  border-color: var(--up);
  background: var(--bg-2);
}

/* ── Wordmark ── */
.wordmark {
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--fg);
  display: inline-flex;
  align-items: center;
  gap: 2px;
}
.wordmark .w2 { color: var(--up); }
.wordmark.lg { font-size: clamp(40px, 5vw, 64px); letter-spacing: 0.01em; line-height: 1; }

/* ── Nav ── */
.nav {
  position: sticky; top: 0; z-index: 50;
  background: var(--bg-0);
}
.nav-inner {
  display: flex; align-items: center; justify-content: space-between;
  height: 60px;
  border-bottom: 1px solid var(--rule);
}
.nav-links {
  display: flex; gap: 26px;
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--fg-mute);
}
.nav-links a:hover { color: var(--up); }
@media (max-width: 920px) { .nav-links { display: none; } }

/* ── Animations ── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── WastePanel layout ── */
.waste-inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 200px;
}
.waste-lines {
  padding: 12px 18px;
  border-right: 1px solid var(--rule);
}
.waste-row {
  display: grid;
  grid-template-columns: 1fr 72px 80px;
  gap: 8px;
}
.waste-summary {
  background: var(--bg-3);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ── Responsive: stack hero grid on mobile ── */
@media (max-width: 900px) {
  .hero-grid {
    grid-template-columns: 1fr !important;
    gap: 32px !important;
  }

  .waste-inner {
    grid-template-columns: 1fr;
  }
  .waste-lines {
    border-right: none;
    padding: 10px 14px;
  }
  .waste-summary {
    border-top: 1px solid var(--rule);
    padding: 16px 14px;
  }
  .waste-row {
    grid-template-columns: 1fr 60px 64px;
    gap: 6px;
  }
}

/* ── Selection ── */
::selection { background: var(--up); color: #082014; }
