/* ============================================================
   TELL — Poker Trainer · Design tokens & base
   Premium dark poker aesthetic
   ============================================================ */

:root {
  /* Surfaces — near-black with a faint green undertone */
  --ink-900: #090B0A;   /* page background */
  --ink-850: #0D100F;
  --ink-800: #121614;   /* card surface */
  --ink-750: #171C1A;
  --ink-700: #1D2421;   /* raised surface */
  --ink-650: #232B28;
  --ink-600: #2C3531;   /* hairline border */
  --ink-500: #3A4641;

  /* Felt — table moments */
  --felt-900: #0A2A1E;
  --felt-700: #0F3E2C;
  --felt-500: #14543B;

  /* Brand — emerald primary */
  --em-500: #2FBF71;
  --em-400: #3FD98A;
  --em-300: #6CE9A8;
  --em-glow: rgba(63, 217, 138, 0.25);

  /* Gold — rewards / premium */
  --gold-500: #E7B85C;
  --gold-400: #F2C94C;
  --gold-300: #F8DC8A;
  --gold-glow: rgba(242, 201, 76, 0.22);

  /* Chip red — bluff / danger / hearts */
  --red-500: #E5484D;
  --red-400: #F2686C;

  /* Blue — info / call */
  --blue-500: #4C8DFF;
  --blue-400: #74A9FF;

  /* Tier colors */
  --t-bronze: #C77B4A;
  --t-silver: #B9C4CC;
  --t-gold: #F2C94C;
  --t-plat: #6FE3D2;
  --t-diamond: #8FB4FF;

  /* Text */
  --tx-hi: #F3F7F4;
  --tx-mid: #A6B2AD;
  --tx-lo: #6B7670;
  --tx-dim: #4B544F;

  /* Radii */
  --r-xs: 8px;
  --r-sm: 12px;
  --r-md: 16px;
  --r-lg: 22px;
  --r-xl: 28px;
  --r-pill: 999px;

  /* Shadows */
  --sh-1: 0 1px 2px rgba(0,0,0,0.4);
  --sh-2: 0 6px 18px rgba(0,0,0,0.35);
  --sh-3: 0 18px 48px rgba(0,0,0,0.5);
  --sh-glow: 0 0 0 1px rgba(63,217,138,0.4), 0 8px 30px rgba(47,191,113,0.25);

  /* Fonts */
  --f-display: "Bricolage Grotesque", system-ui, sans-serif;
  --f-ui: "Familjen Grotesk", system-ui, sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, monospace;

  --shell-max: 1180px;
  --nav-w: 248px;
}

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

button { color: inherit; font-family: var(--f-ui); }

html, body {
  height: 100%;
}

body {
  font-family: var(--f-ui);
  background: var(--ink-900);
  color: var(--tx-hi);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}

#root { height: 100vh; }

::selection { background: var(--em-glow); }

/* Ambient page gradient */
.app-bg {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(900px 600px at 80% -10%, rgba(47,191,113,0.10), transparent 60%),
    radial-gradient(700px 500px at -5% 110%, rgba(242,201,76,0.06), transparent 60%),
    var(--ink-900);
  z-index: 0;
}

/* ---------- App shell ---------- */
.shell {
  position: relative;
  z-index: 1;
  height: 100vh;
  display: grid;
  grid-template-columns: var(--nav-w) 1fr;
}
.shell.full { grid-template-columns: 1fr; }

.scroll {
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--ink-600) transparent;
}
.scroll::-webkit-scrollbar { width: 9px; }
.scroll::-webkit-scrollbar-thumb { background: var(--ink-600); border-radius: 99px; }

.page {
  max-width: 760px;
  margin: 0 auto;
  padding: 28px 24px 120px;
}
.page-wide { max-width: 920px; }

/* ---------- Side nav (desktop) ---------- */
.sidenav {
  border-right: 1px solid var(--ink-600);
  background: linear-gradient(180deg, var(--ink-850), var(--ink-900));
  padding: 26px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  height: 100vh;
  overflow-y: auto;
}
.brand {
  display: flex; align-items: center; gap: 11px;
  padding: 4px 10px 22px;
}
.brand-mark {
  width: 38px; height: 38px; border-radius: 11px;
  background: linear-gradient(150deg, var(--em-400), var(--felt-500));
  display: grid; place-items: center;
  box-shadow: var(--sh-glow);
  flex-shrink: 0;
}
.brand-name {
  font-family: var(--f-display);
  font-weight: 800; font-size: 21px; letter-spacing: -0.02em;
}
.brand-name small { color: var(--em-400); }

