/* ============================================================
   Daily Signals — Terminal Design System (redesign v2)
   Matches the /ai-analysis and /ai-tools redesigns: flat elevated
   surfaces, hairline borders, restrained accents, tabular numerals.
   Consumes global tokens from styles.css (--color-*, --radius-*).

   CONTRACT: every selector used by the template and
   static/js/daily-signals.js is preserved (IDs untouched;
   .faq-item.open, toggle input:checked mechanics, ticker keyframes,
   .ds-alert.success/.error/.info all kept).
   ============================================================ */

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --ds-line:        rgba(148, 163, 200, 0.14);
  --ds-line-strong: rgba(148, 163, 200, 0.24);
  --ds-faint:       #7d8db0;
  --ds-mono:        'JetBrains Mono', ui-monospace, Menlo, Consolas, monospace;
  --ds-display:     'Sora', -apple-system, BlinkMacSystemFont, sans-serif;
  --ds-bull:        #10b981;
  --ds-bear:        #ef4444;
  --ds-focus:       0 0 0 2px var(--color-bg), 0 0 0 4px var(--color-accent);
}

body {
  background: var(--color-bg);
  color: var(--color-text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Sora', sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Live ticker ────────────────────────────────────────────── */
.ticker-wrap {
  overflow: hidden;
  border-bottom: 1px solid var(--ds-line);
  background: var(--color-bg-secondary);
  padding: 8px 0;
}
.ticker-track {
  display: flex;
  gap: 2.4rem;
  width: max-content;
  animation: ticker 42s linear infinite;
}
.ticker-wrap:hover .ticker-track { animation-play-state: paused; }
@keyframes ticker {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}
.ticker-item {
  font-family: var(--ds-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.72rem;
  letter-spacing: 0.03em;
  white-space: nowrap;
  color: var(--ds-bear);
}
.t-bull { color: var(--ds-bull); }

/* ── Hero ───────────────────────────────────────────────────── */
.ds-hero {
  position: relative;
  overflow: hidden;
  padding: 4rem 1.5rem 3rem;
  text-align: center;
  background: linear-gradient(180deg, var(--color-bg-tertiary), var(--color-bg));
  border-bottom: 1px solid var(--ds-line);
}
.ds-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(var(--ds-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--ds-line) 1px, transparent 1px);
  background-size: 44px 44px;
  opacity: 0.3;
  mask-image: linear-gradient(180deg, #000, transparent 80%);
  -webkit-mask-image: linear-gradient(180deg, #000, transparent 80%);
  pointer-events: none;
}
.ds-tag {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 1.4rem;
  padding: 5px 16px;
  border: 1px solid var(--ds-line-strong);
  border-radius: 999px;
  color: var(--color-accent);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ds-bull);
  animation: pulse 1.4s infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }
.ds-hero h1 {
  position: relative;
  margin-bottom: 0.9rem;
  font-family: var(--ds-display);
  font-size: clamp(1.8rem, 4.5vw, 2.8rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: var(--color-text);
}
.grad { color: var(--color-accent); }
.ds-hero p {
  position: relative;
  max-width: 540px;
  margin: 0 auto 2rem;
  font-size: 1rem;
  line-height: 1.7;
  color: var(--color-text-muted);
}
.stat-row {
  position: relative;
  display: flex;
  gap: 2rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 2.5rem;
}
.stat-item { text-align: center; }
.stat-num {
  font-family: var(--ds-mono);
  font-variant-numeric: tabular-nums;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--color-text);
}
.stat-lbl {
  margin-top: 2px;
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ds-faint);
}

/* ── Subscribe card ─────────────────────────────────────────── */
.sub-card {
  position: relative;
  max-width: 480px;
  margin: 0 auto;
  padding: 1.6rem;
  background: var(--color-card);
  border: 1px solid var(--ds-line-strong);
  border-radius: var(--radius-lg);
  text-align: left;
}
.sub-card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--ds-display);
  font-size: 1.02rem;
  font-weight: 700;
  color: var(--color-text);
}
.sub-card-title svg { width: 17px; height: 17px; color: var(--color-accent); flex-shrink: 0; }
.sub-card-sub {
  margin: 0.3rem 0 1rem;
  font-size: 0.82rem;
  line-height: 1.6;
  color: var(--color-text-muted);
}
.input-group { display: flex; gap: 0.6rem; }
@media (max-width: 500px) { .input-group { flex-direction: column; } }
.ds-input {
  flex: 1;
  min-height: 46px;
  padding: 0 0.95rem;
  background: var(--color-bg-secondary);
  border: 1px solid var(--ds-line-strong);
  border-radius: var(--radius-md);
  color: var(--color-text);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 150ms ease-out, box-shadow 150ms ease-out;
}
.ds-input:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.18);
}
.ds-input::placeholder { color: var(--ds-faint); }
.sub-btn {
  min-height: 46px;
  padding: 0 1.4rem;
  background: var(--color-accent);
  border: none;
  border-radius: var(--radius-md);
  color: #04222a;
  font-size: 0.88rem;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  transition: filter 150ms ease-out;
}
.sub-btn:hover { filter: brightness(1.12); }
.sub-btn:focus-visible { outline: none; box-shadow: var(--ds-focus); }
.sub-btn:disabled { opacity: 0.55; cursor: not-allowed; }
.sub-trust {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 0.9rem;
  font-size: 0.72rem;
  color: var(--ds-faint);
}
.sub-trust svg { width: 12px; height: 12px; vertical-align: -2px; margin-right: 3px; }

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 480px;
  margin: 1.4rem auto;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ds-faint);
}
.auth-divider::before,
.auth-divider::after { content: ''; flex: 1; height: 1px; background: var(--ds-line); }
.auth-btns {
  position: relative;
  display: flex;
  gap: 0.8rem;
  justify-content: center;
  flex-wrap: wrap;
}
.auth-btns a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 1.4rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  transition: filter 150ms ease-out, border-color 150ms ease-out, color 150ms ease-out;
}
.btn-signin {
  border: 1px solid var(--ds-line-strong);
  color: var(--color-text-muted);
}
.btn-signup { background: var(--color-primary); color: #fff; }
.btn-signin:hover { border-color: var(--color-accent); color: var(--color-text); }
.btn-signup:hover { filter: brightness(1.12); }

/* ── Sections ───────────────────────────────────────────────── */
.section { max-width: 1080px; margin: 0 auto; padding: 3.4rem 1.5rem 0; }
.section-h {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--ds-display);
  font-size: clamp(1.3rem, 2.6vw, 1.7rem);
  font-weight: 700;
  letter-spacing: -0.01em;
  text-align: center;
  color: var(--color-text);
}
.section-h svg { width: 20px; height: 20px; color: var(--color-accent); }
.section-sub {
  margin: 0.5rem auto 1.8rem;
  max-width: 56ch;
  font-size: 0.9rem;
  line-height: 1.65;
  text-align: center;
  color: var(--color-text-muted);
}

