/* ==========================================================================
   Panel de Salidas — identidad inspirada en los tableros mecánicos
   split-flap de las estaciones de autobuses y en la señalización de carretera.
   ========================================================================== */

:root {
  --ink:            #12151a;
  --panel:          #1b1f27;
  --panel-raised:   #232833;
  --line:           #313846;
  --cyan:           #3fc8eb;
  --cyan-dim:       #2a8aa3;
  --amber:          #ffb020;
  --paper:          #f4f2ec;
  --slate:          #93a0b3;
  --slate-dim:      #5c6577;
  --good:           #55c48a;

  --font-display: 'Space Grotesk', sans-serif;
  --font-mono:    'IBM Plex Mono', monospace;
  --font-body:    'Inter', sans-serif;

  --radius: 10px;
}

* { box-sizing: border-box; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

html, body {
  margin: 0;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-body);
  min-height: 100vh;
}

/* Textura sutil de "recinto" del panel físico ------------------------------ */
.board-frame { position: fixed; inset: 0; pointer-events: none; z-index: 0; }
.frame-slit {
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: repeating-linear-gradient(90deg, var(--amber) 0 18px, transparent 18px 26px);
  opacity: 0.55;
}

a { color: var(--cyan); }

/* ---------------------------------------------------------------- Topbar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 28px;
  padding: 16px 32px;
  background: rgba(18,21,26,0.92);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  font-size: 22px; color: var(--amber);
  display: inline-block; transform: scaleX(1.4);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-title { font-family: var(--font-display); font-weight: 700; font-size: 17px; letter-spacing: 0.02em; }
.brand-sub { font-family: var(--font-mono); font-size: 11px; color: var(--slate); letter-spacing: 0.08em; text-transform: uppercase; }

.tabs { display: flex; gap: 6px; margin-left: 8px; }
.tab-btn {
  font-family: var(--font-mono); font-size: 12.5px; letter-spacing: 0.05em; text-transform: uppercase;
  background: transparent; border: 1px solid var(--line); color: var(--slate);
  padding: 8px 14px; border-radius: 999px; cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.tab-btn:hover { color: var(--paper); border-color: var(--slate-dim); }
.tab-btn.is-active { color: var(--ink); background: var(--cyan); border-color: var(--cyan); }

.stats-strip {
  margin-left: auto;
  font-family: var(--font-mono); font-size: 11.5px; color: var(--slate);
  letter-spacing: 0.04em; white-space: nowrap;
}
.stats-strip b { color: var(--amber); font-weight: 600; }

/* ------------------------------------------------------------------ Main */
main { max-width: 1080px; margin: 0 auto; padding: 0 24px 80px; position: relative; z-index: 1; }

.tab-panel { display: none; }
.tab-panel.is-active { display: block; }

.hero { padding: 56px 0 28px; max-width: 640px; }
.hero-compact { padding: 44px 0 24px; }
.hero-eyebrow {
  font-family: var(--font-mono); color: var(--amber); font-size: 12.5px;
  letter-spacing: 0.12em; text-transform: uppercase; margin: 0 0 14px;
}
.hero-title {
  font-family: var(--font-display); font-weight: 700; font-size: 40px; line-height: 1.08;
  margin: 0 0 16px; letter-spacing: -0.01em;
}
.hero-copy { color: var(--slate); font-size: 15px; line-height: 1.6; margin: 0; }

/* -------------------------------------------------------------- Búsqueda */
.search-panel {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto auto;
  gap: 14px;
  align-items: end;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
}
.field { display: flex; flex-direction: column; gap: 6px; position: relative; }
.field label {
  font-family: var(--font-mono); font-size: 11px; color: var(--slate);
  text-transform: uppercase; letter-spacing: 0.08em;
}
.field input[type="text"], .field input[type="date"] {
  background: var(--panel-raised); border: 1px solid var(--line); color: var(--paper);
  font-family: var(--font-body); font-size: 14.5px; padding: 11px 12px; border-radius: 7px;
  min-width: 180px; outline: none; transition: border-color 0.15s;
}
.field input[type="date"] { font-family: var(--font-mono); color-scheme: dark; }
.field input:focus { border-color: var(--cyan); }

