/* =========================================================
   Live Timing screen styles (most complex screen)
   ========================================================= */
.lt-shell { min-height: 100vh; display: flex; flex-direction: column; position: relative; }

/* Event header: bold broadcast-style strip */
.lt-header {
  position: relative; z-index: 30;
  padding: 22px 28px 18px;
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 18px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(180deg, color-mix(in oklab, var(--bg-1), transparent 20%), transparent 90%),
    linear-gradient(180deg, var(--bg-0), var(--bg-0));
  overflow: hidden;
}
.lt-header::after {
  /* Speed lines */
  content: "";
  position: absolute; inset: 0;
  background:
    repeating-linear-gradient(90deg,
      transparent 0 40px,
      color-mix(in oklab, var(--red), transparent 94%) 40px 41px);
  mask-image: linear-gradient(90deg, transparent, black 20%, black 80%, transparent);
  pointer-events: none;
  opacity: 0.6;
}
.lt-event {
  display: flex; flex-direction: column; gap: 6px; min-width: 0;
  position: relative; z-index: 1;
}
.lt-event .cat-row {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
.lt-event .cat {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(26px, 3.6vw, 44px);
  letter-spacing: 0.06em;
  line-height: 1;
  text-transform: uppercase;
  color: var(--ink-0);
}
.lt-event .cat em {
  font-style: normal;
  color: var(--red);
}
.lt-event .meta {
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; color: var(--ink-2);
  flex-wrap: wrap;
}
.lt-event .meta .sep { width: 3px; height: 3px; border-radius: 999px; background: var(--ink-4); }
.lt-event .run {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 4px 10px; border-radius: 6px;
  background: var(--bg-2);
  border: 1px solid var(--line-soft);
  font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ink-1);
}
.lt-event .run .dot {
  width: 6px; height: 6px; border-radius: 999px; background: var(--ink-3);
}
.lt-event .run.is-qualy .dot { background: var(--amber); }
.lt-event .run.is-race .dot  { background: var(--red); }
.lt-event .run.is-practice .dot { background: var(--blue); }

.lt-actions {
  display: flex; align-items: center; gap: 10px;
  position: relative; z-index: 1;
}

