/* =========================================================================
   HeatScan — design tokens
   Subject: momentum/volatility screener. The signature is the thermal Heat
   Score: color encodes ranking (cool -> hot), so it carries data, not decor.
   ========================================================================= */
:root {
  /* base: deep blue-graphite, not pure black */
  --ink:        #0E1116;
  --surface:    #161B22;
  --surface-2:  #1C232C;
  --hairline:   #232A33;
  --hairline-2: #2E3742;

  /* text */
  --text:       #E8EBF0;
  --text-muted: #8B95A5;
  --text-dim:   #5C6675;

  /* thermal ramp (the signature) */
  --cool:  #3B82C4;
  --warm:  #E8A13A;
  --hot:   #E2562A;

  /* chrome accent stays quiet + monochrome-cool */
  --accent: #5B9BD8;

  --pos: #4FB286;
  --neg: #D96A6A;

  --radius:  14px;
  --radius-s: 9px;
  --gap: 20px;

  --shadow: 0 1px 0 rgba(255,255,255,0.02) inset,
            0 10px 30px -12px rgba(0,0,0,0.6);

  --ff-display: "Space Grotesk", system-ui, sans-serif;
  --ff-body:    "Inter", system-ui, sans-serif;
  --ff-mono:    "JetBrains Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--ink);
  color: var(--text);
  font-family: var(--ff-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ambient: a faint warm glow up top, like heat rising off a terminal */
body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto 0;
  height: 340px;
  background: radial-gradient(70% 100% at 70% -10%,
              rgba(226,86,42,0.10), transparent 60%);
  pointer-events: none;
  z-index: 0;
}

.wrap {
  position: relative;
  z-index: 1;
  max-width: 1080px;
  margin: 0 auto;
  padding: 40px 24px 80px;
}

/* ---------- header ---------- */
.masthead {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  margin-bottom: 28px;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand__mark {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(150deg, var(--cool), var(--warm) 55%, var(--hot));
  box-shadow: 0 0 20px -4px rgba(226,86,42,0.55);
  flex: none;
}
.brand__name {
  font-family: var(--ff-display);
  font-weight: 700;
  font-size: 24px;
  letter-spacing: 0.14em;
  margin: 0;
}
.brand__name span { color: var(--hot); }
.tagline {
  color: var(--text-muted);
  font-size: 13px;
  max-width: 360px;
  line-height: 1.5;
  margin: 6px 0 0;
}
.status {
  font-family: var(--ff-mono);
  font-size: 11px;
  color: var(--text-dim);
  text-align: right;
  line-height: 1.7;
}
.status b { color: var(--text-muted); font-weight: 500; }
.dot { color: var(--neg); }
.dot.on { color: var(--pos); }

/* ---------- honest banner ---------- */
.disclaimer {
  border: 1px solid var(--hairline);
  border-left: 2px solid var(--warm);
  background: var(--surface);
  border-radius: var(--radius-s);
  padding: 12px 16px;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text-muted);
  margin-bottom: 24px;
}
.disclaimer b { color: var(--text); font-weight: 600; }

/* ---------- control panel ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 32px;
}
.controls {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  font-family: var(--ff-mono);
}
.field input,
.field select {
  background: var(--ink);
  border: 1px solid var(--hairline-2);
  border-radius: var(--radius-s);
  color: var(--text);
  font-family: var(--ff-mono);
  font-size: 14px;
  padding: 10px 12px;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.field input:focus,
.field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(91,155,216,0.18);
}

.toggles {
  display: flex;
  gap: 22px;
  align-items: center;
  margin-top: 18px;
  flex-wrap: wrap;
}
.toggle {
  display: flex; align-items: center; gap: 9px;
  font-size: 13px; color: var(--text-muted); cursor: pointer;
}
.toggle input { accent-color: var(--accent); width: 16px; height: 16px; }

.run {
  margin-top: 20px;
  width: 100%;
  border: none;
  border-radius: var(--radius-s);
  padding: 14px;
  font-family: var(--ff-display);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.04em;
  color: #11151b;
  background: linear-gradient(120deg, var(--warm), var(--hot));
  cursor: pointer;
  transition: transform .08s ease, filter .15s ease;
}
.run:hover { filter: brightness(1.06); }
.run:active { transform: translateY(1px); }
.run:disabled { opacity: .55; cursor: progress; }

/* ---------- results ---------- */
.results-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 16px;
}
.results-head h2 {
  font-family: var(--ff-display);
  font-size: 18px; font-weight: 600; margin: 0;
}
.results-head .meta {
  font-family: var(--ff-mono); font-size: 12px; color: var(--text-dim);
}