.swap-btn {
  background: var(--panel-raised); border: 1px solid var(--line); color: var(--cyan);
  width: 38px; height: 38px; border-radius: 50%; font-size: 16px; cursor: pointer;
  margin-bottom: 1px; transition: transform 0.2s, border-color 0.2s;
}
.swap-btn:hover { border-color: var(--cyan); transform: rotate(180deg); }

.go-btn {
  background: var(--cyan); color: var(--ink); border: none; font-family: var(--font-display);
  font-weight: 700; font-size: 14.5px; padding: 12px 22px; border-radius: 7px; cursor: pointer;
  letter-spacing: 0.02em; transition: background 0.15s, transform 0.1s;
}
.go-btn:hover { background: #63d4f0; }
.go-btn:active { transform: scale(0.97); }

@media (max-width: 760px) {
  .search-panel { grid-template-columns: 1fr; }
  .swap-btn { justify-self: center; }
}

/* Combobox / autocompletado ------------------------------------------------ */
.combo-list {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 30;
  background: var(--panel-raised); border: 1px solid var(--line); border-radius: 8px;
  max-height: 260px; overflow-y: auto; display: none;
  box-shadow: 0 12px 30px rgba(0,0,0,0.45);
}
.combo-list.is-open { display: block; }
.combo-item {
  padding: 10px 12px; cursor: pointer; font-size: 13.5px; display: flex; justify-content: space-between; gap: 8px;
  border-bottom: 1px solid var(--line);
}
.combo-item:last-child { border-bottom: none; }
.combo-item:hover, .combo-item.is-hot { background: rgba(63,200,235,0.12); }
.combo-item .tag { font-family: var(--font-mono); font-size: 10.5px; color: var(--slate); text-transform: uppercase; }
.combo-empty { padding: 12px; font-size: 13px; color: var(--slate); }

/* ------------------------------------------------------------------ Board */
.results-wrap { margin-top: 30px; }
.results-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; }
#resultsSummary { font-family: var(--font-mono); font-size: 12.5px; color: var(--slate); letter-spacing: 0.04em; }

.board { display: flex; flex-direction: column; gap: 10px; }

.board-row {
  display: grid;
  grid-template-columns: 90px 1fr 46px 1fr 90px;
  align-items: center;
  gap: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 18px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  animation: flap-in 0.4s ease both;
}
.board-row:hover { border-color: var(--cyan-dim); background: var(--panel-raised); }

@keyframes flap-in {
  0%   { opacity: 0; transform: translateY(-6px) scaleY(0.85); filter: blur(1px); }
  60%  { opacity: 1; transform: translateY(1px) scaleY(1.02); filter: blur(0); }
  100% { opacity: 1; transform: translateY(0) scaleY(1); }
}

.br-time { font-family: var(--font-mono); font-size: 19px; font-weight: 600; }
.br-time.dep { color: var(--paper); }
.br-time.arr { color: var(--slate); text-align: right; }
.br-route {
  display: flex; align-items: center; gap: 10px; overflow: hidden;
}
.route-badge {
  font-family: var(--font-mono); font-weight: 600; font-size: 11.5px;
  padding: 4px 8px; border-radius: 4px; white-space: nowrap; letter-spacing: 0.02em;
  border: 1.5px solid currentColor;
}
.br-headsign { font-size: 13.5px; color: var(--slate); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.br-arrow { text-align: center; color: var(--slate-dim); font-size: 15px; }
.br-duration {
  font-family: var(--font-mono); font-size: 11.5px; color: var(--amber); text-align: right; white-space: nowrap;
}

.board-empty, .board-loading {
  padding: 40px 20px; text-align: center; color: var(--slate);
  border: 1px dashed var(--line); border-radius: 8px; font-size: 14px;
}
.board-loading { font-family: var(--font-mono); letter-spacing: 0.04em; }

@media (max-width: 700px) {
  .board-row { grid-template-columns: 70px 1fr 70px; grid-template-areas: "dep route dur" "dep head dur"; }
  .br-arrow, .br-time.arr { display: none; }
}

/* ---------------------------------------------------------- Líneas / Paradas */
.simple-search { margin-bottom: 22px; }
.simple-search input {
  width: 100%; max-width: 480px; background: var(--panel); border: 1px solid var(--line);
  color: var(--paper); font-size: 14.5px; padding: 12px 14px; border-radius: 8px; outline: none;
}
.simple-search input:focus { border-color: var(--cyan); }

.route-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.route-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px;
  cursor: pointer; transition: border-color 0.15s, transform 0.1s;
}
.route-card:hover { border-color: var(--cyan-dim); transform: translateY(-1px); }
.route-card .route-badge { margin-bottom: 8px; display: inline-block; }
.route-card .route-name { font-size: 13.5px; color: var(--slate); line-height: 1.4; }

