/* ==========================================================================
   AllFours.tt – shared stylesheet
   The page is the card table: dark green felt (the app's own felt tile) with
   white card-stock panels laid on it. Red is the action colour, taken from the
   "Trini Card Game" ribbon on the All Fours logo. Gold marks the top spot.
   Page-level <style> blocks only use the variables below.
   ========================================================================== */

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

:root {
  color-scheme: light;

  /* the table */
  --felt:        #0f3d2b;
  --felt-2:      #145236;
  --felt-line:   rgba(255, 255, 255, .14);
  --on-felt:     #ffffff;
  --on-felt-2:   rgba(255, 255, 255, .76);

  /* card stock (panels) */
  /* dark theme panels: dark grey card stock */
  --card:        #1a1a1a;              /* matches assets/panel-fill-dark.png */
  --surface:     #262626;
  --surface2:    #323232;
  --border:      rgba(255, 255, 255, .09);
  --border-strong: rgba(255, 255, 255, .2);
  --text:        #eef2ef;
  --muted:       #a8b2ac;
  --accent:      #6fd49b;              /* links */
  --accent-bg:   rgba(111, 212, 155, .12);
  --rank-gold:   #f3c14b;
  --pill-us:     #8ab8ff;
  --pill-them:   #ff8f8f;
  --fill-img:    url('/assets/panel-fill-dark.png');   /* the dark suit-pattern fill */

  /* actions */
  --red:         #d3222b;
  --red-dark:    #a8161e;
  --btn:         #d3222b;
  --btn-grad:    linear-gradient(180deg, #e6363e 0%, #c81d26 100%);
  --btn-ink:     #ffffff;
  --gold:        #f3c14b;

  --header-bg:   rgba(11, 46, 32, .86);
  --wash:        linear-gradient(180deg, rgba(8, 36, 24, .70) 0%, rgba(8, 36, 24, .86) 60%, rgba(6, 28, 19, .94) 100%);
  --footer-bg:   rgba(4, 22, 14, .55);
  --hover:       rgba(255, 255, 255, .08);
  --inset:       rgba(4, 24, 15, .55);
  --brand-tt:    #e4202c;
  --tt-stroke:   rgba(255, 255, 255, .7);
  --panel-line:  transparent;
  --shadow:      0 1px 0 rgba(0, 0, 0, .18), 0 22px 44px -24px rgba(0, 0, 0, .7);
  --radius:      16px;

  --font:    'Figtree', ui-sans-serif, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
  --display: 'Fredoka', 'Figtree', ui-rounded, ui-sans-serif, system-ui, sans-serif;
}

/* Light theme: the system setting, or the header toggle (saved as "af-theme") */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --felt:        #e8efea;
    --felt-2:      #145236;
    --felt-line:   rgba(16, 38, 27, .12);
    --on-felt:     #13241b;
    --on-felt-2:   #47564e;
    --header-bg:   rgba(248, 251, 249, .88);
    --wash:        linear-gradient(180deg, rgba(240, 245, 241, .93) 0%, rgba(240, 245, 241, .96) 60%, rgba(236, 242, 238, .98) 100%);
    --footer-bg:   #e1e9e3;
    --hover:       rgba(16, 38, 27, .06);
    --inset:       #ffffff;
    --card:        #ffffff;
    --surface:     #f2f4f1;
    --surface2:    #e6eae5;
    --border:      rgba(16, 38, 27, .12);
    --border-strong: rgba(16, 38, 27, .24);
    --text:        #13241b;
    --muted:       #52615a;
    --accent:      #17734a;
    --accent-bg:   rgba(23, 115, 74, .10);
    --rank-gold:   #8a6200;
    --pill-us:     #1d4ed8;
    --pill-them:   #b91c1c;
    --fill-img:    url('/assets/panel-fill.png');
    --brand-tt:    #e4202c;
    --tt-stroke:   rgba(19, 36, 27, .55);
    --panel-line:  rgba(16, 38, 27, .08);
    --shadow:      0 1px 2px rgba(16, 38, 27, .06), 0 16px 34px -22px rgba(16, 38, 27, .4);
  }
}
:root[data-theme="light"] {
  color-scheme: light;
  --felt:    #e8efea;
  --felt-2:    #145236;
  --felt-line:   rgba(16, 38, 27, .12);
  --on-felt:   #13241b;
  --on-felt-2:   #47564e;
  --header-bg:   rgba(248, 251, 249, .88);
  --wash:    linear-gradient(180deg, rgba(240, 245, 241, .93) 0%, rgba(240, 245, 241, .96) 60%, rgba(236, 242, 238, .98) 100%);
  --footer-bg:   #e1e9e3;
  --hover:     rgba(16, 38, 27, .06);
  --inset:     #ffffff;
  --card:      #ffffff;
  --surface:   #f2f4f1;
  --surface2:  #e6eae5;
  --border:      rgba(16, 38, 27, .12);
  --border-strong: rgba(16, 38, 27, .24);
  --text:        #13241b;
  --muted:       #52615a;
  --accent:      #17734a;
  --accent-bg:   rgba(23, 115, 74, .10);
  --rank-gold:   #8a6200;
  --pill-us:     #1d4ed8;
  --pill-them:   #b91c1c;
  --fill-img:    url('/assets/panel-fill.png');
  --brand-tt:  #e4202c;
  --tt-stroke:   rgba(19, 36, 27, .55);
  --panel-line:  rgba(16, 38, 27, .08);
  --shadow:    0 1px 2px rgba(16, 38, 27, .06), 0 16px 34px -22px rgba(16, 38, 27, .4);
}

