/* Offroad Diesel Tracker - shared tokens, base elements, header/nav, forms, buttons.
   Every colour is a custom property; dark mode only redefines the values. */

:root {
  color-scheme: light dark;

  --bg: #f6f4f1;
  --surface: #ffffff;
  --surface-2: #efebe6;
  --surface-3: #e4ded6;
  --text: #1d1b19;
  --text-muted: #57524c;        /* 7.4:1 on surface */
  --border: #d6cfc6;            /* decorative dividers */
  --border-strong: #78716a;     /* form controls, 4.8:1 on surface */
  --accent: #b3261e;            /* dyed-diesel red, 6.0:1 on white */
  --accent-hover: #8f1e18;
  --on-accent: #ffffff;
  --link: #1d4f91;
  --link-hover: #143a6d;
  --focus: #1a5fb4;
  --focus-halo: #ffffff;
  --success: #1e6b34;
  --success-bg: #e5f3e8;
  --danger: #a1170f;
  --danger-bg: #fbe9e7;
  --warning-bg: #fff3d1;
  --warning-text: #5c4300;
  --shadow: 0 1px 3px rgb(0 0 0 / 0.12), 0 4px 16px rgb(0 0 0 / 0.08);
  --overlay: rgb(20 18 16 / 0.55);

  /* access-type colours (always paired with a text label) */
  --type-retail: #b3261e;
  --type-cardlock: #1d4f91;
  --type-marina: #0b6874;
  --type-bulk_delivery: #7a5000;
  --type-other: #5c5650;
  --on-type: #ffffff;

  --user-dot: #1a73e8;
  --user-ring: rgb(26 115 232 / 0.18);

  --radius: 10px;
  --radius-sm: 6px;
  --gap: 1rem;
  --header-h: 3.75rem;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121110;
    --surface: #1c1a18;
    --surface-2: #26231f;
    --surface-3: #322e29;
    --text: #f1ede8;
    --text-muted: #bdb5ab;
    --border: #3b3631;
    --border-strong: #948b80;
    --accent: #ff8a80;
    --accent-hover: #ffb0a8;
    --on-accent: #240605;
    --link: #9cc0ff;
    --link-hover: #c4d9ff;
    --focus: #9cc0ff;
    --focus-halo: #121110;
    --success: #8fd6a2;
    --success-bg: #18301f;
    --danger: #ff9b92;
    --danger-bg: #3a1714;
    --warning-bg: #3a2f10;
    --warning-text: #f5dc93;
    --shadow: 0 1px 3px rgb(0 0 0 / 0.5), 0 4px 16px rgb(0 0 0 / 0.4);
    --overlay: rgb(0 0 0 / 0.65);

    --type-retail: #ff8a80;
    --type-cardlock: #9cc0ff;
    --type-marina: #6fd3df;
    --type-bulk_delivery: #f2c14e;
    --type-other: #cfc7bd;
    --on-type: #1a1614;

    --user-dot: #6ea8ff;
    --user-ring: rgb(110 168 255 / 0.22);
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}

h1, h2, h3 { line-height: 1.2; margin: 0 0 0.5em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 0.75em; }

a { color: var(--link); text-underline-offset: 0.15em; }
a:hover { color: var(--link-hover); }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  box-shadow: 0 0 0 5px var(--focus-halo);
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute;
  left: 0.5rem; top: -4rem;
  z-index: 2000;
  padding: 0.75rem 1rem;
  background: var(--surface);
  color: var(--link);
  border: 2px solid var(--focus);
  border-radius: var(--radius-sm);
  font-weight: 600;
}
.skip-link:focus { top: 0.5rem; }

/* ---------- Header and navigation ---------- */

.site-header {
  display: flex;
  align-items: center;
  gap: var(--gap);
  min-height: var(--header-h);
  padding: 0.5rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0;
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--text);
  text-decoration: none;
}
a.brand:hover { color: var(--text); }

/* CSS-drawn fuel pump: body + display window + hose + nozzle */
.brand-mark {
  position: relative;
  flex: none;
  width: 1.15rem;
  height: 1.55rem;
  border-radius: 3px 3px 1px 1px;
  background: var(--accent);
  margin-right: 0.45rem;
}
.brand-mark::before { /* display window */
  content: "";
  position: absolute;
  left: 0.2rem; right: 0.2rem; top: 0.22rem;
  height: 0.4rem;
  border-radius: 1px;
  background: var(--surface);
}
.brand-mark::after { /* hose and nozzle */
  content: "";
  position: absolute;
  left: 100%;
  top: 0.35rem;
  width: 0.4rem;
  height: 0.95rem;
  border: 0.17rem solid var(--accent);
  border-left: 0;
  border-radius: 0 0.3rem 0.3rem 0;
}

.site-nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.site-nav { margin-left: auto; }

