/* ------------------------------
   1. Root variables & base styles
   ------------------------------ */

:root {
  --page-max-width: 1600px;

  --header-stack-offset: 50px; /* adjust after you see it (usually 72–104px) */

  --card-width: 300px;
  --card-column-gap: 72px;
  --card-row-gap: 64px;

  --background: #ffffff;
  --text-main: #22221e;
  --text-muted: #7a7a72;

  --font-serif: "Source Serif Pro","Goudy Old Style", "Palatino", "Georgia", serif;
  --font-sans: "Univers STD", "Helvetica Neue", Arial, sans-serif;
  --font-mark: "Baskerville", "Times New Roman", serif;

  --grid-col-gap: 20px;
  --grid-row-gap: 20px;

  --caption-gap: 0px;

  /* tighten these to taste */
  --card-min: 150px;
  --card-max: 220px;
  --card-align: end;  /* try: center | end */

  --caption-min-h: 28px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-serif);
  font-size: 10px;
  line-height: 1.6;
  color: var(--text-main);
  background-color: var(--background);
}

/* Make sure the hero touches the very top of the page */
.hero {
  margin: 0;
}

.page-main {
  max-width: var(--page-max-width);
  margin: 0 auto;
  padding: 40px 20px 0;  /* top | left/right | bottom */
}

/* ------------------------------
   2. Header
   ------------------------------ */

/* Full-bleed fixed bar */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;

  background: transparent;   /* invisible over hero */
  border-bottom: none;
  color: #ffffff;            /* white while on hero */

  transition:
    color 0.3s ease,
    background-color 0.3s ease,
    border-bottom 0.3s ease;
}

/* Inner container aligned to gallery width */
.site-header-inner {
  max-width: var(--page-max-width);
  margin: 0 auto;
  padding: 24px 20px 10px;

  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

/* When we've scrolled past the hero */
body.scrolled .site-header {
  background-color: var(--background);
  color: var(--text-main);
  /* border-bottom: 1px solid rgba(0,0,0,0.15); */
}

/* When header is “active” (after hero), pin controls under it */
body.scrolled .controls-bar{
  position: sticky;
  top: var(--header-stack-offset);
  z-index: 900;                 /* under header (1000), above cards */
  background: var(--background);
  /* border-bottom: 1px solid rgba(0,0,0,0.15); /* the “fine line” under controls */
}

/* Optional: tighten the gap between controls and grid once sticky is on */
body.scrolled .gallery-grid{
  padding-top: 10px; /* you currently have 50px; adjust to taste */
}

/* Logo block */
.site-mark {
  display: flex;
  align-items: center;
}

.site-logo {
  display: block;
  height: 20px;   /* tweak this for size */
  width: auto;
}

/* default: white visible, black hidden */
.site-logo.logo-white {
  display: block;
}

.site-logo.logo-black {
  display: none;
}

/* after scroll: swap */
body.scrolled .site-logo.logo-white {
  display: none;
}

body.scrolled .site-logo.logo-black {
  display: block;
}

/* Nav items */
.site-nav {
  display: flex;
  gap: 24px;
  font-family: var(--font-sans);
  font-size: 10px;
  color: inherit;
}

.nav-item {
  color: inherit;
}

/* Controls bar base */
.controls-bar{
  /* In normal flow it just sits above the grid */
  margin-top: 0;
}

/* Match header width rhythm */
.controls-inner{
  display: flex;
  flex-wrap: wrap;
  gap: 18px 28px;
  align-items: baseline;
  padding: 5px 0 20px;
}

.filter-group {
  display: flex;
  flex-direction: row;      /* keep label + select horizontally arranged */
  align-items: baseline;
  gap: 8px;
  width: 40px;             /* KEY: fixed width so labels + selects align cleanly */
  margin: 0;
  padding: 0;
  line-height: 0;
  justify-content: flex-start;
  font-family: var(--font-sans);
  color: var(--text-muted);
}

.filter-label {
  white-space: nowrap;
}

.filter-select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;

  border: none;
  background: none;
  padding: 0;
  margin: 0;

  font-family: var(--font-sans);
  font-size: 10px;
  /*   letter-spacing: 0.18em;
  text-transform: uppercase; */
  color: var(--text-main);

  cursor: pointer;
}

.filter-select:focus {
  outline: none;
  text-decoration: underline;
}

/* Hide default arrow on old browsers */
.filter-select::-ms-expand {
  display: none;
}

.project-count .filter-value {
  font-family: var(--font-sans);
  font-size: 10px;
  /* letter-spacing: 0.18em;
  text-transform: uppercase; */
  color: var(--text-main);
  padding-top: 10px;
}


.nav-item {
  color: inherit;
}

/* ------------------------------
   Sort Controls (Cereal-style)
   ------------------------------ */

.sort-controls {
  display: flex;
  align-items: baseline;
  gap: 12px;

  /* Moved to left alignment */
  justify-content: flex-start;

  margin-bottom: 32px;
  font-family: var(--font-sans);
  font-size: 10px;
  /* letter-spacing: 0.18em; */
  /* text-transform: uppercase; */
  color: var(--text-muted);
}

