/* ---------- Design tokens ---------- */

:root {
  --bg:           #16140f;
  --surface:      #1f1c16;
  --ink:          #ece8df;
  --ink-soft:     #b4ad9c;
  --rule:         #25211a;
  --accent:       #e3a878;
  --accent-soft:  #3a2c1d;
  --header-bg:    #0d0c09;
  --header-ink:   #f0ebe0;
  --shadow-sm:    0 1px 2px rgba(0, 0, 0, 0.25), 0 1px 3px rgba(0, 0, 0, 0.35);
  --shadow-md:    0 4px 6px rgba(0, 0, 0, 0.3), 0 10px 20px rgba(0, 0, 0, 0.4);
  --shadow-lg:    0 20px 40px rgba(0, 0, 0, 0.5), 0 8px 16px rgba(0, 0, 0, 0.35);
  --radius:       6px;
  --radius-lg:    10px;
  --serif:        Georgia, "Iowan Old Style", "Apple Garamond", Cambria, "Times New Roman", serif;
  --sans:         -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono:         "SF Mono", Menlo, Consolas, monospace;
  --content-max:  96rem;
  --reading-max:  46rem;
  --ease:         cubic-bezier(0.2, 0.7, 0.2, 1);
}

/* ---------- Reset ---------- */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body, h1, h2, h3, p, figure { margin: 0; }
img { display: block; max-width: 100%; height: auto; }
button { font: inherit; cursor: pointer; color: inherit; background: none; border: 0; }
a { color: inherit; text-decoration: none; }

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

body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.55;
  font-size: clamp(15px, 0.9rem + 0.2vw, 17px);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

main { flex: 1; }

/* ---------- Site header ---------- */

.site-header {
  background: var(--header-bg);
  color: var(--header-ink);
  padding-block: 1.5rem;
  border-bottom: 1px solid var(--rule);
}

.site-header__inner {
  max-width: var(--content-max);
  margin: 0 auto;
  padding-inline: clamp(1rem, 4vw, 3rem);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.site-header__lede {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}

.site-header__summary {
  font-family: var(--serif);
  font-style: italic;
  color: var(--header-ink);
  opacity: 0.75;
  font-size: 0.95rem;
  margin: 0;
}

.site-title {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(1.6rem, 1.2rem + 1.4vw, 2.4rem);
  letter-spacing: -0.01em;
}

.site-title a {
  display: inline-block;
  transition: opacity 0.2s var(--ease);
}

.site-title__suffix { white-space: nowrap; }
.site-title__sep {
  display: inline-block;
  margin: 0 0.4em;
  opacity: 0.45;
  font-weight: 300;
}
.site-title__current { color: var(--header-ink); }

/* When the breadcrumb is present, the "Audio Projects" link sits at half-strength
   so the current project reads as the primary heading. */
.site-title:has(.site-title__suffix:not([hidden])) a { opacity: 0.55; }
.site-title:has(.site-title__suffix:not([hidden])) a:hover { opacity: 1; }

.site-tagline {
  font-family: var(--serif);
  font-style: italic;
  color: var(--header-ink);
  opacity: 0.7;
  font-size: 0.95rem;
}

/* ---------- Main shell ---------- */

main {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: clamp(1.5rem, 4vw, 3rem) clamp(1rem, 4vw, 3rem);
}

.section-title {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(1.4rem, 1.1rem + 0.8vw, 2rem);
  letter-spacing: -0.01em;
  margin-bottom: 1.5rem;
}

/* ---------- Project grid (home) ---------- */

.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: clamp(1.5rem, 2.5vw, 2rem);
  list-style: none;
  padding: 0;
  margin: 0;
}
.project-grid > li { list-style: none; }

.project-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform 0.4s var(--ease), box-shadow 0.4s var(--ease);
  border: 1px solid var(--rule);
}

.project-card:hover,
.project-card:focus-within {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
}

.project-card a {
  display: block;
  height: 100%;
  outline: none;
}

.project-card:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.project-card__media {
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: var(--rule);
}

.project-card__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.6s var(--ease), filter 0.6s var(--ease);
}

.project-card:hover .project-card__media img,
.project-card:focus-within .project-card__media img {
  transform: scale(1.04);
}

.project-card__body {
  padding: 1.1rem 1.25rem 1.3rem;
}

.project-card__title {
  font-family: var(--serif);
  font-size: 1.4rem;
  letter-spacing: -0.01em;
}

.project-card__summary {
  margin-top: 0.4rem;
  color: var(--ink-soft);
  font-size: 0.95rem;
}

/* ---------- Gallery ---------- */

/* Tighten the space between the black bar and the stage on the gallery page. */
body[data-page="gallery"] main {
  padding-top: clamp(1rem, 2vw, 1.5rem);
}

.stage {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  display: grid;
  grid-template-columns: 1fr;
}

@media (min-width: 900px) {
  .stage {
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  }
}

.stage__frame {
  position: relative;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  aspect-ratio: 4 / 3;
}

