/* Grand Prix Hub · Fase 2 (propuesta): móvil y orden de En directo.
   Solo cambia la colocación; los colores, letras y datos son los de siempre. */

/* ---------- 1. Clasificación en móvil: cada piloto en dos líneas ---------- */
@media (max-width: 720px) {
  #standingsView .standings-header { display: none; }
  #standingsView .standing-row {
    grid-template-columns: 30px minmax(0, 1fr) auto auto auto;
    grid-template-areas:
      "pos name name name pts"
      "pos team wins pods pts";
    column-gap: 10px;
    row-gap: 3px;
    padding: 11px 14px;
    min-height: 0;
    align-items: center;
  }
  #standingsView .standing-row > .pos { grid-area: pos; align-self: center; }
  #standingsView .standing-row > .driver-cell { grid-area: name; min-width: 0; }
  #standingsView .standing-row > .driver-cell strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #standingsView .standing-row > :nth-child(3) { display: flex; grid-area: team; min-width: 0; font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; }
  #standingsView .standing-row > :nth-child(4) { display: block; grid-area: wins; font-size: 11px; color: var(--muted); white-space: nowrap; }
  #standingsView .standing-row > :nth-child(5) { display: block; grid-area: pods; font-size: 11px; color: var(--muted); white-space: nowrap; }
  #standingsView .standing-row > :nth-child(4)::before { content: "Vic. "; }
  #standingsView .standing-row > :nth-child(5)::before { content: "Pod. "; }
  #standingsView .standing-row > .gph-skel::before { content: none; }
  #standingsView .standing-row > .gph-skel { min-width: 4.5em; }
  #standingsView .standing-row > .points { grid-area: pts; align-items: flex-end; text-align: right; min-width: 44px; }
}

/* ---------- 2. Calendario en móvil: botones en fila y más grandes ---------- */
@media (max-width: 720px) {
  #calendarView .calendar-item {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 12px;
    padding: 14px;
  }
  #calendarView .calendar-item > .calendar-flag { order: 1; flex: 0 0 auto; }
  #calendarView .calendar-item > .gph-cal-main { order: 2; flex: 1 1 calc(100% - 130px); min-width: 0; }
  #calendarView .calendar-item > .calendar-date { order: 3; flex: 0 0 auto; }
  #calendarView .calendar-item > .round {
    order: 4; flex: 1 1 auto;
    font: 600 11px 'DM Sans', sans-serif; letter-spacing: .08em; color: var(--muted);
  }
  #calendarView .calendar-item > .calendar-action { order: 5; flex: 0 0 auto; width: 44px; height: 44px; font-size: 16px; }
  #calendarView .calendar-item > .gph-cal-sessions { order: 6; flex: 1 1 100%; }
}

/* ---------- 3. Barra fija abajo en móvil ---------- */
.gph-tabbar { display: none; }
@media (max-width: 720px) {
  .gph-tabbar {
    position: fixed; z-index: 60; left: 0; right: 0; bottom: 0;
    display: grid; grid-template-columns: repeat(5, 1fr);
    padding: 6px max(8px, env(safe-area-inset-right, 0px)) calc(6px + env(safe-area-inset-bottom, 0px)) max(8px, env(safe-area-inset-left, 0px));
    background: rgba(17, 19, 21, .96); border-top: 1px solid rgba(255, 255, 255, .08);
    backdrop-filter: blur(10px);
  }
  .gph-tabbar button {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    min-height: 48px; padding: 4px 2px; border: 0; border-radius: 10px; background: none;
    color: #a9aca8; font: 600 10.5px 'DM Sans', sans-serif; cursor: pointer;
  }
  .gph-tabbar button span { font-size: 17px; line-height: 1; }
  .gph-tabbar button.active { color: #fff; }
  .gph-tabbar button.active span { color: var(--red); }
  .gph-tabbar button:focus-visible { outline: 2px solid var(--red); outline-offset: -2px; }
  .gph-tabbar .gph-tab-dot { position: relative; }
  .gph-tabbar .gph-tab-dot::after { content: ""; position: absolute; top: -2px; right: -6px; width: 6px; height: 6px; border-radius: 50%; background: var(--red); }
  body.gph-has-tabbar .main-content { padding-bottom: calc(84px + env(safe-area-inset-bottom, 0px)); }
  body.gph-has-tabbar .gph-preview-badge { bottom: calc(76px + env(safe-area-inset-bottom, 0px)); }
}

/* ---------- 4. En directo en PC: los paneles se reparten en columnas ---------- */
@media (min-width: 1101px) {
  #liveView .live-layout {
    grid-template-columns: minmax(0, 1.6fr) minmax(300px, .75fr);
    grid-template-areas:
      "main weekend"
      "main moments"
      "panels panels";
    grid-template-rows: auto 1fr auto;
    align-items: start;
  }
  #liveView .live-main { grid-area: main; }
  #liveView .race-sidebar { display: contents; }
  #liveView #weekendPanel { grid-area: weekend; }
  #liveView .race-sidebar > .side-panel:not(#weekendPanel):not(.tyre-panel) { grid-area: moments; }
  #liveView #livePanels { grid-area: panels; columns: 3 320px; column-gap: 20px; }
  #liveView #livePanels > * { break-inside: avoid; display: inline-block; width: 100%; margin: 0 0 20px; box-sizing: border-box; }
}

