/* ---------- Theme tokens (change colours here) ---------- */
/* Matches reload.html: warm dark palette, bronze accent, square edges */
:root {
  --bg: #171613;
  --surface: #201F1B;
  --text: #ECE7DC;
  --muted: #A8A296;
  --line: #3A382F;
  --accent: #B8874F;
  --radius: 0px;
  --card-aspect: 4 / 3;
  --gutter: 6vw;
  --serif: "Instrument Serif", Georgia, serif;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.5 "Space Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
body.lock { overflow: hidden; }
a { color: inherit; }
[hidden] { display: none !important; }

#page { max-width: 1680px; margin: 0 auto; padding: 0 var(--gutter); }

/* ---------- Sticky top bar (as in reload.html) ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 22px var(--gutter);
  background: rgba(23, 22, 19, .9);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}
.topbar-name { font-family: var(--serif); font-size: 1.3rem; text-decoration: none; color: var(--text); }

/* ---------- Header ---------- */
.site-header {
  display: grid;
  gap: 16px 32px;
  padding: clamp(48px, 12vh, 120px) 0 clamp(28px, 4vw, 48px);
}
#site-name {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(2.4rem, 6vw, 4.2rem);
  font-weight: 400;
  line-height: 1.05;
}
#site-tagline { margin: 12px 0 0; color: var(--muted); font-size: 1.05rem; }
#site-links { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px 28px; }
#site-links a { text-decoration: none; color: var(--muted); font-size: .9rem; transition: color .2s; }
#site-links a:hover { color: var(--accent); }
#site-about { grid-column: 1 / -1; margin: 8px 0 0; max-width: 60ch; color: var(--muted); }

/* ---------- Filters ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 8px; padding-bottom: 28px; border-top: 1px solid var(--line); padding-top: 24px; }
.chip {
  font: inherit; font-size: .85rem; font-weight: 500;
  padding: 8px 18px; border-radius: 0;
  border: 1px solid var(--line); background: transparent; color: var(--muted);
  cursor: pointer; transition: all .15s;
}
.chip:hover { color: var(--accent); border-color: var(--accent); }
.chip[aria-pressed="true"] { background: var(--accent); color: var(--bg); border-color: var(--accent); }

/* ---------- Grid & cards ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr));
  gap: clamp(32px, 4vw, 48px) clamp(16px, 2.5vw, 32px);
  padding-bottom: 96px;
}
.card {
  display: flex; flex-direction: column;
  cursor: pointer;
  animation: rise .7s cubic-bezier(.2, .7, .2, 1) both;
  animation-delay: calc(var(--i, 0) * 70ms);
}
.card-link { text-decoration: none; }
.card-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 4px; }
.card-media {
  position: relative;
  aspect-ratio: var(--card-aspect);
  overflow: hidden;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
}

/* Carousel: a horizontal scroll-snap track (swipe on touch, arrows on desktop) */
.track {
  display: flex; height: 100%;
  overflow-x: auto; overflow-y: hidden;
  scroll-snap-type: x mandatory;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
}
.track::-webkit-scrollbar { display: none; }
.slide { flex: 0 0 100%; height: 100%; overflow: hidden; scroll-snap-align: start; scroll-snap-stop: always; }
.slide > img, .slide > video, .slide > .missing {
  display: block; width: 100%; height: 100%; object-fit: cover;
  transition: transform .8s cubic-bezier(.2, .7, .2, 1);
}
.card:hover .slide > * { transform: scale(1.04); }

.cnav {
  position: absolute; top: 50%; z-index: 2;
  width: 36px; height: 36px; margin-top: -18px;
  border: 0; border-radius: 50%;
  background: rgba(0, 0, 0, .5); color: #fff;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  font: 400 1.5rem/1 system-ui, sans-serif; cursor: pointer;
  opacity: 0; transition: opacity .2s, background .2s;
}
.cnav.prev { left: 10px; }
.cnav.next { right: 10px; }
.card-media:hover .cnav, .cnav:focus-visible { opacity: 1; }
.cnav:hover { background: rgba(0, 0, 0, .75); }
@media (hover: none) { .cnav { display: none; } } /* touch: swipe instead */

