/* ══ Preview (prototype) in the paste-up system (docs/paper-layout-test/) ══
   Cut paper on a grained gesso ground: no borders, 2px radii, hard paste
   shadows, ink for chrome, one vermillion for the primary action (Launch)
   and the host panel mark. Layout rules (grids, carousel) unchanged. */

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

body {
  font-family: 'Nunito', Arial, sans-serif;
  background: #EFE9DC;
  color: #221E1C;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Grain over the gesso, under the paper pieces */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.5;
  background-image:
    radial-gradient(rgba(120,105,80,0.35) 0.5px, transparent 0.6px),
    radial-gradient(rgba(80,70,55,0.22) 0.5px, transparent 0.6px);
  background-size: 4px 4px, 7px 7px;
  background-position: 0 0, 2px 3px;
}

#control-bar {
  background: #FBF7EC;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 20px;
  box-shadow: 0 3px 0 rgba(34,30,28,0.10);
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}

#back-link {
  color: #6E6353;
  text-decoration: none;
  font-size: 0.9em;
  font-weight: 800;
  white-space: nowrap;
}

#back-link:hover {
  color: #221E1C;
}

#control-bar h1 {
  font-family: 'Archivo Black', 'Arial Black', Arial, sans-serif;
  font-size: 0.95em;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #221E1C;
}

.controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.controls label {
  font-size: 0.78em;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #6E6353;
}

/* Inputs sit square with an inset shadow */
#game-select {
  padding: 7px 10px;
  border: none;
  border-radius: 2px;
  background: #FFFDF6;
  box-shadow: inset 2px 2px 0 rgba(34,30,28,0.10), 0 0 0 1px rgba(34,30,28,0.16);
  color: #221E1C;
  font-family: inherit;
  font-weight: 700;
  font-size: 0.9em;
  cursor: pointer;
}

#player-count {
  width: 80px;
  accent-color: #D9481C;
}

#player-count-display {
  font-weight: 800;
  min-width: 1em;
  text-align: center;
}

/* Cut-paper buttons with the two-step snap */
#launch-btn, #reset-btn, #bot-fill-btn, #skip-btn {
  padding: 7px 16px;
  border: none;
  border-radius: 2px;
  box-shadow: 2px 2px 0 rgba(34,30,28,0.18);
  font-family: 'Archivo Black', 'Arial Black', Arial, sans-serif;
  font-size: 0.85em;
  cursor: pointer;
  transition: transform 90ms steps(2, end), box-shadow 90ms steps(2, end);
}

#launch-btn:hover:not(:disabled),
#reset-btn:hover,
#bot-fill-btn:hover,
#skip-btn:hover {
  transform: translate(2px, 2px);
  box-shadow: 0 0 0 rgba(34,30,28,0.18);
}

#launch-btn {
  background: #D9481C;
  color: #FFF6EA;
  transform: rotate(-0.8deg);
}

#launch-btn:hover:not(:disabled) {
  transform: rotate(-0.8deg) translate(2px, 2px);
}

#launch-btn:disabled {
  background: #D8D2C4;
  color: #857A66;
  box-shadow: none;
  transform: none;
  cursor: not-allowed;
}

#bot-fill-btn {
  background: #221E1C;
  color: #FBF7EC;
}

#skip-btn {
  background: #FFFDF6;
  color: #221E1C;
}

#reset-btn {
  background: #FFFDF6;
  color: #221E1C;
}

/* The real-class payoff: preview it here, then host it for real. Sits at
   the far edge, apart from the practice controls, so it reads as the next
   step rather than another knob. */
#host-btn {
  margin-left: auto;
  padding: 7px 16px;
  border: none;
  border-radius: 2px;
  background: #D9481C;
  color: #FFF6EA;
  box-shadow: 2px 2px 0 rgba(34,30,28,0.18);
  font-family: 'Archivo Black', 'Arial Black', Arial, sans-serif;
  font-size: 0.85em;
  white-space: nowrap;
  cursor: pointer;
  transform: rotate(0.6deg);
  transition: transform 90ms steps(2, end), box-shadow 90ms steps(2, end);
}

#host-btn:hover:not(:disabled) {
  transform: rotate(0.6deg) translate(2px, 2px);
  box-shadow: 0 0 0 rgba(34,30,28,0.18);
}

#host-btn:disabled {
  background: #D8D2C4;
  color: #857A66;
  box-shadow: none;
  transform: none;
  cursor: not-allowed;
}

/* View toggle: a scrap holding two chips, the active one flips to ink */
#view-toggle {
  display: flex;
  gap: 2px;
  background: #FFFDF6;
  border: none;
  border-radius: 2px;
  box-shadow: 2px 2px 0 rgba(34,30,28,0.14);
  padding: 3px;
}

/* display:flex above would override the hidden attribute */
#view-toggle[hidden] { display: none; }

.view-btn {
  padding: 5px 12px;
  border: none;
  border-radius: 2px;
  font-family: inherit;
  font-size: 0.85em;
  font-weight: 800;
  cursor: pointer;
  background: transparent;
  color: #6E6353;
}

.view-btn.active {
  background: #221E1C;
  color: #FBF7EC;
}

.view-btn:hover:not(.active) {
  color: #221E1C;
}

