/* Core theme tokens keep the static pages visually consistent. */
:root {
  --paper: #f6f0e6;
  --paper-deep: #e6dccd;
  --ink: #171512;
  --muted: #6c6258;
  --line: #d6cbbb;
  --rust: #9e3f2f;
  --teal: #2d6668;
  --cobalt: #244f8f;
  --shadow: 0 22px 60px rgba(23, 21, 18, 0.16);
  --measure: min(1120px, calc(100% - 40px));
  --display: "Iowan Old Style", "Palatino Linotype", Palatino, serif;
  --body: "Avenir Next", "Gill Sans", "Trebuchet MS", sans-serif;
  --lightbox-viewport-width: 100vw;
  --lightbox-viewport-height: 100vh;
}

/* Dynamic viewport units track mobile browser chrome better when available. */
@supports (height: 100dvh) {
  :root {
    --lightbox-viewport-width: 100dvw;
    --lightbox-viewport-height: 100dvh;
  }
}

/* Border-box sizing makes square image grids predictable at every viewport. */
*,
*::before,
*::after {
  box-sizing: border-box;
}

/* Smooth scrolling is a CSS-only nicety for skip links and anchor jumps. */
html {
  scroll-behavior: smooth;
}

/* Full-screen viewing locks page scroll so mobile gestures stay on the overlay. */
html.lightbox-open,
html.lightbox-open body {
  overflow: hidden;
  overscroll-behavior: none;
}

/* The body uses a subtle paper texture made from layered CSS gradients. */
body {
  margin: 0;
  color: var(--ink);
  font-family: var(--body);
  line-height: 1.55;
  background:
    linear-gradient(90deg, rgba(158, 63, 47, 0.06) 1px, transparent 1px),
    linear-gradient(180deg, rgba(45, 102, 104, 0.05) 1px, transparent 1px),
    var(--paper);
  background-size: 54px 54px, 54px 54px, auto;
}

/* Images render as block elements so grid gaps stay exact. */
img {
  display: block;
  max-width: 100%;
}

/* Links inherit the portfolio palette instead of browser defaults. */
a {
  color: inherit;
}

/* Focus outlines stay visible for keyboard users without changing layout. */
:focus-visible {
  outline: 3px solid var(--cobalt);
  outline-offset: 4px;
}

/* The skip link is hidden until focused so it helps accessibility without visual noise. */
.skip-link {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 10;
  padding: 10px 12px;
  color: var(--paper);
  background: var(--ink);
  text-decoration: none;
  transform: translateY(-150%);
  transition: transform 160ms ease;
}

/* Revealing the skip link on focus makes the control discoverable when needed. */
.skip-link:focus {
  transform: translateY(0);
}

/* The header is constrained to the same measure as the content below it. */
.site-header {
  width: var(--measure);
  margin: 0 auto;
  padding: 24px 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--line);
}

/* The brand is typographic and compact so it does not compete with images. */
.brand {
  font-family: var(--display);
  font-size: 1.35rem;
  font-weight: 700;
  text-decoration: none;
}

/* The navigation uses flex wrapping so links never overflow on narrow screens. */
.nav,
.footer-links {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
  flex-wrap: wrap;
}

/* Navigation links are plain until interaction, preserving the editorial tone. */
.nav a,
.footer-links a {
  color: var(--muted);
  font-size: 0.95rem;
  text-decoration: none;
}

/* Current and hovered links use ink for a small but clear state change. */
.nav a:hover,
.nav a[aria-current="page"],
.footer-links a:hover {
  color: var(--ink);
}

/* The intro uses the shared measure so it aligns with the image grid. */
.intro {
  width: var(--measure);
  margin: 76px auto 38px;
}

/* Kicker labels create hierarchy without relying on oversized type. */
.kicker {
  margin: 0 0 10px;
  color: var(--rust);
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

/* Main headings use a serif display face for a quieter gallery feel. */
h1 {
  max-width: 820px;
  margin: 0;
  font-family: var(--display);
  font-size: 4.25rem;
  line-height: 0.98;
  letter-spacing: 0;
}

/* Paragraphs are capped so text pages remain easy to scan. */
p {
  max-width: 690px;
}

/* The lede gives the home page enough context without becoming a marketing block. */
.lede {
  margin: 24px 0 0;
  color: var(--muted);
  font-size: 1.1rem;
}

/* The event grid uses square tracks for the landing-page event entries. */
.event-grid {
  width: var(--measure);
  margin: 0 auto 84px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

/* Each event card is a full-tile link with a stable square footprint. */
.event-card {
  position: relative;
  min-height: 0;
  aspect-ratio: 1;
  overflow: hidden;
  color: var(--paper);
  background: var(--ink);
  box-shadow: var(--shadow);
  text-decoration: none;
}

/* Card images fill the square while keeping future photos nicely cropped. */
.event-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 360ms ease, filter 360ms ease;
}

/* The overlay gradient keeps white text readable on varied photographs. */
.event-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(23, 21, 18, 0.02), rgba(23, 21, 18, 0.72));
}

