/* =============================================================
   board.css — Split-flap departure board styles
   Arrive Chicago — Phase 2: Board Renderer
   ============================================================= */

/* Google Fonts — Departure Mono for that authentic station board feel */
@import url('https://fonts.googleapis.com/css2?family=Departure+Mono&display=swap');

/* =============================================================
   CSS CUSTOM PROPERTIES
   ============================================================= */
:root {
  --board-bg: #1a1a1a;
  --board-border: #333;
  --board-cell-bg: #1a1a1a;
  --board-text: #fff;
  --board-split: #000;
  --board-header-color: #aaa;
  --flip-duration: 100ms;
}

/* =============================================================
   BOARD SECTION — outer wrapper on the page
   ============================================================= */
.board-section {
  width: 100%;
  background: #111;
  padding: 24px 16px 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: background-color 500ms ease;
}

/* =============================================================
   STATION NAME HEADER
   ============================================================= */
.board-header {
  font-family: 'Departure Mono', 'Share Tech Mono', 'Courier New', monospace;
  font-size: clamp(10px, 2vw, 14px);
  color: var(--board-header-color);
  text-transform: uppercase;
  letter-spacing: 0.25em;
  margin-bottom: 12px;
  text-align: center;
}

/* =============================================================
   BOARD HOUSING — dark metallic panel
   ============================================================= */
.board {
  font-size: clamp(12px, 2.8vw, 18px);
  background: var(--board-bg);
  border: 2px solid var(--board-border);
  border-radius: 8px;
  padding: 12px 16px;
  box-shadow: inset 0 0 15px rgba(0, 0, 0, 0.5);
  /* Ready for line-color glow in Plan 03 */
  transition: box-shadow 500ms ease;
  max-width: 700px;
  width: 100%;
}

/* Loading state — board not yet populated */
.board--loading .flap-cell {
  animation: board-pulse 1.5s ease-in-out infinite;
}

@keyframes board-pulse {
  0%,  100% { opacity: 0.4; }
  50%        { opacity: 0.8; }
}

/* =============================================================
   BOARD BODY — horizontal layout of the three zones
   ============================================================= */
.board-body {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  flex-wrap: nowrap;
}

/* =============================================================
   ZONE SEPARATORS — bullet dots between zones
   ============================================================= */
.zone-sep {
  font-family: 'Departure Mono', 'Share Tech Mono', 'Courier New', monospace;
  color: #555;
  font-size: 0.8em;
  flex-shrink: 0;
  line-height: 1;
  user-select: none;
}

/* =============================================================
   BOARD ZONES — flex rows of flap cells
   ============================================================= */
.board-zone {
  display: flex;
  gap: 1px;
  flex-shrink: 0;
}

/* Fixed widths defined by character count (2ch each + 2px gap) */
/* Each zone contains N flap cells each 2ch wide                 */

/* =============================================================
   FLAP CELL — individual character tile
   ============================================================= */
.flap-cell {
  position: relative;
  width: 1.1ch;
  height: 2em;
  perspective: 400px;
  background: var(--board-cell-bg);
  border-radius: 2px;
  overflow: hidden;
  flex-shrink: 0;
}

/* =============================================================
   FLAP HALVES — top and bottom of each character tile
   ============================================================= */