/* Flag indicator (large) */
.lt-flag {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 14px 8px 10px;
  border-radius: 999px;
  background: var(--bg-2);
  border: 1px solid var(--line-soft);
}
.lt-flag .flag-lg {
  width: 22px; height: 22px; border-radius: 6px;
  position: relative;
  background: var(--ink-4);
}
.lt-flag .flag-lg::after {
  content: ""; position: absolute; inset: -4px; border-radius: 10px;
  animation: flagPulse 2s infinite var(--ease);
}
.lt-flag.green .flag-lg { background: var(--green); }
.lt-flag.green .flag-lg::after { box-shadow: 0 0 0 0 color-mix(in oklab, var(--green), transparent 30%); }
.lt-flag.pacecar .flag-lg { background: linear-gradient(180deg, #fff 0% 33%, #ff6a00 33% 66%, #0080ff 66% 100%); border-radius: 4px; }
.lt-flag.pacecar .flag-lg::after { display: none; }
.lt-flag.pacecar .flag-label { color: #ff6a00; }
.lt-flag.red .flag-lg { background: var(--red); }
.lt-flag.red .flag-lg::after { box-shadow: 0 0 0 0 color-mix(in oklab, var(--red), transparent 30%); }
.lt-flag.checkered .flag-lg { background: repeating-conic-gradient(#000 0% 25%, #fff 0% 50%) 50%/8px 8px; }
.lt-flag.checkered .flag-lg::after { display: none; }
.lt-flag.warmup .flag-lg { background: var(--violet); }
.lt-flag.warmup .flag-lg::after { box-shadow: 0 0 0 0 color-mix(in oklab, var(--violet), transparent 30%); }
.lt-flag.warmup .flag-label { color: var(--violet); }
.lt-flag.fin .flag-lg { background: oklch(0.35 0.01 260); }
.lt-flag.fin .flag-lg::after { display: none; }
.lt-flag.fin .flag-label { color: var(--ink-3); }
.lt-flag .flag-label {
  font-family: var(--font-display);
  font-weight: 800; font-size: 12px;
  letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--ink-1);
}
@keyframes flagPulse {
  0%   { box-shadow: 0 0 0 0 currentColor; opacity: 1; }
  100% { box-shadow: 0 0 0 12px transparent; opacity: 0; }
}

/* ========= Ticker ========= */
.ticker {
  background: color-mix(in oklab, var(--bg-1), transparent 10%);
  border-bottom: 1px solid var(--line-soft);
  display: flex; align-items: center; gap: 14px;
  padding: 0 20px;
  height: 40px;
  overflow: hidden;
  position: relative; z-index: 3;
}
.ticker .tick-label {
  font-family: var(--font-display);
  font-weight: 700; font-size: 11px;
  letter-spacing: 0.22em; text-transform: uppercase;
  padding: 4px 10px; border-radius: 4px;
  background: var(--red); color: #fff;
  white-space: nowrap;
  flex-shrink: 0;
  position: relative; z-index: 2;
}
.ticker .tick-stream {
  display: flex; align-items: center; gap: 28px;
  white-space: nowrap;
  animation: tickScroll 38s linear infinite;
  font-size: 13px;
  color: var(--ink-2);
}
.ticker .tick-stream strong { color: var(--ink-0); font-weight: 600; }
.ticker .tick-stream .ob { color: var(--violet); font-family: var(--font-mono); }
.ticker .tick-stream .pb { color: var(--green); font-family: var(--font-mono); }
.ticker .tick-stream .lap { color: var(--amber); font-family: var(--font-mono); }
@keyframes tickScroll {
  from { transform: translateX(0%); }
  to   { transform: translateX(-50%); }
}

/* ========= Tabs ========= */
.lt-tabs {
  display: flex; align-items: end; gap: 2px;
  padding: 18px 22px 0;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: none;
  position: sticky; top: 58px; z-index: 25;
  background: var(--bg-0);
}
.lt-tabs::-webkit-scrollbar { display: none; }
.lt-tab {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 10px 18px 14px;
  font-family: var(--font-display);
  font-weight: 700; font-size: 13px;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--ink-3);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: color .2s var(--ease);
  position: relative;
}
.lt-tab:hover { color: var(--ink-1); }
.lt-tab[aria-selected="true"] {
  color: var(--ink-0);
  border-bottom-color: var(--red);
}
.lt-tab .badge {
  padding: 2px 7px; border-radius: 999px;
  font-size: 10px; letter-spacing: 0.1em;
  font-weight: 700;
  background: var(--bg-2);
  color: var(--ink-2);
  border: 1px solid var(--line-soft);
}
.lt-tab.is-qualy .badge { background: color-mix(in oklab, var(--amber), transparent 82%); color: var(--amber); border-color: transparent; }
.lt-tab.is-race .badge  { background: color-mix(in oklab, var(--red), transparent 82%);   color: var(--red-ink); border-color: transparent; }
.lt-tab.is-practice .badge { background: color-mix(in oklab, var(--blue), transparent 82%); color: var(--blue); border-color: transparent; }

/* ========= Best-of bar ========= */
.best-bar {
  display: flex; align-items: center; gap: 18px;
  padding: 12px 22px;
  background:
    linear-gradient(90deg,
      color-mix(in oklab, var(--green), transparent 88%),
      color-mix(in oklab, var(--green), transparent 98%));
  border-bottom: 1px solid var(--line-soft);
  font-size: 13px;
}
.best-bar .label {
  font-family: var(--font-display);
  font-weight: 700; font-size: 11px;
  letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--green);
}
.best-bar .who {
  display: inline-flex; align-items: center; gap: 10px;
  color: var(--ink-0); font-weight: 600;
}
.best-bar .time {
  font-family: var(--font-mono);
  font-weight: 700; font-variant-numeric: tabular-nums;
  color: var(--ink-0);
  font-size: 15px;
}
.best-bar .secs {
  display: inline-flex; align-items: flex-end; gap: 18px;
  margin-left: 8px;
}
.best-bar .secs .sec-col {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.best-bar .secs .s-lbl {
  font-family: var(--font-display);
  font-size: 9px; font-weight: 700;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--ink-4);
}
.best-bar .secs .s-val {
  font-family: var(--font-mono);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-size: 15px;
  color: var(--ink-0);
}

/* ========= Main grid: table + rail ========= */
.lt-body {
  display: grid;
  grid-template-columns: 1fr 320px;
  grid-template-rows: 1fr;
  gap: 0;
  flex: 1; min-height: 0;
  overflow: hidden;
}
.lt-body.no-rail { grid-template-columns: 1fr; }

/* ========= Timing table ========= */
.lt-table-wrap {
  overflow: auto;
  position: relative;
  min-height: 0;
}
.lt-table {
  width: 100%;
  min-width: 920px;
  font-family: var(--font-ui);
  border-collapse: separate;
  border-spacing: 0;
}
.lt-table thead th {
  position: sticky; top: 0; z-index: 10;
  background: var(--bg-1);
  color: var(--ink-3);
  font-family: var(--font-display);
  font-weight: 700; font-size: 11px;
  letter-spacing: 0.2em; text-transform: uppercase;
  text-align: left;
  padding: 14px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.lt-table tbody td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
  white-space: nowrap;
  color: var(--ink-1);
}
.lt-table.dense tbody td { padding: 7px 10px; }
.lt-table.dense thead th { padding: 9px 10px; }

.lt-table tbody tr {
  transition: background .15s var(--ease);
}
.lt-table tbody tr:hover { background: color-mix(in oklab, var(--bg-2), transparent 50%); }
.lt-table tbody tr[data-moved="up"]   { animation: rowFlashUp   1.8s var(--ease) forwards; }
.lt-table tbody tr[data-moved="down"] { animation: rowFlashDown 1.8s var(--ease) forwards; }
@keyframes rowFlashUp   { 0% { background: color-mix(in oklab, var(--green), transparent 82%); } 100% { background: transparent; } }
@keyframes rowFlashDown { 0% { background: color-mix(in oklab, var(--red),   transparent 82%); } 100% { background: transparent; } }

/* P1–P3 podium tinge */
.lt-table tbody tr.p1 { background: linear-gradient(90deg, color-mix(in oklab, var(--amber), transparent 90%), transparent 40%); }
.lt-table tbody tr.p2 { background: linear-gradient(90deg, color-mix(in oklab, oklch(0.8 0.01 260), transparent 93%), transparent 40%); }
.lt-table tbody tr.p3 { background: linear-gradient(90deg, color-mix(in oklab, oklch(0.55 0.12 40), transparent 92%), transparent 40%); }

/* Sticky left columns (P, N°, Piloto) - opaque so data scrolls underneath */
.lt-table th.sticky, .lt-table td.sticky {
  position: sticky; z-index: 5;
}
.lt-table thead th.sticky { z-index: 12; background-color: var(--bg-1); }
.lt-table tbody td.sticky { background-color: var(--bg-0); }
.lt-table tbody tr.p1 td.sticky { background-color: color-mix(in oklab, var(--bg-0), var(--amber) 6%); }
.lt-table tbody tr.p2 td.sticky { background-color: color-mix(in oklab, var(--bg-0), oklch(0.8 0.01 260) 4%); }
.lt-table tbody tr.p3 td.sticky { background-color: color-mix(in oklab, var(--bg-0), oklch(0.55 0.12 40) 5%); }
.lt-table tbody tr:hover td.sticky { background-color: var(--bg-2); }
[data-theme="light"] .lt-table tbody td.sticky { background-color: var(--bg-0); }

.lt-table th.sticky.col-pos, .lt-table td.sticky.col-pos { left: 0; min-width: 54px; }
.lt-table th.sticky.col-nro, .lt-table td.sticky.col-nro { left: 54px; min-width: 56px; }
.lt-table th.sticky.col-pil, .lt-table td.sticky.col-pil {
  min-width: 180px;
  box-shadow: 10px 0 14px -10px oklch(0 0 0 / 0.55);
}
[data-theme="light"] .lt-table th.sticky.col-pil,
[data-theme="light"] .lt-table td.sticky.col-pil { box-shadow: 10px 0 14px -10px oklch(0 0 0 / 0.15); }

/* Piloto sticky only on wide screens */
@media (min-width: 821px) {
  .lt-table th.sticky.col-pil, .lt-table td.sticky.col-pil { left: 110px; }
}
@media (max-width: 820px) {
  .lt-table th.col-pil, .lt-table td.col-pil {
    position: static !important;
    box-shadow: none !important;
  }
}

/* Position */
.pos-cell {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-display);
  font-weight: 800; font-size: 17px;
  color: var(--ink-0);
  font-variant-numeric: tabular-nums;
}
.pos-cell.p1 { color: var(--amber); }
.trend {
  font-size: 11px;
  display: inline-flex; align-items: center;
  font-family: var(--font-mono);
  min-width: 14px;
}
.trend.up { color: var(--green); }
.trend.down { color: var(--red); }
.trend.flat { color: var(--ink-4); }

/* Car number */
.nro {
  display: inline-grid; place-items: center;
  min-width: 36px; height: 28px; padding: 0 8px;
  border-radius: 6px;
  background: var(--bg-2);
  border: 1px solid var(--line-soft);
  font-family: var(--font-mono);
  font-weight: 700; font-size: 13px;
  color: var(--ink-0);
  font-variant-numeric: tabular-nums;
}
tr.p1 .nro { background: var(--amber); color: #000; border-color: transparent; }

/* Driver */
.driver { display: flex; align-items: center; gap: 10px; }
.driver .avatar {
  width: 28px; height: 28px; border-radius: 999px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--bg-3), var(--bg-2));
  color: var(--ink-1);
  font-size: 11px; font-weight: 700;
  border: 1px solid var(--line-soft);
  flex-shrink: 0;
}
.driver .name {
  font-weight: 600; color: var(--ink-0); font-size: 14px;
  overflow: hidden; text-overflow: ellipsis;
}