.sort-controls label {
  white-space: nowrap;
}

/* Make the select look like plain text (remove borders/arrow) */
.sort-select {
  appearance: none;            /* remove browser styling */
  -webkit-appearance: none;    /* Safari */
  -moz-appearance: none;       /* Firefox */

  border: none;
  background: none;
  padding: 0;
  margin: 0;

  font-family: var(--font-sans);
  font-size: 10px;
  /* letter-spacing: 0.18em; */
  /* text-transform: uppercase; */
  color: var(--text-main);

  cursor: pointer;
}

/* Remove the focus outline and replace with subtle text underline */
.sort-select:focus {
  outline: none;
  text-decoration: underline;
}

/* Remove the down-arrow space on Safari */
.sort-select::-ms-expand {
  display: none;
}


/* ------------------------------
   2b. Hero (full-bleed video)
   ------------------------------ */

.hero {
  position: relative;
  z-index: 0;                 /* explicitly behind header */
  width: 100%;
  height: 100vh;              /* full viewport height */
  overflow: hidden;
}

/* The video fills the viewport */
.hero-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;          /* crops to fill without distortion */
}

/* Optional: quieten and shape the light so the logo reads nicely */
.hero-overlay {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.1), transparent 60%),
    linear-gradient(to bottom, rgba(0, 0, 0, 0.25), rgba(0, 0, 0, 0.45));
  pointer-events: none;
}


/* ------------------------------
   3. Gallery grid (Faculty-style)
   ------------------------------ */


/* The grid itself */
.gallery-grid{
  display: grid;

  /* key change: tracks have a real max width */
  grid-template-columns: repeat(
    auto-fit,
    minmax(var(--card-min), 1fr)
  );

  column-gap: var(--grid-col-gap);
  row-gap: var(--grid-row-gap);

  padding-top: 10px;
  padding-bottom: 10px;

  /* key change: leftover width goes to the sides */
  justify-content: center;

  /* let each card fill its track */
  justify-items: stretch;


  /* optional: stops mega-wide tracks on ultra-wide screens */
  /* tune the 6/5 numbers if you want a different “max columns before breathing space” */
  max-width: calc((var(--card-max) * 6) + (var(--grid-col-gap) * 5));
  margin-left: auto;
  margin-right: auto;
}

/* Let items grow/shrink with the grid, but cap their max width */
.project-card{
  width: 100%;
  max-width: none; /* important: don’t cap below track width */
  opacity: 0;
  transform: translateY(3px);
  transition: opacity 0.4s ease, transform 0.4s ease;
  align-self: var(--card-align);
}

.project-card.is-visible{
  opacity: 1;
  transform: none;
}

.project-link{
  display: block;
  text-decoration: none;
  color: inherit;
}

/* Make each card a tight vertical system:
   [media slot] -> (36px) -> [caption] */
.project-figure{
  margin: 0;
  display: flex;
  flex-direction: column;
}

/* This is the alignment mechanism.
   Everyone gets the same slot height; images are centered within it. */
.media-slot{
  width: 100%;
  height: auto;          /* key */
  display: block;        /* key */
  overflow: visible;     /* optional; keeps it honest */
}

/* Mixed ratios, no cropping: contain + center */
.media-slot img{
  display: block;
  width: 100%;
  height: auto;          /* key */
}

/* Caption spacing & consistency */
.project-caption{
  margin-top: var(--caption-gap);
  min-height: var(--caption-min-h);
}

/* Title under image */
.project-title{
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 500;
  /* letter-spacing: 0.003em; */
  margin: 0;
}

/* Meta */
.project-meta{
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-family: var(--font-sans);
  font-size: 10px;
  color: var(--text-muted);
}

.project-meta-item{
  white-space: nowrap;
}

.project-link:hover .project-title{
  text-decoration: underline;
}

/* Responsive tuning */
@media (max-width: 900px){
  :root{
    --card-min: 200px;
    --card-max: 320px;
    --grid-col-gap: 24px;
    --grid-row-gap: 88px;
    --caption-gap: 28px;
  }

  .gallery-grid{
    padding-top: 48px;
  }
}

/* ------------------------------
   4. Responsive tweaks
   ------------------------------ */

/* On very small screens */

@media (max-width: 600px){
  :root{
    --card-max: 520px;
    --grid-row-gap: 24px;
    --caption-gap: 10px;
    --caption-min-h: 0px;
  }

  .page-main{
    padding-left: 20px;
    padding-right: 20px;
  }

  .site-header{
    flex-direction: column;
    gap: 16px;
    align-items: flex-start;
  }

  .site-header-inner{
    padding-left: max(20px, env(safe-area-inset-left));
    padding-right: max(20px, env(safe-area-inset-right));
  }

  .gallery-grid{
    grid-template-columns: 1fr;
    column-gap: 0;
    row-gap: var(--grid-row-gap);
    justify-content: start;
    justify-items: stretch;
    max-width: none;
    margin: 0;
  }

  .project-card{
    max-width: none;
  }

  .media-slot{
    height: auto;
    display: block;
    overflow: visible;
  }

  .media-slot img{
    width: 100%;
    height: auto;
    object-fit: initial;
    display: block;
  }

  .project-caption{
    margin-top: var(--caption-gap);
    min-height: var(--caption-min-h);
  }

  .footer-inner {
    padding-left: max(20px, env(safe-area-inset-left));
    padding-right: max(20px, env(safe-area-inset-right));
  }
}