.nav-item {
  display: flex; align-items: center; gap: 13px;
  appearance: none;
  background: transparent;
  padding: 11px 13px; border-radius: var(--r-sm);
  color: var(--tx-mid); font-weight: 600; font-size: 15px;
  cursor: pointer; border: 1px solid transparent;
  text-align: left;
  transition: all .15s ease;
  -webkit-tap-highlight-color: transparent;
}
.nav-item:hover { background: var(--ink-800); color: var(--tx-hi); }
.nav-item.active {
  background: var(--ink-800);
  color: var(--tx-hi);
  border-color: var(--ink-600);
}
.nav-item.active .nav-ico { color: var(--em-400); }
.nav-ico { color: var(--tx-lo); display: grid; place-items: center; }
.nav-spacer { flex: 1; }

.nav-mini-card {
  margin-top: 8px;
  background: var(--ink-800);
  border: 1px solid var(--ink-600);
  border-radius: var(--r-md);
  padding: 14px;
}

/* ---------- Bottom tab bar (mobile) ---------- */
.tabbar { display: none; }

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .sidenav { display: none; }
  .page { padding: 18px 16px 110px; }
  .tabbar {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
    background: rgba(13,16,15,0.92);
    backdrop-filter: blur(16px);
    border-top: 1px solid var(--ink-600);
    padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
  }
  .tab {
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    padding: 6px 0; color: var(--tx-lo); font-size: 10.5px; font-weight: 600;
    cursor: pointer; -webkit-tap-highlight-color: transparent;
    letter-spacing: .01em;
  }
  .tab.active { color: var(--em-400); }
}

/* ---------- Typography helpers ---------- */
.h-display { font-family: var(--f-display); font-weight: 800; letter-spacing: -0.025em; line-height: 1.02; }
.eyebrow {
  font-size: 11.5px; font-weight: 700; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--tx-lo);
}
.mono { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--tx-mid); }
.dim { color: var(--tx-lo); }

/* ---------- Cards / surfaces ---------- */
.card {
  background: var(--ink-800);
  border: 1px solid var(--ink-600);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-2);
}
.card-pad { padding: 20px; }

/* ---------- Buttons ---------- */
.btn {
  font-family: var(--f-ui);
  font-weight: 700; font-size: 15.5px;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  padding: 14px 20px;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  transition: transform .08s ease, filter .15s ease, background .15s ease;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px) scale(0.995); }
.btn-primary {
  background: linear-gradient(160deg, var(--em-400), var(--em-500));
  color: #05140C;
  box-shadow: 0 8px 22px rgba(47,191,113,0.28);
}
.btn-primary:hover { filter: brightness(1.06); }
.btn-gold {
  background: linear-gradient(160deg, var(--gold-400), var(--gold-500));
  color: #2A1E03;
  box-shadow: 0 8px 22px rgba(242,201,76,0.22);
}
.btn-ghost {
  background: var(--ink-750);
  color: var(--tx-hi);
  border-color: var(--ink-600);
}
.btn-ghost:hover { background: var(--ink-700); }
.btn-block { width: 100%; }
.btn-lg { padding: 17px 24px; font-size: 17px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- Pills / badges ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px; border-radius: var(--r-pill);
  font-size: 12.5px; font-weight: 700;
  background: var(--ink-700); color: var(--tx-mid);
  border: 1px solid var(--ink-600);
  white-space: nowrap;
}
.pill-em { background: rgba(63,217,138,0.12); color: var(--em-300); border-color: rgba(63,217,138,0.25); }
.pill-gold { background: rgba(242,201,76,0.12); color: var(--gold-300); border-color: rgba(242,201,76,0.28); }
.pill-red { background: rgba(229,72,77,0.12); color: var(--red-400); border-color: rgba(229,72,77,0.28); }
.pill-blue { background: rgba(76,141,255,0.12); color: var(--blue-400); border-color: rgba(76,141,255,0.28); }

/* ---------- Progress ---------- */
.prog {
  height: 9px; border-radius: 99px; background: var(--ink-700);
  overflow: hidden;
}
.prog > i {
  display: block; height: 100%; border-radius: 99px;
  background: linear-gradient(90deg, var(--em-500), var(--em-300));
}
.prog.gold > i { background: linear-gradient(90deg, var(--gold-500), var(--gold-300)); }

