/* =====================================================================
   Casanova · Línea 6A — Horarios
   Mobile-first · Tema claro "Boleto de día" / oscuro "Terminal nocturna"
   ===================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;700&family=Inter:wght@400;500;600&family=IBM+Plex+Mono:wght@500;600&display=swap');

/* ---------- Tokens: tema claro (por defecto) ---------- */
:root {
  --bg-base: #F3F6FC;
  --surface: #FFFFFF;
  --surface-alt-base: #E7EFFB;
  --ink: #142037;
  --ink-soft: #57647D;
  --primary: #2F6FED;
  --primary-ink: #FFFFFF;
  --accent: #6EA8FF;
  --accent-soft: #DCEAFD;
  --special: #1B8FA0;
  --special-soft: #DCF1F4;
  --signal: #FF0101;
  --signal-ink: #FFFFFF;
  --signal-soft: #FFD9D9;
  --line-base: rgba(20, 32, 55, 0.10);
  --shadow: 0 8px 24px rgba(20, 32, 55, 0.10);
  --focus: #2F6FED;

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

  color-scheme: light;
}

/* ---------- Tokens: tema oscuro ---------- */
[data-theme="dark"] {
  --bg-base: #0A1322;
  --surface: #121D30;
  --surface-alt-base: #1A2740;
  --ink: #E8EEFB;
  --ink-soft: #94A3BF;
  --primary: #5B8DEF;
  --primary-ink: #0A1322;
  --accent: #7FB1FF;
  --accent-soft: rgba(127, 177, 255, 0.18);
  --special: #46C8D9;
  --special-soft: rgba(70, 200, 217, 0.16);
  --signal: #FF0101;
  --signal-ink: #FFFFFF;
  --signal-soft: rgba(255, 1, 1, 0.20);
  --line-base: rgba(255, 255, 255, 0.10);
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
  --focus: #7FB1FF;

  color-scheme: dark;
}

/* ---------- Matiz de fondo según el sentido del viaje ----------
   Hacia Montevideo: tinte azul profundo. Hacia afuera: tinte celeste.
   El cambio es deliberadamente leve, solo en el fondo de la página. */
