/* ==========================================================================
   4WD Corroboree 2026 - drive selection
   Palette is lifted from the event artwork: forest green, burnt orange,
   ochre and aged-paper cream.
   ========================================================================== */

:root {
  --green-900: #1b2115;
  --green-800: #2c3323;
  --green-700: #3c452f;
  --orange-700: #a8431a;
  --orange-600: #c0561f;
  --orange-500: #d76a28;
  --ochre: #e0a33c;

  --paper: #f4ead7;
  --paper-2: #ece0c8;
  --surface: #fffaf0;
  --surface-2: #fdf4e4;

  --ink: #2f2a20;
  --ink-muted: #6b6252;
  --line: #e0cfae;
  --line-strong: #cbb691;

  --ok-bg: #e7f0dd;
  --ok-line: #9cb684;
  --ok-ink: #33501f;
  --warn-bg: #fdf0d5;
  --warn-line: #dfb865;
  --warn-ink: #7a5410;
  --err-bg: #fbe4dc;
  --err-line: #e0a58f;
  --err-ink: #8d2f14;

  --radius: 10px;
  --radius-lg: 14px;
  --shadow-1: 0 1px 2px rgba(43, 33, 15, .08), 0 2px 8px rgba(43, 33, 15, .06);
  --shadow-2: 0 6px 24px rgba(43, 33, 15, .16);

  --font-display: "Oswald", "Arial Narrow", "Segoe UI", system-ui, sans-serif;
  --font-body: "Source Sans 3", "Segoe UI", Roboto, -apple-system, Helvetica, Arial, sans-serif;

  --wrap: 76rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #191d15;
    --paper-2: #12160f;
    --surface: #222719;
    --surface-2: #1c2115;
    --ink: #ece3d0;
    --ink-muted: #a89f8b;
    --line: #3a412e;
    --line-strong: #4d553d;
    --ok-bg: #26301c;
    --ok-line: #4d6338;
    --ok-ink: #cfe2b8;
    --warn-bg: #322710;
    --warn-line: #6a5522;
    --warn-ink: #efd39a;
    --err-bg: #351a12;
    --err-line: #713724;
    --err-ink: #f2bda9;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-2: 0 6px 24px rgba(0, 0, 0, .5);
  }
}

/* --------------------------------------------------------------------------
   Base
   -------------------------------------------------------------------------- */

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

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 17px/1.6 var(--font-body);
  /* Faint paper grain so large cream areas do not read as flat white. */
  background-image:
    radial-gradient(circle at 20% 10%, rgba(224, 163, 60, .07), transparent 45%),
    radial-gradient(circle at 85% 0%, rgba(192, 86, 31, .06), transparent 40%);
  background-attachment: fixed;
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: .01em;
  line-height: 1.15;
  margin: 0 0 .5rem;
  text-wrap: balance;
}

h1 { font-size: clamp(1.7rem, 1.2rem + 2vw, 2.6rem); text-transform: uppercase; }
h2 { font-size: 1.35rem; text-transform: uppercase; }
h3 { font-size: 1.15rem; }

p { margin: 0 0 1rem; }
a { color: var(--orange-700); }
a:hover { color: var(--orange-500); }

img { max-width: 100%; height: auto; display: block; }

.wrap {
  width: min(100% - 2rem, var(--wrap));
  margin-inline: auto;
}

.lede { font-size: 1.05rem; color: var(--ink-muted); max-width: 60ch; }
.fine { font-size: .875rem; color: var(--ink-muted); }
.hint { font-size: .875rem; color: var(--ink-muted); margin: .4rem 0 0; }

.skip-link {
  position: absolute;
  left: -9999px;
  background: var(--green-800);
  color: var(--paper);
  padding: .6rem 1rem;
  z-index: 100;
}
.skip-link:focus { left: 1rem; top: 1rem; }

:where(a, button, input, select, [tabindex]):focus-visible {
  outline: 3px solid var(--orange-500);
  outline-offset: 2px;
  border-radius: 4px;
}

/* --------------------------------------------------------------------------
   Header / footer
   -------------------------------------------------------------------------- */

