/* Theme: AMG GT3 livery — charcoal base, crimson red, gunmetal grey, teal. */
:root {
    --bg: #07090c;
    --panel: #111517;
    --panel-2: #181f25;
    --line: #25313d;
    --text: #ffffff;
    --muted: #9ba4af;
    --accent: #d83139;
    --accent-hover: #ff5a64;
    --accent-2: #68d0ec;
    --gunmetal: #5a6870;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: radial-gradient(1200px 600px at 50% -10%, #0d1318 0%, var(--bg) 60%);
    color: var(--text);
    font: 16px/1.5 "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

a { color: var(--accent-2); }

.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 24px;
    border-bottom: 1px solid var(--line);
    background: rgba(22, 25, 29, .95);
    position: fixed;
    inset: 0 0 auto 0;
    z-index: 999;
    backdrop-filter: blur(6px);
}

html { scroll-padding-top: 96px; }

main { max-width: 1120px; margin: 0 auto; padding: 112px 24px 64px; }

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    font-weight: 700;
    letter-spacing: .04em;
    text-decoration: none;
    text-transform: uppercase;
}

.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: #000;
    color: #fff;
    font-size: 13px;
    box-shadow: inset 0 0 0 1px rgba(47, 176, 189, .5);
}

.site-header nav { display: flex; gap: 8px; }

.site-header nav a {
    padding: 8px 14px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--muted);
    text-decoration: none;
    font-size: 14px;
}

.site-header nav a:hover { color: var(--text); border-color: var(--accent-2); }
.site-header nav a.active { color: #fff; background: var(--accent); border-color: var(--accent); }

h1 { margin: 0 0 4px; font-size: 30px; letter-spacing: -.01em; }
h2 { margin: 0 0 4px; font-size: 20px; }
.subtitle { margin: 0 0 24px; color: var(--muted); }
.muted { color: var(--muted); }
.optional { color: var(--muted); font-weight: 400; font-size: 13px; }

.filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    padding: 18px;
    margin-bottom: 24px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 12px;
}

label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); }

input, select, button {
    width: 100%;
    margin-top: 6px;
    padding: 10px 12px;
    font: inherit;
    color: var(--text);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
}

input:focus, select:focus { outline: 2px solid var(--accent-2); outline-offset: 1px; }

button, .button-link {
    display: inline-block;
    text-align: center;
    font-weight: 600;
    cursor: pointer;
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    text-decoration: none;
}

button:hover, .button-link:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.button-link:hover { background: var(--panel-2); border-color: var(--accent-2); color: var(--text); }

.admin-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap;
    white-space: nowrap;
}

.admin-action-form {
    display: inline-flex;
    margin: 0;
}

.admin-action-btn,
.admin-action-form button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 6px 12px;
    width: auto;
    margin: 0;
    font-size: 13px;
    line-height: 1.2;
    border-radius: 999px;
    text-decoration: none;
}

.admin-action-btn {
    background: var(--accent-2);
    border-color: var(--accent-2);
    color: var(--line);
}

.admin-action-btn:hover {
    background: var(--line);
    border-color: var(--accent-2);
    color: var(--accent-2);
}


.admin-action-form button:not(.admin-action-btn) {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--line);
}

.admin-action-form button:not(.admin-action-btn):hover {
    background: var(--line);
    border-color: var(--accent);
    color: var(--accent);
}

.filter-actions { display: flex; align-items: end; gap: 8px; }
.button-link { background: var(--panel-2); border-color: var(--line); color: var(--muted); padding: 10px 12px; }

table.laps {
    width: 100%;
    border-collapse: collapse;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow: hidden;
    font-size: 14px;
}

table.laps th {
    text-align: left;
    padding: 12px;
    background: linear-gradient(var(--panel-2), var(--panel));
    border-bottom: 1px solid var(--gunmetal);
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .06em;
}