html { min-height: 100%; scroll-behavior: smooth; scroll-padding-top: 5rem; }

body {
  min-height: 100%;
  background-color: var(--felt);
  background-image:
    var(--wash),
    url('/assets/felt-tile.jpg');
  background-size: 100% 100%, 384px 384px;
  color: var(--on-felt);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.6;
  overflow-wrap: break-word;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; height: auto; }
a { color: inherit; }

h1, h2, h3 { font-family: var(--display); font-weight: 600; line-height: 1.1; letter-spacing: -.01em; }

/* ── Header ──────────────────────────────────────────────────────────── */

header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  padding: .6rem clamp(1rem, 3vw, 2rem);
  background: var(--header-bg);
  -webkit-backdrop-filter: saturate(140%) blur(12px);
          backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid var(--felt-line);
}

.brand {
  display: flex;
  align-items: center;
  gap: .65rem;
  color: var(--on-felt);
  text-decoration: none;
  flex-shrink: 0;
}
.brand img { width: 40px; height: 40px; display: block; }
.brand-name { font-family: var(--display); font-weight: 700; font-size: 1.45rem; line-height: 1; }
.brand-dot { color: var(--on-felt); }
.brand-tt {
  font-weight: 700;
  color: var(--brand-tt);
  background: linear-gradient(180deg, #ff6a6f 0%, #e4202c 55%, #b5121b 100%);
  -webkit-background-clip: text;
          background-clip: text;
  -webkit-text-fill-color: transparent;
}

.header-right { display: flex; align-items: center; gap: .25rem; }

nav.main { display: flex; align-items: center; gap: .15rem; }
nav.main a {
  color: var(--on-felt-2);
  text-decoration: none;
  font-weight: 600;
  font-size: .95rem;
  padding: .45rem .8rem;
  border-radius: 10px;
  white-space: nowrap;
  transition: color .15s, background .15s;
}
nav.main a:hover { color: var(--on-felt); background: var(--hover); }
nav.main a[aria-current="page"] { color: var(--on-felt); box-shadow: inset 0 -2px 0 var(--gold); border-radius: 0; }

nav.main a.nav-play {
  margin-left: .5rem;
  color: var(--btn-ink);
  background: var(--btn-grad);
  border-radius: 999px;
  padding: .5rem 1.15rem;
  box-shadow: 0 6px 16px -8px rgba(211, 34, 43, .9);
}
nav.main a.nav-play:hover { filter: brightness(1.07); background: var(--btn-grad); }
nav.main a.nav-play[aria-current="page"] { box-shadow: none; border-radius: 999px; }

/* Theme toggle and social icons */
.header-tools {
  display: flex;
  align-items: center;
  gap: .2rem;
  margin-left: .6rem;
  padding-left: .7rem;
  border-left: 1px solid var(--felt-line);
}
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 0;
  background: transparent;
  color: var(--on-felt-2);
  cursor: pointer;
  transition: color .15s, background .15s;
}
.icon-btn:hover { color: var(--on-felt); background: var(--hover); }
.icon-btn svg { width: 20px; height: 20px; display: block; }
.theme-toggle .i-moon { display: none; }
:root[data-theme="light"] .theme-toggle .i-sun { display: none; }
:root[data-theme="light"] .theme-toggle .i-moon { display: block; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .theme-toggle .i-sun { display: none; }
  :root:not([data-theme="dark"]) .theme-toggle .i-moon { display: block; }
}

