:root {
  --black: #000;
  --white: #fff;
  --orange: #ff6b0a;
  --ash: #b4b4b4;
  --pit: #161616;
  --line: rgba(255, 255, 255, .24);
  --gutter: clamp(16px, 3vw, 40px);
  --cut: 10px;
  --chamfer: polygon(var(--cut) 0, 100% 0, 100% calc(100% - var(--cut)), calc(100% - var(--cut)) 100%, 0 100%, 0 var(--cut));
  --font: "Rock Salt", "Comic Sans MS", cursive;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }

/* Rock Salt runs wide and tall, with very narrow word gaps, and has no bold or
   italic. The sizes, line heights and word spacing below all allow for that. */
body {
  background: var(--black);
  color: var(--white);
  font: 400 .875rem/1.9 var(--font);
  font-synthesis: none;
  word-spacing: .3em;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { font-weight: 400; line-height: 1.5; }
strong, legend, label { font-weight: 400; }
button, input, textarea { font: inherit; word-spacing: inherit; }
a { color: inherit; }
img { display: block; max-width: 100%; }
:focus-visible { outline: 2px solid var(--orange); outline-offset: 3px; }
h2:focus { outline: none; }

.visually-hidden, .trap {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}

/* Top bar */
.bar {
  position: fixed; inset: 0 0 auto; z-index: 40;
  display: flex; justify-content: center; align-items: center;
  padding: max(14px, env(safe-area-inset-top)) var(--gutter) 14px;
  pointer-events: none;
}
.bar > * { pointer-events: auto; }
.bar nav { display: flex; gap: clamp(16px, 2.5vw, 32px); }
.bar nav a {
  font-size: 1.3rem; line-height: 1.4; text-decoration: none; padding: 8px 0;
  border-bottom: 2px solid transparent; text-shadow: 0 0 10px #000;
}
/* With a panel open, the links center in the space beside it. */
.panel-open .bar { padding-left: 520px; }
.bar nav a:hover, .bar nav a[aria-current="page"] { border-bottom-color: var(--orange); }

/* Buttons */
.button {
  display: inline-block; border: 0; cursor: pointer;
  background: var(--orange); color: var(--black);
  font-size: .95rem; line-height: 1.4; text-decoration: none;
  padding: 12px 22px; clip-path: var(--chamfer);
}
.button:hover { background: var(--white); }
.button:focus-visible { clip-path: none; }
.button[disabled] { opacity: .6; cursor: default; }
.button-quiet { background: var(--white); font-size: .75rem; padding: 9px 14px; white-space: nowrap; }
.button-quiet:hover { background: var(--orange); }

/* Track */
.stage { position: fixed; inset: 0; overflow: hidden; }
#track { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; display: block; }
#track:focus-visible { outline: none; }

.intro {
  position: absolute; inset: 0; z-index: 2; pointer-events: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: clamp(10px, 2vh, 20px); padding: 60px var(--gutter) 20px; text-align: center;
}
.intro-logo {
  height: auto; width: min(82vw, 58vh * 1.161); flex: none;
  mix-blend-mode: screen; transform-origin: 50% 46%;
  animation: logo-in 1.1s cubic-bezier(.16, .8, .3, 1) both;
}
@keyframes logo-in { from { opacity: 0; scale: 1.08; } }
.intro-copy { display: grid; justify-items: center; gap: 6px; max-width: 44rem; }
.intro-copy h1 { font-size: clamp(.95rem, 1.9vw, 1.25rem); text-wrap: balance; }
.intro-copy p { color: var(--ash); font-size: .8rem; }
.intro-copy .button { pointer-events: auto; margin-top: 6px; }

/* Photo readout */
.hud {
  position: absolute; inset: auto 0 0; z-index: 3;
  display: flex; justify-content: space-between; align-items: flex-end; gap: 16px;
  padding: 0 var(--gutter) max(20px, env(safe-area-inset-bottom));
  opacity: 0; visibility: hidden; transition: opacity .25s, visibility .25s;
  pointer-events: none;
}
.hud.on { opacity: 1; visibility: visible; }
.hud.on button { pointer-events: auto; }
.hud-photo { display: flex; align-items: center; gap: 14px; min-width: 0; }
.hud-title { font-size: clamp(.85rem, 1.6vw, 1.1rem); line-height: 1.5; text-shadow: 0 0 12px #000; }
.hud-date { color: var(--ash); font-size: .8rem; line-height: 1.6; text-shadow: 0 0 10px #000; }
.hud-actions { display: flex; align-items: center; gap: 10px; flex: none; }
.hud-count { color: var(--ash); font-size: .8rem; margin-right: 6px; white-space: nowrap; }

/* The number plate from the front of a race bike */
.plate {
  --cut: 12px;
  flex: none; min-width: 74px; padding: 6px 12px 4px; text-align: center;
  background: var(--white); color: var(--black);
  font-size: 1.5rem; line-height: 1.5; word-spacing: 0;
  clip-path: var(--chamfer); border-top: 5px solid var(--orange);
}

.progress { position: absolute; inset: auto 0 0; height: 3px; z-index: 3; }
.progress span { display: block; height: 100%; width: 0; background: var(--orange); }

/* Slide-in panels */
.scrim {
  position: fixed; inset: 0; z-index: 10; background: rgba(0, 0, 0, .72);
  opacity: 0; pointer-events: none; transition: opacity .3s;
}
.scrim.on { opacity: 1; pointer-events: auto; }

.panel {
  position: fixed; z-index: 20; inset: 0 auto 0 0; width: min(520px, 100%);
  overflow-y: auto; overscroll-behavior: contain;
  background: var(--pit); padding: 72px clamp(20px, 3vw, 36px) 40px;
  clip-path: polygon(0 0, calc(100% - 36px) 0, 100% 36px, 100% 100%, 0 100%);
  transform: translateX(-102%); visibility: hidden;
  transition: transform .38s cubic-bezier(.2, .8, .2, 1), visibility .38s;
}
/* Visibility flips instantly on open, so focus can move into the layer right away. */
.panel.open { transform: none; visibility: visible; transition: transform .38s cubic-bezier(.2, .8, .2, 1), visibility 0s; }
.panel h2 { font-size: clamp(1.6rem, 4.4vw, 2rem); margin-top: 18px; text-wrap: balance; }
.panel h3 { font-size: 1.2rem; margin: 32px 0 14px; padding-top: 24px; border-top: 1px solid var(--line); }
.panel-lede { margin-top: 14px; max-width: 34rem; color: #e2e2e2; font-size: .9rem; line-height: 2; }
.panel-top { position: absolute; top: 24px; left: clamp(20px, 3vw, 36px); }

.close {
  font-size: .95rem; line-height: 1.4; text-decoration: none;
  border-bottom: 2px solid var(--orange); padding-bottom: 4px;
}
.close:hover { color: var(--orange); }

/* Race day list */
.panel h3.year { font-size: 1rem; line-height: 1.4; color: var(--orange); margin: 26px 0 4px; padding: 0; border: 0; }
.day {
  display: grid; grid-template-columns: 104px 1fr; gap: 16px; align-items: center;
  padding: 12px 0; border-bottom: 1px solid var(--line); text-decoration: none;
}
.day img, .day .thumb {
  width: 104px; height: 70px; object-fit: cover; background: #000; clip-path: var(--chamfer);
}
.day strong { display: block; font-size: .95rem; line-height: 1.5; }
.day:hover strong { color: var(--orange); }
.day small { display: block; color: var(--ash); font-size: .8rem; line-height: 1.7; margin-top: 3px; }

/* Contact form */
form { display: grid; gap: 16px; }
form label, legend { display: grid; gap: 6px; font-size: .95rem; line-height: 1.6; padding: 0; }
input:not([type="radio"]), textarea {
  width: 100%; background: var(--black); color: var(--white);
  border: 1px solid var(--line); border-radius: 0; padding: 10px 12px; font-size: 1rem; line-height: 1.7;
}
input::placeholder { color: #8c8c8c; font-size: .75rem; }
input:focus, textarea:focus { outline: 2px solid var(--orange); outline-offset: 0; border-color: transparent; }
textarea { resize: vertical; }
fieldset { border: 0; margin: 0; padding: 0; }
legend { margin-bottom: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips label { display: block; cursor: pointer; }
.chips input { position: absolute; opacity: 0; }
.chips span { display: block; padding: 8px 12px; border: 1px solid var(--line); font-size: .85rem; line-height: 1.6; }
.chips label:hover span { border-color: var(--white); }
.chips input:checked + span { background: var(--orange); border-color: var(--orange); color: var(--black); }
.chips input:focus-visible + span { outline: 2px solid var(--orange); outline-offset: 2px; }
form .button { justify-self: start; }
.form-status { min-height: 1.9em; font-size: .85rem; }
.form-status.error { color: #ff9a57; }

/* Gallery */
.gallery {
  position: fixed; inset: 0; z-index: 25; background: var(--black);
  overflow-y: auto; overscroll-behavior: contain;
  padding: 28px var(--gutter) 56px;
  visibility: hidden; opacity: 0; transition: opacity .22s, visibility .22s;
}
.gallery.open { visibility: visible; opacity: 1; transition: opacity .22s, visibility 0s; }
.gallery-head { margin-bottom: 24px; }
.gallery-head h2 { font-size: clamp(1.6rem, 5vw, 3.4rem); margin-top: 22px; text-wrap: balance; overflow-wrap: anywhere; }
.gallery-meta { color: var(--ash); font-size: .8rem; margin-top: 6px; }

/* Rows stretch to fill the width; the spacer keeps the last row from ballooning */
.grid { display: flex; flex-wrap: wrap; gap: 6px; }
.grid::after { content: ""; flex-grow: 9999; }
.shot { display: block; position: relative; background: var(--pit); overflow: hidden; }
.shot img { width: 100%; height: 100%; object-fit: cover; }
.shot:hover { outline: 2px solid var(--orange); outline-offset: -2px; }
.shot:hover img { opacity: .9; }
.gallery-end {
  display: flex; flex-wrap: wrap; align-items: center; gap: 16px 24px;
  margin-top: 48px; padding-top: 24px; border-top: 1px solid var(--line);
}
.gallery-end p { font-size: clamp(.95rem, 2.2vw, 1.3rem); line-height: 1.6; }

/* Viewer */
.lightbox {
  position: fixed; inset: 0; z-index: 30; background: var(--black);
  display: grid; grid-template-rows: minmax(0, 1fr) auto;
  visibility: hidden; opacity: 0; transition: opacity .18s, visibility .18s;
}
.lightbox.open { visibility: visible; opacity: 1; transition: opacity .18s, visibility 0s; }
.lightbox-stage { display: flex; min-height: 0; overflow: hidden; }
.lightbox-stage img { width: 100%; height: 100%; object-fit: contain; padding: 16px 16px 0; touch-action: pan-y; }
/* Full size: actual pixels, moved around by scrolling or dragging. Auto margins
   center a photo smaller than the window without clipping a larger one. */
.lightbox-stage.full { overflow: auto; overscroll-behavior: contain; cursor: grab; }
.lightbox-stage.full.dragging { cursor: grabbing; user-select: none; }
.lightbox-stage.full img {
  flex: none; width: auto; height: auto; max-width: none; margin: auto;
  padding: 0; object-fit: fill; touch-action: auto;
}
.lightbox-stage:focus-visible { outline: 2px solid var(--orange); outline-offset: -2px; }
.lightbox-status {
  position: absolute; top: 14px; left: 50%; translate: -50% 0; z-index: 1;
  background: var(--black); color: var(--white); padding: 4px 14px; font-size: .85rem; white-space: nowrap;
}
.lightbox-status:empty { display: none; }
.lightbox-bar {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 12px var(--gutter) max(14px, env(safe-area-inset-bottom));
}

.noscript { position: fixed; inset: 40% 16px auto; text-align: center; z-index: 50; }

/* Too narrow for the links beside an open panel, which has its own Close link. */
@media (max-width: 1000px) {
  .panel-open .bar { display: none; }
}

/* The readout needs two rows once its text and buttons no longer fit on one. */
@media (max-width: 900px) {
  .hud { flex-direction: column; align-items: stretch; gap: 10px; }
  .hud-actions { justify-content: flex-end; }
  .hud-count { margin-right: auto; }
}

@media (max-width: 720px) {
  .bar nav a { font-size: .85rem; }
  .intro-logo { width: min(90vw, 44vh * 1.161); }
  .intro-copy p { font-size: .72rem; }
  .button-quiet { font-size: .68rem; padding: 8px 10px; }
  .hud-actions { gap: 6px; }
  /* No room beside the two buttons, and the plate already shows the photo number. */
  .hud-count { display: none; }
  .plate { min-width: 60px; font-size: 1.25rem; }
  .lightbox-bar .hud-date { display: none; }
  .lightbox-bar { flex-wrap: wrap; }
  .lightbox-bar .plate { min-width: 48px; font-size: 1rem; padding: 4px 8px 2px; }
  .lightbox-bar .hud-actions { flex-wrap: wrap; justify-content: flex-end; flex: 1 1 auto; }
}

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