/* ==========================================================================
   Live Market Wise Guide - "Market Ledger" design system
   Aesthetic: modern financial broadsheet / almanac.
   Paper neutrals + single emerald accent + ruled hairlines + mono data type.
   Plain CSS (Tailwind Play CDN handles utilities; tokens live in tailwind.config).
   ========================================================================== */

:root {
  --paper:      #f3f2ed;
  --sand:       #e9e6dc;
  --surface:    #ffffff;
  --ink:        #16181d;
  --ink-soft:   #4c545f;
  --line:       #d8d3c6;
  --line-soft:  #e4e0d6;
  --pine:       #0e5c43;
  --pine-deep:  #0a3f2e;
  --pine-soft:  #e4efe9;
  --signal:     #c2410c; /* rare warning tone, used only for risk/loss context */
}

html { scroll-behavior: smooth; }

body {
  background-color: var(--paper);
  color: var(--ink);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--pine); color: #fff; }

/* --- Graph-paper ledger texture (the recognizable signature) ----------- */
.grid-paper {
  background-image:
    linear-gradient(to right, rgba(22,24,29,0.045) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(22,24,29,0.045) 1px, transparent 1px);
  background-size: 28px 28px;
}
.grid-paper--dark {
  background-image:
    linear-gradient(to right, rgba(255,255,255,0.05) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255,255,255,0.05) 1px, transparent 1px);
  background-size: 28px 28px;
}

/* --- Eyebrow / mono data label ---------------------------------------- */
.eyebrow {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--pine);
}
.eyebrow--muted { color: var(--ink-soft); }
.eyebrow--light { color: rgba(255,255,255,0.55); }

/* --- Cards / surfaces -------------------------------------------------- */
.ledger-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  transition: border-color .25s ease, transform .25s ease, box-shadow .25s ease;
}
.ledger-card:hover {
  border-color: rgba(14,92,67,0.5);
  box-shadow: 0 18px 40px -28px rgba(22,24,29,0.45);
}

/* --- Buttons ---------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: .5rem;
  font-family: "Hanken Grotesk", sans-serif;
  font-weight: 700;
  border-radius: 11px;
  padding: .85rem 1.5rem;
  line-height: 1;
  transition: transform .15s ease, background-color .2s ease, color .2s ease, border-color .2s ease;
  cursor: pointer;
  text-align: center;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn-primary { background: var(--pine); color: #fff; }
.btn-primary:hover { background: var(--pine-deep); }
.btn-dark { background: var(--ink); color: var(--paper); }
.btn-dark:hover { background: #000; }
.btn-ghost { background: transparent; color: var(--ink); border: 1px solid var(--ink); }
.btn-ghost:hover { background: var(--ink); color: var(--paper); }
.btn-on-dark { background: var(--paper); color: var(--ink); }
.btn-on-dark:hover { background: var(--pine); color: #fff; }

/* --- Links ------------------------------------------------------------ */
.link-pine {
  color: var(--pine); font-weight: 700;
  text-decoration: underline; text-decoration-color: rgba(14,92,67,0.35);
  text-underline-offset: 4px;
}
.link-pine:hover { text-decoration-color: var(--pine); }

/* --- Accessible focus (keyboard) -------------------------------------- */
a:focus-visible, button:focus-visible, input:focus-visible,
textarea:focus-visible, select:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--pine);
  outline-offset: 2px;
  border-radius: 4px;
}
.on-dark a:focus-visible, .on-dark button:focus-visible, .on-dark input:focus-visible {
  outline-color: #7fd6b4;
}

/* --- Ticker tape (header signature) ----------------------------------- */
.ticker { overflow: hidden; white-space: nowrap; }
.ticker__track {
  display: inline-block;
  padding-left: 100%;
  animation: ticker-scroll 38s linear infinite;
}
.ticker:hover .ticker__track { animation-play-state: paused; }
@keyframes ticker-scroll {
  from { transform: translateX(0); }
  to   { transform: translateX(-100%); }
}
.ticker__item { display: inline-flex; align-items: center; gap: .5rem; margin: 0 1.4rem; }
.ticker__up   { color: #4ade80; }
.ticker__down { color: #fb7185; }

/* --- Reveal on load --------------------------------------------------- */
.reveal { opacity: 0; transform: translateY(14px); animation: reveal-in .8s cubic-bezier(.16,1,.3,1) forwards; }
.reveal.d1 { animation-delay: .12s; }
.reveal.d2 { animation-delay: .24s; }
.reveal.d3 { animation-delay: .36s; }
@keyframes reveal-in { to { opacity: 1; transform: translateY(0); } }

/* --- Article / long-form prose ---------------------------------------- */
.prose-ledger { color: var(--ink-soft); line-height: 1.75; font-size: 1.05rem; }
.prose-ledger p { margin-bottom: 1.5rem; }
.prose-ledger h2, .prose-ledger h3 {
  font-family: "Bricolage Grotesque", sans-serif;
  color: var(--ink);
  font-weight: 700;
  line-height: 1.15;
  margin: 2.5rem 0 1rem;
}
.prose-ledger h2 { font-size: 1.7rem; }
.prose-ledger h3 { font-size: 1.35rem; }
.prose-ledger h3::before {
  content: ""; display: inline-block; width: 22px; height: 2px;
  background: var(--pine); vertical-align: middle; margin-right: .65rem;
}
.prose-ledger strong { color: var(--ink); font-weight: 700; }
.prose-ledger ul { margin: 0 0 1.5rem; padding-left: 0; list-style: none; }
.prose-ledger ul li { position: relative; padding-left: 1.4rem; margin-bottom: .6rem; }
.prose-ledger ul li::before {
  content: ""; position: absolute; left: 0; top: .62em;
  width: 6px; height: 6px; background: var(--pine); border-radius: 1px;
}

/* --- Ruled comparison table ------------------------------------------- */
.ledger-table { width: 100%; border-collapse: collapse; }
.ledger-table th, .ledger-table td { text-align: left; padding: 1rem 1.1rem; border-bottom: 1px solid var(--line); }
.ledger-table thead th {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--ink-soft); font-weight: 600;
  border-bottom: 2px solid var(--ink);
}
.ledger-table tbody tr:hover { background: var(--pine-soft); }

/* --- Star rating ------------------------------------------------------ */
.rating-pill {
  font-family: "JetBrains Mono", monospace;
  font-weight: 700; font-size: .8rem;
  color: var(--pine);
}

/* --- Custom scrollbar ------------------------------------------------- */
::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-track { background: var(--paper); }
::-webkit-scrollbar-thumb { background: rgba(22,24,29,0.18); border-radius: 999px; border: 2px solid var(--paper); }
::-webkit-scrollbar-thumb:hover { background: rgba(22,24,29,0.35); }

/* --- Flags ------------------------------------------------------------ */
.flag-chip {
  filter: grayscale(0.55) contrast(1.05);
  transition: filter .4s ease, transform .4s ease;
}
.group:hover .flag-chip { filter: grayscale(0) contrast(1); transform: translateY(-2px) scale(1.04); }

/* --- Line clamp helpers (CDN-safe) ------------------------------------ */
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.clamp-3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* --- Reduced motion --------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; animation: none; }
  .ticker__track { animation: none; padding-left: 0; }
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
