/* Point Counter website — shared design system.
   Mirrors the app's "arcade chunky" tokens (lib/constants/game_tokens.dart). */

@font-face { font-family: "Baloo 2"; src: url("../fonts/Baloo2-Regular.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Baloo 2"; src: url("../fonts/Baloo2-SemiBold.ttf") format("truetype"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Baloo 2"; src: url("../fonts/Baloo2-Bold.ttf") format("truetype"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Baloo 2"; src: url("../fonts/Baloo2-ExtraBold.ttf") format("truetype"); font-weight: 800; font-display: swap; }

:root {
  --bg: #FFF3DC;
  --bg-accent: #FFE6B8;
  --surface: #FFFFFF;
  --sunken: #F3E7D3;
  --ink: #23194A;
  --text: #23194A;
  --muted: #6E6490;
  --primary: #FFC233;
  --on-primary: #23194A;
  --secondary: #7B5CFF;
  --success: #2FD27A;
  --danger: #FF4D5E;
  --warning: #FF9A2E;
  --info: #38B6FF;
  --dot: rgba(35, 25, 74, .07);
  --r-sm: 12px;
  --r-md: 18px;
  --r-lg: 26px;
  --border: 3px;
  --depth: 5px;
  --maxw: 1160px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17123A; --bg-accent: #231B55; --surface: #2C2366; --sunken: #1F1849;
    --ink: #0A0720; --text: #FFFFFF; --muted: #B7AEE6; --secondary: #8E73FF;
    --dot: rgba(255, 255, 255, .05); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #17123A; --bg-accent: #231B55; --surface: #2C2366; --sunken: #1F1849;
  --ink: #0A0720; --text: #FFFFFF; --muted: #B7AEE6; --secondary: #8E73FF;
  --dot: rgba(255, 255, 255, .05); color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: "Baloo 2", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 17px;
  line-height: 1.55;
  color: var(--text);
  background-color: var(--bg);
  background-image:
    radial-gradient(var(--dot) 1.6px, transparent 1.7px),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-accent) 100%);
  background-size: 26px 26px, 100% 100%;
  background-attachment: fixed;
  min-height: 100vh;
  overflow-x: hidden;
}
img { max-width: 100%; display: block; }
a { color: inherit; }
h1, h2, h3, h4 { line-height: 1.12; margin: 0 0 .4em; font-weight: 800; letter-spacing: -.01em; }
p { margin: 0 0 1em; }
:focus-visible { outline: 3px solid var(--secondary); outline-offset: 3px; border-radius: 8px; }

/* Long-form blocks exist in vi and en only: Vietnamese readers get vi, everyone else en. */
html:not([lang="vi"]) [data-lang="vi"], html[lang="vi"] [data-lang="en"] { display: none !important; }
.lang-note { max-width: 760px; margin: 18px auto 0; padding: 10px 16px; border-radius: 14px; background: var(--sunken); color: var(--muted); font-weight: 700; text-align: center; }
/* Hide the page until its dictionary has loaded (boot.js removes this after 2.5 s at worst). */
html.i18n-wait body { opacity: 0; }
body { transition: opacity .15s ease; }

/* Language picker: a native <select> styled as a chunky button. */
.lang-select { position: relative; display: inline-flex; align-items: center; gap: 4px; height: 40px; padding: 0 10px; border-radius: 12px;
  background: var(--surface); color: var(--text); border: 2.5px solid var(--ink); box-shadow: 0 3px 0 var(--ink); font-weight: 800; font-size: .85rem; cursor: pointer; }
.lang-select svg { width: 18px; height: 18px; }
.lang-select select { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; font: inherit; }
.lang-select:focus-within { outline: 3px solid var(--secondary); outline-offset: 2px; }

/* Right-to-left (Arabic, Hebrew) */
[dir="rtl"] .nav { margin-left: 0; margin-right: auto; }
[dir="rtl"] .eyebrow::before { order: 1; }
[dir="rtl"] .prose ul, [dir="rtl"] .prose ol { padding-left: 0; padding-right: 1.3em; }
[dir="rtl"] .prose blockquote { border-left: 0; border-right: 6px solid var(--primary); border-radius: 14px 0 0 14px; }
[dir="rtl"] .callout .btn { margin-left: 0; margin-right: auto; }
[dir="rtl"] .sports-track { animation-direction: reverse; }

