/* value_investing research site — mobile-first static shell */

:root {
  --bg: #0f1216;
  --bg-card: #1a1f27;
  --bg-elevated: #242b36;
  --border: #2e3744;
  --text: #e8eaed;
  --muted: #9aa3b2;
  --accent: #7cb3d9;
  --accent-dim: #4a7a9b;
  --ok: #81c784;
  --warn: #ffb74d;
  --err: #e57373;
  --radius: 10px;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
  --max: 1100px;
  --tap: 44px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  color-scheme: dark;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  min-height: 100vh;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

.wrap {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 1rem 3rem;
}

/* —— site chrome —— */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(15, 18, 22, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.site-header .inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0.65rem 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
}
.site-brand {
  font-weight: 650;
  font-size: 1rem;
  color: var(--text);
  text-decoration: none;
}
.site-brand:hover {
  text-decoration: none;
  color: var(--accent);
}
.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.75rem;
  font-size: 0.9rem;
}
.site-nav a {
  color: var(--muted);
  padding: 0.35rem 0.25rem;
  min-height: var(--tap);
  display: inline-flex;
  align-items: center;
}
.site-nav a:hover,
.site-nav a[aria-current="page"] {
  color: var(--accent);
}

.site-footer {
  max-width: var(--max);
  margin: 2rem auto 0;
  padding: 1.25rem 1rem 2rem;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--muted);
}
.site-footer p {
  margin: 0.35rem 0;
}

/* —— gate (passphrase) —— */
#auth-gate {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(8, 10, 14, 0.94);
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}
#auth-gate.is-open {
  display: flex;
}
.gate-card {
  width: min(100%, 380px);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}
.gate-card h1 {
  margin: 0 0 0.35rem;
  font-size: 1.2rem;
}
.gate-card p {
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: 0.9rem;
}
.gate-card label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}
.gate-card input[type="password"] {
  width: 100%;
  padding: 0.75rem 0.85rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 1rem;
  margin-bottom: 0.75rem;
}
.gate-card button {
  width: 100%;
  min-height: var(--tap);
  border: none;
  border-radius: 8px;
  background: var(--accent-dim);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}
.gate-card button:hover {
  background: var(--accent);
}
.gate-error {
  color: var(--err);
  font-size: 0.85rem;
  min-height: 1.2em;
  margin: 0.5rem 0 0;
}
/* Hide main content only while the unlock gate is showing (not a blank page). */
body.auth-locked #auth-gate.is-open ~ .site-header,
body.auth-locked #auth-gate.is-open ~ .site-content,
body.auth-locked #auth-gate.is-open ~ .site-footer {
  visibility: hidden;
  pointer-events: none;
}

/* —— home —— */
.hero {
  padding: 1.5rem 0 0.5rem;
}
.hero h1 {
  margin: 0 0 0.35rem;
  font-size: 1.55rem;
  font-weight: 700;
}
.hero .lede {
  color: var(--muted);
  margin: 0 0 1rem;
  max-width: 40rem;
}
.meta-line {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0 0 1.25rem;
}

.ticker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
  gap: 1rem;
}

.ticker-card {
  display: block;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  color: inherit;
  text-decoration: none;
  box-shadow: var(--shadow);
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.ticker-card:hover {
  border-color: var(--accent-dim);
  text-decoration: none;
  transform: translateY(-1px);
}
.ticker-card .sym {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.ticker-card .name {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0.15rem 0 0.75rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stat-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  font-size: 0.82rem;
}
.stat-row span {
  color: var(--muted);
}
.stat-row strong {
  color: var(--text);
  font-weight: 600;
}
.ticker-card .when {
  margin-top: 0.75rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.empty-state {
  background: var(--bg-card);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  color: var(--muted);
}

/* —— refresh watchlist —— */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem 1rem;
  margin: 0 0 1.25rem;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 8px;
  background: var(--accent-dim);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}
.btn:hover {
  background: var(--accent);
}
.btn:disabled {
  opacity: 0.55;
  cursor: wait;
}
.btn-secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
}
.btn-secondary:hover {
  border-color: var(--accent-dim);
  color: var(--accent);
  background: transparent;
}
.refresh-status {
  flex: 1 1 12rem;
  font-size: 0.85rem;
  color: var(--muted);
  min-height: 1.2em;
}
.refresh-status.is-ok {
  color: var(--ok);
}
.refresh-status.is-pending {
  color: var(--warn);
}
.refresh-status.is-err,
.refresh-status.is-warn {
  color: var(--warn);
}
.refresh-status.is-err {
  color: var(--err);
}

/* —— analyze form —— */
.analyze-form {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.15rem;
  margin: 1rem 0 1.5rem;
  max-width: 28rem;
  box-shadow: var(--shadow);
}
.analyze-form label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}
.analyze-form input[type="text"] {
  width: 100%;
  padding: 0.75rem 0.85rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 0.85rem;
}
.analyze-form .check-row {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 1rem;
  cursor: pointer;
}
.analyze-form .check-row input {
  margin-top: 0.2rem;
  flex-shrink: 0;
}
.analyze-form .btn {
  width: 100%;
}
.analyze-status {
  margin-top: 0.85rem;
  flex: none;
}
.analyze-status .pack-link,
.refresh-status .pack-link {
  display: inline-block;
  margin-left: 0.35rem;
  font-weight: 600;
}
.cached-tickers {
  margin: 0.75rem 0 1.5rem;
}
.ticker-card-compact {
  padding: 0.85rem 1rem;
}
.ticker-card-compact .sym {
  font-size: 1.1rem;
}

/* —— pages —— */
.page h1 {
  font-size: 1.4rem;
  margin: 1.25rem 0 0.5rem;
}
.page h2 {
  font-size: 1.1rem;
  margin: 1.5rem 0 0.5rem;
}
.page ol,
.page ul {
  padding-left: 1.25rem;
  color: var(--muted);
}
.page li {
  margin: 0.35rem 0;
}
.page code {
  background: var(--bg-elevated);
  padding: 0.1em 0.35em;
  border-radius: 4px;
  font-size: 0.9em;
}
.callout {
  background: var(--bg-card);
  border-left: 3px solid var(--accent-dim);
  padding: 0.85rem 1rem;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin: 1rem 0;
  color: var(--muted);
  font-size: 0.9rem;
}

/* —— ticker gallery —— */
.ticker-hero h1 {
  margin: 1.1rem 0 0.2rem;
  font-size: 1.35rem;
}
.ticker-hero .company {
  color: var(--muted);
  margin: 0 0 0.75rem;
}
.summary-strip {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(7.5rem, 1fr));
  gap: 0.5rem;
  margin: 0 0 1.25rem;
}
.summary-strip .cell {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.55rem 0.65rem;
}
.summary-strip .lbl {
  display: block;
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.summary-strip .val {
  font-size: 0.95rem;
  font-weight: 650;
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
  gap: 1rem;
}
.chart-grid .card-lead {
  grid-column: 1 / -1;
}
.chart-card {
  margin: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.65rem;
}
.chart-card.card-lead {
  border-color: var(--accent-dim);
}
.chart-card figcaption {
  font-size: 0.85rem;
  margin-bottom: 0.45rem;
  color: var(--muted);
}
.chart-card figcaption strong {
  color: var(--text);
  font-weight: 600;
}
.chart-card img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 4px;
  background: #fff;
}

.notes-block {
  margin-top: 1.5rem;
}
.notes-block ul {
  font-size: 0.85rem;
  color: var(--muted);
}
.notes-block .err {
  color: var(--err);
}

.back-link {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  font-size: 0.9rem;
}
