/* ========================================================================
   POWERTOFAIL — Investigative electric gazette
   Typography: Fraunces (display) + Newsreader (body) + JetBrains Mono (data)
   Palette: newsprint cream, deep ink, Texas rust, caution hazard
   ======================================================================== */

:root {
  --paper:       #f1ead8;
  --paper-dark:  #e8dfc7;
  --paper-deep:  #ded3b4;
  --ink:         #1a1512;
  --ink-soft:    #524840;
  --ink-faint:   #8a7d6e;
  --ink-line:    rgba(26, 21, 18, 0.14);
  --rust:        #b8371c;
  --rust-deep:   #8a2815;
  --rust-soft:   rgba(184, 55, 28, 0.08);
  --hazard:      #f4b800;
  --sky:         #3d5b6b;
  --moss:        #4a6b3d;

  --rule-thin:   1px solid var(--ink);
  --rule-thick:  3px solid var(--ink);

  --f-display:   'Fraunces', 'Times New Roman', Georgia, serif;
  --f-body:      'Newsreader', Georgia, 'Times New Roman', serif;
  --f-mono:      'JetBrains Mono', ui-monospace, 'Courier New', monospace;
}

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

/* ---- Body ---------------------------------------------------------------- */
body {
  font-family: var(--f-body);
  font-size: 17px;
  line-height: 1.55;
  color: var(--ink);
  background-color: var(--paper);
  /* Subtle paper grain via inline SVG turbulence */
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.82' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.1 0 0 0 0 0.08 0 0 0 0 0.07 0 0 0 0.09 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  background-blend-mode: multiply;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--rust); color: var(--paper); }

/* ---- Display type -------------------------------------------------------- */
h1, h2, h3, h4, .display {
  font-family: var(--f-display);
  font-variation-settings: 'opsz' 144, 'SOFT' 20, 'WONK' 0;
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 0.95;
  color: var(--ink);
  margin: 0 0 .75rem;
}
h2 { font-size: clamp(1.8rem, 3.5vw, 2.6rem); }
h3 {
  font-size: 1rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 700;
  font-variation-settings: 'opsz' 14;
}
.mono, .num { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }

a { color: var(--rust); text-decoration: none; border-bottom: 1px solid currentColor; }
a:hover { color: var(--rust-deep); background: var(--rust-soft); }

/* ---- Masthead ------------------------------------------------------------ */
.masthead {
  padding: 1.5rem 1.5rem 0.5rem;
  max-width: 1200px;
  margin: 0 auto;
  text-align: center;
  position: relative;
}
.masthead-top-rule {
  border-top: var(--rule-thin);
  border-bottom: var(--rule-thin);
  height: 5px;
  margin-bottom: 1rem;
}
.wordmark {
  font-family: var(--f-display);
  font-variation-settings: 'opsz' 144, 'SOFT' 0, 'WONK' 1;
  font-weight: 900;
  font-size: clamp(3.5rem, 11vw, 8rem);
  letter-spacing: -0.045em;
  line-height: 0.82;
  margin: 0;
}
.wordmark a {
  color: var(--ink);
  border: none;
  text-decoration: none;
}
.wordmark a:hover { background: none; color: var(--ink); }
.wordmark .amp {
  font-style: italic;
  font-variation-settings: 'opsz' 144, 'SOFT' 100, 'WONK' 1;
  color: var(--rust);
  font-weight: 400;
}
.masthead-tag {
  font-family: var(--f-body);
  font-style: italic;
  font-size: 1.15rem;
  color: var(--ink-soft);
  margin: .5rem 0 .75rem;
  font-weight: 300;
}
.masthead-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: var(--rule-thin);
  border-bottom: var(--rule-thin);
  padding: .4rem 0;
  font-family: var(--f-mono);
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-soft);
}
.masthead-meta .vol  { text-align: left; }
.masthead-meta .edition { text-align: center; font-family: var(--f-display); font-style: italic; font-weight: 500; text-transform: none; letter-spacing: 0; font-size: .9rem; }
.masthead-meta .date { text-align: right; }
.masthead-nav {
  margin-top: .6rem;
  font-family: var(--f-display);
  font-size: .9rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
}
.masthead-nav a { border: none; padding: 0 .5rem; font-weight: 600; }
.masthead-nav a:hover { background: var(--ink); color: var(--paper); }
.masthead-nav .sep { color: var(--ink-faint); }

