/* ------------------------------------------------------------------
   Theme. Colours + font can also be changed from /admin → Site.
   To use a custom webfont: drop the file in /public/fonts, add an
   @font-face below, and put its family name in admin → Site → Font.
------------------------------------------------------------------- */
:root {
  --bg: var(--theme-bg, #ffffff);
  --fg: var(--theme-fg, #222222);
  --muted: color-mix(in srgb, var(--fg) 45%, var(--bg));
  --rule: color-mix(in srgb, var(--fg) 12%, var(--bg));
  --font: "Neue Haas Grotesk Display Pro", "Helvetica Neue", Helvetica, Inter, Arial, sans-serif;
  --small: 11px;
  --gutter: 8px;
  --foot-h: 28px;
  --ease: cubic-bezier(.2, .7, .1, 1);
  --menu-size: clamp(52px, 9.6vw, 168px);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: var(--small);
  line-height: 1.25;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  transition: color .9s var(--ease), background-color .9s var(--ease);
}
a { color: inherit; }
button.link {
  font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer;
}
button.link:hover, a:hover { opacity: .55; }
:focus-visible { outline: 1px solid var(--fg); outline-offset: 2px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------------- carousel menu ---------------- */
.menu {
  position: fixed; inset: 0 0 var(--foot-h) 0; z-index: 1;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0%, #000 30%, #000 70%, transparent 100%);
          mask-image: linear-gradient(to bottom, transparent 0%, #000 30%, #000 70%, transparent 100%);
}
.track { position: absolute; inset: 0; }
.item {
  position: absolute; left: var(--gutter); top: 50%;
  font-size: var(--menu-size);
  line-height: 1;
  letter-spacing: -0.035em;
  white-space: nowrap;
  cursor: pointer;
  will-change: transform, opacity;
  transition: color .4s var(--ease);
  color: var(--muted);
}
.item.is-active { color: var(--fg); }
.item.is-label { cursor: default; }
.item:hover { color: var(--fg); }
.probe { visibility: hidden; pointer-events: none; }

/* ---------------- window / panel ---------------- */
.panel {
  position: fixed; top: 0; right: 0; bottom: var(--foot-h);
  width: 50%;
  background: var(--bg);
  border-left: 1px solid var(--rule);
  display: flex; flex-direction: column;
  clip-path: inset(0 0 100% 0);
  visibility: hidden;
  transition: clip-path .7s var(--ease), visibility 0s linear .7s;
  z-index: 10;
}
.panel.is-open { clip-path: inset(0 0 0 0); visibility: visible; transition: clip-path .7s var(--ease), visibility 0s; }
.panel-bar {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 10px var(--gutter) 10px;
  border-bottom: 1px solid var(--rule);
  flex: none;
}
.panel-body {
  overflow-y: auto; overscroll-behavior: contain;
  padding: 0 var(--gutter) 48px;
  flex: 1;
  transition: opacity .25s var(--ease), transform .35s var(--ease);
}
.panel-body:focus { outline: none; }
.panel-body.is-swapping { opacity: 0; transform: translateY(10px); }

/* content entering after open / swap */
.panel.is-open .panel-body > * { animation: rise .7s var(--ease) both; animation-delay: calc(var(--i, 0) * 70ms + 120ms); }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ---------------- projects ---------------- */
.project { padding: 16px 0 18px; border-bottom: 1px solid var(--rule); scroll-margin-top: 8px; }
.proj-head { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.proj-id em, .md em { font-style: italic; }
.proj-fields { margin: 10px 0 0; display: grid; grid-template-columns: auto 1fr; gap: 0 10px; }
.proj-fields dt { color: var(--muted); }
.proj-fields dd { margin: 0; }
.md p { margin: 0 0 1.05em; }
.md p:last-child { margin-bottom: 0; }
.md a { word-break: break-all; }
.proj-links { list-style: none; padding: 0; margin: 12px 0 0; }
.proj-links li + li { margin-top: 2px; }
.tags { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 10px; }
.tags a { text-decoration: none; color: var(--muted); }
.tags a::before { content: "#"; }
.tags a:hover { color: var(--fg); opacity: 1; }

.proj-media { display: grid; gap: 16px; margin-top: 20px; }
.proj-media.layout-grid { grid-template-columns: repeat(2, 1fr); }
.proj-media.layout-wide { margin-left: calc(var(--gutter) * -1); margin-right: calc(var(--gutter) * -1); }
.project.is-collapsed .proj-body, .project.is-collapsed .proj-media figure:nth-child(n + 2) { display: none; }
.proj-foot { display: flex; justify-content: flex-end; gap: 12px; margin-top: 12px; }

figure { margin: 0; }
figure img, figure video { display: block; width: 100%; height: auto; background: var(--rule); }
figure img { cursor: zoom-in; }
figcaption { margin-top: 6px; display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
figcaption .cap-credit { color: var(--muted); }
figcaption .tags { margin-top: 2px; }

.audio {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px;
  padding: 12px 0; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule);
}
.audio .bar { height: 1px; background: var(--rule); position: relative; cursor: pointer; padding: 6px 0; background-clip: content-box; }
.audio .fill { position: absolute; left: 0; top: 6px; height: 1px; background: var(--fg); width: 0; }
.audio .time { font-variant-numeric: tabular-nums; color: var(--muted); }
.doc { display: flex; justify-content: space-between; padding: 12px 0; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); text-decoration: none; }

.empty { padding: 16px 0; color: var(--muted); }
.tag-index { columns: 2; padding-top: 16px; }
.tag-index a { display: block; text-decoration: none; padding: 1px 0; }
.tag-index span { color: var(--muted); }
.list-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--rule); text-decoration: none; }
.media-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 16px; }
.media-grid figcaption { display: block; }

/* ---------------- lightbox ---------------- */
.lightbox {
  position: fixed; inset: 0; z-index: 50; background: var(--bg);
  display: grid; grid-template-rows: auto 1fr auto; padding: 10px var(--gutter);
  opacity: 0; transition: opacity .35s var(--ease);
}
.lightbox[hidden] { display: none; }
.lightbox.is-open { opacity: 1; }
.lb-close { justify-self: end; grid-row: 1; grid-column: 1; }
.lb-prev, .lb-next { position: absolute; top: 50%; z-index: 2; }
.lb-prev { left: var(--gutter); }
.lb-next { right: var(--gutter); }
.lb-stage { grid-row: 2; display: grid; place-items: center; min-height: 0; padding: 12px 60px; }
.lb-stage img, .lb-stage video { max-width: 100%; max-height: 100%; object-fit: contain; }
.lb-caption { grid-row: 3; text-align: center; min-height: 1.25em; }

/* ---------------- aquarium theme ----------------
   Colours/images come from admin → Site → Aquarium (as --aq-* variables). */
html.aquarium { --fg: var(--aq-text); --bg: var(--aq-bottom); }
#tank, #aq-front { position: fixed; inset: 0; pointer-events: none; opacity: 0; transition: opacity 1s var(--ease); }
#tank {
  z-index: 0;
  background: var(--aq-image, none) center / cover no-repeat, linear-gradient(var(--aq-top, #0f5b73), var(--aq-bottom, #031820));
}
#tank::after { /* slow drifting light rays */
  content: ""; position: absolute; inset: -20% -40%;
  background: repeating-linear-gradient(100deg, transparent 0 7%, rgba(255,255,255,.05) 9%, transparent 12% 20%);
  animation: rays 24s linear infinite alternate;
}
@keyframes rays { from { transform: translateX(-6%); } to { transform: translateX(6%); } }
#aq-back, #aq-front { width: 100%; height: 100%; display: block; }
#aq-front { z-index: 5; }
html.aquarium #tank, html.aquarium #aq-front { opacity: 1; }
html.aquarium .foot { background: transparent; }
html.aquarium .panel {
  background: color-mix(in srgb, var(--aq-bottom) 70%, transparent);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
}
html.aquarium.aq-solid .panel { background: var(--aq-bottom); -webkit-backdrop-filter: none; backdrop-filter: none; }
html.aquarium .lightbox { background: var(--aq-bottom); }
.foot-left { display: flex; gap: 14px; }

/* ---------------- footer ---------------- */
.foot {
  position: fixed; left: 0; right: 0; bottom: 0; height: var(--foot-h);
  display: flex; justify-content: space-between; align-items: center;
  padding: 0 var(--gutter); z-index: 20; background: var(--bg);
}
.foot a { text-decoration: none; }

/* ---------------- small screens ---------------- */
@media (max-width: 760px) {
  :root { --menu-size: clamp(40px, 13vw, 90px); }
  .panel {
    width: 100%; border-left: 0;
    clip-path: none; transform: translateY(100%);
    transition: transform .6s var(--ease), visibility 0s linear .6s;
  }
  .panel.is-open { clip-path: none; transform: none; transition: transform .6s var(--ease), visibility 0s; }
  .proj-head, figcaption, .list-row { grid-template-columns: 1fr; gap: 8px; }
  .media-grid { grid-template-columns: repeat(2, 1fr); }
  .lb-stage { padding: 12px 0; }
}

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