/* =====================================================================
   GABDICE — FELT TEXTURE
   Adds a woven felt surface to the game's cards and control bar.
   Loaded AFTER gabdice.css so it overrides the original flat fills.

   Two inline SVG layers are used everywhere:
     felt  = 6x6 basket-weave (shadowed threads)
     grain = sparse white speckle (fabric fibre)
   ===================================================================== */

:root {
  --felt-weave: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='6' height='6'%3E%3Crect width='6' height='6' fill='%230e4433'/%3E%3Crect width='3' height='3' fill='%23135440'/%3E%3Crect x='3' y='3' width='3' height='3' fill='%23135440'/%3E%3C/svg%3E");
  --felt-grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32'%3E%3Cg fill='%23ffffff' fill-opacity='0.035'%3E%3Ccircle cx='4' cy='6' r='0.7'/%3E%3Ccircle cx='19' cy='3' r='0.5'/%3E%3Ccircle cx='27' cy='11' r='0.8'/%3E%3Ccircle cx='9' cy='17' r='0.6'/%3E%3Ccircle cx='23' cy='21' r='0.7'/%3E%3Ccircle cx='14' cy='28' r='0.5'/%3E%3Ccircle cx='30' cy='27' r='0.6'/%3E%3Ccircle cx='2' cy='24' r='0.5'/%3E%3C/g%3E%3C/svg%3E");
}

/* ---------------------------------------------------------------------
   1. Surfaces — play cards, round history, control bar
   --------------------------------------------------------------------- */
#gabdice-game .spinner-card,
#gabdice-game .prompt-card,
#gabdice-game .history-card,
#gabdice-game .topbar {
  background-color: var(--felt-deep, #072A20);
  background-image: var(--felt-weave), var(--felt-grain);
  border-color: var(--brass, #C9A227);
  color: var(--ivory, #F5EFE0);
  box-shadow: 5px 5px 0 rgba(0, 0, 0, .42);
}

/* The control bar reads as a raised rail, not a floating card. */
#gabdice-game .topbar {
  box-shadow: 0 3px 0 rgba(0, 0, 0, .4);
}

/* ---------------------------------------------------------------------
   2. Text / icons — dark-on-light defaults must flip for felt
   --------------------------------------------------------------------- */
#gabdice-game .spinner-card .kicker,
#gabdice-game .spinner-card .spinner-heading,
#gabdice-game .prompt-card #prompt-text,
#gabdice-game .prompt-card #prompt-empty,
#gabdice-game .prompt-card .shortcut-hint,
#gabdice-game .prompt-card #game-status,
#gabdice-game .history-card h2,
#gabdice-game .history-card .helper,
#gabdice-game .history-card .kicker,
#gabdice-game .history-card .history-toggle,
#gabdice-game .history-card #progress-count,
#gabdice-game .topbar .game-title,
#gabdice-game .topbar .game-subtitle,
#gabdice-game .how-to-line {
  color: var(--ivory, #F5EFE0);
}

#gabdice-game .spinner-card .icon,
#gabdice-game .history-card .icon {
  color: var(--brass, #C9A227);
}

/* ---------------------------------------------------------------------
   3. Nested light chips keep dark text (paper, yellow, coral fills)
   --------------------------------------------------------------------- */
#gabdice-game .slot-window,
#gabdice-game .prompt-label,
#gabdice-game .round-pill,
#gabdice-game .round-entry,
#gabdice-game .game-button {
  color: var(--ink, #17223b);
}
#gabdice-game .btn-blue {
  color: #fff;
}

/* ---------------------------------------------------------------------
   3b. Primary roll button.
   Typography matches the "HOW TO PLAY" line: DM Sans 700, no tracking,
   and a dark ink label.
   The felt surfaces are dark, so the label is a near-black that keeps
   contrast on the brass fill and the yellow hover fill, while reading
   as black against the lighter card behind it.
   The base .game-button rules translate the button 2px on hover/press,
   which reads as the card shifting with it, so movement is disabled here
   and feedback comes from the fill and shadow instead.
   --------------------------------------------------------------------- */
