/* ============================================================
   Felt Trainer — Shared design tokens, base styles, and
   common components used across all games.

   Sections:
     - Design tokens (:root)
     - Reset
     - Utilities (.hidden)
     - Tooltips
     - Setup screen
     - Header bar
     - Modal overlay / card / close
     - Toast
   ============================================================ */

/* ==================== Design tokens ==================== */

:root {
  --bg: #0b100e;
  --surface: #141c18;
  --surface-2: #1a251f;
  --surface-3: #243029;
  --border: #2e3f35;
  --text: #e8ede9;
  --text-muted: #94a89c;
  --text-dim: #5a6e60;

  /* Felt greens */
  --felt: #0d6b2c;
  --felt-dark: #095420;
  --felt-light: #0f7d34;

  /* Table lines (used by craps; harmless elsewhere) */
  --line: rgba(255,255,255,.65);
  --line-heavy: rgba(255,255,255,.8);

  /* Colors */
  --green: #2d9f5f;
  --green-bright: #3ab870;
  --green-dim: #132e1e;
  --red: #c93d3d;
  --red-bright: #e05252;
  --red-dim: #3a1515;
  --gold: #e5b84a;
  --gold-bright: #f0cc5e;
  --gold-dim: #5c4210;
  --blue: #5b8ec9;
  --blue-dim: #1a2f45;
  --cyan: #4ea8b8;
  --orange: #d4762a;

  /* Chips */
  --chip-red: #b22828;
  --chip-white: #e8e8e8;
  --chip-blue: #2554a0;
  --chip-green: #1a8a42;
  --chip-black: #1a2420;

  --radius: 6px;
  --radius-lg: 10px;

  /* Typography */
  --font-display: 'DM Serif Display', Georgia, serif;
  --font-body: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
}

/* ==================== Reset ==================== */

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

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

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

/* ==================== Utilities ==================== */

.hidden { display: none !important; }

/* ==================== Tooltips ==================== */

[data-tooltip] {
  position: relative;
}
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,.85);
  color: #e8ede9;
  font-size: 0.7rem;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 100;
}
[data-tooltip]:hover::after,
[data-tooltip]:focus::after {
  opacity: 1;
}
/* Tooltips are hover-only and useless on touch; their nowrap text also
   inflates page width near the right edge on narrow screens (horizontal
   scroll). Don't generate them on touch or small viewports. */
@media (hover: none), (max-width: 600px) {
  [data-tooltip]::after { content: none; }
}

.tooltip-hint {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  margin-left: 6px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.75);
  font-size: 0.65rem;
  font-weight: 600;
  line-height: 1;
  vertical-align: middle;
}

/* ==================== Setup screen ==================== */