/* ---- Main column --------------------------------------------------------- */
main {
  max-width: 1100px;
  margin: 2rem auto 4rem;
  padding: 0 1.5rem;
}
section {
  margin-bottom: 3rem;
}
section > h3 {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 0 0 1.25rem;
}
section > h3::before,
section > h3::after {
  content: '';
  flex: 1;
  height: 0;
  border-top: var(--rule-thin);
}
section > h3 .muted {
  flex: 0;
  font-family: var(--f-mono);
  font-size: .7rem;
  letter-spacing: 0.05em;
  text-transform: none;
  color: var(--ink-faint);
  font-weight: 400;
  white-space: nowrap;
}

/* ---- Page title (zip, plan) --------------------------------------------- */
#zipTitle, #planTitle {
  font-family: var(--f-display);
  font-variation-settings: 'opsz' 144, 'SOFT' 0, 'WONK' 0;
  font-size: clamp(2.5rem, 6vw, 4.5rem);
  font-weight: 900;
  letter-spacing: -0.04em;
  line-height: 0.9;
  margin: 0 0 .5rem;
  border-bottom: var(--rule-thick);
  padding-bottom: .75rem;
}
#zipTitle::before, #planTitle::before {
  content: '▼ ';
  color: var(--rust);
  font-size: .6em;
  vertical-align: middle;
}

/* ---- Summary stat slab --------------------------------------------------- */
.summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0;
  margin: 2rem 0 3rem;
  border-top: var(--rule-thick);
  border-bottom: var(--rule-thick);
}
.summary .stat {
  padding: 1rem 1.25rem;
  border-right: var(--rule-thin);
  background: transparent;
}
.summary .stat:last-child { border-right: none; }
.summary .stat .label {
  font-family: var(--f-display);
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
  padding-bottom: .35rem;
  border-bottom: 1px solid var(--ink-line);
  margin-bottom: .4rem;
}
.summary .stat .value {
  font-family: var(--f-display);
  font-variation-settings: 'opsz' 144, 'SOFT' 0, 'WONK' 1;
  font-weight: 800;
  font-size: 2.4rem;
  line-height: 1;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
@media (max-width: 700px) {
  .summary { grid-template-columns: repeat(2, 1fr); }
  .summary .stat { border-right: var(--rule-thin); border-bottom: var(--rule-thin); }
  .summary .stat:nth-child(2n) { border-right: none; }
}

.pill {
  display: inline-block;
  padding: .35rem .9rem;
  margin-top: 1rem;
  font-family: var(--f-display);
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  border: 2px solid var(--ink);
}
.pill.good { background: var(--moss); color: var(--paper); border-color: var(--moss); }
.pill.warn { background: var(--rust); color: var(--paper); border-color: var(--rust); }

/* ---- Home search --------------------------------------------------------- */
.search { text-align: center; padding: 3rem 0; }
.search h2 {
  font-family: var(--f-display);
  font-variation-settings: 'opsz' 144, 'SOFT' 20, 'WONK' 1;
  font-size: clamp(2rem, 4vw, 3rem);
  font-style: italic;
  margin-bottom: 1.5rem;
}
#zipForm {
  display: flex;
  justify-content: center;
  gap: 0;
  max-width: 500px;
  margin: 0 auto 1rem;
  border: var(--rule-thick);
}
#zipForm input {
  flex: 1;
  border: 0;
  padding: 1rem 1.25rem;
  font-family: var(--f-mono);
  font-size: 1.6rem;
  background: var(--paper);
  color: var(--ink);
  letter-spacing: 0.15em;
  text-align: center;
}
#zipForm input:focus { outline: none; background: #fff8e6; }
#zipForm button {
  border: 0;
  border-left: var(--rule-thick);
  padding: 0 1.5rem;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--f-display);
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  cursor: pointer;
  font-size: .9rem;
}
#zipForm button:hover { background: var(--rust); }
#lookupStatus { text-align: center; font-style: italic; color: var(--ink-soft); margin-top: 1rem; }