/* Icon on the right of a button */
.btn .btn-icon { width: 1.25em; height: 1.25em; flex-shrink: 0; margin-right: -.2em; }

.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 42px;
  height: 42px;
  padding: 0 11px;
  background: transparent;
  border: 1px solid var(--felt-line);
  border-radius: 11px;
  cursor: pointer;
}
.nav-toggle span { display: block; height: 2px; width: 100%; background: var(--on-felt); border-radius: 2px; transition: transform .2s, opacity .2s; }
.nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ── Layout ──────────────────────────────────────────────────────────── */

main { display: block; padding: 0 16px; min-height: 60vh; }

.wrap { max-width: 1120px; margin: 0 auto; }
.wrap-narrow { max-width: 860px; margin: 0 auto; }

/* Page title that sits on the felt, above a panel */
.page-head { max-width: 1120px; margin: 0 auto; padding: 3rem 0 1.5rem; }
.page-head.center { text-align: center; }
.page-head h1 { font-size: clamp(2.2rem, 5vw, 3.2rem); color: var(--on-felt); }
.page-head p { color: var(--on-felt-2); font-size: 1.1rem; margin-top: .6rem; max-width: 40rem; }
.page-head.center p { margin-left: auto; margin-right: auto; }

/* ── Panels (card stock on the felt) ─────────────────────────────────── */

/* White card-stock panels carry the app's suit-pattern fill (assets/panel-fill.png).
   "html" raises the specificity so page-level `background: var(--card)` rules keep it. */
html .panel, html .section, html .tut, html .g-sec, html .toc, html .toc-mobile, html .launch-card {
  background-color: var(--card);
  background-image: var(--fill-img);
  background-size: 256px 256px;
}

.panel, .section {
  background: var(--card);
  border: 1px solid var(--panel-line);
  color: var(--text);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel { padding: clamp(1.25rem, 3vw, 2rem); }

.section {
  max-width: 860px;
  margin: 0 auto;
  padding: clamp(1.5rem, 4vw, 2.75rem);
}
.section-wide { max-width: 1120px; }

.section h1 { font-size: clamp(2rem, 4vw, 2.6rem); margin-bottom: 1.1rem; color: var(--text); }
.section h2 { font-size: 1.4rem; margin: 2.2rem 0 .7rem; color: var(--text); }
.section h3 { font-size: 1.1rem; margin: 1.5rem 0 .5rem; color: var(--text); }
.section p { color: var(--muted); margin-bottom: 1rem; max-width: 72ch; }
.section ul, .section ol { color: var(--muted); padding-left: 1.4rem; margin-bottom: 1rem; max-width: 72ch; }
.section li { margin-bottom: .45rem; }
.section strong { color: var(--text); }
.section a:not(.btn) { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }

.section-divider { border: 0; border-top: 1px solid var(--border); margin: 2.2rem 0; }

.last-updated {
  display: inline-block;
  font-size: .82rem;
  color: var(--muted);
  background: var(--surface);
  border-radius: 999px;
  padding: .15rem .75rem;
  margin-bottom: 1.5rem;
}

.acknowledgment {
  margin-top: 3rem;
  padding: 1.5rem;
  background: var(--surface);
  border-left: 4px solid var(--red);
  border-radius: 12px;
}
.acknowledgment hr { border: 0; border-top: 1px solid var(--border); margin-bottom: 1rem; }
.acknowledgment p:last-child { margin-bottom: 0; }

/* ── Buttons ─────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .8rem 1.5rem;
  border: 2px solid transparent;
  border-radius: 999px;
  background: var(--btn-grad);
  color: var(--btn-ink);
  font: inherit;
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 10px 22px -12px rgba(211, 34, 43, .95);
  transition: transform .15s ease, filter .15s, background .15s;
}
.btn:hover { filter: brightness(1.07); transform: translateY(-1px); }
.btn:active { transform: none; }

/* white "card" button on the felt */
.btn-card, .btn-outline {
  background: var(--card);
  border-color: var(--panel-line);
  color: var(--text);
}
.btn-card {
  background: #ffffff;
  color: #13241b;
  box-shadow: 0 10px 22px -14px rgba(0, 0, 0, .8);
}
/* outlined button inside a white panel */
.panel .btn-outline, .section .btn-outline, .lb-actions .btn-outline, .lb-state .btn-outline {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--text);
  box-shadow: none;
}
.panel .btn-outline:hover, .section .btn-outline:hover { background: var(--surface); filter: none; }