/* ── Email preview frame ────────────────────────────────────── */
.preview-wrap {
  max-width: 660px;
  margin: 0 auto;
  border: 1px solid var(--ds-line-strong);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--color-card);
}
.preview-topbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  background: var(--color-bg-tertiary);
  border-bottom: 1px solid var(--ds-line);
}
.mac-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ds-line-strong); }
.preview-label {
  margin-left: 8px;
  font-family: var(--ds-mono);
  font-size: 0.7rem;
  color: var(--ds-faint);
}
.preview-inner { padding: 1.2rem; }

/* Email mockup body — deliberately email-like, kept light-touch */
.eml { border: 1px solid var(--ds-line); border-radius: var(--radius-md); overflow: hidden; }
.eml-head {
  padding: 1.2rem 1.3rem 1rem;
  background: var(--color-bg-tertiary);
  border-bottom: 1px solid var(--ds-line);
}
.eml-brand {
  font-family: var(--ds-display);
  font-weight: 800;
  font-size: 1.02rem;
  color: var(--color-text);
}
.eml-brand-tag { font-size: 0.68rem; color: var(--ds-faint); letter-spacing: 0.08em; text-transform: uppercase; }
.eml-title { margin-top: 0.7rem; font-size: 1.05rem; font-weight: 700; color: var(--color-text); }
.eml-meta { margin-top: 2px; font-size: 0.72rem; color: var(--ds-faint); }
.eml-idx {
  display: flex;
  border-bottom: 1px solid var(--ds-line);
  background: var(--color-bg-secondary);
}
.eml-idx-cell {
  flex: 1;
  padding: 0.7rem 1.3rem;
  border-right: 1px solid var(--ds-line);
}
.eml-idx-cell:last-child { border-right: none; }
.eml-idx-label {
  font-size: 0.64rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ds-faint);
}
.eml-idx-val {
  font-family: var(--ds-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--color-text);
}
.eml-count { padding: 0.9rem 1.3rem 0; }
.eml-count-badge {
  display: inline-block;
  padding: 4px 12px;
  border: 1px solid var(--ds-line-strong);
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--color-accent);
}
.eml-table { width: 100%; border-collapse: collapse; }
.eml-table thead th {
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--ds-line-strong);
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  text-align: left;
  color: var(--ds-faint);
}
.eml-table thead th:nth-child(3),
.eml-table thead th:nth-child(4),
.eml-table thead th:nth-child(5) { text-align: right; }
.eml-table tbody td {
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--ds-line);
  font-size: 0.8rem;
  vertical-align: top;
}
.eml-sym { font-weight: 700; color: var(--color-text); }
.eml-exch {
  font-family: var(--ds-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.68rem;
  color: var(--ds-faint);
}
.eml-pat { font-size: 0.78rem; color: var(--color-text-muted); }
.bull-badge, .bear-badge {
  display: inline-block;
  margin-top: 2px;
  padding: 1px 7px;
  border-radius: 4px;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}
.bull-badge { background: rgba(16, 185, 129, 0.12); color: var(--ds-bull); }
.bear-badge { background: rgba(239, 68, 68, 0.12); color: var(--ds-bear); }
.eml-prob, .eml-move {
  font-family: var(--ds-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  text-align: right;
  color: var(--color-text);
}
.eml-action { text-align: right; }
.eml-action a { color: var(--color-accent); font-size: 0.74rem; text-decoration: none; }
.eml-cta { display: flex; gap: 0.7rem; justify-content: center; padding: 1.1rem; flex-wrap: wrap; }
.eml-cta-btn {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 1.2rem;
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  font-weight: 700;
  text-decoration: none;
}
.eml-cta-primary { background: var(--color-primary); color: #fff; }
.eml-cta-sec { border: 1px solid var(--ds-line-strong); color: var(--color-text-muted); }
.eml-auth {
  margin: 0 1.1rem 1.1rem;
  padding: 1rem;
  background: var(--color-bg-secondary);
  border: 1px dashed var(--ds-line-strong);
  border-radius: var(--radius-md);
  text-align: center;
}
.eml-auth-title { font-size: 0.85rem; font-weight: 700; color: var(--color-text); }
.eml-auth-sub { margin: 0.3rem 0 0.7rem; font-size: 0.75rem; color: var(--color-text-muted); }
.eml-auth-btns { display: flex; gap: 0.6rem; justify-content: center; flex-wrap: wrap; }
.eml-auth-btns a {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--ds-line-strong);
  color: var(--color-text-muted);
  font-size: 0.74rem;
  font-weight: 600;
  text-decoration: none;
}
.eml-footer {
  padding: 0.9rem 1.3rem;
  border-top: 1px solid var(--ds-line);
  font-size: 0.66rem;
  line-height: 1.6;
  color: var(--ds-faint);
}

/* ── How it works ───────────────────────────────────────────── */
.hiw-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}
.hiw-card {
  padding: 1.3rem;
  background: var(--color-card);
  border: 1px solid var(--ds-line);
  border-radius: var(--radius-md);
  transition: border-color 150ms ease-out;
}
.hiw-card:hover { border-color: var(--ds-line-strong); }
.hiw-num {
  font-family: var(--ds-mono);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--color-accent);
}
.hiw-card h3 {
  margin: 0.5rem 0 0.4rem;
  font-family: var(--ds-display);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--color-text);
}
.hiw-card p { font-size: 0.82rem; line-height: 1.65; color: var(--color-text-muted); }

