:root {
  --bg: #ffffff;
  --text: #151515;
  --muted: #6d6d6d;
  --line: #e8e8e8;
  --accent: #6d3b78;
  --accent-soft: #f3edf5;
  --header-h: 76px;
  --grid-gap: 8px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: rgba(255,255,255,.96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.header-inner {
  min-height: var(--header-h);
  max-width: 1500px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  color: inherit;
  text-decoration: none;
  display: inline-flex;
  align-items: baseline;
  gap: 10px;
  white-space: nowrap;
}
.brand-mark {
  font-size: 1.55rem;
  line-height: 1;
  font-weight: 900;
  letter-spacing: -.04em;
}
.brand-sub {
  color: var(--muted);
  font-size: .82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .12em;
}

.day-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 2px;
}
.day-nav::-webkit-scrollbar { display: none; }
.day-tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 10px 13px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 800;
  white-space: nowrap;
  transition: background .18s ease, color .18s ease;
}
.day-tab:hover { background: #f6f6f6; color: var(--text); }
.day-tab.is-active {
  color: #fff;
  background: var(--accent);
}

main { min-height: 100vh; }
.intro {
  max-width: 1500px;
  margin: 0 auto;
  padding: 34px 24px 22px;
}
.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: .78rem;
  font-weight: 900;
  letter-spacing: .15em;
  text-transform: uppercase;
}
h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 4.6rem);
  line-height: .96;
  letter-spacing: -.055em;
}
.day-summary {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: .98rem;
}

.gallery-wrap {
  width: 100%;
  padding: 0 8px 40px;
}
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: var(--grid-gap);
}
.gallery-item {
  position: relative;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border: 0;
  padding: 0;
  background: #f1f1f1;
  cursor: zoom-in;
}
.gallery-item::after {
  content: "";
  position: absolute;
  inset: 0;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.035);
  pointer-events: none;
}
.gallery-thumb {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  transform: scale(1.001);
  transition: transform .2s ease, opacity .2s ease;
  background: #ececec;
}
.gallery-item:hover .gallery-thumb { transform: scale(1.025); }
.gallery-item:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.gallery-sentinel { height: 1px; }
.noscript { padding: 20px; }

.lightbox[hidden] { display: none; }
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 5000;
  display: grid;
  place-items: center;
}
.lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.93);
}
.lightbox-ui {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) 72px;
  align-items: center;
  padding: max(16px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
}
.lightbox-stage {
  position: relative;
  width: 100%;
  height: 100%;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  touch-action: pan-y;
}
.lightbox-image {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 64px);
  width: auto;
  height: auto;
  object-fit: contain;
  user-select: none;
  -webkit-user-select: none;
  transition: opacity .18s ease;
}
.lightbox-image.is-loading-full { opacity: .72; }
/* While changing images, hide the previous decoded bitmap completely. */
.lightbox-image.is-switching { opacity: 0; }
.lightbox-caption {
  position: absolute;
  left: 50%;
  bottom: 6px;
  transform: translateX(-50%);
  color: rgba(255,255,255,.78);
  font-size: .78rem;
  letter-spacing: .04em;
  white-space: nowrap;
  pointer-events: none;
}
.lightbox-loader {
  position: absolute;
  width: 32px;
  height: 32px;
  border: 3px solid rgba(255,255,255,.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  opacity: 0;
  transition: opacity .12s ease;
}
.lightbox-loader.is-visible { opacity: 1; }
@keyframes spin { to { transform: rotate(360deg); } }

.lightbox-close,
.lightbox-prev,
.lightbox-next {
  position: relative;
  z-index: 2;
  border: 0;
  color: #fff;
  background: rgba(255,255,255,.08);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background .18s ease;
}
.lightbox-close:hover,
.lightbox-prev:hover,
.lightbox-next:hover { background: rgba(255,255,255,.16); }
.lightbox-prev,
.lightbox-next {
  width: 52px;
  height: 72px;
  border-radius: 12px;
  font-size: 3rem;
  line-height: 1;
  justify-self: center;
}
.lightbox-close {
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  right: max(16px, env(safe-area-inset-right));
  width: 44px;
  height: 44px;
  border-radius: 999px;
  font-size: 2rem;
  line-height: 1;
}

body.lightbox-open { overflow: hidden; }

@media (max-width: 1200px) {
  .gallery-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}
@media (max-width: 980px) {
  :root { --header-h: 104px; }
  .header-inner {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
    padding: 10px 14px 8px;
  }
  .day-nav { width: 100%; }
  .gallery-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .intro { padding: 26px 14px 18px; }
}
@media (max-width: 720px) {
  .brand-sub { display: none; }
  .gallery-wrap { padding-left: 4px; padding-right: 4px; }
  .gallery-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
  .lightbox-ui { grid-template-columns: 1fr; padding: 0; }
  .lightbox-prev,
  .lightbox-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 58px;
    font-size: 2.6rem;
    background: rgba(0,0,0,.25);
  }
  .lightbox-prev { left: 6px; }
  .lightbox-next { right: 6px; }
  .lightbox-stage { width: 100vw; height: 100vh; }
  .lightbox-image { max-height: 100vh; }
  .lightbox-caption { bottom: max(10px, env(safe-area-inset-bottom)); }
}
@media (max-width: 420px) {
  .day-tab { padding: 9px 11px; font-size: .9rem; }
  .gallery-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

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

/* Keep each thumbnail's paint work isolated from the rest of the grid. */
.gallery-item { contain: layout paint; }


/* BMXnet.org header branding */
.brand-area {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}
.brand {
  position: relative;
  display: inline-flex;
  align-items: center;
  color: inherit;
  text-decoration: none;
  flex: 0 0 auto;
}
.brand-logo {
  display: block;
  width: auto;
  height: 46px;
  max-width: min(210px, 42vw);
  object-fit: contain;
}
.brand-text-fallback {
  display: none;
  font-size: 1.55rem;
  line-height: 1;
  font-weight: 900;
  letter-spacing: -.04em;
}
.brand.logo-missing .brand-logo { display: none; }
.brand.logo-missing .brand-text-fallback { display: inline; }

.home-link {
  color: var(--text);
  text-decoration: none;
  font-weight: 800;
  white-space: nowrap;
  padding: 10px 13px;
  border-radius: 999px;
}
.home-link:hover,
.home-link:focus-visible {
  background: #f6f6f6;
}
.home-link:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

@media (max-width: 980px) {
  .header-inner {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
  }
  .day-nav { grid-column: 1 / -1; }
  .brand-logo { height: 38px; }
}
@media (max-width: 520px) {
  .brand-sub { display: none; }
  .brand-logo { height: 34px; max-width: 150px; }
  .home-link { padding: 8px 10px; }
}

/* v3 Safari/iOS-safe image replacement */
.lightbox-image-host{position:relative;width:100%;height:100%;display:flex;align-items:center;justify-content:center;overflow:hidden}
.lightbox-image-host .lightbox-image{display:block;max-width:100%;max-height:calc(100vh - 64px);width:auto;height:auto;object-fit:contain;user-select:none;-webkit-user-select:none;opacity:1;transition:opacity .16s ease;will-change:opacity;transform:translateZ(0);-webkit-transform:translateZ(0);backface-visibility:hidden;-webkit-backface-visibility:hidden}
.lightbox-image-host .lightbox-image.is-entering{opacity:0}
.lightbox-image-host .lightbox-image.is-loading-full{opacity:.78}
@media (max-width:720px){.lightbox-image-host .lightbox-image{max-height:100vh}}