.btn-lg { font-size: 1.08rem; padding: 1rem 1.9rem; }
.btn-sm { font-size: .85rem; padding: .45rem .95rem; box-shadow: none; }

a.btn, a.btn:hover { text-decoration: none; }
.section a.btn:not(.btn-outline):not(.btn-card) { color: var(--btn-ink); }

/* ── Store badges ────────────────────────────────────────────────────── */

.store-badges { display: flex; gap: .7rem; flex-wrap: wrap; }
.store-badge { display: inline-flex; border-radius: 10px; transition: transform .15s; }
.store-badge img { height: 46px; width: auto; display: block; }
.store-badge:hover { transform: translateY(-1px); }

/* ── Tag ─────────────────────────────────────────────────────────────── */

.tag {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  font-size: .78rem;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-bg);
  border-radius: 999px;
  padding: .15rem .65rem;
}
.tag.live::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: #1fae5b; box-shadow: 0 0 0 3px rgba(31, 174, 91, .25); }

/* ── Leaderboard switch (players / clans) ────────────────────────────── */

.lb-switch {
  display: flex;
  gap: .25rem;
  width: max-content;
  max-width: 100%;
  margin: 0 auto 1.5rem;
  padding: .25rem;
  background: var(--surface);
  border-radius: 999px;
}
.lb-switch a, .section .lb-switch a {
  color: var(--muted);
  text-decoration: none;
  font-weight: 650;
  font-size: .92rem;
  padding: .45rem 1.15rem;
  border-radius: 999px;
  white-space: nowrap;
}
@media (max-width: 480px) {
  .lb-switch a, .section .lb-switch a { padding: .45rem .8rem; font-size: .86rem; }
}
.lb-switch a:hover, .section .lb-switch a:hover { color: var(--text); }
.lb-switch a[aria-current="page"], .section .lb-switch a[aria-current="page"] {
  color: var(--btn-ink);
  background: var(--felt-2);
}

/* ── Footer ──────────────────────────────────────────────────────────── */

footer {
  margin-top: 5rem;
  padding: 2.5rem clamp(1rem, 3vw, 2rem) 2.8rem;
  border-top: 1px solid var(--felt-line);
  background: var(--footer-bg);
  color: var(--on-felt-2);
  font-size: .9rem;
}
.footer-inner {
  max-width: 1120px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr 1fr;
  gap: 2rem;
}
.footer-brand p { margin-top: .7rem; max-width: 30ch; }
.cc-badge {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  margin-top: 1.1rem;
  color: var(--on-felt);
  font-weight: 700;
  text-decoration: none;
}
.cc-badge img { display: block; width: 50px; height: auto; filter: drop-shadow(0 4px 8px rgba(0, 0, 0, .3)); }
.cc-badge:hover span { text-decoration: underline; }
.cc-powered { font-size: .85rem; margin-top: .5rem !important; }
.footer-col h2 { font-family: var(--font); font-size: .95rem; font-weight: 700; color: var(--on-felt); margin-bottom: .6rem; }
.footer-col ul { list-style: none; display: grid; gap: .35rem; }
.footer-col a { color: var(--on-felt-2); text-decoration: none; }
.footer-col a:hover { color: var(--on-felt); text-decoration: underline; }
.footer-legal {
  max-width: 1120px;
  margin: 2rem auto 0;
  padding-top: 1.2rem;
  border-top: 1px solid var(--felt-line);
  font-size: .82rem;
  color: var(--on-felt-2);
  opacity: .85;
}
.footer-legal a { color: inherit; }