.tracked {
  max-width: 900px;
  margin: 3rem auto 0;
  padding-top: 1.5rem;
  border-top: var(--rule-thin);
  text-align: center;
}
.tracked h3 { justify-content: center; margin-bottom: 1.25rem; }
#zipList {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: baseline;
  gap: 0;
  font-family: var(--f-display);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.9;
}
#zipList li { display: inline; }
#zipList li + li::before {
  content: '—';
  color: var(--ink-faint);
  margin: 0 .85rem;
  font-weight: 300;
}
#zipList a {
  border: none;
  color: var(--ink);
  padding: .15rem .25rem;
  transition: background .15s;
}
#zipList a:hover { background: var(--ink); color: var(--paper); }

/* ---- Tables -------------------------------------------------------------- */
table {
  width: 100%;
  border-collapse: collapse;
}
thead tr { border-top: var(--rule-thick); border-bottom: var(--rule-thin); }
th {
  font-family: var(--f-display);
  font-size: .65rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
  text-align: left;
  padding: .75rem .6rem;
  vertical-align: bottom;
}
td {
  padding: .7rem .6rem;
  border-bottom: 1px solid var(--ink-line);
  font-family: var(--f-body);
  font-size: .92rem;
  color: var(--ink);
}
tbody tr:last-child td { border-bottom: var(--rule-thin); }
tbody tr:hover td { background: var(--rust-soft); }
/* Numeric columns in the ZIP dashboard table */
#currentTable td:nth-child(n+4),
#currentTable th:nth-child(n+4) {
  font-family: var(--f-mono);
  font-variant-numeric: tabular-nums;
  text-align: right;
}
#currentTable th[data-sort] { cursor: pointer; user-select: none; }
#currentTable th[data-sort]:hover { color: var(--rust); }
#currentTable th.sort-asc::after  { content: ' ▲'; color: var(--rust); }
#currentTable th.sort-desc::after { content: ' ▼'; color: var(--rust); }

#currentTable .gimmick-row td { background: #fff8e6; }
.gimmick {
  position: relative;
  display: inline-block;
  cursor: help;
  color: var(--rust);
  font-size: 1em;
  margin-right: .15rem;
  font-weight: 900;
}
.gimmick[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%) translateY(6px);
  width: max-content;
  max-width: 280px;
  padding: .7rem .9rem;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--f-body);
  font-size: .82rem;
  font-weight: 400;
  line-height: 1.4;
  white-space: normal;
  text-align: left;
  border-left: 4px solid var(--hazard);
  box-shadow: 3px 3px 0 var(--ink-line);
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s ease, transform .15s ease;
  z-index: 20;
}
.gimmick[data-tooltip]::before {
  content: '';
  position: absolute;
  bottom: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--ink);
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s ease;
  z-index: 21;
}
.gimmick:hover::after,
.gimmick:hover::before {
  opacity: 1;
}
.gimmick:hover::after {
  transform: translateX(-50%) translateY(0);
}
/* Near the right edge of the table, pin the tooltip to the right so it doesn't overflow */
#currentTable tr td:nth-child(2) .gimmick[data-tooltip]::after {
  left: 0;
  transform: translateX(0) translateY(6px);
}
#currentTable tr td:nth-child(2) .gimmick:hover::after {
  transform: translateX(0) translateY(0);
}
#currentTable tr td:nth-child(2) .gimmick[data-tooltip]::before {
  left: 12px;
  transform: none;
}