.flap-top,
.flap-bottom {
  position: absolute;
  left: 0;
  width: 100%;
  height: 50%;
  overflow: hidden;
  background: var(--board-cell-bg);
  color: var(--board-text);
  font-family: 'Departure Mono', 'Share Tech Mono', 'Courier New', monospace;
  font-size: 1em;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.flap-top {
  top: 0;
  transform-origin: bottom center;
}

.flap-bottom {
  bottom: 0;
  transform-origin: top center;
}

/* Both halves render the same character at the same absolute position.
   The 50%-height container + overflow:hidden clips the appropriate half.
   line-height matches full cell height so the character is centered. */
.flap-top span,
.flap-bottom span {
  display: block;
  text-align: center;
  line-height: 2em; /* must match .flap-cell height */
}

/* Shift bottom span up by container height so the bottom half of the
   character aligns with this container's visible area */
.flap-bottom span {
  margin-top: -1em; /* = negative 50% of cell height */
}

/* =============================================================
   SPLIT LINE — LOCKED DECISION
   Visible horizontal split across each cell middle with shadow
   ============================================================= */
.flap-split {
  position: absolute;
  top: 50%;
  left: 0;
  width: 100%;
  height: 2px;
  background: var(--board-split);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
  z-index: 10;
  pointer-events: none;
}

/* =============================================================
   FLIP ANIMATION KEYFRAMES — LOCKED DECISIONS
   200ms total per character flip (100ms out + 100ms in)
   CSS 3D rotateX for authentic Solari appearance
   ============================================================= */
@keyframes flip-out {
  from { transform: rotateX(0deg); }
  to   { transform: rotateX(-90deg); }
}

@keyframes flip-in {
  from { transform: rotateX(90deg); }
  to   { transform: rotateX(0deg); }
}

/* Top half folds away */
.flapping-out .flap-top {
  animation: flip-out var(--flip-duration) ease-in forwards;
}

/* Bottom half reveals the new character */
.flapping-in .flap-bottom {
  animation: flip-in var(--flip-duration) ease-out forwards;
}

/* =============================================================
   SEARCH BAR — always visible below the board
   ============================================================= */
.search-bar-container {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 700px;
  width: 100%;
  margin: 12px auto 0;
  padding: 0 16px;
  box-sizing: border-box;
}

.search-bar-input {
  flex: 1;
  padding: 10px 14px;
  background: #222;
  border: 1px solid #444;
  border-radius: 6px;
  color: #aaa;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  cursor: pointer;
  outline: none;
}
.search-bar-input:focus {
  border-color: #666;
}

.search-reset-btn {
  background: #333;
  border: 1px solid #555;
  border-radius: 6px;
  color: #ccc;
  font-size: 18px;
  padding: 8px 12px;
  cursor: pointer;
  transition: background 200ms;
  flex-shrink: 0;
}
.search-reset-btn:hover {
  background: #444;
}

/* =============================================================
   FULL-SCREEN SEARCH MODAL
   ============================================================= */
.search-modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.95);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  padding: 20px;
  box-sizing: border-box;
}

.search-modal-header {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
}

.search-modal-input {
  flex: 1;
  padding: 14px 16px;
  background: #1a1a1a;
  border: 2px solid #444;
  border-radius: 8px;
  color: #fff;
  font-size: 16px;
  font-family: 'Inter', sans-serif;
  outline: none;
}
.search-modal-input:focus {
  border-color: #00a1de;
}

.search-modal-close {
  background: none;
  border: none;
  color: #999;
  font-size: 28px;
  cursor: pointer;
  padding: 8px;
  flex-shrink: 0;
}

.search-results {
  list-style: none;
  overflow-y: auto;
  flex: 1;
  margin: 0;
  padding: 0;
}

.search-result-item {
  padding: 14px 16px;
  border-bottom: 1px solid #222;
  color: #ddd;
  font-size: 15px;
  cursor: pointer;
  transition: background 150ms;
}
.search-result-item:hover {
  background: #222;
}
.search-result-item .stop-name {
  font-weight: 600;
}
.search-result-item .stop-detail {
  color: #888;
  font-size: 13px;
  margin-top: 2px;
}

/* =============================================================
   SAFETY ACTION BUTTONS — below the departure board
   ============================================================= */
.safety-actions {
  display: flex;
  gap: 10px;
  max-width: 700px;
  width: 100%;
  margin: 14px auto 0;
  padding: 0 16px;
  box-sizing: border-box;
}

.safety-action-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  border: 1px solid #333;
  border-radius: 10px;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 200ms, border-color 200ms;
}

.safety-action-report {
  background: rgba(245, 158, 11, 0.1);
  color: #f59e0b;
  border-color: rgba(245, 158, 11, 0.3);
}

.safety-action-report:hover {
  background: rgba(245, 158, 11, 0.2);
  border-color: #f59e0b;
}

.safety-action-map {
  background: rgba(0, 161, 222, 0.1);
  color: #00a1de;
  border-color: rgba(0, 161, 222, 0.3);
}

.safety-action-map:hover {
  background: rgba(0, 161, 222, 0.2);
  border-color: #00a1de;
}

/* =============================================================
   REPORT INCIDENT MODAL
   ============================================================= */
.report-modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.95);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  padding: 20px;
  box-sizing: border-box;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.report-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-shrink: 0;
}

.report-modal-header h2 {
  color: #f59e0b;
  font-family: 'Inter', sans-serif;
  font-size: 20px;
  font-weight: 700;
  margin: 0;
}

.report-modal-close {
  background: none;
  border: none;
  color: #999;
  font-size: 28px;
  cursor: pointer;
  padding: 8px;
  flex-shrink: 0;
}

/* Type picker — 3-column grid */
.report-type-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