/* Carousel fixed overlays — sit above iframes */
.carousel-arrow {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  z-index: 9999;
  width: 52px;
  height: 80px;
  border: none;
  border-radius: 2px;
  background: rgba(34, 30, 28, 0.85);
  color: #FBF7EC;
  font-size: 1.6rem;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, opacity 0.15s;
  backdrop-filter: blur(2px);
}

/* Carousel layout is host on the left half, player on the right half —
   the arrows flank the PLAYER panel (the thing being rotated), so the
   left arrow sits at the 50% seam, not over the host screen. */
.carousel-arrow-left  { left: calc(50% + 6px); }
.carousel-arrow-right { right: 6px; }

/* display:flex above would override the hidden attribute — restore it so
   the carousel chrome only exists in "one at a time" mode. */
.carousel-arrow[hidden],
#carousel-dots[hidden] {
  display: none;
}

.carousel-arrow:hover:not(:disabled) { background: rgba(34, 30, 28, 1); }
.carousel-arrow:disabled { opacity: 0.2; cursor: default; }

#carousel-dots {
  position: fixed;
  bottom: 14px;
  /* Carousel layout is host on the left half, player on the right half —
     center the dots over the PLAYER panel (75% = middle of the right half) */
  left: 75%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  gap: 8px;
  align-items: center;
  /* Dark strip so the dots read against gesso game screens in the iframe */
  background: rgba(34, 30, 28, 0.85);
  border: none;
  border-radius: 2px;
  padding: 8px 14px;
  backdrop-filter: blur(2px);
}

.carousel-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid rgba(251,247,236,0.6);
  background: rgba(251,247,236,0.25);
  cursor: pointer;
  padding: 0;
  transition: background 0.15s, transform 0.15s;
}

.carousel-dot.active {
  background: #FBF7EC;
  border-color: #FBF7EC;
  transform: scale(1.3);
}

.carousel-dot:hover:not(.active) {
  background: rgba(251,247,236,0.5);
}

/* Iframe container */
#iframe-container {
  flex: 1;
  display: grid;
  gap: 6px;
  padding: 6px;
  min-height: 0;
  position: relative;
}

/* Layout: host on left, players stacked on right (1-4 players) */
#iframe-container[data-players="1"] {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr;
}

#iframe-container[data-players="2"] {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
}

#iframe-container[data-players="3"] {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr 1fr;
}

#iframe-container[data-players="4"] {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr 1fr 1fr;
}

/* 5+ players: host on top, players in grid below */
#iframe-container[data-players="5"],
#iframe-container[data-players="6"] {
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: 2fr repeat(2, 1fr);
}

#iframe-container[data-players="7"],
#iframe-container[data-players="8"] {
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: 2fr repeat(2, 1fr);
}

/* Panels are paper pieces: hairline ring + paste shadow, vermillion for host */
.iframe-panel {
  position: relative;
  border-radius: 2px;
  overflow: hidden;
  border: none;
  box-shadow: 2px 2px 0 rgba(34,30,28,0.14), 0 0 0 1px rgba(34,30,28,0.25);
  display: flex;
  flex-direction: column;
}

.host-panel {
  box-shadow: 2px 2px 0 rgba(34,30,28,0.14), 0 0 0 2px #D9481C;
}

/* 1-4 players: host spans all rows on left */
#iframe-container[data-players="1"] .host-panel { grid-row: 1 / -1; }
#iframe-container[data-players="2"] .host-panel { grid-row: 1 / -1; }
#iframe-container[data-players="3"] .host-panel { grid-row: 1 / -1; }
#iframe-container[data-players="4"] .host-panel { grid-row: 1 / -1; }

/* 5-6 players: host spans full width on top row */
#iframe-container[data-players="5"] .host-panel,
#iframe-container[data-players="6"] .host-panel {
  grid-column: 1 / -1;
  grid-row: 1;
}

/* 7-8 players: host spans full width on top row */
#iframe-container[data-players="7"] .host-panel,
#iframe-container[data-players="8"] .host-panel {
  grid-column: 1 / -1;
  grid-row: 1;
}

/* One-at-a-time: whatever the player count, the layout collapses to
   host left + the single visible player right, both full height.
   Without this the grid keeps its N stacked rows and the visible
   player fills only the first one (half height at 2 players). */
#iframe-container[data-view="carousel"] {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr;
}

#iframe-container[data-view="carousel"] .host-panel {
  grid-column: 1;
  grid-row: 1;
}

#iframe-container[data-view="carousel"] .player-panel {
  grid-column: 2;
  grid-row: 1;
}

.panel-label {
  background: #221E1C;
  color: #FBF7EC;
  padding: 4px 10px;
  font-size: 0.75em;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  flex-shrink: 0;
}

.host-panel .panel-label {
  background: #D9481C;
  color: #FFF6EA;
}

.player-panel .panel-label {
  background: #221E1C;
  color: #FBF7EC;
}

.iframe-panel iframe {
  flex: 1;
  width: 100%;
  border: none;
  background: #EFE9DC;
}

/* Pre-launch hint — the stage is never silently blank */
#prelaunch-hint {
  text-align: center;
  color: #6E6353;
  font-size: 1rem;
  font-weight: 700;
  padding: 60px 20px;
  grid-column: 1 / -1;
}