/* EFL line items (plan detail) */
#eflTable { margin-top: 1rem; }
#eflTable th {
  width: 40%;
  font-family: var(--f-display);
  text-transform: none;
  letter-spacing: 0;
  font-size: .92rem;
  color: var(--ink);
  border-right: var(--rule-thin);
  padding-right: 1rem;
}
#eflTable td {
  font-family: var(--f-mono);
  padding-left: 1rem;
}

/* ---- Filters ------------------------------------------------------------- */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  margin-bottom: 1rem;
  border: var(--rule-thin);
  background: var(--paper-dark);
}
.filters > * {
  border-right: var(--rule-thin);
  padding: .55rem .8rem;
  background: transparent;
  font-family: var(--f-mono);
  font-size: .85rem;
  color: var(--ink);
  min-height: 2.4rem;
}
.filters > *:last-child { border-right: none; }
.filters input[type="search"] {
  flex: 1;
  min-width: 200px;
  border: 0;
  outline: none;
  font-family: var(--f-body);
  font-style: italic;
}
.filters input[type="search"]::placeholder { color: var(--ink-faint); }
.filters select {
  border: 0;
  outline: none;
  cursor: pointer;
  font-family: var(--f-display);
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  background: transparent;
}
.filters .check {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-family: var(--f-display);
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}
.filters .check input { accent-color: var(--rust); }

/* ---- Charts -------------------------------------------------------------- */
canvas {
  background: var(--paper);
  border: var(--rule-thin);
  padding: 1rem;
  max-height: 420px;
}

/* ---- Banners / warnings -------------------------------------------------- */
.warn {
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
  font-family: var(--f-body);
  font-size: .95rem;
  background: #fff4d9;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-image: repeating-linear-gradient(135deg, var(--hazard) 0 14px, var(--ink) 14px 28px) 6;
  color: var(--ink);
}
.warn strong { font-family: var(--f-display); font-weight: 800; }
#gimmickWarn::before {
  content: '§ NOTICE — ';
  font-family: var(--f-display);
  font-weight: 900;
  letter-spacing: 0.12em;
  color: var(--rust-deep);
}

.redirect-banner {
  padding: .85rem 1.25rem;
  margin-bottom: 1.25rem;
  background: var(--paper-dark);
  border-left: 6px solid var(--sky);
  border-right: 6px solid var(--sky);
  font-family: var(--f-body);
  font-style: italic;
  color: var(--ink);
}
.redirect-banner::before {
  content: '§ ';
  font-family: var(--f-display);
  font-style: normal;
  font-weight: 800;
  color: var(--sky);
  margin-right: .25rem;
}

/* ---- Provider links (plan detail) ---------------------------------------- */
.provider-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .75rem;
  padding: 1rem 1.25rem;
  margin-bottom: 2rem;
  border-top: var(--rule-thin);
  border-bottom: var(--rule-thin);
  background: transparent;
}
.provider-links .btn {
  display: inline-block;
  padding: .6rem 1.1rem;
  font-family: var(--f-display);
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border: 2px solid var(--ink);
  color: var(--ink);
  background: var(--paper);
  text-decoration: none;
  transition: background .15s, color .15s;
}
.provider-links .btn:hover { background: var(--ink); color: var(--paper); }
.provider-links .btn.primary { background: var(--rust); border-color: var(--rust); color: var(--paper); }
.provider-links .btn.primary:hover { background: var(--rust-deep); border-color: var(--rust-deep); }
.provider-links .btn.ghost { border-color: var(--ink-line); color: var(--ink-soft); font-weight: 500; }
.provider-links .btn.ghost:hover { border-color: var(--ink); color: var(--ink); background: var(--paper); }
.provider-links .phone {
  font-family: var(--f-body);
  font-style: italic;
  color: var(--ink-soft);
}
.provider-links .phone a { font-family: var(--f-mono); font-style: normal; font-weight: 600; border-bottom: 1px solid; }