#gabdice-game .roll-both {
  background: var(--brass, #C9A227);
  color: #111a1c;
  border-color: var(--ink, #17223b);
  box-shadow: 4px 4px 0 rgba(0, 0, 0, .5);
  /* tighter box, label set like the how-to line */
  min-height: 54px;
  padding: 7px 18px;
  font-family: "DM Sans", system-ui, sans-serif;
  font-weight: 700;
  font-size: clamp(1.15rem, 2.1vw, 1.55rem);
  letter-spacing: normal;
  text-transform: none;
  transform: none;
}
#gabdice-game .roll-both:hover:not(:disabled) {
  /* matches the round pill in the control bar */
  background: var(--yellow, #ffd84d);
  color: #111a1c;
  border-color: var(--ink, #17223b);
  box-shadow: 5px 5px 0 rgba(0, 0, 0, .5);
  transform: none;
}
#gabdice-game .roll-both:active:not(:disabled) {
  box-shadow: 2px 2px 0 rgba(0, 0, 0, .5);
  transform: none;
}
#gabdice-game .roll-both:disabled {
  background: var(--brass, #C9A227);
  color: rgba(17, 26, 28, .65);
  border-color: rgba(245, 239, 224, .55);
}

/* Empty-state box: dashed ink is invisible on felt. */
#gabdice-game .empty-rounds {
  border-color: rgba(245, 239, 224, .45);
  color: var(--ivory, #F5EFE0);
}

/* ---------------------------------------------------------------------
   4. Contrast for chrome that sits directly on the felt table
   --------------------------------------------------------------------- */
#gabdice-game .progress-marker {
  border-color: var(--brass, #C9A227);
}
#gabdice-game .slot-window,
#gabdice-game .die-face {
  box-shadow: inset 0 -4px 0 rgba(23, 34, 59, .09), 4px 4px 0 rgba(0, 0, 0, .4);
}

/* ---------------------------------------------------------------------
   5. MOBILE LAYOUT (< 1000px)
   Everything below is scoped to this breakpoint; the desktop three-column
   board is untouched.

   Two things are happening:
   a) gabdice.css hides the Feeling / Situation cards here, which leaves
      the rolled values with no labels. They are restored as compact
      "chips" so the pairing is still readable.
   b) The layout is re-flowed into a 2-column grid so the two dice sit
      together on one row, side by side, instead of each taking a
      full-width slot of their own.

   Grid areas, and :has() is used to target the two flex wrappers, which
   are otherwise identical in the markup.
   --------------------------------------------------------------------- */
