/* ---------------------------------------------------------------------------
   bingbongblitz.com -- shared shell.

   Visual direction: Pennsylvania Dutch hex-sign folk art -- milk paint on barn
   wood. Chosen because the flagship game (Dutch Blitz) is a Pennsylvania Dutch
   game whose own iconography is rosettes and tulips, so the motif unifies four
   unrelated games without being arbitrary.
--------------------------------------------------------------------------- */

:root {
  --ground:      #1b1410;  /* dark walnut, warm-biased near-black */
  --ground-lift: #241b15;  /* plaque face */
  --ground-edge: #3a2c22;  /* carved edge */
  --ink:         #f5ead8;  /* milk paint */
  --ink-soft:    #d9c9b0;
  --muted:       #a8927a;  /* aged linen -- hue-biased toward the ground */
  --shadow:      0 18px 40px -22px rgb(0 0 0 / 0.85);

  --blitz:      #e23a2e;   /* barn red */
  --guesswhere: #4ea883;   /* field green */
  --trio:       #7d84e0;   /* indigo */
  --dabashi:    #c9a227;   /* brass */
  --antipodle:  #cf6a34;   /* rust -- the far side of the earth, seen through it */

  /* Account green. Tracks --guesswhere, since accounts come from that game, but
     it is tuned for CONTRAST rather than for sitting on a plaque: it serves as
     text on the page ground AND as a button fill behind --ground text, and one
     hex can't pass both at both themes. --guesswhere's light value (#2f7d5e)
     measured 4.02 against the paper -- under AA -- which is why this exists
     rather than just reusing it. */
  --go:         #4ea883;

  --measure: 62ch;
  --radius: 14px;
}

@media (prefers-color-scheme: light) {
  :root {
    --ground:      #efe6d6;
    --ground-lift: #f8f2e6;
    --ground-edge: #d9c9ad;
    --ink:         #2a1f17;
    --ink-soft:    #4a3a2c;
    --muted:       #6b5940;
    --shadow:      0 18px 38px -24px rgb(74 52 30 / 0.5);

    --blitz:      #c22a20;
    --guesswhere: #2f7d5e;
    --trio:       #4a51b8;
    --dabashi:    #8f7212;
    --antipodle:  #9c4a1d;
    --go:         #24614a;
  }
}

/* The viewer's own toggle stamps the root and must win over the media query
   in both directions, so both themes are restated here. */
:root[data-theme="light"] {
  --ground:      #efe6d6;
  --ground-lift: #f8f2e6;
  --ground-edge: #d9c9ad;
  --ink:         #2a1f17;
  --ink-soft:    #4a3a2c;
  --muted:       #6b5940;
  --shadow:      0 18px 38px -24px rgb(74 52 30 / 0.5);

  --blitz:      #c22a20;
  --guesswhere: #2f7d5e;
  --trio:       #4a51b8;
  --dabashi:    #8f7212;
  --antipodle:  #9c4a1d;
  --go:         #24614a;
}

:root[data-theme="dark"] {
  --ground:      #1b1410;
  --ground-lift: #241b15;
  --ground-edge: #3a2c22;
  --ink:         #f5ead8;
  --ink-soft:    #d9c9b0;
  --muted:       #a8927a;
  --shadow:      0 18px 40px -22px rgb(0 0 0 / 0.85);

  --blitz:      #e23a2e;
  --guesswhere: #4ea883;
  --trio:       #7d84e0;
  --dabashi:    #c9a227;
  --antipodle:  #cf6a34;
  --go:         #4ea883;
}

* { box-sizing: border-box; }

/* Form controls do NOT inherit font-family from their ancestors -- browsers
   hand them a UA default, which on Windows is Arial. This page had no controls
   at all until the account bar, so nothing here caught it; the same omission
   silently rendered every button and input on the Blitz lobby in Arial for
   months. Set it once, before any control exists to be caught out. */
button, input, select, textarea { font: inherit; color: inherit; }

