/* ── Reset & base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #303234;
  --surface:     #3a3c3f;
  --border:      #4b4e51;
  --accent:      #AE0D39;
  --accent-dim:  #7a0928;
  --text:        #f0f1f2;
  --text-muted:  #a8abaf;
  --seat-avail:  #4caf82;
  --seat-sel:    #AE0D39;
  --seat-unavail:#6b3333;
  --tab-h:       48px;
  --header-h:    52px;
  --panel-w:     320px;
  --radius:      6px;
  --transition:  200ms ease;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, sans-serif;
  font-size: 14px;
  overflow: hidden;
}

body {
  display: flex;
  flex-direction: column;
}

/* ── Utility ── */
.hidden { display: none !important; }

/* ── Tab bar ── */
.section-tabs {
  display: flex;
  align-items: stretch;
  flex-wrap: wrap;
  min-height: var(--tab-h);
  flex-shrink: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.tab-btn {
  flex-shrink: 0;
  padding: 14px 20px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: .04em;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color var(--transition), border-color var(--transition);
  white-space: nowrap;
}
.tab-btn:hover  { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ── Viewport & screens ── */
.viewport {
  position: relative;
  width: 100%;
  flex: 1;              /* fills whatever the tab bar doesn't use */
  min-height: 0;
  overflow: hidden;
}

.screen {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}
.screen.active {
  opacity: 1;
  pointer-events: auto;
}

/* ── Overview ── */
.overview-container {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

#overview-canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* ── Shared hotspot SVG layer ── */
.hotspot-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;   /* individual elements opt-in */
  overflow: visible;
}

/* Overview section polygons */
.section-region {
  fill: rgba(174,13,57,.15);
  stroke: var(--accent);
  stroke-width: 1.5;
  cursor: pointer;
  pointer-events: all;
  transition: fill var(--transition);
}
.section-region:hover { fill: rgba(174,13,57,.35); }
.section-region:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.section-label,
.static-label {
  fill: #fff;
  /* font-size set per-render in overview.js so labels scale with the map */
  font-family: "Century Gothic", "CenturyGothic", "Questrial", sans-serif;
  font-weight: 300;
  text-shadow: 0 1px 4px #000;
  pointer-events: none;
}

/* ── Section screen ── */
.section-header {
  display: flex;
  align-items: center;
  gap: 16px;
  height: var(--header-h);
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.back-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition);
  flex-shrink: 0;
}
.back-btn:hover { color: var(--text); border-color: var(--text-muted); }

.section-title {
  font-size: 16px;
  font-weight: 600;
  flex: 1;
}

.section-capacity {
  font-size: 12px;
  color: var(--text-muted);
  flex-shrink: 0;
}

#section-screen {
  display: flex;
  flex-direction: column;
}

.section-body {
  flex: 1;
  display: flex;
  overflow: hidden;
  position: relative;
}

/* ── Tile viewport (pan + zoom target) ── */
.tile-viewport {
  flex: 1;
  position: relative;
  overflow: hidden;
  cursor: grab;
  background: #000;
  touch-action: none;
}
.tile-viewport.panning { cursor: grabbing; }

#tile-canvas {
  position: absolute;
  top: 0;
  left: 0;
  /* transform set by JS — do NOT set width/height here */
  image-rendering: pixelated;
}

/* ── Seat markers (circle + label groups inside #seat-svg) ──
   Markers live in a group whose transform tracks pan/zoom; radius and
   font-size are counter-scaled via --seat-inv-scale (set per-frame in
   seats.js) so seats stay a constant size on screen at any zoom level. */
#seat-svg {
  --seat-base-r:  14px;
  --seat-base-fs: 11px;
}

.seat-marker {
  cursor: pointer;
  pointer-events: all;
}

.seat-marker circle {
  r: calc(var(--seat-base-r) * var(--seat-size-f, 1) * var(--seat-inv-scale, 1));
  fill: #fff;
  transition: fill var(--transition);
}

.seat-marker text {
  fill: var(--accent);
  font-family: "Century Gothic", "CenturyGothic", "Questrial", sans-serif;
  font-size: calc(var(--seat-base-fs) * var(--seat-size-f, 1) * var(--seat-inv-scale, 1));
  font-weight: 700;
  opacity: var(--seat-label-o, 1);   /* density-based fade, set in seats.js */
  pointer-events: none;
  transition: fill var(--transition);
}

