/* ───────────────────────────────────────────────────────────────
   MailScore — "mail-transport diagnostic" visual identity.
   Deep petrol-ink console, brass signal gauge, monospace readouts.
   ─────────────────────────────────────────────────────────────── */
:root {
  --bg:        #0c1620;   /* petrol ink — the console body            */
  --bg-2:      #0a121b;   /* deeper, for grain/vignette               */
  --panel:     #122131;   /* raised panel                             */
  --panel-2:   #16293b;   /* nested / hover panel                     */
  --line:      #21384c;   /* hairline borders                         */
  --text:      #e9eff4;   /* cool off-white                           */
  --muted:     #829bad;   /* muted slate                              */
  --faint:     #4f6a7e;   /* faintest readable                        */

  --signal:    #f3b03f;   /* BRAND — instrument brass / signal amber  */
  --signal-dk: #c98a23;

  --pass:      #46d39a;   /* semantic: pass  (green)                  */
  --fail:      #f06a6a;   /* semantic: fail  (red)                    */
  --warn:      #c9a14a;   /* semantic: soft warning (dull gold)       */

  --radius:    14px;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "Space Grotesk", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--text);
  background:
    radial-gradient(120% 80% at 50% -10%, #14283a 0%, var(--bg) 46%, var(--bg-2) 100%);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* faint film-grain / scanline texture, very subtle */
.grain {
  position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: .04;
  background-image: repeating-linear-gradient(
    0deg, #fff 0, #fff 1px, transparent 1px, transparent 3px);
  mix-blend-mode: overlay;
}

main, .masthead, .foot { position: relative; z-index: 1; }

/* ── Masthead ─────────────────────────────────────────────── */
.masthead {
  max-width: 760px; margin: 0 auto; padding: 30px 22px 8px;
  display: flex; align-items: baseline; justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); }
.brand-mark { color: var(--muted); display: inline-flex; }
.brand-name {
  font-weight: 700; font-size: 20px; letter-spacing: -.01em;
}
.tagline {
  margin: 0; font-family: var(--mono); font-size: 12px;
  color: var(--faint); text-transform: lowercase; letter-spacing: .04em;
}

/* ── Cards ────────────────────────────────────────────────── */
main { max-width: 760px; margin: 0 auto; padding: 18px 22px 40px; }

.card {
  background: linear-gradient(180deg, var(--panel) 0%, #0f1d2b 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 30px;
  box-shadow: 0 1px 0 rgba(255,255,255,.03) inset, 0 18px 40px -28px #000;
}

/* ── Setup phase ──────────────────────────────────────────── */
.lede {
  font-size: clamp(26px, 4.5vw, 38px); line-height: 1.08;
  letter-spacing: -.02em; margin: 0 0 12px; font-weight: 600;
}
.sub { margin: 0 0 26px; color: var(--muted); max-width: 56ch; font-size: 15.5px; }

.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 22px; }
.step { display: grid; grid-template-columns: 36px 1fr; gap: 16px; }
.step-no {
  width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center;
  font-family: var(--mono); font-weight: 600; font-size: 15px;
  color: var(--signal); background: #0e1e2c;
  border: 1px solid var(--signal-dk);
}
.step-title { margin: 4px 0 12px; font-weight: 600; font-size: 16px; }

.address-field {
  display: flex; align-items: stretch; gap: 0;
  border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
  background: #0a151f;
}
.address {
  flex: 1; min-width: 0; padding: 14px 16px;
  font-family: var(--mono); font-size: clamp(13px, 2.6vw, 16px);
  color: var(--signal); letter-spacing: .01em;
  overflow-x: auto; white-space: nowrap; user-select: all;
  display: flex; align-items: center;
}
.copy {
  flex: none; border: none; border-left: 1px solid var(--line);
  background: var(--panel-2); color: var(--text);
  font-family: var(--mono); font-size: 13px; cursor: pointer;
  padding: 0 16px; display: flex; align-items: center; gap: 7px;
  transition: background .15s;
}
.copy:hover { background: #1d3850; }
.copy.copied { color: var(--pass); }
.copy-ico { font-size: 15px; }

.hint { margin: 10px 0 0; font-size: 13px; color: var(--faint); }

.check-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.primary {
  font-family: var(--sans); font-weight: 600; font-size: 15px;
  color: #20140a; background: var(--signal);
  border: none; border-radius: 10px; padding: 12px 22px; cursor: pointer;
  box-shadow: 0 8px 18px -8px var(--signal-dk);
  transition: transform .08s, box-shadow .15s, background .15s;
}
.primary:hover { background: #f7bd5a; }
.primary:active { transform: translateY(1px); }
.primary:disabled { opacity: .55; cursor: progress; }

.listen { display: inline-flex; align-items: center; gap: 9px; color: var(--muted);
  font-family: var(--mono); font-size: 13px; }
.pulse {
  width: 9px; height: 9px; border-radius: 50%; background: var(--signal);
  box-shadow: 0 0 0 0 var(--signal); animation: pulse 1.6s infinite;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(243,176,63,.55); }
  70%  { box-shadow: 0 0 0 9px rgba(243,176,63,0); }
  100% { box-shadow: 0 0 0 0 rgba(243,176,63,0); }
}

/* ── Results ──────────────────────────────────────────────── */
.results { display: grid; gap: 18px; }

.score-card {
  display: grid; grid-template-columns: 240px 1fr; gap: 28px; align-items: center;
}
.gauge-wrap { position: relative; }
.gauge { width: 100%; height: auto; display: block; overflow: visible; }
.gauge-center {
  position: absolute; left: 0; right: 0; bottom: 6px;
  text-align: center; line-height: 1;
}
.score-num {
  font-family: var(--mono); font-weight: 600;
  font-size: 46px; letter-spacing: -.02em; color: var(--text);
}
.score-den { display: block; margin-top: 2px; color: var(--faint);
  font-family: var(--mono); font-size: 13px; }

.grade { display: inline-block; font-size: 22px; font-weight: 700; letter-spacing: -.01em;
  text-transform: capitalize; }
.grade-note { margin: 8px 0 18px; color: var(--muted); font-size: 14.5px; max-width: 38ch; }
.ghost {
  font-family: var(--sans); font-size: 14px; color: var(--text);
  background: transparent; border: 1px solid var(--line); border-radius: 9px;
  padding: 9px 16px; cursor: pointer; transition: border-color .15s, background .15s;
}
.ghost:hover { border-color: var(--muted); background: var(--panel-2); }

.share { display: flex; gap: 8px; margin: 0 0 14px; max-width: 420px; }
.share-link {
  flex: 1; min-width: 0; padding: 9px 12px;
  background: #0a151f; border: 1px solid var(--line); border-radius: 9px;
  color: var(--signal); font-family: var(--mono); font-size: 12.5px;
}
.share-link:focus { outline: 2px solid var(--signal-dk); outline-offset: 1px; }
.share .ghost { white-space: nowrap; }
@media (max-width: 600px) { .share { margin-left: auto; margin-right: auto; } }

/* deductions */
.section-h { font-size: 13px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); margin: 0 0 14px; font-weight: 600; }
.deduction-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.deduction-list li { display: grid; grid-template-columns: 58px 1fr; gap: 12px;
  align-items: baseline; font-size: 14.5px; }
.deduction-list .pts { font-family: var(--mono); color: var(--fail); font-weight: 600; }

/* check sections (accordion) */
.checks { display: grid; gap: 12px; }
.sec {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: linear-gradient(180deg, var(--panel) 0%, #0f1d2b 100%); overflow: hidden;
}
.sec-head {
  width: 100%; text-align: left; cursor: pointer;
  display: grid; grid-template-columns: 18px 1fr auto 12px; gap: 14px; align-items: center;
  padding: 18px 22px; background: none; border: none; color: var(--text);
  font-family: var(--sans); font-size: 16px; font-weight: 600;
}
.sec-head:hover { background: rgba(255,255,255,.015); }
.sec-dot { width: 11px; height: 11px; border-radius: 50%; }
.sec-dot.pass { background: var(--pass); }
.sec-dot.fail { background: var(--fail); }
.sec-dot.warn { background: var(--warn); }
.sec-summary { font-family: var(--mono); font-size: 13px; color: var(--muted); font-weight: 500; }
.sec-caret { color: var(--faint); transition: transform .2s; font-size: 12px; }
.sec.open .sec-caret { transform: rotate(90deg); }

.sec-body { display: none; padding: 4px 22px 20px; }
.sec.open .sec-body { display: block; }

.row { display: grid; grid-template-columns: 20px 1fr; gap: 12px; align-items: start;
  padding: 9px 0; border-top: 1px solid rgba(255,255,255,.045); font-size: 14.5px; }
.row:first-child { border-top: none; }
.row .ico { font-family: var(--mono); font-weight: 700; line-height: 1.5; }
.row.pass .ico { color: var(--pass); }
.row.fail .ico { color: var(--fail); }
.row.warn .ico { color: var(--warn); }
.row .rule { font-family: var(--mono); font-size: 12px; color: var(--faint); display: block; margin-top: 2px; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px;
  font-family: var(--mono); font-size: 13px; margin-top: 6px; }
.kv dt { color: var(--faint); }
.kv dd { margin: 0; color: var(--text); word-break: break-all; }

.tag { display: inline-block; font-family: var(--mono); font-size: 11px;
  padding: 2px 8px; border-radius: 20px; margin-right: 6px; border: 1px solid var(--line); }
.tag.pass { color: var(--pass); border-color: rgba(70,211,154,.4); }
.tag.fail { color: var(--fail); border-color: rgba(240,106,106,.4); }
.tag.none { color: var(--muted); }

/* ── Footer ───────────────────────────────────────────────── */
.foot { max-width: 760px; margin: 0 auto; padding: 10px 22px 50px; }
.foot p { color: var(--faint); font-size: 12.5px; max-width: 60ch; margin: 0; }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 600px) {
  .card { padding: 22px; }
  .score-card { grid-template-columns: 1fr; text-align: center; }
  .gauge-wrap { max-width: 240px; margin: 0 auto; }
  .grade-note { margin-left: auto; margin-right: auto; }
  .copy-label { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .pulse { animation: none; }
  * { transition: none !important; }
}