:root,
[data-direction="montevideo"] {
  --bg: color-mix(in srgb, var(--bg-base) 92%, #1D4ED8 8%);
  --surface-alt: color-mix(in srgb, var(--surface-alt-base) 90%, #1D4ED8 10%);
  --line: var(--line-base);
}

[data-direction="afuera"] {
  --bg: color-mix(in srgb, var(--bg-base) 92%, #38BDF8 8%);
  --surface-alt: color-mix(in srgb, var(--surface-alt-base) 90%, #38BDF8 10%);
  --line: var(--line-base);
}

/* Línea N6: Covisa-Mevir (celeste) / B. Libertador (azul) */
[data-direction="covisa"] {
  --bg: color-mix(in srgb, var(--bg-base) 92%, #38BDF8 8%);
  --surface-alt: color-mix(in srgb, var(--surface-alt-base) 90%, #38BDF8 10%);
  --line: var(--line-base);
}

[data-direction="libertador"] {
  --bg: color-mix(in srgb, var(--bg-base) 92%, #1D4ED8 8%);
  --surface-alt: color-mix(in srgb, var(--surface-alt-base) 90%, #1D4ED8 10%);
  --line: var(--line-base);
}

/* Línea N33: Toledo KM 24 (celeste) */
[data-direction="toledo"] {
  --bg: color-mix(in srgb, var(--bg-base) 92%, #38BDF8 8%);
  --surface-alt: color-mix(in srgb, var(--surface-alt-base) 90%, #38BDF8 10%);
  --line: var(--line-base);
}

/* ---------- Reset base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.45s ease, color 0.25s ease;
}

img { max-width: 100%; display: block; }
a { color: inherit; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

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

/* ---------- Layout shell ---------- */
.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 16px;
}

/* ---------- Top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  backdrop-filter: saturate(140%) blur(6px);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 16px;
  max-width: 720px;
  margin: 0 auto;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface-alt);
  color: var(--ink);
  cursor: pointer;
  font-size: 1.05rem;
  transition: transform 0.15s ease, background 0.2s ease;
}

.icon-btn:hover { background: var(--accent-soft); }
.icon-btn:active { transform: scale(0.94); }

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand img {
  height: 92px;
  width: auto;
}

.brand-text {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.theme-toggle {
  position: relative;
}

.theme-toggle .icon-sun,
.theme-toggle .icon-moon {
  display: none;
}

[data-theme="light"] .theme-toggle .icon-sun,
:root:not([data-theme="dark"]) .theme-toggle .icon-sun { display: inline; }
[data-theme="dark"] .theme-toggle .icon-moon { display: inline; }
[data-theme="dark"] .theme-toggle .icon-sun { display: none; }

/* Llamada atención: cruce real luna↔sol, ícono inactivo aparece y se retira */
.theme-toggle.attn .icon-sun,
.theme-toggle.attn .icon-moon {
  display: inline-block;
  position: absolute;
  top: 50%;
  left: 50%;
}

:root:not([data-theme="dark"]) .theme-toggle.attn .icon-sun {
  animation: attnActiveSeq 2s cubic-bezier(0.22, 1, 0.36, 1);
}
:root:not([data-theme="dark"]) .theme-toggle.attn .icon-moon {
  animation: attnInactiveSeq 2s cubic-bezier(0.22, 1, 0.36, 1);
}
[data-theme="dark"] .theme-toggle.attn .icon-moon {
  animation: attnActiveSeq 2s cubic-bezier(0.22, 1, 0.36, 1);
}
[data-theme="dark"] .theme-toggle.attn .icon-sun {
  animation: attnInactiveSeq 2s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Fase 1 (0%-55%): giro+achique claro, ícono inactivo toma su lugar.
   Fase 2 (55%-100%): recién ahí vuelve el activo. La rotación termina en 70%;
   de ahí en más solo el scale rebota, así el final no "salta". */
@keyframes attnActiveSeq {
  0%   { opacity: 1; transform: translate(-50%, -50%) scale(1)    rotate(0deg); }
  25%  { opacity: 0; transform: translate(-50%, -50%) scale(0.15) rotate(180deg); }
  55%  { opacity: 0; transform: translate(-50%, -50%) scale(0.15) rotate(180deg); }
  70%  { opacity: 1; transform: translate(-50%, -50%) scale(1.3)  rotate(360deg); }
  85%  { opacity: 1; transform: translate(-50%, -50%) scale(0.93) rotate(360deg); }
  100% { opacity: 1; transform: translate(-50%, -50%) scale(1)    rotate(360deg); }
}

@keyframes attnInactiveSeq {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.15) rotate(-180deg); }
  25%  { opacity: 1; transform: translate(-50%, -50%) scale(1.1)  rotate(0deg); }
  55%  { opacity: 1; transform: translate(-50%, -50%) scale(1)    rotate(0deg); }
  75%  { opacity: 0; transform: translate(-50%, -50%) scale(0.15) rotate(180deg); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(0.15) rotate(180deg); }
}

/* ---------- Hero ---------- */
.hero {
  padding: 28px 0 20px;
}

.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.line-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--signal);
  color: var(--signal-ink);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  flex-shrink: 0;
}

.hero h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.5rem, 5vw, 2.1rem);
  line-height: 1.15;
  margin: 0 0 14px;
  text-align: center;
}

.hero-subtitle {
  margin-top: -6px;
}

.hero-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.hero p.validity {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.95rem;
}

.hero-actions {
  display: flex;
  flex-wrap: nowrap;
  gap: 10px;
}

.hero-actions .btn {
  flex: 1;
  min-width: 0;
  justify-content: center;
  white-space: nowrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 0.92rem;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.25s ease, filter 0.2s ease, background 0.2s ease;
}

.btn:hover {
  transform: translateY(-4px);
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--signal);
  color: var(--signal-ink);
}
.btn-primary:hover { filter: brightness(1.08); }

.btn-ghost {
  background: var(--surface-alt);
  color: var(--ink);
  border-color: var(--line);
}
.btn-ghost:hover { background: var(--accent-soft); }

/* ---------- Next departure card (elemento signature) ---------- */
.next-card {
  margin: 20px 0 28px;
  padding: 18px;
  border-radius: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.next-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: var(--accent);
}

.next-card-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 6px;
}

.next-card-label .dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.6s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.75); }
}

.next-card-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.next-card-time {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: clamp(1.8rem, 8vw, 2.4rem);
  letter-spacing: 0.02em;
}

.next-card-route {
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.next-card-eta {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--ink-soft);
  background: var(--accent-soft);
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

.next-card-stop {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--primary);
  text-decoration: none;
  text-align: right;
}

.next-card-stop:hover { text-decoration: underline; }

