/*
 * Shared look of all pages of the rF2 gateway: F1 broadcast style in the colors of RCCO World eX
 * (electric lime on warm carbon in dark mode, cool white in light mode).
 * Loaded by every page right after its own <style>: it defines the colors (light, and dark as the
 * default via theme.js) and the common building blocks (header, panels, tables, buttons, fields,
 * tags). The pages keep only their own layout.
 *
 * The one signature element: the angled wedge of the broadcast graphics, on the page title and on
 * every panel title, in the eX lime (--brand). The lime is only used for this and the active page;
 * it differs from the green of personal bests (--green), errors use --red, links and focus --accent.
 */

@font-face {
  font-family: "Titillium Web"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("/fonts/titillium-web-latin-400-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Titillium Web"; font-style: normal; font-weight: 600; font-display: swap;
  src: url("/fonts/titillium-web-latin-600-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Titillium Web"; font-style: normal; font-weight: 700; font-display: swap;
  src: url("/fonts/titillium-web-latin-700-normal.woff2") format("woff2");
}

/* ---------- colors ---------- */

/* Light: cool white with a petrol tint */
:root {
  --bg: #e6eceb; --panel: #ffffff; --panel-2: #f0f4f3; --row: #f5f8f7; --code: #ebf0ef;
  --text: #0f1a1c; --muted: #546568; --line: #d1dbd9;
  --brand: #5cb800; --brand-ink: #0f1a1c; --accent: #1b5bd0;
  --green: #0d8a3a; --red: #c8102e; --amber: #9a5b06; --yellow: #9a5b06; --purple: #7a2fd6;
  --green-bg: #e1f3e8; --red-bg: #fbe6e9; --amber-bg: #fbf0da; --changed: #fff3c4;
  --pos-bg: #0f1a1c; --pos-text: #ffffff;
  --radius: 3px;
}

/* Dark (default): warm carbon */
:root[data-theme="dark"] {
  --bg: #12110e; --panel: #1b1a16; --panel-2: #23221d; --row: #1f1e19; --code: #0f0e0b;
  --text: #f3f2ec; --muted: #a29e91; --line: #34322b;
  --brand: #a6e22e; --brand-ink: #12110e; --accent: #62a0ff;
  --green: #2ed06a; --red: #ff5a67; --amber: #f0b03c; --yellow: #f3c84a; --purple: #b56dff;
  --green-bg: #11301d; --red-bg: #3a151b; --amber-bg: #372911; --changed: #3a3213;
  --pos-bg: #f3f2ec; --pos-text: #12110e;
}

/* ---------- base ---------- */

body {
  font-family: "Titillium Web", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px; line-height: 1.4; background: var(--bg); color: var(--text);
  -webkit-font-smoothing: antialiased;
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
a { color: var(--accent); }
::selection { background: var(--brand); color: var(--brand-ink); }

/* ---------- header ---------- */

header {
  background: var(--panel); border-bottom: 1px solid var(--line);
  box-shadow: inset 0 3px 0 var(--brand);
}
header h1 { font-weight: 700; font-size: 22px; letter-spacing: .005em; line-height: 1.2; }
header h1::before {
  content: ""; display: inline-block; width: 12px; height: .85em; margin-right: 12px;
  background: var(--brand); transform: skewX(-20deg); vertical-align: -0.04em;
}
header nav a { color: var(--muted); font-weight: 600; position: relative; padding: 2px 0; }
header nav a:hover { color: var(--text); }
header nav a.active { color: var(--text); font-weight: 700; }
header nav a.active::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -4px; height: 3px;
  background: var(--brand); transform: skewX(-20deg);
}

/* ---------- panels ---------- */

.panel, .map-panel, .savebar, .card, .empty.boxed {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
}
.panel > h2, .map-head h2 { font-weight: 700; font-size: 16px; letter-spacing: .01em; }
.panel > h2 {
  position: relative; background: var(--panel-2); padding-left: 24px;
  border-radius: var(--radius) var(--radius) 0 0;
}
/* the wedge of the broadcast graphics */
.panel > h2::after, .map-head h2::before, .lr-head h2::before, .summary .title h2::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 10px; background: var(--brand);
  clip-path: polygon(0 0, 100% 0, 45% 100%, 0 100%); border-top-left-radius: var(--radius);
}
.map-head h2, .lr-head h2, .summary .title h2 { position: relative; padding-left: 20px; }
.map-head h2::before, .lr-head h2::before, .summary .title h2::before {
  top: .12em; bottom: .12em; border-radius: 0;
}
.panel.collapsed > h2 { border-radius: var(--radius); }
.panel > h2 span, .panel > h2 small { font-weight: 400; }
.pagebar h2 { font-weight: 700; }

/* ---------- tables (not the long run graphic) ---------- */

table:not(.lr) th {
  background: var(--panel-2); color: var(--muted); font-weight: 700; font-size: 12px;
  letter-spacing: .06em; text-transform: uppercase; border-bottom: 1px solid var(--line);
}
table:not(.lr) td { font-variant-numeric: tabular-nums; }
/* position: the tile of the timing tower */
td.pos .p {
  display: inline-block; min-width: 1.9em; padding: 0 5px; text-align: center; font-weight: 700;
  background: var(--pos-bg); color: var(--pos-text); border-radius: 2px;
}
/* timing colors: purple = best of all, green = personal best of the driver */
.purple { color: var(--purple); }
.pb { color: var(--green); font-weight: 600; }

/* ---------- buttons and fields ---------- */

/* base look for pages without their own button style (zero specificity: page rules win) */
:where(button) {
  padding: 6px 12px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  cursor: pointer;
}
:where(button):hover:not(:disabled) { border-color: var(--accent); }
button { font-family: inherit; font-weight: 600; border-radius: var(--radius); }
input, select, textarea {
  font-family: inherit; border-radius: var(--radius); background: var(--panel-2);
  border-color: var(--line);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

/* ---------- tags ---------- */

.badge, .chip, .type, .pill, .m {
  border-radius: 2px; font-weight: 700; letter-spacing: .04em;
}
.notice, .msg, .gp, .chat-log, pre.json, .url { border-radius: var(--radius); }
.lr-panel { border-radius: var(--radius); }
