@view-transition {
  navigation: auto;
}

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 260ms;
  animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-size: 1rem;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

html:has(body.page-photography) {
  background: #0d0c0b;
}

body.page-photography {
  --photo-bg: #0d0c0b;
  --photo-fg: #f4efe6;
  --photo-muted: #9a8f82;
  --photo-soft: #cfc4b5;
  --photo-line: rgba(244, 239, 230, 0.1);
  --photo-sand: #d2b48c;
  --photo-surface: #161310;
  --photo-veil: rgba(6, 5, 4, 0.78);
  --photo-control-fill: rgba(255, 255, 255, 0.02);
  --photo-gap: 1.5rem;
  --photo-shadow: 0 20px 44px rgba(0, 0, 0, 0.5);
  --font-serif: Newsreader, Georgia, "Times New Roman", Times, serif;
  --font-sans: "IBM Plex Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
  background:
    radial-gradient(120% 80% at 50% -10%, #1a1612 0%, transparent 55%),
    var(--photo-bg);
  color: var(--photo-fg);
  color-scheme: dark;
  font-family: var(--font-serif);
  font-optical-sizing: auto;
}

body.page-photography main {
  max-width: none;
  margin: 0;
  padding: 0;
  background: transparent;
}

body.page-photography a {
  color: var(--photo-sand);
  text-decoration: none;
  text-underline-offset: 3px;
}

body.page-photography a:visited {
  color: var(--photo-sand);
}

body.page-photography a:hover {
  background: transparent;
  text-decoration: underline;
}

.photo-header {
  width: min(90vw, 70rem);
  margin: 0 auto;
  padding: 3.25rem 0 1.75rem;
  border-bottom: 1px solid var(--photo-line);
}

.photo-header-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.photo-header .home-link {
  display: inline-block;
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--photo-muted);
}

.gallery-controls {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.sort-toggle,
.view-toggle {
  display: inline-flex;
  gap: 0.2rem;
  padding: 0.28rem;
  border: 1px solid var(--photo-line);
  background: var(--photo-control-fill);
  border-radius: 999px;
}

.sort-toggle button,
.view-toggle button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--photo-muted);
  padding: 0.52rem;
  cursor: pointer;
  line-height: 0;
  display: grid;
  place-items: center;
  border-radius: 999px;
}

.sort-toggle button svg,
.view-toggle button svg {
  width: 1rem;
  height: 1rem;
  display: block;
}

.view-toggle button svg {
  fill: currentColor;
}

.sort-toggle button[aria-pressed="true"],
.view-toggle button[aria-pressed="true"] {
  color: var(--photo-bg);
  background: var(--photo-sand);
}

.sort-toggle button:focus-visible,
.view-toggle button:focus-visible {
  outline: 1.5px solid var(--photo-sand);
  outline-offset: 2px;
}

@media (max-width: 639px) {
  .gallery-controls {
    display: none;
  }

  .photo-header {
    padding: 2.25rem 0 1.35rem;
  }

  .photo-header h1 {
    font-size: clamp(2.6rem, 14vw, 3.4rem);
  }

  .photo-gallery {
    width: min(92vw, 70rem);
    padding: 1.25rem 0 5.5rem;
  }

  body.page-photography {
    --photo-gap: 1.25rem;
  }
}

.photo-header h1 {
  margin: 1.35rem 0 0;
  font-family: var(--font-serif);
  font-size: clamp(3rem, 9vw, 5.75rem);
  font-weight: 500;
  line-height: 0.95;
  letter-spacing: -0.03em;
}

.photo-gallery {
  width: min(90vw, 70rem);
  margin: 0 auto;
  padding: 2rem 0 8rem;
  overflow: visible;
  min-height: 70vh;
}

body:not([data-gallery="ready"]) .photo-gallery {
  visibility: hidden;
}

body[data-view="masonry"] .photo-gallery {
  display: flex;
  align-items: flex-start;
  gap: var(--photo-gap);
}

body[data-view="masonry"] .photo-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--photo-gap);
}

body[data-view="masonry"] .photo-figure {
  margin: 0;
  width: 100%;
}

body[data-view="grid"] .photo-gallery {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--photo-gap);
  align-items: start;
}