/* Marca */
.marca-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 8px; border-radius: 6px;
  background: var(--bg-2);
  border: 1px solid var(--line-soft);
  font-size: 11px; color: var(--ink-2);
  text-transform: uppercase; letter-spacing: 0.05em;
}

/* Logo images in marca column */
[data-theme="dark"] { --logo-filter: brightness(1.1) saturate(0.9); }
[data-theme="light"] { --logo-filter: none; }

/* Timing cells */
.t { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 13px; font-weight: 500; color: var(--ink-0); }
.t.best { color: var(--violet); }
.t.pb   { color: var(--green); }
.t.ob   { color: var(--violet); font-weight: 700; }
.t.warn { color: var(--amber); }

.gap { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 13px; color: var(--ink-2); }
.gap.up { color: var(--green); }
.gap.down { color: var(--red); }

.sector-cell {
  position: relative;
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
  font-size: 12.5px;
  padding-left: 14px !important;
}
.sector-cell::before {
  content: "";
  position: absolute;
  left: 6px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 14px; border-radius: 2px;
  background: var(--ink-4);
}
.sector-cell.pb { color: var(--green); }
.sector-cell.pb::before { background: var(--green); box-shadow: 0 0 8px var(--green); }
.sector-cell.ob { color: var(--violet); font-weight: 600; }
.sector-cell.ob::before { background: var(--violet); box-shadow: 0 0 10px var(--violet); }

