/* ─── Design Tokens ──────────────────────────────────────────────────────── */
:root {
  --bg:           #0d0f12;
  --surface:      #111418;
  --surface-2:    #181c24;
  --border:       #1e2430;
  --border-2:     #252c3a;

  --text-1: #d5d8db;
  --text-2: #a4a7b1;
  --text-3: #a4a7b1;

  --amber:    #d4a017;
  --amber-hi: #f0b429;
  --amber-lo: #7a5c0a;

  --green:        #2ea043;
  --green-bg:     #0d2018;
  --green-border: #1a4029;

  --red:        #f85149;
  --red-bg:     #200d0c;
  --red-border: #451a18;

  --yellow:        #e3b341;
  --yellow-bg:     #1e180a;
  --yellow-border: #4a3a10;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  --font-mono: "SF Mono", "Fira Code", "Cascadia Code", Consolas,
               "Liberation Mono", monospace;

  --radius: 3px;
  --tr: 150ms ease;
}

/* ─── Reset ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 17px; }

body {
  background: var(--bg);
  color: var(--text-1);
  font-family: var(--font-sans);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--amber); text-decoration: none; }
a:hover { color: var(--amber-hi); }

/* ─── Header ─────────────────────────────────────────────────────────────── */
.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.site-header__inner {
  max-width: 920px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.site-header__logo {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: var(--text-1);
}
.logo-mark { color: var(--amber); }
.site-header__date {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-3);
  letter-spacing: 0.06em;
}

/* ─── Main layout ────────────────────────────────────────────────────────── */
.main {
  flex: 1;
  max-width: 920px;
  width: 100%;
  margin: 0 auto;
  padding: 56px 24px 72px;
}

/* ─── Panel visibility — driven by body[data-state] ─────────────────────── */
.panel { display: none; }
body[data-state="idle"]       .panel--input    { display: block; }
body[data-state="submitting"] .panel--input    { display: block; }
body[data-state="running"]    .panel--progress { display: block; }
body[data-state="done"]       .panel--result   { display: block; }
body[data-state="error"]      .panel--error    { display: block; }

/* ─── Input panel ────────────────────────────────────────────────────────── */
.input-tagline {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 24px;
}

.input-row {
  display: flex;
  max-width: 560px;
}

.ticker-input {
  flex: 1;
  min-width: 0;
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--amber-hi);
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-right: none;
  border-radius: var(--radius) 0 0 var(--radius);
  padding: 14px 20px;
  outline: none;
  caret-color: var(--amber);
  transition: border-color var(--tr), box-shadow var(--tr);
}
.ticker-input::placeholder { color: var(--text-3); font-weight: 400; }
.ticker-input:focus {
  border-color: var(--amber);
  box-shadow: inset 0 0 0 1px var(--amber-lo);
}

/* Buttons */
.btn {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 0 24px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background var(--tr), border-color var(--tr), color var(--tr);
  white-space: nowrap;
}
.btn--primary {
  background: var(--amber);
  color: #000;
  border-color: var(--amber);
  border-radius: 0 var(--radius) var(--radius) 0;
  min-width: 110px;
  justify-content: center;
}
.btn--primary:hover:not(:disabled) { background: var(--amber-hi); border-color: var(--amber-hi); }
.btn--primary:disabled { opacity: 0.45; cursor: not-allowed; }

.btn--ghost {
  background: transparent;
  color: var(--text-2);
  border-color: var(--border-2);
  padding: 10px 22px;
}
.btn--ghost:hover { border-color: var(--amber); color: var(--amber); }

.btn--download {
  background: transparent;
  color: var(--amber);
  border: 1px solid var(--amber-lo);
  padding: 8px 18px;
  font-size: 13px;
  border-radius: var(--radius);
}
.btn--download:hover { background: rgba(212, 160, 23, 0.08); border-color: var(--amber); }

/* Spinner (shown in submitting state) */
.btn__spinner { display: none; }
body[data-state="submitting"] .btn__spinner {
  display: inline-block;
  width: 11px; height: 11px;
  border: 2px solid rgba(0, 0, 0, 0.25);
  border-top-color: #000;
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
}
body[data-state="submitting"] .btn__label { display: none; }

@keyframes spin { to { transform: rotate(360deg); } }

