/* ============================================================================
   1776 CROSSWORD — game styles
   Built on the shared America 250 design tokens (design.css). No new colors
   are invented; everything derives from --c-navy / --accent / --c-red / etc.
   ============================================================================ */

.cw-wrap {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--s-5);
  align-items: start;
}
@media (min-width: 900px) {
  .cw-wrap { grid-template-columns: minmax(280px, 520px) 1fr; }
}

/* --- puzzle picker + toolbar ------------------------------------------- */
.cw-picker {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
  margin-bottom: var(--s-4);
}
.cw-picker .usa-btn.is-active {
  --btn-bg: var(--c-gold);
  --btn-fg: var(--c-navy-deep);
  border-color: var(--accent);
  background: var(--c-gold);
  color: var(--c-navy-deep);
}

.cw-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
  margin-top: var(--s-4);
}

/* --- the active-clue banner -------------------------------------------- */
.cw-activeclue {
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--r-md);
  padding: var(--s-3) var(--s-4);
  font-size: var(--t-sm);
  color: var(--c-cream);
  min-height: 2.6em;
  display: flex;
  align-items: center;
  margin-bottom: var(--s-3);
}

/* --- status line ------------------------------------------------------- */
.cw-status {
  font-size: var(--t-sm);
  color: var(--text-dim);
  min-height: 1.4em;
  margin-top: var(--s-3);
}
.cw-status.is-flash { animation: cwFlash .5s ease; }
@keyframes cwFlash {
  0% { color: var(--c-gold-light); }
  100% { color: var(--text-dim); }
}

