/*
 * The board as a physical object.
 *
 * `.game-board` is the printed panel: a dark rail around the edge, a double
 * brass rule printed just inside it, brass corner fittings, the city map
 * visible through a veil, and a paper grain over everything.
 *
 * `.board-zone` is an area printed onto that panel. Zones are recessed (see
 * `--well`) so pieces placed in them read as sitting above the surface.
 */

.geometry-preview.game-screen {
  width: min(112.5rem, calc(100vw - 2rem));
  margin: clamp(0.75rem, 2vw, 1.5rem) auto;
}

.geometry-preview .game-board {
  position: relative;
  width: 100%;
  padding: clamp(0.55rem, 1.1cqi, 1.15rem);
  border: clamp(0.4rem, 0.85cqi, 0.95rem) solid var(--board-rail);
  border-radius: clamp(0.8rem, 1.4cqi, 1.6rem);
  background:
    /* lamplight falling on the middle of the table */
    radial-gradient(115% 85% at 50% 40%, rgba(214, 176, 104, 0.13), transparent 62%),
    /* a veil light enough that the map is actually legible */
    linear-gradient(rgba(11, 18, 13, 0.4), rgba(6, 11, 8, 0.56)),
    url("../assets/images/city-map-bg.png") center / cover no-repeat,
    #0b110d;
  box-shadow:
    /* the printed double rule just inside the rail */
    inset 0 0 0 0.1cqi rgba(180, 148, 84, 0.5),
    inset 0 0 0 0.34cqi rgba(0, 0, 0, 0.45),
    inset 0 0 0 0.42cqi rgba(180, 148, 84, 0.22),
    inset 0 0 3.5cqi 1.2cqi rgba(0, 0, 0, 0.45),
    0 0.15cqi 0 rgba(255, 255, 255, 0.05),
    0 1.6cqi 3.4cqi rgba(0, 0, 0, 0.8);
  container-type: inline-size;
}

/* Paper grain across the whole board, and nothing else. */
.geometry-preview .game-board::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: inherit;
  background: var(--grain) repeat;
  background-size: 15cqi;
  mix-blend-mode: overlay;
  opacity: 0.42;
  pointer-events: none;
}

/* Brass corner fittings, one background layer per corner. */
.geometry-preview .game-board::after {
  content: "";
  position: absolute;
  inset: 0.45cqi;
  z-index: 3;
  background-repeat: no-repeat;
  background-size: 4.6cqi 4.6cqi;
  background-position: left top, right top, left bottom, right bottom;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Cg fill='none' stroke='%23b3924f' stroke-width='1.5' stroke-linecap='round' opacity='.72'%3E%3Cpath d='M3 17V8a5 5 0 0 1 5-5h9'/%3E%3Cpath d='M7 20V9.5a2.5 2.5 0 0 1 2.5-2.5H20' opacity='.45'/%3E%3C/g%3E%3Cpath d='M3 3.4 6.2 3 5.8 6.2z' fill='%23b3924f' opacity='.8'/%3E%3C/svg%3E"),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Cg transform='rotate(90 20 20)'%3E%3Cg fill='none' stroke='%23b3924f' stroke-width='1.5' stroke-linecap='round' opacity='.72'%3E%3Cpath d='M3 17V8a5 5 0 0 1 5-5h9'/%3E%3Cpath d='M7 20V9.5a2.5 2.5 0 0 1 2.5-2.5H20' opacity='.45'/%3E%3C/g%3E%3Cpath d='M3 3.4 6.2 3 5.8 6.2z' fill='%23b3924f' opacity='.8'/%3E%3C/g%3E%3C/svg%3E"),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Cg transform='rotate(270 20 20)'%3E%3Cg fill='none' stroke='%23b3924f' stroke-width='1.5' stroke-linecap='round' opacity='.72'%3E%3Cpath d='M3 17V8a5 5 0 0 1 5-5h9'/%3E%3Cpath d='M7 20V9.5a2.5 2.5 0 0 1 2.5-2.5H20' opacity='.45'/%3E%3C/g%3E%3Cpath d='M3 3.4 6.2 3 5.8 6.2z' fill='%23b3924f' opacity='.8'/%3E%3C/g%3E%3C/svg%3E"),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Cg transform='rotate(180 20 20)'%3E%3Cg fill='none' stroke='%23b3924f' stroke-width='1.5' stroke-linecap='round' opacity='.72'%3E%3Cpath d='M3 17V8a5 5 0 0 1 5-5h9'/%3E%3Cpath d='M7 20V9.5a2.5 2.5 0 0 1 2.5-2.5H20' opacity='.45'/%3E%3C/g%3E%3Cpath d='M3 3.4 6.2 3 5.8 6.2z' fill='%23b3924f' opacity='.8'/%3E%3C/g%3E%3C/svg%3E");
  pointer-events: none;
}