.cards { display: flex; flex-direction: column; gap: var(--gap); }

.card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  display: grid;
  grid-template-columns: 44px 1fr auto;
  gap: 18px;
  align-items: center;
  cursor: pointer;
  transition: border-color .15s ease, transform .1s ease;
}
.card:hover { border-color: var(--hairline-2); transform: translateY(-1px); }

.rank {
  font-family: var(--ff-mono);
  font-size: 13px;
  color: var(--text-dim);
  text-align: center;
}

.idblock { min-width: 0; }
.idline { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.ticker {
  font-family: var(--ff-mono);
  font-weight: 700;
  font-size: 19px;
  letter-spacing: 0.02em;
}
.price { font-family: var(--ff-mono); font-size: 14px; color: var(--text-muted); }
.coname {
  color: var(--text-dim);
  font-size: 12.5px;
  margin-top: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 360px;
}

/* signal mini-bars */
.signals { display: flex; gap: 14px; margin-top: 12px; flex-wrap: wrap; }
.sig { display: flex; flex-direction: column; gap: 5px; min-width: 78px; }
.sig__label {
  font-family: var(--ff-mono);
  font-size: 9.5px; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--text-dim);
}
.sig__val { font-family: var(--ff-mono); font-size: 12.5px; color: var(--text); }
.sig__bar { height: 3px; border-radius: 2px; background: var(--hairline-2); overflow: hidden; }
.sig__fill { height: 100%; border-radius: 2px; background: var(--accent); }

/* the thermal Heat Score — the signature element */
.heat { text-align: center; min-width: 92px; }
.heat__num {
  font-family: var(--ff-display);
  font-weight: 700;
  font-size: 40px;
  line-height: 1;
  letter-spacing: -0.02em;
}
.heat__label {
  font-family: var(--ff-mono);
  font-size: 9.5px; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--text-dim);
  margin-top: 6px;
}
.heat__scale {
  height: 4px; border-radius: 3px; margin-top: 8px;
  background: linear-gradient(90deg, var(--cool), var(--warm), var(--hot));
  position: relative;
}
.heat__tick {
  position: absolute; top: -2px; width: 2px; height: 8px;
  background: var(--text); border-radius: 2px;
  box-shadow: 0 0 6px rgba(255,255,255,0.5);
}

/* expandable AI note */
.note {
  grid-column: 1 / -1;
  border-top: 1px dashed var(--hairline-2);
  margin-top: 4px; padding-top: 14px;
  font-size: 13.5px; line-height: 1.65; color: var(--text-muted);
  display: none;
}
.card.open .note { display: block; }
.note__tag {
  font-family: var(--ff-mono); font-size: 10px; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--accent); display: block; margin-bottom: 6px;
}

/* states */
.state {
  text-align: center; padding: 60px 20px; color: var(--text-muted);
}
.state h3 { font-family: var(--ff-display); color: var(--text); margin: 0 0 8px; }
.state p { margin: 0 auto; max-width: 420px; line-height: 1.6; font-size: 14px; }

.spinner {
  width: 30px; height: 30px; margin: 0 auto 18px;
  border: 3px solid var(--hairline-2);
  border-top-color: var(--hot);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.hidden { display: none !important; }

/* ---------- responsive ---------- */
@media (max-width: 760px) {
  .controls { grid-template-columns: 1fr 1fr; }
  .card { grid-template-columns: 30px 1fr; }
  .heat { grid-column: 2; grid-row: 2; text-align: left; margin-top: 4px; }
  .heat__scale { max-width: 160px; }
  .coname { max-width: 220px; }
}
@media (max-width: 440px) {
  .controls { grid-template-columns: 1fr; }
  .wrap { padding: 28px 16px 60px; }
}

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

/* ---------- scan progress bar ---------- */
.progress {
  height: 5px; width: 100%; max-width: 360px;
  margin: 18px auto 0;
  background: var(--hairline-2);
  border-radius: 3px; overflow: hidden;
}
.progress__fill {
  display: block; height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--warm), var(--hot));
  border-radius: 3px;
  transition: width .4s ease;
}