/* ---------- 5. Contraste: los textos grises secundarios usan el gris de cada tema ---------- */
:root { --muted: #666a6a; }
[data-theme="ocean"] { --muted: #4f686e; }
[data-theme="sunset"] { --muted: #77605a; }
[data-theme="mono"] { --muted: #5e5e5e; }
/* El tema nocturno se queda como estaba: sus tarjetas siguen siendo claras y el gris claro se leería peor. */
body:not([data-theme="night"]) :is(.calendar-item p, .calendar-item .calendar-date small, .calendar-date small, .round,
.standings-header, .standing-row .pos, .standing-row .gph-gap, .standings-switch button:not(.active), .standings-switch span,
.race-row.head, .last-update, .news-card time, .card-footer, .timeline small, .live-card-head p,
.driver-info span, .mini-stats span, .big-points small, .filter, .page-heading .eyebrow, .small-muted:not(.gph-circ-map .small-muted)) {
  color: var(--muted);
}

/* ---------- 6. Esperas: una barra gris animada en vez de «…» ---------- */
.gph-skel {
  -webkit-text-fill-color: transparent;
  display: inline-block; min-width: 2.4em; min-height: .9em; line-height: 1; vertical-align: middle;
  border-radius: 4px;
  background: linear-gradient(90deg, color-mix(in srgb, currentColor 10%, transparent) 0%, color-mix(in srgb, currentColor 22%, transparent) 50%, color-mix(in srgb, currentColor 10%, transparent) 100%);
  background-size: 200% 100%;
  animation: gph-shimmer 1.2s ease-in-out infinite;
}
.gph-skel-text { position: relative; }
.gph-skel-text::after {
  content: ""; display: block; height: 10px; margin-top: 10px; width: 60%; border-radius: 4px;
  background: linear-gradient(90deg, color-mix(in srgb, currentColor 10%, transparent), color-mix(in srgb, currentColor 22%, transparent), color-mix(in srgb, currentColor 10%, transparent));
  background-size: 200% 100%; animation: gph-shimmer 1.2s ease-in-out infinite;
}
@keyframes gph-shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .gph-skel, .gph-skel-text::after { animation: none; } }

/* ---------- 7. Circuitos en el móvil: un desplegable en vez de la tira lateral ---------- */
.gph-circ-select-wrap { display: none; }
@media (max-width: 720px) {
  #circuitsBox .gph-circ-list { display: none; }
  .gph-circ-select-wrap { display: block; margin: 0 0 14px; }
  .gph-circ-select-wrap label { display: block; font: 600 11px 'DM Sans', sans-serif; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
  .gph-circ-select-wrap select {
    width: 100%; min-height: 48px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px;
    background: var(--card); color: var(--ink); font: 600 15px 'DM Sans', sans-serif;
  }
}