@media (min-width: 640px) {
  body[data-view="grid"] .photo-gallery {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  body[data-view="grid"] .photo-gallery {
    grid-template-columns: repeat(3, 1fr);
  }
}

body[data-view="grid"] .photo-figure {
  margin: 0;
  width: 100%;
}

.photo-figure {
  position: relative;
}

.photo-button {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: var(--photo-surface);
  cursor: zoom-in;
  text-align: left;
  border-radius: 0;
  overflow: hidden;
  transform-origin: center center;
  box-shadow: none;
  transition:
    transform 0.5s cubic-bezier(0.16, 1, 0.3, 1),
    box-shadow 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.photo-figure.is-visible .photo-button:hover {
  transform: scale(1.028) rotate(-0.9deg);
  box-shadow: var(--photo-shadow);
  z-index: 2;
}

.photo-button:focus-visible {
  outline: 1.5px solid var(--photo-sand);
  outline-offset: 4px;
}

.photo-button img {
  display: block;
  width: 100%;
  height: auto;
  vertical-align: middle;
  background: var(--photo-surface);
  opacity: 0;
  transition: opacity 0.85s cubic-bezier(0.16, 1, 0.3, 1);
}

.photo-figure.is-visible .photo-button img {
  opacity: 1;
}

.photo-caption {
  margin: 0.8rem 0 0;
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
  min-height: 2.6rem;
  font-family: var(--font-sans);
  opacity: 0;
  transform: translateY(0.35rem);
  transition:
    opacity 0.7s cubic-bezier(0.16, 1, 0.3, 1) 0.1s,
    transform 0.7s cubic-bezier(0.16, 1, 0.3, 1) 0.1s;
}

.photo-figure.is-visible .photo-caption {
  opacity: 1;
  transform: none;
}

.photo-caption .caption-title {
  font-family: var(--font-sans);
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: 0.01em;
  color: var(--photo-fg);
}

.photo-caption .caption-context {
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 400;
  font-style: normal;
  line-height: 1.4;
  letter-spacing: 0.02em;
  color: var(--photo-soft);
}

.photo-caption .caption-tech {
  font-family: var(--font-sans);
  font-size: 0.7rem;
  font-weight: 400;
  font-style: normal;
  line-height: 1.4;
  letter-spacing: 0.015em;
  color: var(--photo-muted);
}

.photo-count {
  width: min(90vw, 70rem);
  margin: -5.5rem auto 0;
  padding: 0 0 4rem;
  font-family: var(--font-sans);
  font-size: 0.72rem;
  letter-spacing: 0.02em;
  color: var(--photo-muted);
}

@media (max-width: 639px) {
  .photo-count {
    width: min(92vw, 70rem);
    margin-top: -3.5rem;
  }
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background: var(--photo-veil);
  backdrop-filter: blur(10px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.28s ease, visibility 0.28s ease;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.lightbox.is-open {
  opacity: 1;
  visibility: visible;
}

.lightbox-inner {
  position: relative;
  width: min(100%, 40rem);
  max-width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.9rem;
  transform: scale(0.96);
  transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1);
}

.lightbox.is-open .lightbox-inner {
  transform: none;
}

.lightbox img {
  display: block;
  box-sizing: border-box;
  max-width: 100%;
  width: auto;
  height: auto;
  max-height: min(72vh, 900px);
  object-fit: contain;
  background: var(--photo-surface);
  box-shadow: var(--photo-shadow);
}

.lightbox-caption {
  margin: 0;
  width: min(100%, 28rem);
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  align-items: center;
  font-family: var(--font-sans);
}

.lightbox-caption .caption-title {
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--photo-fg);
}

.lightbox-caption .caption-context {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  color: var(--photo-soft);
}

.lightbox-caption .caption-tech {
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-style: normal;
  color: var(--photo-muted);
}

.lightbox-controls {
  display: contents;
}

.lightbox-close,
.lightbox-nav {
  position: absolute;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 1px solid var(--photo-line);
  border-radius: 999px;
  background: rgba(9, 8, 7, 0.55);
  backdrop-filter: blur(6px);
  color: var(--photo-soft);
  cursor: pointer;
  transition:
    color 160ms ease,
    background-color 160ms ease,
    border-color 160ms ease;
}

.lightbox-close svg,
.lightbox-nav svg {
  display: block;
  width: 1.125rem;
  height: 1.125rem;
}

.lightbox-close:hover,
.lightbox-nav:hover {
  color: var(--photo-fg);
  background: rgba(9, 8, 7, 0.82);
  border-color: rgba(244, 239, 230, 0.28);
}

.lightbox-close:focus-visible,
.lightbox-nav:focus-visible {
  outline: 1.5px solid var(--photo-sand);
  outline-offset: 2px;
}

.lightbox-close {
  top: 1.25rem;
  right: 1.25rem;
}

.lightbox-nav {
  top: 50%;
  transform: translateY(-50%);
}

.lightbox-prev {
  left: 1.25rem;
}

.lightbox-next {
  right: 1.25rem;
}

@media (max-width: 859px) {
  .lightbox {
    padding: 4.5rem 0.85rem 5.75rem;
    align-content: center;
  }

  .lightbox-inner {
    width: 100%;
    max-width: 100%;
  }

  .lightbox img {
    width: 100%;
    max-width: 100%;
    max-height: min(64vh, 100dvh - 15rem);
    height: auto;
  }

  .lightbox-controls {
    display: flex;
    position: absolute;
    left: 50%;
    bottom: 1.25rem;
    transform: translateX(-50%);
    gap: 0.75rem;
  }

  .lightbox-nav {
    position: static;
    transform: none;
  }

  .lightbox-close {
    top: 1rem;
    right: 1rem;
  }
}

body.lightbox-open {
  overflow: hidden;
}

@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(root),
  ::view-transition-new(root) {
    animation-duration: 1ms;
  }

  .photo-button,
  .photo-button img,
  .photo-caption,
  .lightbox,
  .lightbox-inner {
    transition: none;
    filter: none;
    transform: none;
  }

  .photo-button img,
  .photo-caption {
    opacity: 1;
  }

  .photo-figure.is-visible .photo-button:hover {
    transform: none;
    box-shadow: none;
  }
}