/* ========= Right rail ========= */
.lt-rail {
  border-left: 1px solid var(--line);
  background: var(--bg-1);
  padding: 22px 20px;
  display: flex; flex-direction: column; gap: 22px;
  overflow-y: auto;
  min-height: 0;
}
.rail-title {
  font-family: var(--font-display);
  font-weight: 700; font-size: 11px;
  letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--ink-3);
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}

.sector-card {
  background: var(--bg-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
  padding: 12px;
  display: flex; align-items: center; gap: 10px;
}
.sector-card + .sector-card { margin-top: 8px; }
.sector-card .s-label {
  width: 34px; height: 34px; border-radius: 8px;
  display: grid; place-items: center;
  background: var(--violet); color: #0b0812;
  font-family: var(--font-display); font-weight: 800; font-size: 13px;
  letter-spacing: 0.1em;
  flex-shrink: 0;
}
.sector-card .s-who { flex: 1; min-width: 0; font-size: 13px; }
.sector-card .s-who .drv { font-weight: 600; color: var(--ink-0); }
.sector-card .s-who .sub { color: var(--ink-3); font-size: 11.5px; }
.sector-card .s-time {
  font-family: var(--font-mono); font-weight: 600; color: var(--violet); font-size: 14px;
}

.mini-stat {
  background: var(--bg-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
  padding: 12px;
}
.mini-stat .k { font-size: 10.5px; letter-spacing: 0.18em; color: var(--ink-3); text-transform: uppercase; }
.mini-stat .v { font-family: var(--font-mono); font-size: 22px; font-weight: 600; color: var(--ink-0); margin-top: 4px; }
.mini-stat .sub { font-size: 12px; color: var(--ink-2); margin-top: 2px; }

/* Compact footer status */
.lt-footer {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 22px;
  border-top: 1px solid var(--line);
  background: var(--bg-0);
  font-size: 12px; color: var(--ink-3);
}
.lt-footer .conn {
  display: inline-flex; align-items: center; gap: 6px;
}
.lt-footer .conn-dot {
  width: 6px; height: 6px; border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
}
.lt-footer .right { margin-left: auto; display: flex; gap: 14px; align-items: center; }

/* ===== SESSION CLOCKS ===== */
.lt-clocks {
  display: flex;
  flex-direction: row;
  gap: 8px;
  align-items: stretch;
  justify-content: flex-end;
  position: relative; z-index: 1;
}
.lt-clock {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 10px 18px;
  background: color-mix(in oklab, var(--bg-2), transparent 30%);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
  min-width: 110px;
}
.lt-clock-lbl {
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-4);
  white-space: nowrap;
}
.lt-clock-val {
  font-family: var(--font-mono);
  font-size: clamp(18px, 2vw, 26px);
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--ink-0);
  font-variant-numeric: tabular-nums;
  line-height: 1;
  white-space: nowrap;
}
.lt-clock-timetogo .lt-clock-val { color: var(--amber); }
.lt-clock-timetogo { border-color: color-mix(in oklab, var(--amber), transparent 70%); }