.nav-link {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  padding: 0.5rem 0.85rem;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link[aria-current="page"] { background: var(--surface-2); box-shadow: inset 0 -3px 0 var(--accent); }

/* Mobile: navigation collapses behind a fixed bottom-left "Menu" button. */
.menu-button { display: none; }

@media (max-width: 767.98px) {
  .menu-button {
    display: inline-flex;
    align-items: center;
    position: fixed;
    left: 0.75rem;
    bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
    z-index: 1200;
    min-height: 3rem;
    padding: 0.6rem 1.1rem;
    border: 2px solid var(--surface);
    border-radius: 999px;
    background: var(--accent);
    color: var(--on-accent);
    font: inherit;
    font-weight: 700;
    box-shadow: var(--shadow);
    cursor: pointer;
  }
  .menu-button[aria-expanded="true"] { background: var(--text); color: var(--bg); }

  .site-nav {
    display: none;
    position: fixed;
    left: 0.75rem;
    bottom: calc(4.5rem + env(safe-area-inset-bottom, 0px));
    z-index: 1200;
    min-width: 15rem;
    max-width: calc(100vw - 1.5rem);
    padding: 0.5rem;
    margin: 0;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
  }
  .site-nav.is-open { display: block; }
  .site-nav ul { flex-direction: column; }
  .nav-link { width: 100%; }
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 2.75rem;
  padding: 0.55rem 1rem;
  border: 2px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
}
.btn:hover { background: var(--surface-2); color: var(--text); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--on-accent); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: var(--on-accent); }
.btn-danger:hover { filter: brightness(0.92); color: var(--on-accent); background: var(--danger); }
.btn-small { min-height: 2.75rem; padding: 0.35rem 0.75rem; font-size: 0.9rem; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.6; cursor: not-allowed; }
.btn-link {
  border: 0;
  background: none;
  padding: 0.5rem 0.25rem;
  min-height: 2.75rem;
  color: var(--link);
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 0.15em;
  cursor: pointer;
}
.btn-link:hover { color: var(--link-hover); }

/* CSS-drawn crosshair for "Use my location" */
.icon-locate {
  position: relative;
  display: inline-block;
  flex: none;
  width: 1.1rem;
  height: 1.1rem;
  border: 2px solid currentColor;
  border-radius: 50%;
}
.icon-locate::before { /* centre dot */
  content: "";
  position: absolute;
  inset: 0.22rem;
  border-radius: 50%;
  background: currentColor;
}
.icon-locate::after { /* N/S/E/W ticks */
  content: "";
  position: absolute;
  inset: -0.4rem;
  background:
    linear-gradient(currentColor, currentColor) top center / 2px 0.3rem no-repeat,
    linear-gradient(currentColor, currentColor) bottom center / 2px 0.3rem no-repeat,
    linear-gradient(currentColor, currentColor) left center / 0.3rem 2px no-repeat,
    linear-gradient(currentColor, currentColor) right center / 0.3rem 2px no-repeat;
}

/* CSS-drawn close "X" */
.icon-close {
  position: relative;
  display: inline-block;
  width: 1rem;
  height: 1rem;
}
.icon-close::before,
.icon-close::after {
  content: "";
  position: absolute;
  left: 50%; top: 0;
  width: 2px; height: 100%;
  margin-left: -1px;
  background: currentColor;
  transform: rotate(45deg);
}
.icon-close::after { transform: rotate(-45deg); }

/* ---------- Forms ---------- */

.field { margin: 0 0 1rem; }
.field label, .field .label, fieldset legend { display: block; margin-bottom: 0.3rem; font-weight: 600; }
.field .hint { display: block; margin: -0.15rem 0 0.35rem; font-size: 0.9rem; color: var(--text-muted); }
.req { color: var(--danger); font-weight: 700; }

input[type="text"], input[type="search"], input[type="email"], input[type="tel"], input[type="url"],
input[type="password"], input[type="number"], input[type="date"], select, textarea {
  width: 100%;
  min-height: 2.75rem;
  padding: 0.5rem 0.65rem;
  border: 2px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
textarea { min-height: 6rem; resize: vertical; }
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--danger); }

.field-error { margin: 0.35rem 0 0; color: var(--danger); font-weight: 600; font-size: 0.95rem; }
.field-error:empty { display: none; }
.field-error:not(:empty)::before { content: "Error: "; }

fieldset { margin: 0 0 1rem; padding: 0; border: 0; min-width: 0; }

.choice {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 2.75rem;
  font-weight: 400;
  cursor: pointer;
}
.choice input { width: 1.25rem; height: 1.25rem; margin: 0; accent-color: var(--accent); flex: none; }

.notice {
  margin: 0 0 1rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  border-left: 5px solid var(--border-strong);
  background: var(--surface-2);
}
.notice:empty { display: none; }
.notice-ok { border-color: var(--success); background: var(--success-bg); }
.notice-error { border-color: var(--danger); background: var(--danger-bg); }
.notice-warn { border-color: var(--warning-text); background: var(--warning-bg); color: var(--warning-text); }

/* Access-type colour swatches (always shown next to a text label) */
.type-retail { --pin: var(--type-retail); }
.type-cardlock { --pin: var(--type-cardlock); }
.type-marina { --pin: var(--type-marina); }
.type-bulk_delivery { --pin: var(--type-bulk_delivery); }
.type-other { --pin: var(--type-other); }
.swatch {
  display: inline-block;
  flex: none;
  width: 0.8rem;
  height: 0.8rem;
  border-radius: 50%;
  background: var(--pin);
  box-shadow: 0 0 0 1px var(--surface), 0 0 0 2px var(--pin);
}

.legend { display: grid; gap: 0.75rem; margin: 0 0 1rem; }
.legend dt { display: flex; align-items: center; gap: 0.5rem; font-weight: 700; }
.legend dd { margin: 0.15rem 0 0 1.3rem; }

.honeypot { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

.page { max-width: 52rem; margin: 0 auto; padding: 1.5rem 1rem 6rem; }
.page h1 { font-size: 1.75rem; }
.page h2 { margin-top: 1.75rem; }

.site-footer {
  padding: 1.25rem 1rem 6rem;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.9rem;
  text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}
