/* =========================================================
   APG Live Timing – table layout (final)
   - Spacing & alignment for <table class="apg-lt-table">
   - Compact / Wide variants via container classes
   - Sticky header + mobile collapse
   ========================================================= */

/* ---------- Base container ---------- */
.apg-lt-container {
  background-color: var(--apg-bg, #111) !important;
  color: var(--apg-fg, #fff) !important;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  padding: 16px 20px;
  border-radius: 10px;
  line-height: 1.6;

  /* tunables (affect table layout below) */
  --apg-row-gap: 10px;          /* visual gap between table rows */
  --apg-cell-x: 18px;           /* left/right cell padding */
  --apg-header-x: 16px;         /* header cell padding */
  --apg-font-nums: tabular-nums;

  /* column widths */
  --col-pos: 44px;
  --col-no:  60px;
  --col-name-min: 240px;
  --col-gap:  120px;
  --col-last: 120px;
  --col-best: 120px;
  --col-laps: 80px;
}

/* Wide variant (opt-in with class="apg-wide" on container or shortcode class) */
.apg-lt-container.apg-wide {
  --apg-row-gap: 12px;
  --apg-cell-x: 20px;
  --apg-header-x: 18px;

  --col-name-min: 260px;
  --col-gap:  130px;
  --col-last: 130px;
  --col-best: 130px;
  --col-laps: 90px;
}

/* Compact variant (opt-in with class="apg-compact") */
.apg-lt-container.apg-compact {
  --apg-row-gap: 6px;
  --apg-cell-x: 12px;
  --apg-header-x: 12px;

  --col-name-min: 200px;
  --col-gap:  100px;
  --col-last: 100px;
  --col-best: 100px;
  --col-laps: 70px;
}

/* ---------- Section title ---------- */
.apg-lt-container .apg-lt-header {
  font-weight: 600;
  border-bottom: 2px solid var(--apg-accent, #ffcc00);
  margin-bottom: 14px;
  padding-bottom: 6px;
  font-size: 1.1rem;
  letter-spacing: 0.3px;
}

/* =========================================================
   TABLE: .apg-lt-table
   ========================================================= */
.apg-lt-table {
  width: 100%;
  border-collapse: separate;             /* allow row spacing via border-spacing */
  border-spacing: 0 var(--apg-row-gap);  /* vertical space between rows */
  font-variant-numeric: var(--apg-font-nums);
  font-feature-settings: "tnum" 1;
}

/* Optional: if you include a <colgroup> with 7 <col> elements,
   these width rules will apply perfectly. */
.apg-lt-table col:nth-child(1) { width: var(--col-pos); }
.apg-lt-table col:nth-child(2) { width: var(--col-no); }
.apg-lt-table col:nth-child(3) { width: auto; min-width: var(--col-name-min); }
.apg-lt-table col:nth-child(4) { width: var(--col-gap); }
.apg-lt-table col:nth-child(5) { width: var(--col-last); }
.apg-lt-table col:nth-child(6) { width: var(--col-best); }
.apg-lt-table col:nth-child(7) { width: var(--col-laps); }

/* Header */
.apg-lt-table thead th {
  padding: 10px var(--apg-header-x);
  text-transform: uppercase;
  letter-spacing: .5px;
  font-weight: 600;
  color: var(--apg-accent, #ffcc00);
  border-bottom: 2px solid var(--apg-accent, #ffcc00);
  text-align: left; /* Name column left by default; we right-align numbers below */
  background: rgba(255,255,255,0.05);
  position: sticky;         /* sticky header */
  top: 0;
  z-index: 5;
  backdrop-filter: blur(6px);
}

/* Body cells */
.apg-lt-table tbody td {
  padding: 12px var(--apg-cell-x);
  background: rgba(255,255,255,0.05);
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

/* Row hover */
.apg-lt-table tbody tr:hover td {
  background: rgba(255,255,255,0.08);
}

/* Right-align numeric columns; keep Name left */
.apg-lt-table th:nth-child(1),
.apg-lt-table th:nth-child(2),
.apg-lt-table th:nth-child(4),
.apg-lt-table th:nth-child(5),
.apg-lt-table th:nth-child(6),
.apg-lt-table th:nth-child(7),
.apg-lt-table td:nth-child(1),
.apg-lt-table td:nth-child(2),
.apg-lt-table td:nth-child(4),
.apg-lt-table td:nth-child(5),
.apg-lt-table td:nth-child(6),
.apg-lt-table td:nth-child(7) { text-align: right; }
.apg-lt-table th:nth-child(3),
.apg-lt-table td:nth-child(3) { text-align: left; }

/* Divider style: give the first and last cells rounded corners (row “pill” look) */
.apg-lt-table tbody tr td:first-child {
  border-top-left-radius: 8px;
  border-bottom-left-radius: 8px;
}
.apg-lt-table tbody tr td:last-child {
  border-top-right-radius: 8px;
  border-bottom-right-radius: 8px;
}

/* =========================================================
   MOBILE: collapse less-critical columns into wrapped lines
   ========================================================= */
@media (max-width: 900px) {
  .apg-lt-table { border-spacing: 0 6px; }
  .apg-lt-table thead { display: none; } /* simplify on small screens */

  /* Turn each row into a 4-col grid: pos | no | name | gap */
  .apg-lt-table tbody tr {
    display: grid;
    grid-template-columns: var(--col-pos) var(--col-no) minmax(140px, 1fr) 90px;
    column-gap: 10px;
  }
  .apg-lt-table tbody td {
    padding: 8px 10px;
  }
  /* Push last/best/laps to a second line across full width */
  .apg-lt-table tbody td:nth-child(n+5) {
    grid-column: 1 / -1;
    opacity: .9;
    font-size: .92em;
    padding-top: 2px;
  }
}

/* =========================================================
   Archive section (as before, lightly cleaned)
   ========================================================= */
.apg-arch-wrap {
  display: grid; grid-template-columns: 1fr 2fr; gap: 16px;
}
.apg-arch-controls { margin: 8px 0; }
.apg-arch-controls input[type="search"] {
  width: 100%; padding: 8px; border: 1px solid var(--apg-border,#ccc);
  border-radius: 8px; background: transparent; color: inherit;
}
.apg-arch-items {
  list-style: none; padding: 0; margin: 0; display: grid; gap: 8px;
}
.apg-arch-item button {
  width: 100%; text-align: left; padding: 10px; border-radius: 8px;
  border: 1px solid var(--apg-border,#ddd); background: var(--apg-muted,#f7f7f7);
  color: inherit; cursor: pointer;
}
.apg-arch-more {
  margin-top: 10px; padding: 10px 12px; border-radius: 8px;
  border: 1px solid var(--apg-border,#ddd); background: transparent; color: inherit;
  cursor: pointer;
}
.apg-arch-view {
  border: 1px solid var(--apg-border,#ddd); border-radius: 10px; padding: 10px; min-height: 280px;
}
@media (max-width: 900px) { .apg-arch-wrap { grid-template-columns: 1fr; } }