body {
  margin: 0;
  min-height: 100vh;
  padding: clamp(1.5rem, 5vw, 3.5rem) 1.25rem clamp(2.5rem, 6vw, 4rem);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(2rem, 5vw, 3rem);

  background:
    radial-gradient(120% 80% at 50% -10%, color-mix(in srgb, var(--ground-edge) 55%, transparent), transparent 70%),
    var(--ground);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 1rem;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* --- masthead ----------------------------------------------------------- */

.masthead {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
  text-align: center;
}

.masthead__mark { width: 58px; height: 58px; }

.masthead__title {
  margin: 0;
  font-family: Georgia, "Bookman Old Style", "Times New Roman", serif;
  font-weight: 700;
  font-size: clamp(2.1rem, 6vw, 3.25rem);
  letter-spacing: -0.015em;
  line-height: 1.05;
  text-wrap: balance;
}

/* --- the account bar ----------------------------------------------------- */

/* One account covers every game here, and Guesswhere owns it -- signing in on
   this page signs you in everywhere, because its session cookie is scoped to
   the whole domain. Hence the green: it is literally Guesswhere's accent.

   It sits as the masthead's third element rather than floating in a corner.
   The composition is a centered folk sign; a corner widget would fight it. */
.account {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.5rem 0.75rem;
  min-height: 2.2rem;
  color: var(--muted);
  font-size: 0.9rem;
}

/* `hidden` is a UA `display: none`, which the rule above would otherwise beat.
   The bar starts hidden so a signed-in visitor never sees a signed-out state
   flash past on load -- that reads as having been logged out. */
.account[hidden] { display: none; }

.account__who { color: var(--ink); }
.account__who b { font-weight: 600; }

/* --- shared controls ----------------------------------------------------- */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.95rem;
  border: 1px solid var(--ground-edge);
  border-radius: 999px;
  background: none;
  color: var(--ink-soft);
  font-size: 0.88rem;
  cursor: pointer;
  transition: border-color 200ms ease, color 200ms ease;
}

.pill:hover, .pill:focus-visible { border-color: var(--muted); color: var(--ink); }
.pill:focus-visible { outline: 2px solid var(--muted); outline-offset: 3px; }
.pill:disabled { opacity: 0.5; cursor: default; }

.pill--go {
  border-color: color-mix(in srgb, var(--go) 55%, transparent);
  color: var(--go);
}
.pill--go:hover, .pill--go:focus-visible {
  border-color: var(--go);
  background: color-mix(in srgb, var(--go) 12%, transparent);
  color: var(--go);
}

.linkbtn {
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 0.86rem;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: color-mix(in srgb, var(--go) 50%, transparent);
  cursor: pointer;
  transition: color 200ms ease;
}
.linkbtn:hover, .linkbtn:focus-visible { color: var(--ink); }

/* --- the sign-in dialog -------------------------------------------------- */

/* A native <dialog>: Esc, focus trapping and the backdrop come free, which is
   the whole reason to use one on a page with no framework and no build step. */
.authbox {
  width: min(100% - 2rem, 26rem);
  padding: clamp(1.4rem, 4vw, 1.9rem);
  border: 1px solid var(--ground-edge);
  border-radius: var(--radius);
  background: var(--ground-lift);
  box-shadow: var(--shadow);
  color: var(--ink);
}

.authbox::backdrop { background: rgb(0 0 0 / 0.62); }

.authbox__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.1rem;
}

.authbox__title {
  margin: 0;
  font-family: Georgia, "Bookman Old Style", "Times New Roman", serif;
  font-size: 1.5rem;
  line-height: 1.15;
}

.authbox__close {
  flex: 0 0 auto;
  width: 1.9rem;
  height: 1.9rem;
  padding: 0;
  border: 1px solid var(--ground-edge);
  border-radius: 999px;
  background: none;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}
.authbox__close:hover { border-color: var(--muted); color: var(--ink); }

.authbox__form { display: flex; flex-direction: column; gap: 0.7rem; }

.field {
  width: 100%;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--ground-edge);
  border-radius: 8px;
  background: color-mix(in srgb, var(--ground) 55%, var(--ground-lift));
  color: var(--ink);
  font-size: 0.98rem;
}
.field::placeholder { color: color-mix(in srgb, var(--muted) 80%, transparent); }
.field:focus { outline: 2px solid var(--go); outline-offset: 1px; border-color: transparent; }

.cta {
  margin-top: 0.35rem;
  padding: 0.7rem 1.2rem;
  border: 0;
  border-radius: 8px;
  background: var(--go);
  color: var(--ground);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: filter 160ms ease;
}
.cta:hover:not(:disabled) { filter: brightness(1.1); }
.cta:disabled { opacity: 0.55; cursor: default; }

.authbox__hint { margin: 0; color: var(--muted); font-size: 0.8rem; line-height: 1.5; }

.authbox__note {
  margin: 0.9rem 0 0;
  padding: 0.55rem 0.8rem;
  border: 1px solid;
  border-radius: 8px;
  font-size: 0.88rem;
}
.authbox__note--bad  { border-color: color-mix(in srgb, var(--blitz) 45%, transparent);      background: color-mix(in srgb, var(--blitz) 12%, transparent);      color: var(--blitz); }
.authbox__note--good { border-color: color-mix(in srgb, var(--go) 45%, transparent); background: color-mix(in srgb, var(--go) 12%, transparent); color: var(--go); }

.authbox__switch {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.1rem;
  margin-top: 1.15rem;
}

/* --- the shelf of games -------------------------------------------------- */

.shelf {
  width: min(100%, 62rem);
  display: grid;
  gap: clamp(0.85rem, 2vw, 1.15rem);
  grid-template-columns: 1fr;
  list-style: none;
  margin: 0;
  padding: 0;
}