/* ── FAQ ────────────────────────────────────────────────────── */
.faq-item {
  border: 1px solid var(--ds-line);
  border-radius: var(--radius-md);
  margin-bottom: 0.7rem;
  background: var(--color-card);
  overflow: hidden;
}
.faq-q {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 52px;
  padding: 0.9rem 1.1rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-text);
  cursor: pointer;
  transition: color 150ms ease-out;
}
.faq-q:hover { color: var(--color-accent); }
.faq-a {
  display: none;
  padding: 0 1.1rem 1rem;
  font-size: 0.85rem;
  line-height: 1.7;
  color: var(--color-text-muted);
}
.faq-item.open .faq-a { display: block; }
.faq-arrow {
  flex-shrink: 0;
  font-size: 0.7rem;
  color: var(--ds-faint);
  transition: transform 200ms ease-out;
}
.faq-item.open .faq-arrow { transform: rotate(180deg); }

/* ── Alerts ─────────────────────────────────────────────────── */
.ds-alert {
  display: none;
  margin-bottom: 0.9rem;
  padding: 0.7rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  line-height: 1.5;
}
.ds-alert.success {
  display: block;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.35);
  color: #6ee7b7;
}
.ds-alert.error {
  display: block;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #fca5a5;
}
.ds-alert.info {
  display: block;
  background: rgba(6, 182, 212, 0.1);
  border: 1px solid rgba(6, 182, 212, 0.35);
  color: #67e8f9;
}