.seat-marker:hover circle,
.seat-marker:focus-visible circle,
.seat-marker.selected circle { fill: var(--accent); }

.seat-marker:hover text,
.seat-marker:focus-visible text,
.seat-marker.selected text   { fill: #fff; }

.seat-marker.unavailable circle { fill: var(--seat-unavail); }
.seat-marker.unavailable        { cursor: not-allowed; }

/* ── Seat detail popup (anchored above the clicked seat) ──
   Light card on a dark map; tokens here are popup-scoped so the rest of
   the UI keeps the charcoal theme. */
.seat-popup {
  --popup-bg:     #fff;
  --popup-line:   rgba(0,0,0,.10);
  --popup-muted:  #6b6f76;

  position: absolute;
  width: min(500px, calc(100vw - 24px));
  transform: translate(-50%, -100%);   /* anchor point = bottom centre */
  background: var(--popup-bg);
  border: 1px solid var(--popup-line);
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0,0,0,.20);
  z-index: 30;
  /* Transparent to pointers so a drag started over the popup still pans
     the map underneath; the close button opts back in below. */
  pointer-events: none;
}

.seat-popup-arrow {
  position: absolute;
  left: 50%;
  bottom: -10px;
  width: 19px;
  height: 19px;
  transform: translateX(-50%) rotate(45deg);
  background: var(--popup-bg);
  border-right: 1px solid var(--popup-line);
  border-bottom: 1px solid var(--popup-line);
  border-bottom-right-radius: 3px;
}

/* Optically matched to the title rather than numerically: the × glyph has
   far less ink than capitals at the same font-size, so it runs oversized —
   25px puts its ink a shade above the title's 11px caps. `top` is set so
   the two ink centres line up (both 23px from the popup's top edge). */
.close-popup {
  position: absolute;
  top: 5px;
  right: 6px;
  background: transparent;
  border: none;
  color: var(--accent);
  font-family: "Century Gothic", "CenturyGothic", "Questrial", sans-serif;
  font-size: 25px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: var(--radius);
  transition: color var(--transition), background var(--transition);
  z-index: 1;
  pointer-events: auto;   /* the one part of the popup that takes clicks */
}
.close-popup:hover,
.close-popup:focus-visible {
  background: var(--accent);
  color: #fff;
}

.seat-popup-content {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.seat-popup-content h2 {
  font-family: "Century Gothic", "CenturyGothic", "Questrial", sans-serif;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;          /* shared with .close-popup so they align */
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--accent);
  padding-right: 28px;       /* clears the close button */
}
.seat-popup-content p  { font-size: 12px; color: var(--popup-muted); line-height: 1.5; }

.view-from-seat {
  width: 100%;
  height: auto;        /* show the whole render, whatever its aspect ratio */
  max-height: 46vh;    /* but never let a tall image push the popup off-screen */
  background: #000;
  border-radius: var(--radius);
  object-fit: contain;
}

/* ── Zoom controls ── */
.zoom-controls {
  position: absolute;
  bottom: 16px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 10;
}

.zoom-btn {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
}
.zoom-btn:hover { background: var(--border); }

/* ── Mobile ── */
@media (max-width: 640px), (pointer: coarse) {
  /* Bigger touch targets */
  .tab-btn   { padding: 12px 14px; font-size: 14px; }
  .zoom-btn  { width: 44px; height: 44px; font-size: 22px; }
  .back-btn  { padding: 10px 14px; }

  /* Larger seat hit area on touch */
  #seat-svg { --seat-base-r: 16px; --seat-base-fs: 12px; }

  /* Slightly narrower popup so it fits small screens */
  .seat-popup { width: min(460px, calc(100vw - 12px)); }

  .section-header { padding: 0 10px; gap: 10px; }
  .section-title  { font-size: 15px; }
}

/* Surfaces problems that would otherwise look identical to "not built yet" */
.section-banner {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  max-width: min(560px, calc(100% - 24px));
  padding: 10px 14px;
  background: #4a1220;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  color: #ffd9e1;
  font-size: 12px;
  line-height: 1.45;
  z-index: 25;
  pointer-events: none;
}