.report-type-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 8px;
  background: #1a1a1a;
  border: 2px solid #333;
  border-radius: 10px;
  color: #ccc;
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 200ms, background 200ms;
}

.report-type-btn:hover {
  background: #222;
  border-color: #555;
}

.report-type-btn.selected {
  border-color: #f59e0b;
  background: rgba(245, 158, 11, 0.08);
  color: #f59e0b;
}

.report-type-btn .type-emoji {
  font-size: 24px;
}

/* Form inputs — match search modal style */
.report-input {
  width: 100%;
  padding: 14px 16px;
  background: #1a1a1a;
  border: 2px solid #333;
  border-radius: 8px;
  color: #fff;
  font-size: 16px;
  font-family: 'Inter', sans-serif;
  outline: none;
  box-sizing: border-box;
  margin-bottom: 12px;
}

.report-input:focus {
  border-color: #f59e0b;
}

.report-input::placeholder {
  color: #666;
}

textarea.report-input {
  resize: vertical;
  min-height: 80px;
}

/* Location status */
.report-location-status {
  color: #888;
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.report-location-status.detected {
  color: #4ade80;
}

/* Submit button */
.report-submit-btn {
  width: 100%;
  padding: 16px;
  background: #f59e0b;
  color: #000;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 700;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: opacity 200ms;
}

.report-submit-btn:hover {
  opacity: 0.9;
}

.report-submit-btn:disabled {
  background: #444;
  color: #888;
  cursor: not-allowed;
  opacity: 1;
}

/* Feedback pill */
.report-feedback {
  text-align: center;
  padding: 12px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  margin-top: 12px;
  display: none;
}

.report-feedback.success {
  display: block;
  background: rgba(74, 222, 128, 0.12);
  color: #4ade80;
}

.report-feedback.error {
  display: block;
  background: rgba(248, 113, 113, 0.12);
  color: #f87171;
}

/* =============================================================
   ACTIVE REPORTS MAP MODAL
   ============================================================= */
.map-modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: #000;
  z-index: 1000;
  display: flex;
  flex-direction: column;
}

.map-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: rgba(0, 0, 0, 0.9);
  flex-shrink: 0;
  z-index: 2;
}

.map-modal-header h2 {
  color: #f59e0b;
  font-family: 'Inter', sans-serif;
  font-size: 18px;
  font-weight: 700;
  margin: 0;
}

.map-modal-close {
  background: none;
  border: none;
  color: #999;
  font-size: 28px;
  cursor: pointer;
  padding: 8px;
  flex-shrink: 0;
}

#incidents-map {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
}

/* Mapbox popup overrides — dark theme */
.mapboxgl-popup-content {
  background: #1c1917 !important;
  color: #e7e5e4 !important;
  border-radius: 10px !important;
  padding: 14px !important;
  font-family: 'Inter', sans-serif !important;
  max-width: 260px !important;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5) !important;
}

.mapboxgl-popup-tip {
  border-top-color: #1c1917 !important;
}

.mapboxgl-popup-close-button {
  color: #999 !important;
  font-size: 18px !important;
  right: 6px !important;
  top: 6px !important;
}

.popup-type {
  display: inline-block;
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.popup-title {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 4px;
}

.popup-desc {
  font-size: 12px;
  color: #a8a29e;
  margin-bottom: 6px;
}

.popup-meta {
  font-size: 11px;
  color: #78716c;
}

/* Map legend — bottom-left overlay */
.map-legend {
  position: absolute;
  bottom: 30px;
  left: 10px;
  background: rgba(28, 25, 23, 0.9);
  backdrop-filter: blur(8px);
  border-radius: 10px;
  padding: 12px 14px;
  z-index: 3;
  font-family: 'Inter', sans-serif;
}

.map-legend h4 {
  color: #a8a29e;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin: 0 0 8px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.legend-item:last-child {
  margin-bottom: 0;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.legend-label {
  color: #d6d3d1;
  font-size: 11px;
}

/* =============================================================
   RESPONSIVE SCALING — ANIM-05
   Target: three zones fit at 375px with no horizontal overflow
   ============================================================= */
@media (max-width: 480px) {
  .board-body {
    gap: 4px;
  }

  .board-zone {
    gap: 1px;
  }

  .board {
    padding: 10px 8px;
  }

  /* Safety net — never trigger at 375px target, but prevents reflow breaking layout */
  .board-body {
    overflow-x: auto;
  }

  .zone-sep {
    font-size: 0.6em;
  }
}

@media (max-width: 360px) {
  .board {
    font-size: clamp(10px, 3vw, 12px);
  }
}