table.laps td { padding: 12px; border-top: 1px solid var(--line); }
table.laps tbody tr:hover { background: #242a31; }
table.laps tbody tr:first-child { box-shadow: inset 3px 0 0 var(--accent-2); }
table.laps tbody tr:first-child .time { color: var(--accent-2); }

.pos { color: var(--muted); width: 48px; }
.time, .gap { font-variant-numeric: tabular-nums; font-weight: 600; }
.gap { color: var(--muted); font-weight: 400; }

.badge {
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid var(--line);
}

.badge-race { background: rgba(180, 35, 47, .2); color: #f09098; border-color: rgba(180, 35, 47, .5); }
.badge-practice { background: rgba(47, 176, 189, .14); color: #7fd7e0; border-color: rgba(47, 176, 189, .4); }

.lap-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
    padding: 22px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 12px;
}

.lap-form button { grid-column: 1 / -1; padding: 12px; }
.lap-form .lap-form-actions {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 8px;
}
.lap-form .admin-save-btn {
    grid-column: 1 / -1;
    justify-self: start;
    width: auto;
    min-width: 180px;
    background: var(--accent-2);
    border-color: var(--accent-2);
    color: var(--line);
}
.lap-form .admin-save-btn:hover {
    background: var(--line);
    border-color: var(--accent-2);
    color: var(--accent-2);
}
.lap-form .admin-cancel-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    justify-self: end;
    width: auto;
    min-width: 140px;
    padding: 12px;
    border: 1px solid var(--accent);
    border-radius: 8px;
    background: var(--accent);
    color: var(--line);
    font-weight: 600;
}
.lap-form .admin-cancel-btn:hover {
    background: var(--line);
    border-color: var(--accent);
    color: var(--accent);
}
.lap-form .admin-save-btn,
.lap-form .admin-cancel-btn {
    margin-top: 0;
}

.lap-form .admin-save-btn + .admin-cancel-btn {
    margin-left: auto;
}

.lap-form.is-editing .admin-save-btn,
.lap-form.is-editing .admin-cancel-btn {
    grid-column: auto;
}

.lap-form.is-editing .admin-cancel-btn {
    justify-self: start;
    margin-left: auto;
}

.session-type { border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; margin: 0; }
.session-type legend { color: var(--muted); font-size: 13px; font-weight: 600; padding: 0 6px; }
.session-type .radio { display: inline-flex; align-items: center; gap: 6px; color: var(--text); font-weight: 400; margin-right: 16px; }
.session-type input { width: auto; margin: 0; }

.field-error { display: block; margin-top: 6px; color: #f09098; font-weight: 400; }

.notice { padding: 12px 16px; border-radius: 8px; border: 1px solid var(--line); }
.notice.success { background: rgba(47, 176, 189, .12); border-color: rgba(47, 176, 189, .4); }
.notice.error { background: rgba(180, 35, 47, .14); border-color: rgba(180, 35, 47, .5); }
.empty { color: var(--muted); }

.hint { display: block; margin-top: 6px; font-weight: 400; color: var(--muted); font-size: 12px; }
.lap-form .wide { grid-column: 1 / -1; }
.breadcrumb { margin: 0 0 12px; font-size: 14px; }

.track-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 14px;
}

.track-card {
    display: flex;
    flex-direction: column;
    padding: 16px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-left: 3px solid var(--accent);
    border-radius: 10px;
    color: var(--text);
    text-decoration: none;
}

.track-card { position: relative; }

.incident-pill {
    position: absolute;
    right: 14px;
    bottom: 12px;
    background: var(--panel-2);
    border: 1px solid var(--line);
    color: var(--muted);
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}


.incident-count {
    color: var(--accent);
    margin-right: 8px;
    font-weight: 900;
}

.track-card:hover { border-left-color: var(--accent-2); background: #242a31; }
.track-card h3 { margin: 0; font-size: 17px; }
.track-layout { margin: 2px 0 10px; color: var(--muted); font-size: 13px; }

.track-facts {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 10px;
    padding: 0;
    list-style: none;
    font-size: 12px;
}

.track-facts li {
    padding: 3px 8px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--muted);
}

.track-best {
    margin: auto 0 0;
    font-size: 13px;
    color: var(--muted);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.track-laps { color: var(--muted); font-weight: 600; }
.track-unique { font-weight: 800; color: var(--text); }
.track-best strong { color: var(--accent-2); font-variant-numeric: tabular-nums; }

.layout-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--line);
}

.layout-tabs a {
    padding: 8px 14px;
    border: 1px solid var(--accent-2);
    border-radius: 8px;
    background: var(--panel);
    color: var(--muted);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
}

.layout-tabs a:hover { color: var(--line); border-color: var(--accent-2); background: var(--accent-2);}
.layout-tabs a.active { color: var(--line); background: var(--accent-2); border-color: var(--accent-2); }
.layout-tabs .tab-meta { display: block; font-size: 11px; font-weight: 400; opacity: .8; font-variant-numeric: tabular-nums; }

.track-detail {
    display: grid;
    /* allow the left column to grow to the image's intrinsic width while remaining responsive */
    grid-template-columns: minmax(360px, max-content) 1fr;
    gap: 0;
    align-items: stretch;
    margin-bottom: 16px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow: hidden;
}

/* Map on the left, info on the right — both inside a single rounded panel */
.track-detail > .track-map { grid-column: 1; display: block; margin: 0; width: auto; max-width: 100%; height: auto; min-height: 260px; }
.track-detail > .track-info { grid-column: 2; padding: 24px 28px; border-left: 1px solid rgba(255,255,255,0.03); background: transparent; }

@media (max-width: 720px) {
    .track-detail { grid-template-columns: 1fr; }
    .track-detail > .track-info, .track-detail > .track-map { grid-column: auto; border-left: none; }
}

.track-info {
    display: grid;
    grid-template-columns: 1fr; /* vertical stack by default */
    gap: 12px;
    margin: 0;
}

/* On large screens allow multiple columns */
@media (min-width: 1000px) {
    .track-info { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
}

.track-info dt { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.track-info dd { margin: 4px 0 0; font-weight: 600; }
.track-map { width: auto; max-width: 100%; height: auto; display: block; object-fit: none; }
.track-notes { color: var(--muted); margin: 0 0 28px; }

.livery {
    position: relative;
    margin-bottom: 20px;
    border: 1px solid var(--line);
    border-radius: 14px;
    overflow: hidden;
    background: var(--gunmetal);
}

.livery-art { display: block; width: 100%; height: 200px; object-fit: cover; }

.livery-content {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 10px 32px 0;
}

.livery-number {
    display: grid;
    place-items: center;
    width: 92px;
    height: 92px;
    border: 3px solid #f2f4f6;
    border-radius: 8px;
    background: rgba(22, 25, 29, .82);
    color: #f2f4f6;
    font-size: 46px;
    font-weight: 800;
    font-style: italic;
    letter-spacing: -.02em;
}

.livery-titles {
    align-self: stretch;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    /* Padding lines the two lines up with the top and bottom edges of the number
       box; the top value is reduced by the font's cap-height offset. */
    padding: 48px 0 51px;
    text-shadow: 0 2px 10px rgba(0, 0, 0, .6);
}

.livery-team {
    margin: 0;
    font-size: 30px;
    line-height: 1;
    font-weight: 800;
    font-style: italic;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: #fff;
}

.livery-tag { margin: 0; font-size: 13px; line-height: 1; letter-spacing: .16em; text-transform: uppercase; color: #dfe5ea; }

@media (max-width: 640px) {
    .livery-art { height: 150px; }
    .livery-content { gap: 14px; padding: 0 18px; }
    .livery-number { width: 64px; height: 64px; font-size: 32px; }
    .livery-titles { padding: 43px 0; }
    .livery-team { font-size: 20px; }
    .livery-tag { font-size: 11px; letter-spacing: .1em; }
}

.hero {
    position: relative;
    overflow: hidden;
    margin-bottom: 40px;
    padding: 24px 32px;
    border: 1px solid var(--line);
    border-left: 4px solid var(--accent);
    border-radius: 14px;
    background:
        radial-gradient(120% 140% at 100% 0%, rgba(47, 176, 189, .16), transparent 60%),
        linear-gradient(135deg, var(--panel-2), var(--panel));
}

.hero-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 12px;
    margin: 0;
    padding: 0;
    list-style: none;
    text-align: center;
}

.hero-stats strong { display: block; font-size: 26px; color: var(--text); font-variant-numeric: tabular-nums; }
.hero-stats span { display: block; margin-bottom: 4px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }

.home-section { margin-bottom: 40px; }

.section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 12px;
}

.section-head h2 { margin: 0; }
.section-head a { font-size: 13px; }

.record-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }

@media (max-width: 900px) { .record-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 520px) { .record-grid { grid-template-columns: 1fr; } }

.record-card {
    display: block;
    padding: 16px;
    border: 1px solid var(--line);
    border-top: 3px solid var(--accent);
    border-radius: 10px;
    background: var(--panel);
    text-decoration: none;
    color: var(--text);
}

.record-card:hover { border-color: var(--accent-2); background: var(--panel-2); }
.record-track { margin: 0 0 6px; font-weight: 600; }
.record-time { margin: 0 0 6px; font-size: 24px; color: var(--accent-2); font-variant-numeric: tabular-nums; }
.record-meta { margin: 0; font-size: 12px; color: var(--muted); }

@media (max-width: 640px) {
    .hero { padding: 20px; }
}

.inline-filter { margin: 0; }
.inline-filter label { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }

.video-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }

.video-card {
    display: block;
    border: 1px solid var(--line);
    border-radius: 10px;
    overflow: hidden;
    background: var(--panel);
    color: var(--text);
    text-decoration: none;
}

.video-card:hover { border-color: var(--accent-2); }
.video-card img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
.video-card span { display: block; padding: 10px 12px; font-size: 13px; line-height: 1.35; }

.incident-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }

.incident-card {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--line);
    border-left: 3px solid var(--accent);
    border-radius: 10px;
    overflow: hidden;
    background: var(--panel);
}

.incident-thumb img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
.incident-body { padding: 14px 16px; }
.incident-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 0 0 8px; font-size: 12px; }
.incident-card h3 { margin: 0 0 6px; font-size: 17px; }
.incident-where { margin: 0 0 8px; font-size: 13px; color: var(--muted); }
.incident-text { margin: 0; font-size: 13px; color: var(--text); }

.badge-type { background: rgba(90, 100, 112, .35); border-color: var(--gunmetal); color: var(--text); }

.lap-form label.wide { grid-column: 1 / -1; }

.lap-form textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-2);
    color: var(--text);
    font: inherit;
    resize: vertical;
}

.lap-form textarea:focus { outline: none; border-color: var(--accent-2); }

.featured { margin-top: 32px; }
.video-frame { position: relative; padding-top: 56.25%; margin-top: 12px; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); }
.video-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

.site-footer { padding: 24px; border-top: 1px solid var(--line); color: var(--muted); text-align: center; font-size: 13px; }

@media (max-width: 720px) {
    table.laps { display: block; overflow-x: auto; }
}

.admin-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.admin-head h1 { margin: 0; }
.admin-head form { margin: 0; }

button.secondary {
    background: var(--accent);
    border: 1px solid var(--accent);
    color: var(--line);
}
button.secondary:hover {
    background: var(--line);
    border-color: var(--accent);
    color: var(--accent);
}

.login-form { display: grid; gap: 14px; max-width: 320px; margin-top: 20px; }

.incident-grid-home { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 900px) { .incident-grid-home { grid-template-columns: 1fr; } }