.site-logo-link {
  display: inline-block;
  text-decoration: none;
}

.site-logo-link:visited {
  color: inherit;
}

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

.site-footer {
  margin-top: 10px;                 /* space above footer */
  padding: 24px 0 32px 0;           /* top/bottom breathing room */

  /* move the line here so it runs full-bleed */
  /* border-top: 1px solid rgba(0,0,0,0.15); */
}

.footer-inner {
  max-width: var(--page-max-width);
  margin: 0 auto;

  padding: 0 20px;              /* desktop rhythm */
  display: flex;
  flex-direction: column;       /* stack vertically */
  align-items: flex-start;      /* left align */
}

.footer-line {
  font-size: 10px;
  color: var(--text-muted);
  font-family: var(--font-sans);
  margin: 6px 0 0 0;   /* subtle separation */
}

.footer-tagline {
  font-size: 10px;
  font-family: var(--font-sans);
  font-style: oblique;
  color: var(--text-main);
  margin: 0;
  line-height: 1.5;
  margin: 0 0 0 0;   /* subtle separation */
}

.show-more-link,
.show-more-link:visited,
.show-more-link:hover,
.show-more-link:active,
.show-more-link:focus {
  font-family: var(--font-sans);
  color: var(--text-main);
  text-decoration: none;
}

.show-more-link:hover {
  text-decoration: underline;
}

.show-more-link.is-hidden {
  display: none;
}

/* ------------------------------
   Single Project Page
   ------------------------------ */

body.project-page {
  background-color: var(--background);
}

.project-main {
  max-width: var(--page-max-width);
  margin: 0 auto;
  padding: 120px 40px 80px; /* top | sides | bottom */
}

/* Breadcrumb / back to archive */
.project-breadcrumb {
  margin-bottom: 32px;
  font-family: var(--font-sans);
  font-size: 10px;
}

.project-breadcrumb-link {
  color: var(--text-muted);
  text-decoration: none;
}

.project-breadcrumb-link:hover {
  text-decoration: underline;
}

/* Core layout:
   - Left side: centered 700px column (image + text)
   - Right side: thumbnail tray
*/
.project-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px; /* main + tray width */
  column-gap: 48px;
  align-items: start;
}

/* Main image wrapper centers its contents */
.project-media-main {
  width: 100%;
  display: flex;
  justify-content: center;
}

/* Constrain the main image to 700px and let it scale down responsively */
.project-media-main img {
  display: block;
  width: 100%;
  max-width: 700px;
  height: auto;
}

/* Vertical tray on the right */
.project-media-tray {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: flex-end;
}

/* Thumbnail buttons */
.project-thumb {
  border: none;
  padding: 0;
  background: none;
  cursor: pointer;
  display: block;
  width: 100%;
  opacity: 0.55;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.project-thumb img {
  display: block;
  width: 100%;
  height: auto;
}

/* Hover / active states */
.project-thumb:hover {
  opacity: 0.8;
  transform: translateY(-1px);
}

.project-thumb.is-active {
  opacity: 1;
}

/* Text block:
   - Shares the same 700px width as the image
   - Centered as a "box" but text is left-aligned
*/
.project-text {
  grid-column: 1 / 2;            /* stay in the main column */
  margin-top: 32px;
  max-width: 700px;
  margin-left: auto;
  margin-right: auto;
  text-align: left;
}

/* Title + meta */
.project-text-header {
  margin-bottom: 16px;
}

.project-detail-title {
  font-family: var(--font-serif);
  font-size: 12px;
  font-weight: 500;
  /* letter-spacing: 0.02em; */
  margin: 0 0 8px 0;
}

.project-detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-family: var(--font-sans);
  font-size: 10px;
  color: var(--text-muted);
}

.project-detail-meta-item {
  white-space: nowrap;
}

/* Body copy */
.project-description {
  font-family: var(--font-serif);
  font-size: 10px;
  font-weight: 300;
  line-height: 1.7;
  margin-top: 24px;
}

.project-description p {
  margin: 0 0 5px 0;
}

/* ------------------------------
   Responsive tweaks for project page
   ------------------------------ */

@media (max-width: 900px) {
  .project-main {
    padding: 100px 20px 60px;
  }

  .project-layout {
    grid-template-columns: 1fr;
    column-gap: 0;
    row-gap: 24px;
  }

  .project-media-main {
    justify-content: center;
  }

  .project-media-main img {
    max-width: 100%;
  }

  .project-media-tray {
    flex-direction: row;
    align-items: flex-start;
    justify-content: flex-start;
    overflow-x: auto;
  }

  .project-thumb {
    width: 90px;  /* small horizontal thumbs */
    flex: 0 0 auto;
  }

  .project-text {
    grid-column: 1 / -1;
    max-width: 100%;
    margin-left: 0;
    margin-right: 0;
  }
}