.input-error {
  margin-top: 10px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--red);
  min-height: 18px;
}
.input-hint {
  margin-top: 12px;
  font-size: 13px;
  color: var(--text-3);
}

.input-row.shake { animation: shake 0.35s ease; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-5px); }
  40%       { transform: translateX(5px); }
  60%       { transform: translateX(-3px); }
  80%       { transform: translateX(3px); }
}

/* ─── Progress panel ─────────────────────────────────────────────────────── */
.progress-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 36px;
}
.progress-ticker {
  font-family: var(--font-mono);
  font-size: 38px;
  font-weight: 700;
  color: var(--amber-hi);
  letter-spacing: 0.06em;
}
.progress-elapsed {
  font-family: var(--font-mono);
  font-size: 16px;
  color: var(--text-3);
  letter-spacing: 0.06em;
}

.stages { list-style: none; }
.stage-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 0;
  border-bottom: 1px solid var(--border);
  font-size: 17px;
}
.stage-item:last-child { border-bottom: none; }

.stage-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--text-3);
  transition: background var(--tr);
}
.stage-item--active .stage-dot {
  background: var(--amber);
  box-shadow: 0 0 0 3px var(--amber-lo);
  animation: pulse-dot 1.5s ease-in-out infinite;
}
.stage-item--done .stage-dot { background: var(--green); box-shadow: none; }

@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 0 3px var(--amber-lo); }
  50%       { box-shadow: 0 0 0 6px transparent; }
}

.stage-label {
  flex: 1;
  color: var(--text-3);
  transition: color var(--tr);
}
.stage-item--active .stage-label { color: var(--text-1); }
.stage-item--done   .stage-label { color: var(--text-2); }

.stage-check {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--green);
  opacity: 0;
  transition: opacity var(--tr);
  width: 12px;
}
.stage-item--done .stage-check { opacity: 1; }

.stage-elapsed {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-3);
  min-width: 36px;
  text-align: right;
}

/* ─── Result panel ───────────────────────────────────────────────────────── */
.result-header {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}
.result-ticker {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 700;
  color: var(--amber-hi);
  letter-spacing: 0.06em;
}
.result-sep  { color: var(--text-3); font-size: 15px; }
.result-name { font-size: 16px; font-weight: 500; }
.result-meta {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-2);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* Rating row */
.rating-row {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 32px;
}
.rating-badge {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 2px;
  border: 1px solid currentColor;
  white-space: nowrap;
}
.rating--strong_buy  { color: #4ade80; background: var(--green-bg);   border-color: var(--green-border); }
.rating--buy         { color: #86efac; background: #0a1a10;            border-color: #1a3320; }
.rating--hold        { color: var(--yellow); background: var(--yellow-bg); border-color: var(--yellow-border); }
.rating--sell        { color: #fca5a5; background: #1f0a0a;            border-color: #3a1515; }
.rating--strong_sell { color: var(--red); background: var(--red-bg);   border-color: var(--red-border); }

.confidence-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 160px;
}
.confidence-bar {
  flex: 1;
  height: 4px;
  background: var(--border-2);
  border-radius: 2px;
  overflow: hidden;
}
.confidence-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--amber-lo), var(--amber));
  border-radius: 2px;
  transition: width 0.6s ease;
}
.confidence-pct {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-2);
  white-space: nowrap;
}
.horizon-pill {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 3px 8px;
  border: 1px solid var(--border-2);
  border-radius: 2px;
  color: var(--text-2);
}

/* Sections */
.section { margin-bottom: 32px; }
.section-header {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-3);
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
  margin-bottom: 16px;
}

.summary-text {
  font-size: 15px;
  line-height: 1.8;
  color: var(--text-1);
}

/* Bullet lists */
.bullet-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.bullet-list li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 15px;
  color: var(--text-1);
}
.bullet-list li::before { content: "—"; color: var(--text-3); flex-shrink: 0; margin-top: 1px; }

.risk-item { display: flex; align-items: flex-start; gap: 10px; }
.risk-text  { flex: 1; font-size: 15px; color: var(--text-1); }
.risk-severity {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 2px;
  flex-shrink: 0;
  margin-top: 3px;
}
.risk-severity--high   { color: var(--red);    background: var(--red-bg);    border: 1px solid var(--red-border); }
.risk-severity--medium { color: var(--yellow); background: var(--yellow-bg); border: 1px solid var(--yellow-border); }
.risk-severity--low    { color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border-2); }