/* --- the grid ---------------------------------------------------------- */
.cw-gridwrap { position: relative; }
.cw-grid {
  --cols: 15;
  --rows: 15;
  display: grid;
  grid-template-columns: repeat(var(--cols), 1fr);
  grid-template-rows: repeat(var(--rows), 1fr);
  gap: 2px;
  background: var(--line-soft);
  border: 2px solid var(--accent);
  border-radius: var(--r-sm);
  padding: 2px;
  /* keep it square and never overflow on mobile */
  width: 100%;
  max-width: min(94vw, 540px);
  aspect-ratio: var(--cols) / var(--rows);
  margin-inline: auto;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.cw-block {
  background: transparent;
}

.cw-cell {
  position: relative;
  background: var(--c-cream);
  color: var(--c-ink);
  border-radius: 1px;
  display: grid;
  place-items: center;
  cursor: pointer;
  overflow: hidden;
  transition: background .1s ease, box-shadow .1s ease;
}
.cw-cell::after {
  /* subtle inner stroke so cells read as a grid on cream */
  content: "";
  position: absolute; inset: 0;
  box-shadow: inset 0 0 0 1px rgba(10,35,66,0.12);
  pointer-events: none;
}

.cw-num {
  position: absolute;
  top: 1px; left: 2px;
  font-family: var(--font-sans);
  font-size: clamp(7px, 1.7vw, 11px);
  line-height: 1;
  font-weight: 700;
  color: var(--c-navy);
  opacity: 0.8;
  pointer-events: none;
}
.cw-letter {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: clamp(13px, 3.6vw, 24px);
  line-height: 1;
  color: var(--c-navy-deep);
  text-transform: uppercase;
}

/* highlight states */
.cw-cell.is-active { background: #DCE9FB; }           /* pale federal blue tint */
.cw-cell.is-cursor {
  background: var(--c-gold-light);
  box-shadow: inset 0 0 0 2px var(--c-red);
  z-index: 2;
}
.cw-cell.is-wrong .cw-letter { color: var(--c-red); }
.cw-cell.is-wrong { background: #F7D9DC; }
.cw-cell.is-revealed .cw-letter { color: var(--c-red-deep); }
.cw-cell.is-solved {
  background: #E6F0DC;
}
.cw-cell.is-solved .cw-letter { color: #1f5e2a; }

.cw-grid.is-won { animation: cwWin .6s ease; }
@keyframes cwWin {
  0%, 100% { box-shadow: none; }
  50% { box-shadow: 0 0 0 3px var(--c-gold), var(--shadow-2); }
}

/* hidden input that summons the mobile soft keyboard */
.cw-hidden-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  height: 1px; width: 1px;
  left: 50%; top: 0;
  font-size: 16px; /* avoid iOS zoom */
}

/* --- clue panels ------------------------------------------------------- */
.cw-clues {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--s-4);
}
@media (min-width: 560px) {
  .cw-clues { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 900px) {
  .cw-clues { grid-template-columns: 1fr 1fr; }
}

.cw-cluecol h3 {
  font-size: var(--t-md);
  color: var(--c-gold-light);
  margin-bottom: var(--s-2);
  padding-bottom: var(--s-1);
  border-bottom: 1px solid var(--line);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.cw-cluelist {
  list-style: none;
  margin: 0; padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 42vh;
  overflow: auto;
}
@media (min-width: 900px) { .cw-cluelist { max-height: 60vh; } }

.cw-clue {
  display: flex;
  gap: var(--s-2);
  align-items: baseline;
  padding: 6px 8px;
  border-radius: var(--r-sm);
  font-size: var(--t-sm);
  color: var(--text-dim);
  cursor: pointer;
  min-height: 36px;
  transition: background .1s ease, color .1s ease;
}
.cw-clue:hover { background: rgba(247,243,232,0.06); color: var(--c-cream); }
.cw-clue.is-active {
  background: rgba(201,162,39,0.16);
  color: var(--c-cream);
  box-shadow: inset 3px 0 0 var(--accent);
}
.cw-clue__num {
  font-weight: 700;
  color: var(--accent);
  min-width: 1.6em;
  text-align: right;
  flex: 0 0 auto;
}

/* slightly bigger tap targets on touch */
@media (pointer: coarse) {
  .cw-clue { min-height: 44px; }
}

/* ============================================================================
   LIBERTY ARCADE SKIN — operator-approved assets (Graphics C · Backgrounds B)
   ----------------------------------------------------------------------------
   - board-bg.png (library-study, pkg B) is the fixed board backdrop.
   - logo.png (bg-removed) is the masthead emblem above the title.
   - corner-flourish.png (bg-removed) brackets the four grid corners.
   - the cell material (cream enamel face, navy serif glyphs, gold + brushed-
     steel bevel) is derived from the chosen letter-tile / grid-cell / cursor
     renders, applied as CSS so the flat top-down grid keeps working.
   ============================================================================ */

/* Board backdrop: the colonial study scene, scrimmed for legibility. Fixed so
   it reads as the room behind the whole puzzle, not a tiled texture. */
body {
  background-color: var(--c-navy-deep);
}
.usa-section {
  position: relative;
}
.usa-section::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    linear-gradient(180deg, rgba(8,20,38,0.62), rgba(8,20,38,0.78)),
    url("../assets/bg/board-bg.png") center / cover no-repeat;
  pointer-events: none;
}

/* Masthead emblem (the 1776 / America Liberty Crossword badge) */
.cw-masthead {
  display: flex;
  justify-content: center;
  margin: 0 auto var(--s-2);
}
.cw-masthead img {
  width: clamp(150px, 38vw, 240px);
  height: auto;
  filter: drop-shadow(0 6px 16px rgba(0,0,0,0.55));
  user-select: none;
  -webkit-user-drag: none;
}
/* The badge already carries the wordmark — hide the redundant text H1 but keep
   it for screen readers. The puzzle subtitle still appears in the status line. */
#cwTitle {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

/* Grid wrapper gains a framed brass plinth so the cream cells read against the
   busy backdrop, plus the four eagle corner flourishes. */
.cw-gridwrap {
  position: relative;
  padding: clamp(14px, 3.4vw, 26px);
  border-radius: var(--r-md);
  background:
    linear-gradient(180deg, rgba(15,32,58,0.92), rgba(10,22,42,0.96));
  border: 1px solid rgba(201,162,39,0.45);
  box-shadow:
    0 10px 30px rgba(0,0,0,0.45),
    inset 0 0 0 1px rgba(255,255,255,0.04);
}
.cw-corner {
  position: absolute;
  width: clamp(46px, 11vw, 78px);
  height: auto;
  pointer-events: none;
  z-index: 3;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}
.cw-corner--tl { top: -6px;  left: -6px;  }
.cw-corner--tr { top: -6px;  right: -6px;  transform: scaleX(-1); }
.cw-corner--bl { bottom: -6px; left: -6px; transform: scaleY(-1); }
.cw-corner--br { bottom: -6px; right: -6px; transform: scale(-1, -1); }

/* --- cell material skin (derived from the chosen letter-tile render) ------- */
.cw-grid {
  background: linear-gradient(180deg, #7d8794, #565d68); /* brushed-steel grout */
  border: 3px solid;
  border-image: linear-gradient(135deg, #e8c66a, #9a7b2e 50%, #e8c66a) 1;
  box-shadow:
    0 0 0 1px rgba(10,35,66,0.6),
    inset 0 0 14px rgba(0,0,0,0.4);
}
.cw-cell {
  background:
    linear-gradient(180deg, #fdfbf2, #efe7d2);   /* cream enamel face */
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.9),
    inset 0 -1px 2px rgba(120,100,50,0.18);
}
.cw-cell::after {
  /* thin gold inner keyline echoing the tile's enamel border */
  box-shadow: inset 0 0 0 1px rgba(154,123,46,0.35);
}
.cw-num {
  color: #9a7b2e;            /* engraved gold numeral, like the coin render */
  opacity: 0.95;
  text-shadow: 0 1px 0 rgba(255,255,255,0.6);
}
.cw-letter {
  color: var(--c-navy-deep); /* deep navy serif glyph, as on the enamel tile */
  text-shadow: 0 1px 0 rgba(255,255,255,0.5);
}

/* active word: pale federal-blue enamel */
.cw-cell.is-active {
  background: linear-gradient(180deg, #e4eefb, #cfe0f6);
}
/* cursor: the red + gold bevel from the cursor-highlight render */
.cw-cell.is-cursor {
  background: linear-gradient(180deg, #fff4cf, #ffe79c);
  box-shadow:
    inset 0 0 0 2px #b3171f,
    inset 0 0 0 4px #e8c66a;
  z-index: 2;
}
.cw-cell.is-wrong {
  background: linear-gradient(180deg, #fbdcdf, #f3c2c7);
}
.cw-cell.is-revealed .cw-letter { color: var(--c-red-deep); }
.cw-cell.is-solved {
  background: linear-gradient(180deg, #e9f3dd, #d6e8c2);
}