@media (max-width: 999px) {

  /* a. lighter weave so text stays crisp */
  #gabdice-game .spinner-card,
  #gabdice-game .prompt-card,
  #gabdice-game .history-card {
    box-shadow: 3px 3px 0 rgba(0, 0, 0, .42);
  }

  /* b. reclaim horizontal space */
  #gabdice-game .gabdice-wrap { padding: 12px 12px 16px; }

  /* --- compact board ---
     Two equal-height columns, each holding its chip and its die, then the
     prompt full width below.

     The die slots live INSIDE the same .flex wrapper as their card, so they
     are not grid items: the wrapper is the grid item. Because the chips have
     different natural heights ("Most surprising" wraps, "Meal" does not), the
     columns would be different heights and the two dice would sit at
     different vertical offsets. Stretching the columns to a common height and
     pushing each die to the bottom with margin-top:auto lines the dice up on
     one shared row. */
  #gabdice-game .gabdice-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas:
      "feeling   situation"
      "prompt    prompt";
    align-items: stretch;
    column-gap: 8px;
    row-gap: 8px;
    margin-top: 12px;
  }
  #gabdice-game .gabdice-grid > .flex:has(.card-feeling),
  #gabdice-game .gabdice-grid > .flex:has(.card-situation) {
    min-width: 0;
    display: flex;
    flex-direction: column;
  }
  #gabdice-game .gabdice-grid > .flex:has(.card-feeling)   { grid-area: feeling; }
  #gabdice-game .gabdice-grid > .flex:has(.card-situation) { grid-area: situation; }
  #gabdice-game .gabdice-grid > .prompt-card               { grid-area: prompt; }

  /* --- dice: both on the shared row --- */
  #gabdice-game .die-slot,
  #gabdice-game .die-face {
    width: 74px;
    height: 74px;
  }
  #gabdice-game .die-slot {
    /* top auto pushes it to the foot of the column; sides auto centre it */
    margin: auto auto 0;
  }
  #gabdice-game .die-grid { gap: 4px; padding: 8px; }

  /* --- minimal value chips (restored from display:none) --- */
  #gabdice-game .spinner-card {
    display: block;
    min-height: 0;
    padding: 8px 10px;
    border-radius: 12px;
  }
  #gabdice-game .spinner-card .spinner-head { align-items: center; gap: 6px; }
  #gabdice-game .spinner-card .kicker { display: none; }
  #gabdice-game .spinner-card .spinner-heading {
    font-size: .92rem; margin: 0; letter-spacing: -.02em;
  }
  #gabdice-game .spinner-card .icon { width: 15px; height: 15px; }
  /* Fixed height so the chip never grows or shrinks as values cycle during a
     roll. 85px fits the longest value ("Most awkward" wraps to two lines)
     without leaving the extra air a taller box had. */
  #gabdice-game .spinner-card .slot-window {
    height: 85px; min-height: 85px; margin: 6px 0 0; padding: 3px 6px;
    box-shadow: inset 0 -3px 0 rgba(23, 34, 59, .09);
  }
  #gabdice-game .spinner-card .slot-result {
    font-size: 1rem; padding: 2px 6px; letter-spacing: -.02em;
    text-align: center;
    /* Keep a single long word on one unbroken line. overflow-wrap:anywhere
       is intentionally avoided: it masks the horizontal overflow that the
       shrinker (fitSlotTexts → checkWidth) keys on, so the font never
       shrank and a word like "Meaningful" broke into "meanin gful". */
    max-width: 100%;
  }

  /* --- prompt card: the visual anchor --- */
  #gabdice-game .prompt-card { padding: 14px 14px 12px; border-radius: 16px; }
  #gabdice-game .prompt-display { min-height: 88px; max-height: 112px; margin-top: 4px; }
  #gabdice-game #prompt-empty { font-size: 1.3rem; }
  #gabdice-game #prompt-text { font-size: clamp(1.25rem, 6vw, 1.7rem); }
  #gabdice-game .roll-both {
    min-height: 48px; font-size: 1.05rem; padding: 6px 14px; margin-top: 6px;
  }
  /* "Press R to roll or shift+R to reset" is a keyboard affordance with no
     meaning on a touch device. */
  #gabdice-game .shortcut-row-hint { display: none; }

  /* --- trimming the tall stuff below the board --- */
  #gabdice-game .how-to-line { font-size: .82rem; margin-top: 12px; line-height: 1.35; }
  #gabdice-game .history-card { margin-top: 12px; padding: 10px 12px; border-radius: 14px; }
  #gabdice-game .history-head h2 { font-size: .98rem; }
  #gabdice-game .history-card .helper { display: none; }
  #gabdice-game .progress-wrap { margin-top: 8px; }
  #gabdice-game .progress-rail { gap: 3px; margin-top: 6px; }
  #gabdice-game .progress-marker { height: 9px; }
  #gabdice-game .history-toggle { margin-top: 8px; min-height: 44px; }

  /* --- tap targets --- */
  .site-header .nav .btn { min-height: 44px; padding: .55rem 1.1rem; }
}

/* ---------------------------------------------------------------------
   6. PHONE CONTROL BAR (<= 700px)
   The board is compact all the way up to 999px, but the topbar has room for
   the three-part row (name left / round pill centre / Reset right) above
   that. Only on true phones do we stack it: name above pill, Reset hidden
   until the game is complete (then shown centred below the pill).
   --------------------------------------------------------------------- */
@media (max-width: 700px) {
  #gabdice-game .topbar {
    padding: 10px 12px; border-radius: 16px; margin-top: 0;
    box-shadow: 3px 3px 0 rgba(0, 0, 0, .42);
  }
  /* The brand mark is now logo artwork in the header, so the control bar's
     copy is hidden here to avoid repeating the same line. */
  #gabdice-game .topbar .game-subtitle { display: none; }
  /* Reset game stays hidden during normal play and is revealed by the JS once
     every round has been played. */
  #gabdice-game .topbar .topbar-controls { display: none; }
  #gabdice-game .topbar.is-complete .topbar-controls { display: flex; justify-content: center; }
  #gabdice-game .topbar .min-w-0 { width: 100%; text-align: center; }
  #gabdice-game .topbar .signed-in-as { margin: 0 0 6px; text-align: center; }
  #gabdice-game .topbar .topbar-row { justify-content: center; }
  #gabdice-game .round-pill {
    min-height: 40px;
    display: inline-flex; align-items: center; justify-content: center;
    padding: 8px 14px;
  }
}