@media (min-width: 900px) {
  .stage__frame {
    aspect-ratio: auto;
    height: clamp(380px, 62vh, 640px);
  }
}

.stage__img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  transition: opacity 0.35s var(--ease);
}

.stage__img.is-loading { opacity: 0; }

.stage__nav {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: clamp(48px, 8vw, 72px);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: clamp(1.2rem, 2vw, 1.6rem);
  background: linear-gradient(to right, rgba(0,0,0,0.35), rgba(0,0,0,0));
  opacity: 0;
  transition: opacity 0.25s var(--ease), background 0.25s var(--ease);
}

.stage__nav--next {
  right: 0;
  left: auto;
  background: linear-gradient(to left, rgba(0,0,0,0.35), rgba(0,0,0,0));
}

.stage:hover .stage__nav,
.stage:focus-within .stage__nav { opacity: 1; }

.stage__nav:hover { background: rgba(0,0,0,0.55); }

.stage__nav:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -4px;
  opacity: 1;
}

.stage__counter {
  position: absolute;
  bottom: 0.75rem;
  right: 1rem;
  font-family: var(--mono);
  font-size: 0.8rem;
  color: white;
  background: rgba(0,0,0,0.55);
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  letter-spacing: 0.02em;
}

/* Caption — proper figcaption, readable measure.
   Fixed-height scroll area so navigation never shifts page geometry. */
.caption {
  padding: 1.5rem clamp(1rem, 3vw, 2rem) 1.75rem;
  border-top: 1px solid var(--rule);
  font-family: var(--serif);
  font-size: 1.05rem;
  line-height: 1.7;
  color: var(--ink);
  overflow-y: auto;
  min-height: 240px;
  scrollbar-width: thin;
  scrollbar-color: var(--rule) transparent;
}

.caption::-webkit-scrollbar { width: 8px; }
.caption::-webkit-scrollbar-thumb { background: var(--rule); border-radius: 4px; }
.caption::-webkit-scrollbar-track { background: transparent; }

.caption p { margin: 0; }
.caption p + p { margin-top: 0.9em; }

@media (min-width: 900px) {
  .caption {
    border-top: 0;
    border-left: 1px solid var(--rule);
    height: clamp(380px, 62vh, 640px);
    min-height: 0;
  }
}

/* Thumbnail strip */
.thumbs {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(72px, 1fr);
  gap: 0.5rem;
  margin: 1.5rem 0 0;
  padding: 0.5rem 0.25rem 1rem;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  scrollbar-width: thin;
  list-style: none;
}
.thumbs > li { list-style: none; }

@media (min-width: 900px) {
  .thumbs {
    grid-auto-flow: row;
    grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
    grid-auto-columns: auto;
    overflow-x: visible;
  }
}

.thumb {
  position: relative;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius);
  overflow: hidden;
  border: 2px solid transparent;
  background: var(--rule);
  scroll-snap-align: start;
  transition: border-color 0.2s var(--ease), transform 0.2s var(--ease);
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.65;
  transition: opacity 0.2s var(--ease);
}

.thumb:hover img { opacity: 1; }
.thumb:hover { transform: translateY(-1px); }

.thumb.is-active {
  border-color: var(--accent);
}
.thumb.is-active img { opacity: 1; }

.thumb:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Footer ---------- */

.site-footer {
  margin-top: 3rem;
  padding: 1.5rem clamp(1rem, 4vw, 3rem);
  border-top: 1px solid var(--rule);
  color: var(--ink-soft);
  font-size: 0.85rem;
  text-align: center;
}

/* ---------- Empty / error state ---------- */

.notice {
  padding: 3rem 1rem;
  text-align: center;
  color: var(--ink-soft);
  font-family: var(--serif);
  font-style: italic;
}

/* ---------- Mobile vertical view ---------- */

/* All image+caption pairs stacked vertically. Hidden by default; shown only
   when the viewport is narrow enough that the side-by-side slideshow
   becomes awkward. */
.slides-mobile { display: none; }

.slide-mobile {
  margin: 0 0 clamp(1.5rem, 5vw, 2.5rem);
  padding: 0;
}

.slide-mobile img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
  background: #000;
}

.slide-mobile__caption {
  margin-top: 0.75rem;
  padding: 0 0.25rem;
  font-family: var(--serif);
  font-size: clamp(1.05rem, 0.95rem + 0.6vw, 1.2rem);
  line-height: 1.7;
  color: var(--ink);
}

.slide-mobile__caption p { margin: 0; }
.slide-mobile__caption p + p { margin-top: 0.75em; }

/* Switch to the vertical view on phones (always) and on any portrait-
   oriented viewport — tablets held in portrait benefit too, since the
   side-by-side layout starts to feel cramped below ~1024px wide. */
@media (max-width: 768px), (orientation: portrait) and (max-width: 1024px) {
  .stage, .thumbs { display: none; }
  .slides-mobile { display: block; }
}

/* ---------- Motion preferences ---------- */

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