/* Metrics grid */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.metric-cell {
  background: var(--surface);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: background var(--tr);
}
.metric-cell:hover { background: var(--surface-2); }
.metric-label {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-3);
}
.metric-value {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 600;
  color: var(--text-1);
  letter-spacing: 0.02em;
}
.metric-value--pos { color: var(--green); }
.metric-value--neg { color: var(--red); }

/* Rationale */
.rationale-text {
  font-size: 17px;
  line-height: 1.75;
  color: var(--text-2);
  font-style: italic;
  padding: 14px 16px;
  background: var(--surface);
  border-left: 2px solid var(--border-2);
  border-radius: 0 var(--radius) var(--radius) 0;
}

/* Sentiment bars */
.sentiment-bars { display: flex; flex-direction: column; gap: 14px; }
.sentiment-row  { display: flex; align-items: center; gap: 12px; }
.sentiment-label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-3);
  width: 64px;
  flex-shrink: 0;
}
.sentiment-bar-wrap {
  flex: 1;
  height: 6px;
  background: var(--border-2);
  border-radius: 3px;
  position: relative;
}
.sentiment-bar-fill {
  position: absolute;
  top: 0; bottom: 0;
  border-radius: 3px;
  transition: width 0.7s ease, left 0.7s ease;
}
.sentiment-score {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-2);
  width: 46px;
  text-align: right;
  flex-shrink: 0;
}
.sentiment-caption {
  margin-top: 14px;
  font-size: 15px;
  line-height: 1.65;
  color: var(--text-2);
}

/* Downloads + reset */
.download-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 20px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}
.reset-link { font-size: 13px; color: var(--text-3); }
.reset-link:hover { color: var(--amber); }

.disclaimer-text {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-3);
  letter-spacing: 0.04em;
  line-height: 1.6;
}

/* ─── Error panel ────────────────────────────────────────────────────────── */
.panel--error { text-align: center; padding: 72px 0; }
.error-icon   { font-size: 28px; margin-bottom: 14px; color: var(--red); }
.error-message {
  font-size: 15px;
  color: var(--text-2);
  margin-bottom: 24px;
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
}

/* ─── Footer ─────────────────────────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 14px 24px;
  text-align: center;
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-3);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* ─── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .main { padding: 36px 16px 56px; }
  .ticker-input { font-size: 22px; padding: 12px 16px; }
  .progress-ticker { font-size: 30px; }
  .metrics-grid { grid-template-columns: repeat(2, 1fr); }
  .result-header { gap: 6px; }
  .rating-row { gap: 12px; }
  .btn--primary { min-width: 90px; }
}

/* ─── Password Gate ───────────────────────────────────────────────────────── */
.gate {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 24px;
}

/* When authenticated, hide the gate and reveal the rest of the page. */
body[data-auth="ok"] .gate  { display: none; }
body:not([data-auth="ok"]) .site-header,
body:not([data-auth="ok"]) .main,
body:not([data-auth="ok"]) .site-footer { display: none; }

.gate__box {
  width: 100%;
  max-width: 360px;
  padding: 40px 32px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.gate__logo {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--amber);
  text-align: center;
}

.gate__hint {
  font-size: 0.82rem;
  color: var(--text-2);
  text-align: center;
}

.gate__row {
  display: flex;
  gap: 8px;
}

.gate__input {
  flex: 1;
  min-width: 0;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  color: var(--text-1);
  font-family: var(--font-mono);
  font-size: 0.95rem;
  padding: 10px 14px;
  outline: none;
  transition: border-color var(--tr);
}

.gate__input:focus { border-color: var(--amber); }

/* Override btn--primary defaults that are tailored to the ticker row */
.gate__row .btn--primary {
  border-radius: var(--radius);
  min-width: auto;
  padding: 0 20px;
  flex-shrink: 0;
  height: 42px;
}

.gate__error {
  font-size: 0.78rem;
  color: var(--red);
  text-align: center;
  min-height: 1em;
}

.gate__row.shake {
  animation: shake 0.35s ease;
}