.setup-screen {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 24px;
  background:
    radial-gradient(ellipse at 50% 40%, rgba(13,107,44,.08) 0%, transparent 60%),
    var(--bg);
}
.setup-card {
  background:
    linear-gradient(160deg, rgba(45,159,95,.03) 0%, transparent 40%),
    var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 48px 40px; max-width: 440px; width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,.4), 0 0 0 1px rgba(229,184,74,.05);
}
.setup-brand {
  display: flex; align-items: center; gap: 14px; margin-bottom: 6px;
}
.setup-chip {
  width: 42px; height: 42px; border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, var(--red-bright) 0%, var(--chip-red) 70%);
  border: 3px solid rgba(255,255,255,.4);
  box-shadow: 0 2px 8px rgba(0,0,0,.4), inset 0 -2px 4px rgba(0,0,0,.3);
  position: relative;
  flex-shrink: 0;
}
.setup-chip::before {
  content: '';
  position: absolute; inset: 2px;
  border: 2px dashed rgba(255,255,255,.3);
  border-radius: 50%;
}
.setup-card h1 {
  font-family: var(--font-display);
  font-size: 32px; font-weight: 400; color: var(--gold);
  letter-spacing: 0.5px;
}
.setup-card .subtitle {
  color: var(--text-muted); font-size: 14px; margin-bottom: 32px;
  line-height: 1.6;
}
.game-label {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--green-bright);
  margin-top: 2px;
}
.form-group { margin-bottom: 18px; }
.form-group label {
  display: block; font-size: 11px; font-weight: 700; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: .8px; margin-bottom: 5px;
}
.form-group input, .form-group select {
  width: 100%; padding: 11px 14px; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text); font-size: 15px;
  font-family: var(--font-body); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.form-group input:focus, .form-group select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(45,159,95,.12);
}
.btn-start {
  width: 100%; padding: 15px; background: var(--green); color: #fff; border: none;
  border-radius: var(--radius); font-size: 16px; font-weight: 700; cursor: pointer;
  margin-top: 12px; font-family: var(--font-body);
  letter-spacing: .3px;
  box-shadow: 0 2px 12px rgba(45,159,95,.25);
  transition: all .15s;
}
.btn-start:hover { background: var(--green-bright); box-shadow: 0 4px 16px rgba(45,159,95,.35); transform: translateY(-1px); }
.btn-start:active { transform: translateY(0); }
.back-link {
  display: block;
  text-align: center;
  margin-top: 16px;
  color: var(--text-dim);
  font-size: 0.85rem;
  text-decoration: none;
}
.back-link:hover { color: var(--text-muted); }
.setup-nav { display: flex; justify-content: center; gap: 22px; flex-wrap: wrap; }
.setup-nav .back-link { margin-top: 16px; }
.setup-nav .back-link.is-learn { color: var(--green-bright); }
.setup-nav .back-link.is-learn:hover { color: var(--green-bright); filter: brightness(1.15); }

/* ==================== Header bar ==================== */

.header-bar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 10px 20px; gap: 16px; flex-wrap: wrap;
}
.header-left { display: flex; align-items: center; gap: 12px; }
.header-left h2 {
  font-family: var(--font-display);
  font-size: 17px; font-weight: 400; color: var(--gold); white-space: nowrap;
}
/* Brand doubles as a home link — keep it gold, not the default green link color */
.header-left h2 a {
  color: inherit; text-decoration: none;
  transition: color .15s;
}
.header-left h2 a:hover { color: var(--gold-bright); text-decoration: none; }
.header-stats { display: flex; gap: 20px; }
.stat { text-align: center; }
.stat-label {
  display: block; font-size: 9px; text-transform: uppercase;
  letter-spacing: .8px; color: var(--text-dim); font-weight: 600;
}
.stat-value { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-value.positive { color: var(--green-bright); }
.stat-value.negative { color: var(--red-bright); }
.header-actions { display: flex; gap: 6px; align-items: center; }
.btn-hdr {
  padding: 6px 10px; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text-muted); font-size: 14px; cursor: pointer;
  font-family: var(--font-body);
  transition: all .15s; line-height: 1;
}
.btn-hdr:hover { background: var(--surface-3); color: var(--text); }

/* ==================== Modal ==================== */

.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 24px;
  backdrop-filter: blur(2px);
}
.modal-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 32px;
  max-width: 500px; width: 100%; max-height: 85vh; overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.modal-wide { max-width: 780px; }
.modal-header {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px;
}
.modal-header h2 {
  font-family: var(--font-display);
  font-size: 20px; color: var(--gold); font-weight: 400;
}
.btn-close {
  background: none; border: none; color: var(--text-muted);
  font-size: 24px; cursor: pointer; padding: 0 4px; line-height: 1;
}
.btn-close:hover { color: var(--text); }

/* ==================== Toast ==================== */

.toast {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
  background: var(--surface); color: var(--text); padding: 10px 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius); font-size: 14px; font-weight: 600;
  z-index: 200; transition: opacity .3s, transform .3s;
  box-shadow: 0 4px 20px rgba(0,0,0,.5);
  max-width: calc(100vw - 32px);
  text-align: center;
}
.toast.show { opacity: 1; }
.toast.hidden { opacity: 0; pointer-events: none; }

/* ==================== Tutorial ==================== */
/* Shared guided-tutorial chrome: the setup-screen launch button, the
   floating card (fixed bottom-right by default — craps + blackjack), the
   progress bar, step counter, body, buttons, hint, skip, and spotlight.
   Game overrides: roulette docks the card into its own column and adds a
   Move toggle; blackjack right-aligns the step counter beside a Back link. */