/* ── Language menu ───────────────────────────────────────────────────── */
.lang-pick { position: relative; }
.lang-pick > summary { list-style: none; cursor: pointer; width: auto; padding: 0 .5rem; gap: .3rem; grid-auto-flow: column; font-size: .8rem; font-weight: 800; letter-spacing: .04em; }
.lang-pick > summary::-webkit-details-marker { display: none; }
.lang-pick > summary svg { width: 18px; height: 18px; }
.lang-pick[open] > summary { background: var(--hover); color: var(--on-felt); }
.lang-menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 30; min-width: 170px; list-style: none; margin: 0; padding: .35rem;
  background: var(--card); border: 1px solid var(--border-strong); border-radius: 12px; box-shadow: 0 18px 40px -16px rgba(0, 0, 0, .6);
}
.lang-menu a { display: flex; align-items: center; gap: .65rem; padding: .55rem .7rem; border-radius: 8px; color: var(--text); text-decoration: none; font-weight: 600; font-size: .95rem; }
.lang-menu a b { display: inline-grid; place-items: center; min-width: 2rem; padding: .1rem .3rem; border-radius: 6px; background: var(--surface); color: var(--muted); font-size: .72rem; letter-spacing: .05em; }
.lang-menu a:hover { background: var(--surface); }
.lang-menu a[aria-current="true"] b { background: var(--red); color: #fff; }
@media (max-width: 1280px) { .lang-menu { right: auto; left: 0; } }
@media (max-width: 1360px) { html:not([lang="en"]) .lang-menu { right: auto; left: 0; } }

/* ── Accessibility ───────────────────────────────────────────────────── */

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  background: var(--card);
  color: var(--text);
  font-weight: 700;
  padding: .75rem 1.25rem;
  border-radius: 0 0 10px 0;
  text-decoration: none;
}
.skip-link:focus { left: 0; }

a:focus-visible, button:focus-visible, [tabindex]:focus-visible, summary:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
  border-radius: 8px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

[hidden] { display: none !important; }

/* ── Responsive ──────────────────────────────────────────────────────── */

@media (max-width: 1280px) {
  .nav-toggle { display: flex; }
  .header-right { display: none; width: 100%; padding: .4rem 0 .5rem; }
  .header-right.is-open { display: block; }
  .header-tools { margin: .6rem 0 0; padding: .6rem 0 0; border-left: 0; border-top: 1px solid var(--felt-line); }
  nav.main { flex-direction: column; align-items: stretch; }
  nav.main a { padding: .75rem .9rem; font-size: 1.05rem; }
  nav.main a[aria-current="page"] { box-shadow: inset 3px 0 0 var(--gold); }
  nav.main a.nav-play { margin: .5rem 0 0; text-align: center; }
}

/* Spanish and French menu labels are longer, so the menu folds up sooner. */
@media (max-width: 1360px) {
  html:not([lang="en"]) .nav-toggle { display: flex; }
  html:not([lang="en"]) .header-right { display: none; width: 100%; padding: .4rem 0 .5rem; }
  html:not([lang="en"]) .header-right.is-open { display: block; }
  html:not([lang="en"]) .header-tools { margin: .6rem 0 0; padding: .6rem 0 0; border-left: 0; border-top: 1px solid var(--felt-line); }
  html:not([lang="en"]) nav.main { flex-direction: column; align-items: stretch; }
  html:not([lang="en"]) nav.main a { padding: .75rem .9rem; font-size: 1.05rem; }
  html:not([lang="en"]) nav.main a[aria-current="page"] { box-shadow: inset 3px 0 0 var(--gold); }
  html:not([lang="en"]) nav.main a.nav-play { margin: .5rem 0 0; text-align: center; }
}


@media (max-width: 900px) {
  .footer-inner { grid-template-columns: 1fr 1fr 1fr; }
  .footer-brand { grid-column: 1 / -1; }
}

@media (max-width: 640px) {
  main { padding: 0 12px; }
  .page-head { padding: 2rem .25rem 1.1rem; }
  .section { border-radius: 14px; }
  .store-badge img { height: 42px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

@media print {
  header, footer, .nav-toggle, .skip-link, .store-badges, .lb-switch { display: none !important; }
  body { background: #fff; color: #000; }
  .section, .panel { box-shadow: none; padding: 0; }
}

/* A page that opens straight onto a panel */
main > .section:first-child { margin-top: clamp(2rem, 5vw, 3rem); }