/* ---- True cost calculator ------------------------------------------------ */
#usage {
  font-family: var(--f-mono);
  font-size: 1.3rem;
  padding: .4rem .6rem;
  background: var(--paper);
  border: var(--rule-thin);
  color: var(--ink);
  width: 8rem;
  text-align: right;
}
#trueCost {
  font-family: var(--f-display);
  font-size: 1.35rem;
  font-weight: 700;
  margin-top: 1rem;
  padding: 1rem 1.25rem;
  background: var(--ink);
  color: var(--paper);
  display: inline-block;
}
#trueCost:empty { display: none; }

/* ---- Misc --------------------------------------------------------------- */
.muted { color: var(--ink-faint); font-weight: normal; font-family: var(--f-mono); font-size: .75rem; }

/* Page-load reveal — single orchestrated moment, not scattered nonsense. */
@keyframes reveal {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.masthead, main > * {
  animation: reveal .7s cubic-bezier(.2,.7,.2,1) both;
}
main > *:nth-child(1) { animation-delay: .05s; }
main > *:nth-child(2) { animation-delay: .12s; }
main > *:nth-child(3) { animation-delay: .19s; }
main > *:nth-child(4) { animation-delay: .26s; }
main > *:nth-child(5) { animation-delay: .33s; }
main > *:nth-child(6) { animation-delay: .40s; }
@media (prefers-reduced-motion: reduce) {
  .masthead, main > * { animation: none; }
}

/* ---- Footer -------------------------------------------------------------- */
.site-footer {
  max-width: 1100px;
  margin: 4rem auto 2rem;
  padding: 0 1.5rem;
  text-align: center;
}
.site-footer-rule {
  border-top: var(--rule-thin);
  border-bottom: var(--rule-thin);
  height: 5px;
  margin-bottom: 1.25rem;
}
.site-footer .colophon {
  font-family: var(--f-body);
  font-size: .82rem;
  color: var(--ink-soft);
  max-width: 680px;
  margin: 0 auto .5rem;
  line-height: 1.55;
}
.site-footer .colophon strong {
  font-family: var(--f-display);
  font-weight: 800;
  color: var(--ink);
}
.site-footer .colophon a { color: var(--rust); font-weight: 600; }
.site-footer .colophon-meta {
  font-family: var(--f-mono);
  font-size: .65rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: .75rem 0 0;
}
.site-footer .colophon-meta em { font-family: var(--f-display); font-style: italic; text-transform: none; letter-spacing: 0; font-size: .78rem; color: var(--ink-soft); }

/* ---- Prose (disclaimer page) -------------------------------------------- */
main.prose {
  max-width: 720px;
}
main.prose h2 {
  font-size: clamp(2.2rem, 5vw, 3.2rem);
  border-bottom: var(--rule-thick);
  padding-bottom: .75rem;
  margin-bottom: 1rem;
}
main.prose .dek {
  font-family: var(--f-body);
  font-style: italic;
  font-size: 1.15rem;
  color: var(--ink-soft);
  margin: 0 0 2.5rem;
  padding-bottom: 1.25rem;
  border-bottom: var(--rule-thin);
}
main.prose h3 {
  margin-top: 2.25rem;
  margin-bottom: .5rem;
  font-size: .95rem;
}
main.prose p {
  font-family: var(--f-body);
  font-size: 1.02rem;
  line-height: 1.65;
  margin: 0 0 1.1rem;
  color: var(--ink);
}
main.prose p strong { font-weight: 600; }
main.prose p code {
  font-family: var(--f-mono);
  font-size: .88em;
  background: var(--paper-dark);
  padding: .05rem .35rem;
  border: 1px solid var(--ink-line);
}