/* ── Preferences panel ──────────────────────────────────────── */
.manage-panel {
  max-width: 560px;
  margin: 0 auto;
  padding: 1.4rem;
  background: var(--color-card);
  border: 1px solid var(--ds-line);
  border-radius: var(--radius-lg);
}
.manage-panel h3 {
  font-family: var(--ds-display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-text);
}
.pref-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 0;
  border-bottom: 1px solid var(--ds-line);
}
.pref-row:last-child { border-bottom: none; }
.pref-label { font-size: 0.88rem; font-weight: 600; color: var(--color-text); }
.pref-sublabel { margin-top: 2px; font-size: 0.74rem; color: var(--ds-faint); }

/* Toggle — input + track + thumb sibling structure preserved */
.toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
  cursor: pointer;
}
.toggle input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  margin: 0;
  cursor: pointer;
  z-index: 2;
}
.toggle-track {
  position: absolute;
  inset: 0;
  background: var(--color-bg-secondary);
  border: 1px solid var(--ds-line-strong);
  border-radius: 999px;
  transition: background 150ms ease-out, border-color 150ms ease-out;
}
.toggle input:checked + .toggle-track {
  background: rgba(6, 182, 212, 0.25);
  border-color: var(--color-accent);
}
.toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--ds-faint);
  transition: transform 150ms ease-out, background 150ms ease-out;
  pointer-events: none;
}
.toggle input:checked ~ .toggle-thumb {
  transform: translateX(20px);
  background: var(--color-accent);
}
.toggle input:focus-visible + .toggle-track { box-shadow: var(--ds-focus); }

/* ── Motion preferences ─────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .ticker-track { animation: none; flex-wrap: wrap; }
  .live-dot { animation: none; }
  .faq-arrow { transition: none; }
  .toggle-track, .toggle-thumb { transition: none; }
}