/* ---------- password gate ---------- */
.gate {
  position: fixed; inset: 0; z-index: 10;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: rgba(8, 10, 13, 0.72);
  backdrop-filter: blur(6px);
}
.gate__card {
  width: 100%; max-width: 340px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px 24px;
  text-align: center;
}
.gate__mark {
  width: 40px; height: 40px; border-radius: 11px; margin: 0 auto 16px;
  background: linear-gradient(150deg, var(--cool), var(--warm) 55%, var(--hot));
  box-shadow: 0 0 22px -4px rgba(226,86,42,0.6);
}
.gate__card h3 { font-family: var(--ff-display); margin: 0 0 6px; font-size: 17px; }
.gate__card p { color: var(--text-muted); font-size: 13px; line-height: 1.55; margin: 0 0 16px; }
.gate__card input {
  width: 100%;
  background: var(--ink);
  border: 1px solid var(--hairline-2);
  border-radius: var(--radius-s);
  color: var(--text);
  font-family: var(--ff-mono); font-size: 14px;
  padding: 11px 12px; outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.gate__card input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(91,155,216,0.18);
}
.gate__card .run { margin-top: 14px; }
.gate__err { color: var(--neg); font-size: 12.5px; min-height: 16px; margin-top: 10px; }

/* keep the home-screen app clear of the iPhone notch / home indicator */
@supports (padding: max(0px)) {
  .wrap {
    padding-left: max(24px, env(safe-area-inset-left));
    padding-right: max(24px, env(safe-area-inset-right));
    padding-bottom: max(80px, env(safe-area-inset-bottom));
  }
}

/* ---------- shared-hosting build: 3-up controls + action row ---------- */
.controls--3 { grid-template-columns: repeat(3, 1fr); }

.actions { display: flex; gap: 12px; align-items: center; margin-top: 20px; flex-wrap: wrap; }
.actions .run { margin-top: 0; flex: 1 1 auto; }

.ghost {
  border: 1px solid var(--hairline-2);
  background: transparent;
  color: var(--text-muted);
  border-radius: var(--radius-s);
  padding: 14px 18px;
  font-family: var(--ff-body);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color .15s ease, color .15s ease;
}
.ghost:hover { border-color: var(--accent); color: var(--text); }
.ghost:disabled { opacity: .55; cursor: progress; }

@media (max-width: 760px) {
  .controls--3 { grid-template-columns: 1fr 1fr; }
  .actions { flex-direction: column; align-items: stretch; }
}
@media (max-width: 440px) {
  .controls--3 { grid-template-columns: 1fr; }
}

/* ---------- quiet footer disclaimer ---------- */
.footer {
  margin-top: 48px;
  padding-top: 18px;
  border-top: 1px solid var(--hairline);
  color: var(--text-dim);
  font-size: 11.5px;
  line-height: 1.6;
  text-align: center;
  max-width: 560px;
  margin-left: auto;
  margin-right: auto;
}

/* keep iOS from auto-inflating text so mobile matches desktop exactly */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

/* mobile-only: drop the results meta onto its own line under the heading */
@media (max-width: 760px) {
  .results-head { flex-direction: column; align-items: flex-start; gap: 4px; }
  .results-head .meta { text-align: left; }
}

/* belt-and-suspenders: never allow sideways scroll */
html, body { overflow-x: hidden; max-width: 100%; }

/* mobile: stop the tagline forcing overflow, and lay the masthead out cleanly */
@media (max-width: 760px) {
  .masthead { flex-direction: column; align-items: stretch; gap: 14px; }
  .tagline { max-width: 100%; }
  .status { text-align: left; }
}

/* ---------- collapsible Settings header ---------- */
.settings-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0;
  margin-bottom: 18px;
  font-family: var(--ff-display);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}
.settings-head:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(91,155,216,0.18);
  border-radius: 6px;
}
.chev {
  display: inline-block;            /* spans ignore width/height without this */
  width: 10px; height: 10px;
  border-right: 2px solid var(--text-muted);
  border-bottom: 2px solid var(--text-muted);
  transform: rotate(45deg);          /* points down when expanded */
  transition: transform .18s ease;
  margin-right: 4px;
  flex: none;
}
.settings-head:hover .chev { border-color: var(--text); }
.settings-head[aria-expanded="false"] .chev { transform: rotate(-45deg); } /* points right when collapsed */

#settingsBody {
  overflow: hidden;
  transition: max-height .25s ease, opacity .2s ease, margin .25s ease;
  max-height: 600px;
  opacity: 1;
}
#settingsBody.collapsed {
  max-height: 0;
  opacity: 0;
  margin: 0;
  pointer-events: none;
}