/* ---------- Tabs ---------- */
.tabs {
  display: flex;
  gap: 6px;
  background: var(--surface-alt);
  border-radius: 14px;
  padding: 5px;
  margin-bottom: 16px;
  transition: background-color 0.45s ease;
}

.tab {
  flex: 1;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-soft);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.88rem;
  padding: 10px 8px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.tab:hover {
  background: var(--accent-soft);
  color: var(--ink);
  transform: translateY(-0.75px);
  box-shadow: 0 2px 5px rgba(20, 32, 55, 0.075);
}

.tab[aria-selected="true"]:hover {
  background: var(--accent-soft);
  box-shadow: var(--shadow), 0 2px 5px rgba(20, 32, 55, 0.075);
}

.tab[aria-selected="true"] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}

/* ---------- Trip list ---------- */
.trip-list {
  list-style: none;
  margin: 0 0 8px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.trip {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
}

.trip-time {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 1.05rem;
  min-width: 64px;
  flex-shrink: 0;
}

.trip-route {
  color: var(--ink-soft);
  font-size: 0.9rem;
  flex: 1;
}

.trip-badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--signal);
  color: var(--signal-ink);
  white-space: nowrap;
}

.trip--next {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.trip--past {
  opacity: 0.45;
}

@media (hover: hover) {
  .trip:hover {
    background: var(--accent-soft);
    color: var(--ink);
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
  }
}

.panel { display: none; }
.panel[data-active="true"] { display: block; }

.empty-state {
  text-align: center;
  padding: 24px 12px;
  color: var(--ink-soft);
  font-size: 0.9rem;
}

/* ---------- Sections ---------- */
.section-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.3rem;
  margin: 0 0 14px;
}

main { padding-bottom: 24px; }

/* ---------- Contact / footer ---------- */
footer {
  background: var(--surface);
  border-top: 1px solid var(--line);
  margin-top: 24px;
  padding: 28px 0 90px;
}

.contact-grid {
  display: grid;
  gap: 12px;
}

.contact-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--surface-alt);
  font-size: 0.92rem;
}

.contact-item .icon-btn {
  width: 36px; height: 36px;
  pointer-events: none;
  background: var(--bg);
}

.contact-item a {
  text-decoration: none;
  font-weight: 600;
}

.copyright {
  text-align: center;
  color: var(--ink-soft);
  font-size: 0.8rem;
  margin-top: 22px;
}

/* ---------- Floating to-top button ---------- */
.to-top-button {
  position: fixed;
  right: 16px;
  bottom: 16px;
  width: 50px;
  height: 50px;
  border-radius: 16px;
  background: var(--primary);
  color: var(--primary-ink);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  box-shadow: var(--shadow);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 60;
}

.to-top-button.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

/* ---------- Flap-in entrance (una sola vez, sutil) ---------- */
@media (prefers-reduced-motion: no-preference) {
  .trip {
    animation: flapIn 0.32s ease both;
  }
}

@keyframes flapIn {
  from { opacity: 0; transform: translateY(-6px) scaleY(0.92); }
  to { opacity: 1; transform: translateY(0) scaleY(1); }
}

/* ---------- Tablet / desktop refinements ---------- */
@media (max-width: 380px) {
  .hero-actions .btn {
    padding: 12px 10px;
    font-size: 0.8rem;
    gap: 6px;
  }
}

@media (min-width: 600px) {
  .hero h1 { font-size: 2.3rem; }
  .trip { padding: 14px 18px; }
  .next-card { padding: 24px; }
  .brand img { height: 108px; }
}

@media (min-width: 900px) {
  .wrap { padding: 0 24px; }
}


.hero-actions {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  gap: 8px;
  width: 100%;
}

.hero-actions .btn {
  flex: 1;
  justify-content: center;
  padding: 10px 8px;
  font-size: 0.8rem;
  white-space: nowrap;
}

@media (max-width: 480px) {
  .hero-actions .btn {
    font-size: 0.72rem;
    padding: 9px 4px;
    gap: 4px;
  }
  .hero-actions .btn i {
    font-size: 0.85rem;
  }
}

.icon-btn[href$="bus.html"] {
  position: relative;
  animation: pulse-game 2s infinite;
}

@keyframes pulse-game {
  0%, 100% { box-shadow: 0 0 0 0 rgba(227, 28, 28, 0.5); }
  50% { box-shadow: 0 0 0 6px rgba(227, 28, 28, 0); }
}
 