/* The event text sits inside the square without changing card dimensions. */
.event-card__text {
  position: absolute;
  inset: auto 18px 18px;
  z-index: 1;
  display: grid;
  gap: 2px;
}

/* Eyebrow labels add a quick event category. */
.event-card__eyebrow {
  color: rgba(246, 240, 230, 0.76);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

/* Event titles remain compact enough to fit inside square tiles. */
.event-card__title {
  font-family: var(--display);
  font-size: 1.65rem;
  line-height: 1;
}

/* Counts are secondary metadata and intentionally subdued. */
.event-card__count {
  color: rgba(246, 240, 230, 0.72);
  font-size: 0.86rem;
}

/* Hover motion is CSS-only and does not affect layout. */
.event-card:hover img {
  filter: saturate(1.08) contrast(1.04);
  transform: scale(1.04);
}

/* Text pages share the intro rhythm but give paragraphs more vertical room. */
.text-page {
  width: var(--measure);
  min-height: 52vh;
  margin: 86px auto 96px;
}

/* Text page paragraphs are slightly larger for a readable biography/contact block. */
.text-page p {
  color: var(--muted);
  font-size: 1.08rem;
}

/* Inline text links get a visible underline that feels intentional. */
.text-link {
  color: var(--rust);
  font-weight: 700;
  text-decoration-thickness: 2px;
  text-underline-offset: 5px;
}

/* The contact line stays calm and compact inside the about page. */
.contact-line {
  margin: 0;
  color: var(--ink);
  font-family: var(--display);
  font-size: clamp(1.7rem, 4vw, 2.8rem);
  line-height: 1.08;
}

/* Event detail pages use one centered content column. */
.event-detail {
  width: var(--measure);
  margin: 66px auto 92px;
}

/* The event hero pairs copy with a large image while staying unframed. */
.event-hero {
  display: grid;
  grid-template-columns: minmax(0, 0.82fr) minmax(360px, 1.18fr);
  align-items: end;
  gap: 34px;
  margin-bottom: 42px;
}

/* Event hero copy stays readable beside landscape or square images. */
.event-hero__copy p:last-child {
  color: var(--muted);
  font-size: 1.08rem;
}

/* Hero images get a fixed ratio so page height does not jump between events. */
.event-hero__image {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  box-shadow: var(--shadow);
}

/* The gallery grid creates an orderly contact-sheet feel. */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

/* Thumbnail links fill the figure image area without changing caption flow. */
.photo-thumb {
  display: block;
  color: inherit;
  overflow: hidden;
  text-decoration: none;
}

/* Thumbnail hover movement hints that each image opens a larger view. */
.photo-thumb img {
  transition: filter 220ms ease, transform 220ms ease;
}

/* Hover and keyboard focus share the same visual treatment. */
.photo-thumb:hover img,
.photo-thumb:focus-visible img {
  filter: saturate(1.05) contrast(1.04);
  transform: scale(1.025);
}

/* Figures reset browser spacing so captions align exactly with images. */
figure {
  margin: 0;
}

/* Gallery images use a square ratio for a clean event overview. */
figure img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: var(--paper-deep);
}

/* Captions are small and muted so they support rather than dominate photos. */
figcaption {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.88rem;
}

/* The lightbox container has no layout footprint until a child is targeted. */
.lightbox-set {
  display: contents;
}

/* Lightbox panels are hidden by default and activated by URL fragments. */
.lightbox {
  display: none;
}

/* The targeted lightbox becomes a viewport-sized overlay with a reserved nav border. */
.lightbox:target {
  --lightbox-control-size: clamp(42px, 3.8vw, 54px);
  --lightbox-control-gap: clamp(10px, 1.2vw, 18px);
  --lightbox-edge-space: calc(var(--lightbox-control-size) + var(--lightbox-control-gap) + var(--lightbox-control-gap));
  position: fixed;
  top: 0;
  left: 0;
  width: var(--lightbox-viewport-width);
  height: var(--lightbox-viewport-height);
  z-index: 30;
  display: grid;
  place-items: stretch;
  color: var(--paper);
  background: rgba(23, 21, 18, 0.94);
  overscroll-behavior: none;
  touch-action: none;
}