.stop-list { display: flex; flex-direction: column; gap: 8px; }
.stop-row {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px 16px;
}
.stop-row .stop-name { font-size: 14px; }
.stop-row .stop-type { font-family: var(--font-mono); font-size: 10.5px; color: var(--slate); text-transform: uppercase; letter-spacing: 0.06em; }
.stop-row button {
  background: transparent; border: 1px solid var(--cyan-dim); color: var(--cyan);
  font-family: var(--font-mono); font-size: 11px; padding: 6px 10px; border-radius: 6px; cursor: pointer;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.stop-row button:hover { background: rgba(63,200,235,0.12); }

/* --------------------------------------------------------------- Drawers */
.drawer {
  position: fixed; top: 0; right: 0; height: 100vh; width: min(420px, 100vw); z-index: 40;
  background: var(--panel); border-left: 1px solid var(--line);
  box-shadow: -20px 0 40px rgba(0,0,0,0.4);
  animation: slide-in 0.2s ease both;
  overflow-y: auto;
}
@keyframes slide-in { from { transform: translateX(100%); } to { transform: translateX(0); } }
.drawer-inner { padding: 24px; }
.drawer-close, .trip-modal-card .drawer-close {
  background: var(--panel-raised); border: 1px solid var(--line); color: var(--slate);
  width: 30px; height: 30px; border-radius: 50%; cursor: pointer; font-size: 13px;
  margin-bottom: 16px;
}
.drawer-close:hover { color: var(--paper); border-color: var(--slate-dim); }

/* ------------------------------------------------------------- Trip modal */
.trip-modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 24px; }
.trip-modal[hidden] { display: none; }
.trip-modal-backdrop { position: absolute; inset: 0; background: rgba(8,10,13,0.72); backdrop-filter: blur(2px); }
.trip-modal-card {
  position: relative; z-index: 1; background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 24px; max-width: 520px; width: 100%; max-height: 82vh; overflow-y: auto;
  animation: pop-in 0.18s ease both;
}
@keyframes pop-in { from { opacity: 0; transform: scale(0.97); } to { opacity: 1; transform: scale(1); } }

.trip-route-head { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.trip-headsign { font-family: var(--font-display); font-weight: 700; font-size: 19px; margin: 10px 0 4px; }
.trip-cal { font-family: var(--font-mono); font-size: 11.5px; color: var(--slate); margin-bottom: 18px; }
.trip-cal .day-on { color: var(--good); }
.trip-cal .day-off { color: var(--slate-dim); text-decoration: line-through; }

.stop-timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.stop-timeline::before {
  content: ""; position: absolute; left: 5px; top: 8px; bottom: 8px; width: 1px; background: var(--line);
}
.stop-timeline li {
  position: relative; padding: 0 0 18px 26px; font-size: 13.5px;
}
.stop-timeline li::before {
  content: ""; position: absolute; left: 0; top: 3px; width: 11px; height: 11px; border-radius: 50%;
  background: var(--ink); border: 2px solid var(--cyan);
}
.stop-timeline li:first-child::before, .stop-timeline li:last-child::before { background: var(--cyan); }
.stop-timeline .st-time { font-family: var(--font-mono); color: var(--amber); margin-right: 10px; }
.stop-timeline .st-name { color: var(--paper); }

/* -------------------------------------------------------------------- Footer */
.page-footer {
  text-align: center; padding: 26px; font-size: 11.5px; color: var(--slate-dim);
  font-family: var(--font-mono); letter-spacing: 0.03em; position: relative; z-index: 1;
}

/* Scrollbars discretas ------------------------------------------------------ */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }
