/* PBBU race tracker. Look and feel follows pbbu.co.za/teamsa.html. Fonts are bundled so the app works offline. */
@font-face { font-family: 'Archivo'; src: url('../fonts/archivo-latin-var.woff2') format('woff2'); font-weight: 100 900; font-display: swap; }
@font-face { font-family: 'Barlow Condensed'; src: url('../fonts/barlowcondensed-600.woff2') format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Barlow Condensed'; src: url('../fonts/barlowcondensed-700.woff2') format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Barlow Condensed'; src: url('../fonts/barlowcondensed-900.woff2') format('woff2'); font-weight: 900; font-display: swap; }
@font-face { font-family: 'Barlow Condensed'; src: url('../fonts/barlowcondensed-700i.woff2') format('woff2'); font-weight: 700; font-style: italic; font-display: swap; }

:root {
  --bg: #0c0c0d; --surface: #141416; --card: #1b1b1e; --card-2: #222226; --line: #2b2b30;
  --green: #007A4D; --green-ink: #25c184; --gold: #FFB81C; --red: #DE3831; --red-ink: #f4655e; --blue: #002395; --blue-ink: #6f8cff;
  --ink: #E9E6DF; --mute: #8d8d95; --dim: #5a5a62;
  --head: 'Barlow Condensed', 'Arial Narrow', sans-serif;
  --body: 'Archivo', 'Helvetica Neue', Arial, sans-serif;
  --flag: linear-gradient(90deg, var(--green) 0 20%, var(--gold) 20% 40%, #F5F3EE 40% 60%, var(--red) 60% 80%, var(--blue) 80% 100%);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body { background: var(--bg); color: var(--ink); font-family: var(--body); font-size: 16px; line-height: 1.55; -webkit-font-smoothing: antialiased; min-height: 100vh; }
a { color: var(--gold); text-decoration: none; }
a:hover { color: #fff; }
img { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
.wrap { max-width: 1300px; margin: 0 auto; padding: 0 clamp(1rem, 4vw, 3rem); }
.tnum { font-variant-numeric: tabular-nums; }
.mute { color: var(--mute); }
.hidden { display: none !important; }

/* ---- nav ---- */
.topnav { position: sticky; top: 0; z-index: 60; height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0 clamp(1rem, 4vw, 3rem); background: rgba(12,12,13,.9); backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: .65rem; font-family: var(--head); font-weight: 900; font-size: 1.15rem; letter-spacing: .03em; text-transform: uppercase; color: #fff; white-space: nowrap; }
.brand:hover { color: #fff; }
.brand .za { flex: none; border-radius: 2px; }
.navlinks { display: flex; gap: 1.4rem; list-style: none; flex-wrap: wrap; justify-content: flex-end; }
.navlinks a { font-family: var(--head); font-weight: 700; font-size: .82rem; letter-spacing: .13em; text-transform: uppercase; color: var(--mute); }
.navlinks a:hover, .navlinks a.on { color: var(--gold); }
@media (max-width: 860px) { .navlinks { gap: .9rem; } .navlinks .opt { display: none; } }

/* ---- type ---- */
.eyebrow { font-family: var(--head); font-weight: 700; font-size: .82rem; letter-spacing: .24em; text-transform: uppercase; color: var(--gold); margin-bottom: .6rem; }
h1, h2, h3 { font-family: var(--head); font-weight: 900; text-transform: uppercase; color: #fff; line-height: .95; }
h1 { font-size: clamp(2.6rem, 6vw, 4.6rem); letter-spacing: -.01em; }
h2 { font-size: clamp(1.9rem, 4vw, 2.8rem); margin-bottom: 1rem; }
h3 { font-size: 1.3rem; margin-bottom: .6rem; }
h1 span, h2 span { color: var(--gold); }
h1 .g { color: var(--green); }
.lede { color: var(--mute); max-width: 66ch; margin-bottom: 2rem; }
.label { font-family: var(--head); font-weight: 700; font-size: .72rem; letter-spacing: .16em; text-transform: uppercase; color: var(--mute); }

main.page { padding: clamp(1.5rem, 4vw, 3rem) 0 4rem; }
.page-h { display: flex; justify-content: space-between; align-items: flex-end; gap: 1.5rem; flex-wrap: wrap; margin-bottom: 2rem; }
.page-h h1 { font-size: clamp(2.2rem, 5vw, 3.6rem); }

/* ---- buttons ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; padding: .75rem 1.4rem; font-family: var(--head); font-weight: 700; font-size: .9rem; letter-spacing: .12em; text-transform: uppercase; border-radius: 3px; border: 1.5px solid transparent; cursor: pointer; background: none; transition: transform .15s, background .2s, border-color .2s, color .2s; white-space: nowrap; }
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn-p { background: var(--gold); color: #111; }
.btn-p:hover { color: #111; background: #ffc94d; }
.btn-g { border-color: var(--line); color: #fff; }
.btn-g:hover { border-color: #fff; color: #fff; }
.btn-green { background: var(--green); color: #fff; }
.btn-green:hover { background: #009660; color: #fff; }
.btn-danger { border-color: rgba(222,56,49,.55); color: var(--red-ink); }
.btn-danger:hover { background: var(--red); border-color: var(--red); color: #fff; }
.btn-sm { padding: .4rem .8rem; font-size: .76rem; }
.btns { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }
.linkbtn { background: none; border: 0; padding: 0; cursor: pointer; color: var(--gold); font: inherit; }

/* ---- panels ---- */
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.panel-h { background: linear-gradient(120deg, var(--green), #00593a); padding: 1.1rem 1.5rem; display: flex; align-items: center; gap: .9rem; flex-wrap: wrap; }
.panel-h h3 { margin: 0; font-size: 1.25rem; }
.panel-h .chip { font-family: var(--head); font-weight: 900; font-size: .7rem; letter-spacing: .18em; text-transform: uppercase; background: rgba(255,255,255,.18); color: #fff; padding: 4px 9px; border-radius: 2px; }
.panel-b { padding: 1.4rem 1.5rem; }
.panel + .panel { margin-top: 1.5rem; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 1.5rem; align-items: start; }
@media (max-width: 980px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---- stats row ---- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); border: 1px solid var(--line); border-radius: 10px; background: var(--card); overflow: hidden; }
.stat { padding: 1rem 1.25rem; border-right: 1px solid var(--line); }
.stat:last-child { border-right: none; }
.stat b { display: block; font-family: var(--head); font-weight: 900; font-size: 2.1rem; line-height: 1; color: var(--gold); font-variant-numeric: tabular-nums; }
.stat b em { font-style: normal; font-size: 1.1rem; }
.stat span { display: block; font-family: var(--head); font-size: .74rem; letter-spacing: .16em; text-transform: uppercase; color: var(--mute); margin-top: .3rem; }

/* ---- status pills ---- */
.pill { display: inline-block; padding: .2rem .7rem; border-radius: 999px; font-family: var(--head); font-weight: 700; font-size: .76rem; letter-spacing: .08em; text-transform: uppercase; white-space: nowrap; border: 1px solid; }
.pill.ready { color: var(--mute); border-color: var(--line); }
.pill.onCourse { color: var(--gold); border-color: rgba(255,184,28,.4); background: rgba(255,184,28,.08); }
.pill.inCorral { color: var(--green-ink); border-color: rgba(0,122,77,.5); background: rgba(0,122,77,.14); }
.pill.out { color: var(--red-ink); border-color: rgba(222,56,49,.4); background: rgba(222,56,49,.1); }
.pill.winner { color: #111; border-color: var(--gold); background: var(--gold); }

/* ---- tables ---- */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-family: var(--head); font-weight: 700; font-size: .72rem; letter-spacing: .15em; text-transform: uppercase; color: var(--mute); padding: .7rem .75rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: .65rem .75rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tbody tr:hover { background: rgba(255,255,255,.02); }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl .bib { font-family: var(--head); font-weight: 900; font-size: 1.25rem; color: var(--gold); }
.tbl .who { display: flex; align-items: center; gap: .75rem; }
.tbl .who b { font-family: var(--head); font-weight: 700; font-size: 1.05rem; letter-spacing: .02em; text-transform: uppercase; color: #fff; display: block; line-height: 1.1; }
.tbl .who small { color: var(--mute); font-size: .8rem; }
.table-scroll { overflow-x: auto; }

/* ---- avatars ---- */
.av { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; background: var(--surface); flex: none; border: 2px solid var(--line); }
.av-fallback { display: inline-flex; align-items: center; justify-content: center; font-family: var(--head); font-weight: 900; color: var(--gold); }

/* ---- forms ---- */
.form { display: grid; gap: 1.1rem; }
.form .row2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1.1rem; }
.field label, .field .label { display: block; margin-bottom: .35rem; }
.field input:not([type=checkbox]):not([type=range]), .field select, .field textarea, .input {
  width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: .7rem .85rem; color: #fff; outline: none; transition: border-color .15s;
}
.field input:focus, .field select:focus, .field textarea:focus, .input:focus { border-color: var(--gold); }
.field textarea { min-height: 110px; resize: vertical; }
.field .hint { font-size: .8rem; color: var(--mute); margin-top: .3rem; }
.field-validation-error, .validation-summary-errors, .err { color: var(--red-ink); font-size: .85rem; }
.validation-summary-errors ul { list-style: none; }
input[type=datetime-local] { color-scheme: dark; }
.check { display: flex; align-items: center; gap: .5rem; color: var(--mute); font-size: .9rem; }

/* ---- flash ---- */
.flash { padding: .9rem 1.2rem; border-radius: 6px; margin-bottom: 1.5rem; border: 1px solid; font-weight: 500; }
.flash.ok { border-color: rgba(0,122,77,.6); background: rgba(0,122,77,.14); color: var(--green-ink); }
.flash.bad { border-color: rgba(222,56,49,.5); background: rgba(222,56,49,.1); color: var(--red-ink); }

/* ---- launcher tiles ---- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1.25rem; }
.tile { display: block; background: var(--card); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; color: inherit; transition: transform .18s, border-color .18s; }
.tile:hover { transform: translateY(-4px); border-color: var(--gold); color: inherit; }
.tile .s { height: 4px; }
.tile .b { padding: 1.3rem 1.4rem 1.4rem; }
.tile .r { font-family: var(--head); font-weight: 700; font-size: .7rem; letter-spacing: .18em; text-transform: uppercase; color: var(--mute); }
.tile h3 { margin: .35rem 0 .45rem; font-size: 1.45rem; }
.tile p { font-size: .9rem; color: var(--mute); margin-bottom: .9rem; }
.tile .go { font-family: var(--head); font-weight: 700; font-size: .78rem; letter-spacing: .15em; text-transform: uppercase; color: var(--gold); }
.tile .go::after { content: ' →'; }

.urls { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: .8rem; }
.urls code { font-family: var(--head); font-weight: 700; font-size: 1.3rem; letter-spacing: .04em; color: #fff; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: .35rem .8rem; }

/* ---- footer ---- */
.fstripe { height: 4px; border-radius: 2px; background: var(--flag); }
footer.site { border-top: 1px solid var(--line); padding: 2rem 0; color: var(--mute); font-size: .8rem; }
footer.site .fstripe { margin-bottom: 1.4rem; }
footer.site .wrap > div:last-child { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }

/* ---- dialog ---- */
dialog { margin: auto; background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: 12px; padding: 0; width: min(520px, calc(100vw - 2rem)); }
dialog::backdrop { background: rgba(6,6,7,.8); backdrop-filter: blur(4px); }
dialog .d-b { padding: 1.5rem; }
dialog .d-f { padding: 1rem 1.5rem; border-top: 1px solid var(--line); display: flex; gap: .6rem; justify-content: flex-end; flex-wrap: wrap; }

/* ---- photo cropper (dashboard) ---- */
.cropper { display: grid; grid-template-columns: auto 1fr; gap: 1.25rem; align-items: start; }
.crop-box { width: 220px; height: 220px; border-radius: 50%; overflow: hidden; position: relative; background: var(--surface); border: 2px solid var(--gold); cursor: grab; touch-action: none; }
.crop-box img { position: absolute; max-width: none; user-select: none; -webkit-user-drag: none; pointer-events: none; }
.crop-box.empty { display: flex; align-items: center; justify-content: center; color: var(--dim); font-family: var(--head); letter-spacing: .14em; text-transform: uppercase; font-size: .8rem; cursor: default; border-color: var(--line); }
.crop-tools { display: grid; gap: .8rem; }
.crop-tools input[type=range] { width: 100%; accent-color: var(--gold); }
@media (max-width: 600px) { .cropper { grid-template-columns: 1fr; } }