.btn-tutorial {
  width: 100%; padding: 12px; background: transparent; color: var(--text-muted);
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 14px; font-weight: 600; cursor: pointer; margin-top: 10px;
  font-family: var(--font-body);
  transition: all .15s;
}
.btn-tutorial:hover { background: var(--surface-2); color: var(--text); border-color: var(--text-dim); }

.tutorial-card {
  position: fixed; z-index: 60;
  bottom: 24px; right: 24px;
  width: 380px; max-width: calc(100vw - 48px);
  background: var(--surface); border: 1px solid var(--green);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 40px rgba(0,0,0,.6), 0 0 0 1px rgba(45,159,95,.15);
  overflow: hidden;
  animation: tutSlideIn .3s ease;
}
@keyframes tutSlideIn {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

.tut-progress-bar {
  height: 3px; background: var(--surface-3); width: 100%;
}
.tut-progress-fill {
  height: 100%; background: var(--green);
  transition: width .4s ease;
}
.tut-step-count {
  display: flex;
  align-items: center;
  padding: 14px 18px 0;
}
.tut-step-counter {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1px; color: var(--green);
}
.tut-back-link {
  background: transparent;
  border: none;
  padding: 0;
  font-family: var(--font-body);
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1px; color: var(--text-dim);
  cursor: pointer;
  transition: color .15s;
}
.tut-back-link:hover { color: var(--text-muted); }
.tut-title {
  padding: 4px 18px 0;
  font-family: var(--font-display);
  font-size: 17px; font-weight: 400; color: var(--text);
}
.tut-body {
  padding: 10px 18px;
  font-size: 13px; line-height: 1.7; color: var(--text-muted);
}
.tut-body strong { color: var(--text); font-weight: 700; }
.tut-actions {
  padding: 0 18px 14px;
}
.tut-btn {
  padding: 10px 22px; border: none; border-radius: var(--radius);
  font-size: 14px; font-weight: 700; cursor: pointer;
  font-family: var(--font-body);
  transition: all .15s;
}
.tut-btn-next { background: var(--green); color: #fff; }
.tut-btn-next:hover { background: var(--green-bright); }
.tut-btn-finish { background: var(--gold); color: #1a1a1a; }
.tut-btn-finish:hover { background: var(--gold-bright); }
.tut-hint {
  font-size: 12px; color: var(--green); font-weight: 600;
  padding: 6px 0;
  animation: tutPulse 2s ease-in-out infinite;
}
@keyframes tutPulse {
  0%, 100% { opacity: .6; }
  50%      { opacity: 1; }
}
.tut-skip {
  display: block; width: 100%;
  padding: 8px; background: var(--surface-2); border: none; border-top: 1px solid var(--border);
  color: var(--text-dim); font-size: 11px; cursor: pointer;
  font-family: var(--font-body);
  transition: color .15s;
}
.tut-skip:hover { color: var(--text-muted); }

/* Spotlight — highlight the element a step is pointing at */
.tut-spotlight-target {
  position: relative; z-index: 10;
  box-shadow: 0 0 0 4px rgba(45,159,95,.5), 0 0 20px rgba(45,159,95,.3) !important;
  border-radius: 4px;
}
.tut-pulse {
  animation: tutTargetPulse 1.5s ease-in-out 2;
}
@keyframes tutTargetPulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(45,159,95,.5), 0 0 20px rgba(45,159,95,.3); }
  50%      { box-shadow: 0 0 0 8px rgba(45,159,95,.6), 0 0 30px rgba(45,159,95,.5); }
}

@media (max-width: 860px) {
  .tutorial-card {
    bottom: 12px; right: 12px; left: 12px;
    width: auto; max-width: none;
  }
}
@media (max-width: 520px) {
  .tutorial-card {
    bottom: auto; top: 60px; right: 8px; left: 8px;
    width: auto; max-width: none;
    max-height: 45vh; overflow-y: auto;
  }
  .tut-title { font-size: 15px; }
  .tut-body { font-size: 12px; padding: 8px 14px; line-height: 1.6; }
  .tut-step-count { padding: 10px 14px 0; }
  .tut-actions { padding: 0 14px 10px; }
}

/* ============================================================
   SEO / "Learn" content sections (below the game on each page)
   Crawlable, AI-citable reference content. Shared across games.
   ============================================================ */
.seo-content {
  max-width: 820px;
  margin: 0 auto;
  padding: 56px 24px 80px;
  border-top: 1px solid var(--border);
  color: var(--text);
  line-height: 1.7;
}
.seo-content h2 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.8rem;
  margin: 40px 0 14px;
  letter-spacing: 0.01em;
}
.seo-content h2:first-child { margin-top: 0; }
.seo-content h3 {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 26px 0 8px;
}
.seo-content p { color: var(--text-muted); margin-bottom: 14px; }
.seo-content ul, .seo-content ol { color: var(--text-muted); margin: 0 0 16px 1.2em; }
.seo-content li { margin-bottom: 7px; }
.seo-content a { color: var(--green-bright); }
.seo-content strong { color: var(--text); }
.seo-content .lede { font-size: 1.08rem; color: var(--text); }
.seo-content .seo-byline { font-size: 0.82rem; color: var(--text-dim); margin: -4px 0 18px; }
.seo-content .seo-byline a { color: var(--text-muted); text-decoration: underline; }