.site-header {
  background: linear-gradient(180deg, var(--green-800), var(--green-900));
  border-bottom: 4px solid var(--orange-600);
  color: var(--paper);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .7rem 0;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: .85rem;
  color: inherit;
  text-decoration: none;
}
.brand img {
  width: 68px;
  height: 68px;
  object-fit: contain;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, .45));
}
.brand-text { display: grid; }
.brand-text strong {
  font-family: var(--font-display);
  font-size: 1.3rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ochre);
}
.brand-text span { font-size: .82rem; color: #cfc7b2; letter-spacing: .04em; }

.logout-form { display: flex; align-items: center; gap: .6rem; }
.whoami { font-size: .9rem; color: #cfc7b2; }

.site-footer {
  margin-top: 3rem;
  padding: 1.5rem 0 2rem;
  background: var(--green-900);
  color: #b7b0a0;
  font-size: .85rem;
}
.site-footer a { color: var(--ochre); }
.site-footer p { margin: 0; }

main.wrap { padding: 1.75rem 0 1rem; }

/* --------------------------------------------------------------------------
   Flashes
   -------------------------------------------------------------------------- */

.flash {
  border: 1px solid var(--line-strong);
  border-left-width: 5px;
  border-radius: var(--radius);
  padding: .8rem 1rem;
  margin: 0 0 1.25rem;
  background: var(--surface);
  font-size: .95rem;
}
.flash-success { background: var(--ok-bg); border-color: var(--ok-line); color: var(--ok-ink); }
.flash-error   { background: var(--err-bg); border-color: var(--err-line); color: var(--err-ink); }
.flash-warn    { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn-ink); }
.flash-info    { background: var(--surface-2); border-color: var(--line-strong); }

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

.btn {
  --btn-bg: var(--surface);
  --btn-ink: var(--ink);
  --btn-line: var(--line-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  font: 600 1rem/1 var(--font-body);
  padding: .72rem 1.1rem;
  border: 1px solid var(--btn-line);
  border-radius: var(--radius);
  background: var(--btn-bg);
  color: var(--btn-ink);
  cursor: pointer;
  text-decoration: none;
  transition: transform .06s ease, background-color .15s ease, border-color .15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn[disabled] { opacity: .55; cursor: not-allowed; transform: none; }

.btn-primary {
  --btn-bg: var(--orange-600);
  --btn-ink: #fff8ee;
  --btn-line: var(--orange-700);
  box-shadow: var(--shadow-1);
  text-transform: uppercase;
  letter-spacing: .04em;
  font-family: var(--font-display);
  font-size: 1.05rem;
}
.btn-primary:hover { --btn-bg: var(--orange-500); }

.btn-ghost {
  --btn-bg: transparent;
  --btn-ink: var(--paper);
  --btn-line: #6d7560;
}
.btn-ghost:hover { --btn-bg: rgba(255, 255, 255, .1); }

.btn-sm { padding: .4rem .75rem; font-size: .85rem; }
.btn-block { width: 100%; }

.btn-link {
  background: none;
  border: none;
  padding: 0;
  color: var(--orange-700);
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
}
.btn-link[disabled] { color: var(--ink-muted); text-decoration: none; }

/* --------------------------------------------------------------------------
   Cards and forms (login / verify)
   -------------------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
  padding: clamp(1.25rem, 1rem + 2vw, 2rem);
}

.auth-card {
  max-width: 30rem;
  margin: 1rem auto 2rem;
  border-top: 5px solid var(--orange-600);
}

.stack { display: grid; gap: 1.1rem; }
.field { display: grid; gap: .35rem; }

label { font-weight: 600; font-size: .95rem; }

input[type="tel"],
input[type="text"],
select {
  font: inherit;
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: .7rem .85rem;
  width: 100%;
}
input:focus, select:focus { border-color: var(--orange-500); }

.code-input {
  font: 700 1.9rem/1 var(--font-display);
  letter-spacing: .5em;
  text-align: center;
  padding: .85rem .5rem .85rem 1rem;
}
.code-input::placeholder { color: var(--line-strong); letter-spacing: .5em; }

.auth-alt {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .6rem;
  flex-wrap: wrap;
  margin: 1.1rem 0 .5rem;
  font-size: .95rem;
}
.auth-alt .sep { color: var(--line-strong); }
.inline-form { display: inline; }

/* Poster strip on the login page */
.preview { margin: 2rem auto 0; max-width: 46rem; text-align: center; }
.preview h2 { font-size: 1.05rem; letter-spacing: .1em; color: var(--ink-muted); }
.preview-list {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(7rem, 1fr));
  gap: 1rem;
  padding: 0;
  margin: 1rem 0 0;
}
.preview-list li { display: grid; gap: .45rem; justify-items: center; }
.preview-list img {
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  object-position: top center;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  box-shadow: var(--shadow-1);
}
.preview-list span { font-size: .8rem; color: var(--ink-muted); line-height: 1.3; }

/* --------------------------------------------------------------------------
   Selection page
   -------------------------------------------------------------------------- */

.page-intro { margin-bottom: 1.5rem; }
.deadline { font-size: .95rem; color: var(--ink-muted); }

.selection-layout {
  display: grid;
  gap: 1.5rem;
  align-items: start;
}

@media (min-width: 62rem) {
  .selection-layout { grid-template-columns: 23rem minmax(0, 1fr); }
  .picks-inner { position: sticky; top: 1rem; }
}

/* ---- priority list ------------------------------------------------------ */

.picks {
  background: var(--green-800);
  color: var(--paper);
  border-radius: var(--radius-lg);
  border: 1px solid var(--green-900);
  box-shadow: var(--shadow-1);
  overflow: clip;
}
.picks-inner { padding: 1.1rem 1.1rem 1.25rem; }
.picks h2 { color: var(--ochre); margin-bottom: .15rem; font-size: 1.15rem; letter-spacing: .06em; }
.picks-count { font-size: .85rem; color: #c3bbaa; margin: 0 0 .9rem; }
.picks-empty {
  font-size: .9rem;
  color: #c3bbaa;
  border: 1px dashed #5c6450;
  border-radius: var(--radius);
  padding: 1.1rem;
  text-align: center;
  margin: 0;
}

.pick-list { list-style: none; margin: 0 0 1rem; padding: 0; display: grid; gap: .55rem; }
.pick-list:empty { margin: 0; }

.pick {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto;
  align-items: center;
  gap: .5rem;
  background: var(--green-700);
  border: 1px solid #545c44;
  border-left: 4px solid var(--ochre);
  border-radius: var(--radius);
  padding: .5rem .55rem;
}
.pick:first-child { border-left-color: var(--orange-500); }

/* Selection closed: no handle, no action buttons, so close the grid up. */
.pick.is-locked { grid-template-columns: auto minmax(0, 1fr); }

.pick-handle {
  background: none;
  border: none;
  color: #b3ab97;
  padding: .25rem;
  cursor: grab;
  touch-action: none;   /* let the pointer drag work on touch screens */
  line-height: 0;
}
.pick-handle svg { fill: currentColor; }
.pick-handle:hover { color: var(--ochre); }

.pick-rank {
  font: 700 1.05rem/1 var(--font-display);
  width: 1.7rem;
  height: 1.7rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--ochre);
  color: var(--green-900);
  flex: none;
}
.pick:first-child .pick-rank { background: var(--orange-500); color: #fff8ee; }

.pick-body { display: grid; min-width: 0; }
.pick-name {
  font-weight: 600;
  font-size: .92rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
}
.pick-ordinal { font-size: .72rem; color: #b3ab97; text-transform: uppercase; letter-spacing: .06em; }

.pick-actions { display: flex; gap: .15rem; }
.icon-btn {
  background: none;
  border: 1px solid transparent;
  color: #b3ab97;
  font-size: .8rem;
  line-height: 1;
  padding: .35rem .4rem;
  border-radius: 6px;
  cursor: pointer;
}
.icon-btn:hover { background: rgba(255, 255, 255, .12); color: var(--paper); }
.icon-btn[disabled] { opacity: .3; cursor: not-allowed; }
.icon-btn-danger:hover { background: var(--orange-700); color: #fff; }

/* while dragging */
.pick.is-dragging {
  opacity: .9;
  box-shadow: var(--shadow-2);
  transform: scale(1.02);
  cursor: grabbing;
}
.pick.is-placeholder { opacity: .25; }

.picks-save { border-top: 1px solid #4a5240; padding-top: .9rem; }
.save-state { font-size: .85rem; margin: .55rem 0 0; min-height: 1.2em; color: #c3bbaa; }
.save-state.is-dirty { color: var(--ochre); }
.save-state.is-saved { color: #b8d39a; }
.save-state.is-error { color: #f0a98f; }

/* ---- drive cards -------------------------------------------------------- */

.drive-grid {
  display: grid;
  gap: 1.1rem;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr));
}

.drive {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
  overflow: clip;
  transition: border-color .15s ease, box-shadow .15s ease, transform .1s ease;
}
.drive:hover { box-shadow: var(--shadow-2); }
.drive.is-picked {
  border-color: var(--orange-600);
  box-shadow: 0 0 0 2px rgba(192, 86, 31, .28), var(--shadow-1);
}

.drive-media { position: relative; background: var(--green-900); }
.drive-media img {
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  object-position: top center;
}

.drive-badge {
  position: absolute;
  top: .6rem;
  left: .6rem;
  width: 2.1rem;
  height: 2.1rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--orange-600);
  color: #fff8ee;
  font: 700 1.15rem/1 var(--font-display);
  border: 2px solid #fff8ee;
  box-shadow: var(--shadow-1);
}
.drive-badge[hidden] { display: none; }

.drive-zoom {
  position: absolute;
  right: .6rem;
  bottom: .6rem;
  background: rgba(27, 33, 21, .84);
  color: var(--paper);
  font-size: .78rem;
  font-weight: 600;
  padding: .35rem .6rem;
  border-radius: 999px;
  text-decoration: none;
  backdrop-filter: blur(2px);
}
.drive-zoom:hover { background: var(--orange-700); color: #fff; }

.drive-body { padding: .9rem 1rem .25rem; flex: 1; }
.drive-body h3 { margin-bottom: .35rem; }
.drive-body p { font-size: .9rem; color: var(--ink-muted); margin: 0; }

.drive-foot { padding: .9rem 1rem 1rem; }
.drive-state { font-size: .9rem; font-weight: 600; color: var(--ink-muted); }

.btn-select {
  width: 100%;
  --btn-bg: var(--surface-2);
  --btn-line: var(--line-strong);
}
.btn-select:hover { --btn-bg: var(--paper-2); }
.btn-select .label-remove { display: none; }
.btn-select[aria-pressed="true"] {
  --btn-bg: var(--orange-600);
  --btn-ink: #fff8ee;
  --btn-line: var(--orange-700);
}
.btn-select[aria-pressed="true"] .label-add { display: none; }
.btn-select[aria-pressed="true"] .label-remove { display: inline; }
.btn-select[disabled] { --btn-bg: var(--surface-2); }

/* ---- no-JavaScript fallback -------------------------------------------- */

.nojs-controls {
  padding: .8rem 1rem 1rem;
  border-top: 1px dashed var(--line-strong);
  display: grid;
  gap: .5rem;
  font-size: .9rem;
}
.nojs-controls label { display: flex; align-items: center; gap: .5rem; font-weight: 400; }
.nojs-controls select { width: auto; padding: .35rem .5rem; }
.nojs-save { border: none; justify-items: start; }

.js .nojs-controls { display: none; }

/* --------------------------------------------------------------------------
   Lightbox
   -------------------------------------------------------------------------- */

.lightbox {
  border: none;
  padding: 0;
  background: transparent;
  max-width: min(96vw, 46rem);
  max-height: 94vh;
  overflow: visible;
}
.lightbox::backdrop { background: rgba(20, 16, 8, .82); }
.lightbox img {
  width: 100%;
  max-height: 88vh;
  object-fit: contain;
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
  background: var(--surface);
}
.lightbox-title {
  color: var(--paper);
  font-size: 1rem;
  margin: 0 0 .5rem;
  text-align: center;
  letter-spacing: .06em;
}
.lightbox-close {
  position: absolute;
  top: -.4rem;
  right: -.4rem;
  z-index: 2;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 50%;
  border: 2px solid var(--paper);
  background: var(--green-800);
  color: var(--paper);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
}
.lightbox-close:hover { background: var(--orange-700); }

/* --------------------------------------------------------------------------
   Utilities
   -------------------------------------------------------------------------- */

[hidden] { display: none !important; }

/* Available to screen readers, out of the layout for everyone else. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 61.99rem) {
  .wide-only { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

@media print {
  .site-header, .site-footer, .drive-foot, .picks-save, .drive-zoom, .nojs-controls { display: none; }
  body { background: #fff; }
  .picks { background: #fff; color: #000; border: 1px solid #000; }
}