.geometry-preview .board-table {
  position: relative;
  z-index: 1;
  width: 100%;
  aspect-ratio: 1.6 / 1;
  display: grid;
  grid-template-columns: 13fr 57fr 13fr 17fr;
  grid-template-rows: 17fr 66fr 17fr;
  gap: 0.85cqi;
}

/* A printed area on the board: recessed, ruled in brass, grained. */
.geometry-preview .board-zone {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 0.65cqi;
  border: 0;
  border-radius: 0.55cqi;
  /* Slightly translucent, so the printed map ghosts through the plate. */
  background:
    linear-gradient(158deg, rgba(255, 255, 255, 0.05), transparent 44%),
    linear-gradient(rgba(27, 38, 31, 0.7), rgba(15, 22, 17, 0.82));
  box-shadow:
    inset 0 0 0 0.09cqi var(--brass-rule),
    var(--well);
  color: var(--muted);
  text-align: center;
}

.geometry-preview .board-zone::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: inherit;
  background: var(--grain) repeat;
  background-size: 9cqi;
  mix-blend-mode: overlay;
  opacity: 0.3;
  pointer-events: none;
}

/*
 * Lift zone content above the grain overlay painted by ::before.
 *
 * `:not()` matters here: this selector outranks `position: fixed` in
 * modals.css, so without it any modal rendered inside a zone (the action
 * modal is a child of .zone-actions) becomes `position: relative` and is
 * clipped away by that zone's `overflow: hidden`.
 */
.geometry-preview .board-zone > *:not(.modal-scrim):not(.modal-backdrop) {
  position: relative;
  z-index: 1;
}

.geometry-preview .zone-dice { grid-area: 1 / 1; }
.geometry-preview .zone-player-top { grid-area: 1 / 2; }
.geometry-preview .zone-reserve { grid-area: 1 / 3; }
.geometry-preview .zone-tracks { grid-area: 1 / 4; }

.geometry-preview .zone-player-left { grid-area: 2 / 1; }
.geometry-preview .zone-city { grid-area: 2 / 2; }
.geometry-preview .zone-player-right { grid-area: 2 / 3; }
.geometry-preview .zone-actions { grid-area: 2 / 4 / 4 / 5; }

.geometry-preview .zone-events { grid-area: 3 / 1; }
.geometry-preview .zone-player-bottom { grid-area: 3 / 2; }
.geometry-preview .zone-problems { grid-area: 3 / 3; }

/*
 * Deck zones hold a stack of cards rather than printed content, so the board
 * shows through and only a faint outline marks where the stack belongs.
 */
.geometry-preview .zone-events,
.geometry-preview .zone-problems {
  padding: 0.5cqi;
  background: linear-gradient(rgba(10, 16, 12, 0.34), rgba(6, 11, 8, 0.46));
  box-shadow:
    inset 0 0 0 0.08cqi rgba(180, 148, 84, 0.16),
    inset 0 0.1cqi 0.3cqi rgba(0, 0, 0, 0.5);
}

/*
 * The city is the middle of the table: the map is least veiled here, so the
 * problem cards look like they were dealt onto the city itself.
 */
.geometry-preview .zone-city {
  padding: 0;
  background:
    /* lamplight over the old town, then a light veil towards the edges */
    radial-gradient(72% 58% at 50% 44%, rgba(220, 176, 100, 0.11), transparent 72%),
    radial-gradient(92% 72% at 50% 45%, transparent 8%, rgba(6, 11, 8, 0.46) 82%);
  box-shadow:
    inset 0 0 0 0.09cqi rgba(180, 148, 84, 0.3),
    inset 0 0 1.8cqi 0.4cqi rgba(0, 0, 0, 0.42);
}

.geometry-preview .zone-city::before {
  opacity: 0.2;
}

.geometry-preview .zone-actions {
  align-content: start;
  border-radius: 0.7cqi;
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.055), transparent 40%),
    linear-gradient(rgba(24, 36, 28, 0.86), rgba(12, 19, 14, 0.92));
}

/* Station zones carry their own board plate; see stations.css. */
.geometry-preview .station-zone-filled {
  display: block;
  padding: 0;
  overflow: visible;
  background: none;
  box-shadow: none;
}

.geometry-preview .station-zone-filled::before {
  content: none;
}

@media (max-width: 1100px) {
  .geometry-preview.game-screen {
    width: calc(100vw - 0.8rem);
    margin: 0.4rem auto;
  }

  .geometry-preview .game-board {
    padding: 0.4rem;
    border-width: 0.35rem;
  }

  .geometry-preview .board-table {
    gap: 0.7cqi;
  }

  .geometry-preview .game-board::after {
    background-size: 3.4cqi 3.4cqi;
  }
}