.container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Chunky primitives ---------- */
.chunk {
  background: var(--surface);
  border: var(--border) solid var(--ink);
  border-radius: var(--r-lg);
  box-shadow: 0 var(--depth) 0 var(--ink);
}
.btn {
  --btn-bg: var(--surface);
  --btn-fg: var(--text);
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  font: inherit; font-weight: 800; font-size: 1rem; line-height: 1;
  min-height: 48px; padding: 0 20px;
  color: var(--btn-fg); background: var(--btn-bg);
  border: var(--border) solid var(--ink); border-radius: var(--r-md);
  box-shadow: 0 var(--depth) 0 var(--ink);
  text-decoration: none; cursor: pointer; user-select: none;
  transition: transform .08s ease, box-shadow .08s ease, filter .15s;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { filter: brightness(1.04); }
.btn:active { transform: translateY(var(--depth)); box-shadow: 0 0 0 var(--ink); }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn-primary { --btn-bg: var(--primary); --btn-fg: var(--on-primary); }
.btn-secondary { --btn-bg: var(--secondary); --btn-fg: #fff; }
.btn-success { --btn-bg: var(--success); --btn-fg: #fff; }
.btn-danger { --btn-bg: var(--danger); --btn-fg: #fff; }
.btn-lg { min-height: 60px; font-size: 1.15rem; padding: 0 28px; border-radius: 20px; }
.btn-sm { min-height: 38px; font-size: .9rem; padding: 0 14px; border-radius: 12px; --depth: 3px; }
.btn-icon { width: 48px; padding: 0; }
.btn svg { width: 1.3em; height: 1.3em; flex: none; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 12px; border: 2.5px solid var(--ink); border-radius: 999px;
  background: var(--surface); font-weight: 800; font-size: .85rem;
}
.eyebrow {
  display: inline-flex; align-items: center; gap: 10px;
  font-weight: 800; font-size: .85rem; letter-spacing: .14em; text-transform: uppercase; color: var(--muted);
}
.eyebrow::before { content: ""; width: 8px; height: 22px; border-radius: 4px; background: var(--primary); border: 2px solid var(--ink); }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  border-bottom: 2px solid color-mix(in srgb, var(--ink) 12%, transparent);
}
.site-header .container { display: flex; align-items: center; gap: 16px; min-height: 72px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 800; font-size: 1.25rem; white-space: nowrap; }
.brand img { width: 40px; height: 40px; border-radius: 12px; border: 2.5px solid var(--ink); box-shadow: 0 3px 0 var(--ink); }
.nav { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.nav a { text-decoration: none; font-weight: 700; padding: 8px 12px; border-radius: 12px; }
.nav a:hover, .nav a[aria-current="page"] { background: var(--sunken); }
.header-tools { display: flex; align-items: center; gap: 8px; }
.theme-toggle {
  font: inherit; font-weight: 800; font-size: .85rem; cursor: pointer;
  min-width: 44px; height: 40px; padding: 0 10px; border-radius: 12px;
  background: var(--surface); color: var(--text); border: 2.5px solid var(--ink); box-shadow: 0 3px 0 var(--ink);
}
.theme-toggle:active { transform: translateY(3px); box-shadow: none; }
.theme-toggle svg { width: 20px; height: 20px; vertical-align: middle; }
.menu-btn { display: none; }
@media (max-width: 880px) {
  .nav { position: fixed; inset: 72px 12px auto 12px; flex-direction: column; align-items: stretch; gap: 2px;
    padding: 10px; background: var(--surface); border: 3px solid var(--ink); border-radius: 20px; box-shadow: 0 6px 0 var(--ink);
    transform: translateY(-12px); opacity: 0; pointer-events: none; transition: .18s ease; }
  .nav.open { transform: none; opacity: 1; pointer-events: auto; }
  .nav a { padding: 12px 14px; }
  .menu-btn { display: inline-flex; margin-left: auto; }
  .header-tools { margin-left: 0; }
  .header-cta { display: none; }
}

/* ---------- Sections ---------- */
section { padding: 72px 0; }
.section-head { max-width: 720px; margin: 0 auto 40px; text-align: center; }
.section-head h2 { font-size: clamp(2rem, 4.4vw, 3rem); margin-top: 8px; }
.section-head p { color: var(--muted); font-size: 1.1rem; }

/* ---------- Footer ---------- */
.site-footer { margin-top: 40px; padding: 48px 0 32px; border-top: 3px solid var(--ink); background: var(--surface); }
.footer-grid { display: grid; grid-template-columns: 1.4fr repeat(3, 1fr); gap: 32px; }
.footer-grid h4 { font-size: .85rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.footer-grid ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.footer-grid a { text-decoration: none; font-weight: 600; }
.footer-grid a:hover { text-decoration: underline; }
.footer-bottom { margin-top: 32px; padding-top: 20px; border-top: 2px dashed color-mix(in srgb, var(--ink) 20%, transparent);
  display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; color: var(--muted); font-size: .9rem; }
@media (max-width: 760px) { .footer-grid { grid-template-columns: 1fr 1fr; } .footer-grid > :first-child { grid-column: 1 / -1; } }

/* ---------- Prose (blog / legal) ---------- */
.page-hero { padding: 56px 0 24px; text-align: center; }
.page-hero h1 { font-size: clamp(2.2rem, 5vw, 3.4rem); }
.page-hero p { color: var(--muted); font-size: 1.1rem; max-width: 640px; margin: 0 auto; }
.prose { max-width: 760px; margin: 0 auto; padding: 32px clamp(20px, 5vw, 48px); }
.prose h2 { font-size: 1.6rem; margin-top: 1.6em; }
.prose h3 { font-size: 1.25rem; margin-top: 1.3em; }
.prose ul, .prose ol { padding-left: 1.3em; margin: 0 0 1em; }
.prose li { margin-bottom: .35em; }
.prose a { color: var(--secondary); font-weight: 700; }
.prose code { background: var(--sunken); padding: 1px 6px; border-radius: 6px; font-size: .92em; }
.prose table { width: 100%; border-collapse: collapse; margin: 0 0 1.2em; font-size: .95rem; }
.prose th, .prose td { text-align: left; padding: 8px 10px; border-bottom: 2px solid var(--sunken); vertical-align: top; }
.prose th { font-weight: 800; }
.prose blockquote { margin: 0 0 1em; padding: 12px 18px; border-left: 6px solid var(--primary); background: var(--sunken); border-radius: 0 14px 14px 0; }
.prose .meta { color: var(--muted); font-size: .95rem; margin-bottom: 1.4em; }
.callout { display: flex; gap: 14px; align-items: center; padding: 18px 20px; margin: 1.5em 0; border-radius: 20px;
  background: var(--primary); color: var(--on-primary); border: 3px solid var(--ink); box-shadow: 0 5px 0 var(--ink); }
.callout p { margin: 0; font-weight: 700; }
.callout .btn { margin-left: auto; flex: none; }
@media (max-width: 560px) { .callout { flex-direction: column; align-items: stretch; } .callout .btn { margin-left: 0; } }

/* ---------- Store badges ---------- */
.store-row { display: flex; flex-wrap: wrap; gap: 12px; }
.store-btn { --btn-bg: var(--ink); --btn-fg: #fff; min-height: 58px; padding: 0 18px; gap: 10px; text-align: left; }
:root[data-theme="dark"] .store-btn { --btn-bg: #000; }
.store-btn small { display: block; font-size: .7rem; font-weight: 600; opacity: .8; }
.store-btn span { display: block; font-size: 1.05rem; line-height: 1.1; }
.store-btn svg { width: 26px; height: 26px; }

/* Reveal on scroll */
.reveal { opacity: 0; transform: translateY(18px); transition: opacity .6s ease, transform .6s ease; }
.reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; transition: none; }
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
/* Score labels like "+2", "−2", "15–30" read left-to-right even in RTL pages. */
.sbtn, .qbtn, .pscore, .vs, .code-demo, .code-boxes, .rstep, .mrow b, #demoClock { direction: ltr; unicode-bidi: isolate; }