@media (min-width: 56rem) {
  .shelf { grid-template-columns: repeat(2, 1fr); }
}

.plaque {
  --accent: var(--muted);

  position: relative;
  display: flex;
  align-items: center;
  gap: clamp(0.9rem, 2.5vw, 1.4rem);
  padding: clamp(1rem, 2.5vw, 1.4rem);
  min-height: 7.5rem;

  border: 1px solid var(--ground-edge);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--accent) 7%, var(--ground-lift)), var(--ground-lift));
  box-shadow: var(--shadow);

  color: inherit;
  text-decoration: none;
  transition: transform 220ms ease, border-color 220ms ease, box-shadow 220ms ease;
}

.plaque__art { flex: 0 0 auto; width: clamp(64px, 15vw, 84px); height: clamp(64px, 15vw, 84px); }

.plaque__body { display: flex; flex-direction: column; gap: 0.28rem; min-width: 0; }

.plaque__name {
  margin: 0;
  font-family: Georgia, "Bookman Old Style", "Times New Roman", serif;
  font-size: clamp(1.3rem, 2.6vw, 1.6rem);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.15;
}

.plaque__blurb { margin: 0; color: var(--muted); font-size: 0.94rem; }

.plaque__tag {
  align-self: flex-start;
  margin-top: 0.15rem;
  padding: 0.16rem 0.5rem;
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  border-radius: 999px;
  color: var(--accent);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

/* Interactive plaques announce themselves; the unreleased one does not. */
.plaque--live { --accent-hover: var(--accent); }

.plaque--live:hover,
.plaque--live:focus-visible {
  transform: translateY(-3px);
  border-color: color-mix(in srgb, var(--accent) 60%, var(--ground-edge));
  box-shadow: var(--shadow), 0 0 0 1px color-mix(in srgb, var(--accent) 30%, transparent);
}

.plaque--live:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* The rosette's outer ring turns a few degrees under the cursor -- one
   orchestrated micro-interaction rather than scattered effects. */
.plaque__art .ring { transform-origin: 50% 50%; transition: transform 500ms cubic-bezier(0.22, 1, 0.36, 1); }
.plaque--live:hover .plaque__art .ring,
.plaque--live:focus-visible .plaque__art .ring { transform: rotate(22.5deg); }

.plaque--soon { opacity: 0.66; cursor: default; }

.plaque__go {
  margin-left: auto;
  flex: 0 0 auto;
  color: var(--accent);
  font-size: 1.3rem;
  line-height: 1;
  opacity: 0;
  transform: translateX(-6px);
  transition: opacity 220ms ease, transform 220ms ease;
}

.plaque--live:hover .plaque__go,
.plaque--live:focus-visible .plaque__go { opacity: 1; transform: translateX(0); }

/* Load sequence: the shelf fills in top to bottom, once. */
@media (prefers-reduced-motion: no-preference) {
  .plaque { animation: rise 520ms cubic-bezier(0.22, 1, 0.36, 1) backwards; }
  .shelf > :nth-child(1) .plaque { animation-delay: 60ms; }
  .shelf > :nth-child(2) .plaque { animation-delay: 130ms; }
  .shelf > :nth-child(3) .plaque { animation-delay: 200ms; }
  .shelf > :nth-child(4) .plaque { animation-delay: 270ms; }
  .shelf > :nth-child(5) .plaque { animation-delay: 340ms; }
}

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* --- interior pages ------------------------------------------------------ */

.panel {
  width: min(100%, 34rem);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.1rem;
  padding: clamp(1.75rem, 5vw, 2.75rem);
  border: 1px solid var(--ground-edge);
  border-radius: var(--radius);
  background: var(--ground-lift);
  box-shadow: var(--shadow);
  text-align: center;
}

.panel__art { width: clamp(96px, 26vw, 132px); height: clamp(96px, 26vw, 132px); }

.panel__title {
  margin: 0;
  font-family: Georgia, "Bookman Old Style", "Times New Roman", serif;
  font-size: clamp(1.6rem, 4.5vw, 2.1rem);
  line-height: 1.15;
  text-wrap: balance;
}

.panel__text { margin: 0; max-width: var(--measure); color: var(--muted); text-wrap: pretty; }

.backlink {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.55rem 1.1rem;
  border: 1px solid var(--ground-edge);
  border-radius: 999px;
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 0.92rem;
  transition: border-color 200ms ease, color 200ms ease;
}

.backlink:hover, .backlink:focus-visible { border-color: var(--muted); color: var(--ink); }
.backlink:focus-visible { outline: 2px solid var(--muted); outline-offset: 3px; }

.colophon { color: var(--muted); font-size: 0.82rem; letter-spacing: 0.06em; text-transform: uppercase; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