.dots {
  position: absolute; left: 0; right: 0; bottom: 10px; z-index: 2;
  display: flex; justify-content: center; gap: 6px; pointer-events: none;
}
.dots span {
  width: 6px; height: 6px; border-radius: 3px;
  background: rgba(255, 255, 255, .5); box-shadow: 0 0 3px rgba(0, 0, 0, .4);
  transition: width .25s, background .25s;
}
.dots span.on { width: 16px; background: #fff; }
/* While autoplay is counting down, the active dot fills up like a progress bar */
.dots span { position: relative; overflow: hidden; }
.card-media.ticking .dots span.on { background: rgba(255, 255, 255, .5); }
.card-media.ticking .dots span.on::after {
  content: ""; position: absolute; inset: 0; background: #fff;
  transform-origin: left; animation: dot-fill var(--autoplay, 4s) linear both;
}
@keyframes dot-fill { from { transform: scaleX(0); } }

.badge {
  position: absolute; top: 10px; right: 10px;
  padding: 3px 9px; border-radius: 999px;
  background: rgba(0, 0, 0, .55); color: #fff;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  font-size: .75rem; font-weight: 600; font-variant-numeric: tabular-nums;
}
.card-text { padding: 14px 2px 0; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; }
.card h3 { margin: 0; font-family: var(--serif); font-size: 1.6rem; font-weight: 400; line-height: 1.15; }
.card time { color: var(--accent); font-size: .85rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.card p {
  margin: 6px 0 0; color: var(--muted); font-size: .95rem; white-space: pre-line;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card p a, .info-desc a { color: var(--accent); text-decoration: none; }
.card p a:hover, .info-desc a:hover { color: var(--text); text-decoration: underline dotted; }
.empty { color: var(--muted); }

.missing {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  padding: 12px; text-align: center; font-size: .8rem; color: var(--muted);
  background: repeating-linear-gradient(45deg, var(--surface) 0 14px, transparent 14px 28px), var(--bg);
}
.missing code { opacity: .8; word-break: break-all; }

footer { padding: 8vh 0; border-top: 1px solid var(--line); color: var(--muted); font-size: .9rem; }

@keyframes rise { from { opacity: 0; transform: translateY(16px); } }

/* ---------- Viewer (always dark, so media looks its best) ---------- */
.viewer {
  position: fixed; inset: 0; z-index: 100;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  grid-template-rows: minmax(0, 1fr) auto;
  background: rgba(23, 22, 19, .97);
  color: var(--text);
  animation: fade .25s ease both;
}
@keyframes fade { from { opacity: 0; } }

.viewer button { font: inherit; color: inherit; cursor: pointer; }
.viewer-close {
  position: absolute; top: 14px; right: 16px; z-index: 3;
  width: 44px; height: 44px; border: 0; border-radius: 50%;
  background: rgba(255, 255, 255, .08); font-size: 1.6rem; line-height: 1;
}
.viewer-close:hover, .nav:hover { background: rgba(255, 255, 255, .18); }

.stage { position: relative; grid-column: 1; grid-row: 1; display: flex; min-height: 0; padding: 56px 76px 12px; }
.stage-media { flex: 1; display: flex; min-width: 0; min-height: 0; }
.stage-figure {
  flex: 1; margin: 0; display: flex; flex-direction: column; gap: 10px; min-width: 0; min-height: 0;
  animation: fade .3s ease both;
}
.stage-figure.in-next { animation: slide-next .45s cubic-bezier(.2, .7, .2, 1) both; }
.stage-figure.in-prev { animation: slide-prev .45s cubic-bezier(.2, .7, .2, 1) both; }
@keyframes slide-next { from { opacity: 0; transform: translateX(60px); } }
@keyframes slide-prev { from { opacity: 0; transform: translateX(-60px); } }
.stage-figure > img, .stage-figure > video, .stage-figure > iframe, .stage-figure > .missing {
  flex: 1 1 0; min-height: 0; width: 100%; object-fit: contain; border: 0;
}
/* Videos and embeds: the player is sized to the video's aspect ratio and centered */
.stage-figure > .frame { flex: 1 1 0; min-height: 0; container-type: size; display: grid; place-items: center; }
.frame > video, .frame > iframe {
  display: block; border: 0; height: auto;
  aspect-ratio: var(--ar, 16 / 9);
  width: min(100cqw, 100cqh * var(--ar, 16 / 9));
}
.frame > .missing { width: 100%; height: 100%; }
.stage-figure figcaption { text-align: center; font-size: .85rem; color: var(--muted); }
.counter { position: absolute; top: 24px; left: 28px; font-size: .85rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.nav {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 2;
  width: 48px; height: 48px; border: 0; border-radius: 50%;
  background: rgba(255, 255, 255, .08); font-size: 1.8rem; line-height: 1;
}
.nav.prev { left: 16px; }
.nav.next { right: 16px; }
.viewer.single .nav, .viewer.single .thumbs { display: none; }

.thumbs { grid-column: 1; grid-row: 2; display: flex; justify-content: center; gap: 8px; padding: 8px 16px 20px; overflow-x: auto; }
.thumb {
  flex: none; width: 68px; aspect-ratio: 1; padding: 0; border: 0; border-radius: 0; overflow: hidden;
  background: var(--surface); opacity: .45; transition: opacity .2s, box-shadow .2s;
}
.thumb:hover { opacity: .8; }
.thumb[aria-current="true"] { opacity: 1; box-shadow: 0 0 0 2px var(--accent); }
.thumb > img, .thumb > video, .thumb > .missing { display: block; width: 100%; height: 100%; object-fit: cover; font-size: 0; }

.info {
  grid-column: 2; grid-row: 1 / span 2;
  padding: 80px 36px 36px; overflow-y: auto;
  border-left: 1px solid var(--line);
}
.info-date { color: var(--accent); font-size: .85rem; font-variant-numeric: tabular-nums; }
.info-title { margin: 8px 0 16px; font-family: var(--serif); font-size: 2.1rem; font-weight: 400; line-height: 1.1; }
.info-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 20px; }
.info-tags:empty { display: none; }
.tag { font-size: .75rem; font-weight: 500; padding: 3px 10px; border: 1px solid var(--line); color: var(--muted); }
.info-desc { margin: 0; white-space: pre-line; line-height: 1.7; color: var(--muted); }

/* ---------- Mobile ---------- */
@media (max-width: 860px) {
  #site-links { gap: 6px 16px; }
  .viewer { display: block; overflow-y: auto; }
  .stage { height: 64vh; padding: 60px 8px 8px; }
  .nav { width: 40px; height: 40px; font-size: 1.5rem; background: rgba(0, 0, 0, .45); }
  .nav.prev { left: 8px; }
  .nav.next { right: 8px; }
  .counter { top: 26px; left: 16px; }
  .thumbs { justify-content: flex-start; }
  .info { border-left: 0; border-top: 1px solid var(--line); padding: 24px 20px 48px; overflow: visible; }
}

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