/* The top bar floats above the stage so it does not steal image height. */
.lightbox__top {
  position: absolute;
  top: var(--lightbox-control-gap);
  left: var(--lightbox-control-gap);
  right: var(--lightbox-control-gap);
  z-index: 2;
  min-height: var(--lightbox-control-size);
  padding: 0 var(--lightbox-edge-space);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

/* The full-screen title behaves like a caption rather than a second heading. */
.lightbox__title {
  margin: 0;
  max-width: min(42vw, 520px);
  overflow: hidden;
  color: rgba(246, 240, 230, 0.82);
  font-size: 0.95rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* The stage reserves enough edge space for the centered navigation buttons. */
.lightbox__stage {
  width: var(--lightbox-viewport-width);
  height: var(--lightbox-viewport-height);
  min-height: 0;
  padding: var(--lightbox-edge-space);
  display: grid;
  place-items: center;
}

/* Images use their native size until the viewport forces them to scale down. */
.lightbox__stage img {
  width: auto;
  height: auto;
  max-width: calc(var(--lightbox-viewport-width) - var(--lightbox-edge-space) - var(--lightbox-edge-space));
  max-height: calc(var(--lightbox-viewport-height) - var(--lightbox-edge-space) - var(--lightbox-edge-space));
  object-fit: contain;
  opacity: var(--lightbox-drag-opacity, 1);
  background: var(--ink);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.42);
  transform:
    translate3d(var(--lightbox-drag-x, 0px), var(--lightbox-drag-y, 0px), 0)
    translate3d(var(--lightbox-pan-x, 0px), var(--lightbox-pan-y, 0px), 0)
    scale(var(--lightbox-zoom-scale, 1));
  transform-origin: center center;
  will-change: transform, opacity;
}

/* Active drags track the finger directly with no easing delay. */
.lightbox--dragging .lightbox__stage img {
  transition: none;
}

/* Settling and exiting states animate the photo after the finger is released. */
.lightbox--settling .lightbox__stage img,
.lightbox--leaving .lightbox__stage img {
  transition: transform 220ms cubic-bezier(0.2, 0.8, 0.2, 1), opacity 220ms ease;
}

/* The nav wrapper covers the overlay while allowing only its buttons to receive clicks. */
.lightbox__controls {
  position: absolute;
  inset: 0;
  z-index: 3;
  opacity: 1;
  pointer-events: none;
  transition: opacity 160ms ease, visibility 160ms ease;
  visibility: visible;
}

/* Clicking the enlarged photo can hide the edge nav without hiding close. */
.lightbox--controls-hidden .lightbox__controls {
  opacity: 0;
  visibility: hidden;
}

/* Symbol controls are stable touch targets sized from the overlay variables. */
.lightbox__button {
  width: var(--lightbox-control-size, 44px);
  height: var(--lightbox-control-size, 44px);
  display: grid;
  place-items: center;
  color: var(--paper);
  font-weight: 800;
  line-height: 1;
  background: rgba(246, 240, 230, 0.1);
  border: 1px solid rgba(246, 240, 230, 0.28);
  text-decoration: none;
}

/* Edge navigation is positioned by role, keeping the photo centered and large. */
.lightbox__controls .lightbox__button {
  position: absolute;
  pointer-events: auto;
}

/* The previous-image control sits at the left center of the reserved border. */
.lightbox__controls a[aria-label="Go to previous image"] {
  top: 50%;
  left: var(--lightbox-control-gap);
  transform: translateY(-50%);
}

/* The next-image control sits at the right center of the reserved border. */
.lightbox__controls a[aria-label="Go to next image"] {
  top: 50%;
  right: var(--lightbox-control-gap);
  transform: translateY(-50%);
}

/* Hover states make the controls feel active while staying restrained. */
.lightbox__button:hover {
  color: var(--ink);
  background: var(--paper);
}

/* The close control remains in the top bar where viewers expect it. */
.lightbox__close {
  flex: 0 0 auto;
}

/* The footer mirrors the header measure and keeps links at the page bottom. */
.site-footer {
  width: var(--measure);
  margin: 0 auto;
  padding: 24px 0 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-top: 1px solid var(--line);
}

/* Footer text is intentionally quiet. */
.site-footer p {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

/* Medium screens switch gallery grids to two columns for stronger image size. */
@media (max-width: 900px) {
  .event-grid,
  .photo-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .event-hero {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 3.2rem;
  }
}

/* Small screens reduce spacing and stack footer/header links comfortably. */
@media (max-width: 620px) {
  .site-header,
  .site-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .intro,
  .text-page {
    margin-top: 54px;
  }

  .event-grid,
  .photo-grid {
    grid-template-columns: 1fr;
  }

  .event-card__title {
    font-size: 2rem;
  }

  h1 {
    font-size: 2.55rem;
  }

  .event-hero {
    margin-bottom: 30px;
  }

  /* Mobile event pages skip the duplicate hero image and move into the grid faster. */
  .event-hero__image {
    display: none;
  }

}

/* Touch viewers, including landscape phones, let nav overlap the full-size image. */
@media (max-width: 620px), (hover: none) and (pointer: coarse) {
  .lightbox:target {
    --lightbox-control-size: 40px;
    --lightbox-control-gap: 8px;
    --lightbox-edge-space: 0px;
  }

  .lightbox__stage {
    padding: 0;
  }

  .lightbox__stage img {
    max-width: var(--lightbox-viewport-width);
    max-height: var(--lightbox-viewport-height);
  }

  .lightbox__top {
    padding: 0 var(--lightbox-control-gap);
  }
}
