:root {
  --bg: #ededed;
  --overlay-bg: #ffffff;
  --text: #000000;
  --text-muted: #000000;
  --border: #d4d4d4;
  --gap: 12px;
  --header-h: 72px;
  --font-display: "Cormorant Garamond", Georgia, serif;
  --font-body: "DM Sans", system-ui, sans-serif;
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  height: var(--header-h);
  background: rgba(237, 237, 237, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.site-header__inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.site-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 400;
  letter-spacing: 0.02em;
}

.layout-switcher {
  display: flex;
  gap: 4px;
}

.layout-btn {
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 2px;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.layout-btn:hover {
  border-color: var(--text);
}

.layout-btn.is-active {
  color: var(--overlay-bg);
  background: var(--text);
  border-color: var(--text);
}

.layout-btn:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
}

/* --- Gallery tile (shared) --- */
.gallery-tile {
  margin: 0;
  padding: 0;
  border: 1px solid var(--border);
  background: var(--overlay-bg);
  cursor: pointer;
  display: block;
  overflow: hidden;
  border-radius: 0;
}

.gallery-tile:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

.gallery-tile img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* --- Square grid --- */
.gallery--square {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--gap);
}

.gallery--square .gallery-tile {
  aspect-ratio: 1;
}

.gallery--square .gallery-tile img {
  aspect-ratio: 1;
  object-fit: cover;
}

/* --- Vertical masonry (CSS columns) --- */
.gallery--vertical {
  column-count: 4;
  column-gap: var(--gap);
}

@media (max-width: 1100px) {
  .gallery--vertical {
    column-count: 3;
  }
}

@media (max-width: 700px) {
  .gallery--vertical {
    column-count: 2;
  }
}

.gallery--vertical .gallery-tile {
  break-inside: avoid;
  margin-bottom: var(--gap);
}

.gallery--vertical .gallery-tile img {
  width: 100%;
  height: auto;
  object-fit: contain;
}

/* --- Justified rows --- */
.gallery--horizontal {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.justified-row {
  display: flex;
  gap: var(--gap);
  width: 100%;
}

.gallery--horizontal .gallery-tile {
  flex-shrink: 0;
}

.gallery--horizontal .gallery-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* --- Overlay --- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.overlay[hidden] {
  display: none;
}

.overlay__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  cursor: pointer;
}

.overlay__panel {
  position: relative;
  z-index: 1;
  max-width: min(92vw, 1100px);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  background: var(--overlay-bg);
  padding: 32px;
}

.overlay__close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  transition: opacity 0.15s;
}

.overlay__close:hover {
  opacity: 0.6;
}

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

.overlay__figure {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: 92vh;
}

.overlay__figure img {
  display: block;
  max-width: 100%;
  max-height: calc(92vh - 120px);
  width: auto;
  height: auto;
  margin: 0 auto;
  object-fit: contain;
}

.overlay__caption {
  text-align: center;
}

.overlay__title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 400;
  letter-spacing: 0.01em;
  color: var(--text);
}

.overlay__year {
  margin: 4px 0 0;
  color: var(--text);
  font-size: 0.9rem;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .layout-btn,
  .overlay__close {
    transition: none;
  }
}