.seo-table-wrap { overflow-x: auto; margin: 8px 0 22px; }
.seo-content .seo-table-note { font-size: 0.82rem; color: var(--text-dim); margin: -14px 0 0; }
.seo-content .seo-aside {
  font-size: 0.9rem;
  color: var(--text-muted);
  border-left: 3px solid var(--gold-dim);
  background: rgba(212,175,55,0.06);
  padding: 10px 14px;
  border-radius: 0 8px 8px 0;
  margin: 18px 0;
}
.seo-content table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
.seo-content th, .seo-content td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
.seo-content th {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  font-weight: 700;
}
.seo-content td { color: var(--text-muted); }
.seo-content td:first-child { color: var(--text); font-weight: 600; }
.edge-good { color: var(--green-bright); font-weight: 700; }
.edge-bad  { color: var(--chip-red); font-weight: 700; }

.seo-faq details {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 4px 18px;
  margin-bottom: 10px;
  background: var(--surface);
}
.seo-faq summary {
  cursor: pointer;
  padding: 12px 0;
  font-weight: 600;
  color: var(--text);
  list-style: none;
}
.seo-faq summary::-webkit-details-marker { display: none; }
.seo-faq summary::after { content: "+"; float: right; color: var(--green-bright); font-size: 1.2rem; }
.seo-faq details[open] summary::after { content: "\2212"; }
.seo-faq details[open] summary { border-bottom: 1px solid var(--border); }
.seo-faq p { padding: 12px 0 6px; margin: 0; }

.seo-cross-links {
  display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px;
}
.seo-cross-links a {
  display: inline-block;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 99px;
  text-decoration: none;
  color: var(--text);
  font-size: 0.9rem;
  transition: border-color .2s;
}
.seo-cross-links a:hover { border-color: var(--green); }

@media (max-width: 520px) {
  .seo-content { padding: 40px 18px 60px; }
  .seo-content h2 { font-size: 1.5rem; }
}

/* SEO content-page extras (breadcrumb + practice CTA) */
.seo-crumb { font-size: 0.82rem; color: var(--text-dim); margin-bottom: 18px; }
.seo-crumb a { color: var(--text-muted); text-decoration: none; }
.seo-crumb a:hover { color: var(--green-bright); }
.seo-cta {
  margin: 32px 0;
  padding: 24px;
  border: 1px solid var(--green-dim);
  border-radius: var(--radius-lg);
  background: var(--green-dim);
  text-align: center;
}
.seo-cta-btn {
  display: inline-block;
  font-weight: 700;
  font-size: 1.02rem;
  color: var(--green-bright);
  text-decoration: none;
}
.seo-cta-btn:hover { text-decoration: underline; }
.seo-cta-note { font-size: 0.82rem; color: var(--text-dim); margin: 8px 0 0; }