/* ---------- Playing cards ---------- */
.pcard {
  --w: 54px;
  width: var(--w); height: calc(var(--w) * 1.42);
  border-radius: calc(var(--w) * 0.13);
  background: linear-gradient(160deg, #FCFDFD, #EAEEEC);
  border: 1px solid rgba(0,0,0,0.18);
  box-shadow: 0 4px 12px rgba(0,0,0,0.4), inset 0 1px 0 #fff;
  position: relative; flex-shrink: 0;
  font-family: var(--f-display);
  color: #14181A;
}
.pcard .corner {
  position: absolute; display: flex; flex-direction: column; align-items: center;
  line-height: 0.82; font-family: var(--f-display); font-weight: 800;
}
.pcard .corner .cr { font-size: calc(var(--w) * 0.27); letter-spacing: -0.04em; }
.pcard .corner .cs { font-size: calc(var(--w) * 0.2); line-height: 1; margin-top: calc(var(--w) * 0.01); }
.pcard .corner.tl { top: 6%; left: 8%; }
.pcard .corner.br { bottom: 6%; right: 8%; transform: rotate(180deg); }
.pcard .pips { position: absolute; inset: 15% 14%; }
.pcard .pip {
  position: absolute; transform: translate(-50%, -50%);
  font-size: calc(var(--w) * 0.21); line-height: 1;
}
.pcard .pip.flip { transform: translate(-50%, -50%) rotate(180deg); }
.pcard .pip.ace { font-size: calc(var(--w) * 0.42); }
.pcard .face-frame {
  position: absolute; inset: 13% 11%;
  border: 1.5px solid currentColor; opacity: 0.32;
  border-radius: calc(var(--w) * 0.07);
}
.pcard .face-mono {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-family: var(--f-display); font-weight: 800; font-size: calc(var(--w) * 0.46);
}
.pcard.red { color: var(--red-500); }
.pcard.back {
  background:
    repeating-linear-gradient(45deg, #123, #123 5px, #1a3a4a 5px, #1a3a4a 10px);
  border-color: #0a1a22;
}
.pcard.dim { filter: grayscale(0.3) brightness(0.7); }

.board {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
}
.hole {
  display: flex; gap: 6px;
}
.hole .pcard { box-shadow: 0 6px 18px rgba(0,0,0,0.5), inset 0 1px 0 #fff; }

/* ---------- Felt table block ---------- */
.felt {
  background:
    radial-gradient(120% 90% at 50% 18%, var(--felt-700), var(--felt-900));
  border: 1px solid rgba(63,217,138,0.18);
  border-radius: var(--r-xl);
  box-shadow: inset 0 0 60px rgba(0,0,0,0.45), var(--sh-2);
  position: relative;
  overflow: hidden;
}
.felt::after {
  content: ""; position: absolute; inset: 10px;
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: calc(var(--r-xl) - 6px);
  pointer-events: none;
}

/* ---------- Answer options ---------- */
.opt {
  display: flex; align-items: center; gap: 14px;
  width: 100%; text-align: left;
  background: var(--ink-750);
  border: 1.5px solid var(--ink-600);
  border-radius: var(--r-md);
  padding: 16px 18px;
  cursor: pointer; color: var(--tx-hi);
  font-family: var(--f-ui); font-size: 16px; font-weight: 600;
  transition: all .14s ease;
  -webkit-tap-highlight-color: transparent;
}
.opt:hover:not(:disabled) { border-color: var(--ink-500); background: var(--ink-700); transform: translateY(-1px); }
.opt:disabled { cursor: default; }
.opt-key {
  width: 30px; height: 30px; border-radius: 9px; flex-shrink: 0;
  background: var(--ink-650); display: grid; place-items: center;
  font-family: var(--f-mono); font-weight: 700; font-size: 14px; color: var(--tx-mid);
}
.opt.correct { border-color: var(--em-400); background: rgba(63,217,138,0.10); }
.opt.correct .opt-key { background: var(--em-400); color: #05140C; }
.opt.wrong { border-color: var(--red-500); background: rgba(229,72,77,0.10); }
.opt.wrong .opt-key { background: var(--red-500); color: #fff; }
.opt.faded { opacity: .5; }
.opt-tag { margin-left: auto; font-size: 13px; font-weight: 700; }

/* ---------- Misc layout ---------- */
.row { display: flex; align-items: center; gap: 12px; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.col { display: flex; flex-direction: column; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; }
.wrap { flex-wrap: wrap; }
.gap6{gap:6px}.gap8{gap:8px}.gap10{gap:10px}.gap16{gap:16px}.gap20{gap:20px}
.mt8{margin-top:8px}.mt12{margin-top:12px}.mt16{margin-top:16px}.mt20{margin-top:20px}.mt24{margin-top:24px}.mt32{margin-top:32px}

.avatar {
  border-radius: 50%; background: linear-gradient(150deg, var(--felt-500), var(--ink-700));
  display: grid; place-items: center; font-family: var(--f-display);
  font-weight: 800; color: var(--tx-hi); flex-shrink: 0;
  border: 1.5px solid var(--ink-600);
}

.divider { height: 1px; background: var(--ink-600); border: 0; }

.tile {
  background: var(--ink-750);
  border: 1px solid var(--ink-600);
  border-radius: var(--r-md);
  padding: 15px 16px;
}
.tile .big { font-family: var(--f-display); font-weight: 800; font-size: 26px; letter-spacing: -0.02em; }

/* ---------- Animations ---------- */
@keyframes pop { 0%{transform:scale(.96);opacity:0} 100%{transform:scale(1);opacity:1} }
@keyframes slideup { 0%{transform:translateY(14px);opacity:0} 100%{transform:translateY(0);opacity:1} }
@keyframes dealin { 0%{transform:translateY(-10px) rotate(-4deg);opacity:0} 100%{transform:none;opacity:1} }
@keyframes flamepulse { 0%,100%{transform:scale(1)} 50%{transform:scale(1.12)} }
.anim-pop { animation: pop .25s cubic-bezier(.2,.8,.2,1) both; }
.anim-up { animation: slideup .3s cubic-bezier(.2,.8,.2,1) both; }
.deal > * { animation: dealin .3s cubic-bezier(.2,.8,.2,1) both; }
.deal > *:nth-child(2){animation-delay:.05s}
.deal > *:nth-child(3){animation-delay:.1s}
.deal > *:nth-child(4){animation-delay:.15s}
.deal > *:nth-child(5){animation-delay:.2s}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; }
}

/* ============================================================
   i18n — script fonts + RTL
   ============================================================ */
html[data-lang="fa"] {
  --f-display: "Vazirmatn", system-ui, sans-serif;
  --f-ui: "Vazirmatn", system-ui, sans-serif;
}
html[data-lang="ar"] {
  --f-display: "Cairo", system-ui, sans-serif;
  --f-ui: "Cairo", system-ui, sans-serif;
}
html[data-lang="fa"] .h-display,
html[data-lang="ar"] .h-display { letter-spacing: 0; line-height: 1.4; }
html[data-lang="fa"] .eyebrow,
html[data-lang="ar"] .eyebrow { letter-spacing: 0.04em; }

/* Playing-card pips stay LTR (cards are cards) */
.pcard { direction: ltr; }
/* numbers/odds: keep latin digits readable */
.mono { direction: ltr; unicode-bidi: embed; }

/* RTL structural fixes */
[dir="rtl"] .sidenav { border-right: none; border-left: 1px solid var(--ink-600); }
[dir="rtl"] .opt-tag { margin-left: 0; margin-right: auto; }
[dir="rtl"] .tabbar { direction: rtl; }
[dir="rtl"] .timer-ring svg { transform: rotate(-90deg) scaleX(-1); }
/* direction-aware icon flip handled in JS (back / chevron / play) */

/* ---------- Quiz runner top bar ---------- */
.qbar {
  position: sticky; top: 0; z-index: 20;
  background: linear-gradient(180deg, var(--ink-900) 60%, transparent);
  padding: 16px 0 12px;
}
.qprog-seg { display: flex; gap: 4px; flex: 1; }
.qprog-seg > i {
  flex: 1; height: 5px; border-radius: 99px; background: var(--ink-700);
}
.qprog-seg > i.done { background: var(--em-400); }
.qprog-seg > i.cur { background: var(--tx-mid); }

.timer-ring { position: relative; width: 46px; height: 46px; }
.timer-ring svg { transform: rotate(-90deg); }
.timer-ring .t-num {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-family: var(--f-mono); font-weight: 700; font-size: 15px;
}

/* numeric keypad */
.kp { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; }
.kp button {
  font-family: var(--f-mono); font-size: 22px; font-weight: 600;
  padding: 16px; border-radius: var(--r-sm);
  background: var(--ink-750); border: 1px solid var(--ink-600); color: var(--tx-hi);
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.kp button:active { background: var(--ink-700); }

/* range grid */
.range-grid {
  display: grid; grid-template-columns: repeat(13, 1fr); gap: 2px;
  max-width: 420px;
}
.range-cell {
  aspect-ratio: 1; border-radius: 3px; font-size: 8.5px; font-weight: 700;
  display: grid; place-items: center; font-family: var(--f-mono);
  background: var(--ink-700); color: var(--tx-lo);
}
.range-cell.in { background: var(--em-500); color: #05140C; }
.range-cell.hl { outline: 2px solid var(--gold-400); outline-offset: -1px; z-index:2; color: #fff; }

.confetti-num { font-family: var(--f-display); font-weight:800; letter-spacing:-0.03em; }