/* Mobile live-timing adjustments */
@media (max-width: 820px) {
  .lt-body { grid-template-columns: 1fr; }
  .lt-rail { border-left: 0; border-top: 1px solid var(--line); }
  .lt-header { padding: 18px 16px 14px; grid-template-columns: 1fr; }
  .lt-clocks { grid-column: 1; grid-row: 2; justify-content: flex-start; gap: 6px; padding-top: 4px; }
  .lt-clock { padding: 7px 12px; min-width: 80px; }
  .lt-clock-val { font-size: 16px; }
  .lt-clock-lbl { font-size: 9px; }
  .lt-actions { justify-content: space-between; grid-column: 1; grid-row: 3; }
  .best-bar { flex-wrap: wrap; padding: 10px 16px; }
  .best-bar .secs { width: 100%; margin: 0; padding-top: 8px; border-top: 1px dashed var(--line-soft); gap: 14px; }
  .best-bar .secs .s-val { font-size: 13px; }
  .lt-tabs { padding: 14px 12px 0; }

  /* Tighter sticky columns so more data is visible on small screens */
  .lt-table { min-width: 720px; }
  .lt-table tbody td { padding: 11px 9px; }
  .lt-table thead th { padding: 11px 9px; }
  .lt-table th.sticky.col-pos, .lt-table td.sticky.col-pos { min-width: 36px; }
  .lt-table th.sticky.col-nro, .lt-table td.sticky.col-nro { left: 36px; min-width: 44px; }
  .lt-table .driver .avatar { display: none; }
  .lt-table .driver .name {
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    max-width: 140px; font-size: 13px;
  }
  .lt-table .nro { min-width: 30px; height: 24px; font-size: 12px; padding: 0 6px; }
  .pos-cell { font-size: 15px; gap: 4px; }
}



/* ===== BEST-TIME TOOLTIP ===== */
.lt-tip {
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  /* `bottom` is set via inline style (vh - r.top + gap).
     Only horizontal centering needed here — no translateY. */
  transform: translateX(-50%);
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.5);
  padding: 5px 12px;
  font-family: var(--font-display, sans-serif);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-1);
  white-space: nowrap;
}
/* Arrow pointing down toward the element */
.lt-tip::after {
  content: '';
  position: absolute;
  bottom: -5px;
  left: 50%;
  width: 8px; height: 8px;
  background: var(--bg-1);
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  transform: translateX(-50%) rotate(45deg);
}
/* Hoverable cells */
.tb-cell  { cursor: default; }
.tb-cell:hover .t { opacity: 0.8; }
.best-bar { cursor: default; }
.best-bar:hover { background: color-mix(in oklab, var(--violet), transparent 90%); }

/* Tooltip is a pointer/hover feature — hide on touch devices */
@media (hover: none) {
  .lt-tip { display: none !important; }
}
