:root {
  --color-page: #f6f4f0;
  --color-surface-soft: #e7e1d8;
  --color-text: #25231f;
  --color-muted: #6f6a60;
  --color-border: #ddd7cd;
  --color-accent: #52675a;
  --color-error: #9f3d34;
  --shadow-card: 0 16px 36px rgba(37, 35, 31, 0.11);
  --radius-large: 16px;
  --radius-medium: 10px;
  --container: min(1180px, calc(100% - 40px));
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--color-page);
  color: var(--color-text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

body.no-scroll {
  overflow: hidden;
}

button {
  font: inherit;
  cursor: pointer;
}

img {
  display: block;
  max-width: 100%;
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 3px solid rgba(82, 103, 90, 0.45);
  outline-offset: 3px;
}

.intro-section,
.gallery-section {
  width: var(--container);
  margin: 0 auto;
}

.intro-section {
  padding: clamp(42px, 7vw, 82px) 0 clamp(26px, 5vw, 58px);
}

.intro-section h1 {
  width: min(100%, 920px);
  max-width: 920px;
  margin: 0 auto clamp(20px, 4vw, 34px);
  color: var(--color-text);
  font-size: clamp(2.35rem, 7vw, 5rem);
  line-height: 0.98;
  letter-spacing: 0;
}

.main-text {
  width: min(100%, 860px);
  max-width: 860px;
  margin: 0 auto;
  color: var(--color-text);
  font-size: clamp(1.05rem, 1.8vw, 1.22rem);
}

.main-text p {
  margin: 0 0 1.05em;
}

.main-text p:last-child {
  margin-bottom: 0;
}

.gallery-section {
  padding: clamp(18px, 4vw, 42px) 0;
}

.gallery-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: clamp(16px, 3vw, 26px);
}

.gallery-header h2 {
  margin: 0;
  color: var(--color-text);
  font-size: clamp(1.55rem, 3.5vw, 2.35rem);
  line-height: 1.1;
  letter-spacing: 0;
}

.gallery-toggle {
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: #ffffff;
  color: var(--color-accent);
  font-size: 0.92rem;
  font-weight: 750;
  white-space: nowrap;
  transition: transform 180ms ease, border-color 180ms ease, color 180ms ease;
}

.gallery-toggle:hover {
  transform: translateY(-1px);
  border-color: rgba(82, 103, 90, 0.45);
  color: var(--color-text);
}

.gallery-panel {
  display: grid;
  gap: clamp(16px, 3vw, 26px);
}

.category-filters {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.filter-button {
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--color-muted);
  font-size: 0.92rem;
  font-weight: 700;
  transition: transform 180ms ease, background 180ms ease, border-color 180ms ease, color 180ms ease;
}

.filter-button:hover {
  transform: translateY(-1px);
  border-color: rgba(82, 103, 90, 0.45);
  color: var(--color-accent);
}

.filter-button.is-active {
  border-color: var(--color-accent);
  background: var(--color-accent);
  color: #ffffff;
}

.state-message {
  min-height: 86px;
  display: grid;
  place-items: center;
  margin: 16px 0;
  padding: 22px;
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-medium);
  background: rgba(255, 255, 255, 0.64);
  color: var(--color-muted);
  text-align: center;
}

.state-message span {
  color: var(--color-text);
  font-weight: 750;
}

.state-message-error {
  border-color: rgba(159, 61, 52, 0.35);
  color: var(--color-error);
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
  gap: clamp(12px, 2vw, 22px);
}

.gallery-card {
  width: 100%;
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(221, 215, 205, 0.82);
  border-radius: var(--radius-large);
  background: #ffffff;
  color: inherit;
  text-align: left;
  box-shadow: 0 8px 24px rgba(37, 35, 31, 0.07);
  transition: transform 220ms ease, box-shadow 220ms ease, border-color 220ms ease;
}

.gallery-card:hover {
  transform: translateY(-4px);
  border-color: rgba(82, 103, 90, 0.38);
  box-shadow: var(--shadow-card);
}

.card-image-wrap {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: var(--color-surface-soft);
}

.card-image-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 320ms ease;
}

.gallery-card:hover img {
  transform: scale(1.035);
}

.image-fallback {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  background:
    linear-gradient(135deg, rgba(82, 103, 90, 0.12), rgba(221, 215, 205, 0.48)),
    var(--color-surface-soft);
}

.image-fallback::before {
  content: "";
  width: 56px;
  height: 42px;
  border: 2px solid rgba(82, 103, 90, 0.32);
  border-radius: 8px;
  background:
    radial-gradient(circle at 72% 28%, rgba(82, 103, 90, 0.34) 0 5px, transparent 6px),
    linear-gradient(135deg, transparent 48%, rgba(82, 103, 90, 0.24) 49% 55%, transparent 56%),
    linear-gradient(45deg, transparent 42%, rgba(82, 103, 90, 0.18) 43% 58%, transparent 59%);
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  grid-template-columns: minmax(52px, 1fr) minmax(0, 1040px) minmax(52px, 1fr);
  align-items: center;
  gap: 16px;
  padding: 28px;
  background: rgba(18, 18, 16, 0.86);
}

.lightbox-content {
  position: relative;
  max-height: calc(100vh - 56px);
  overflow: auto;
  border-radius: var(--radius-large);
  background: #ffffff;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

.lightbox-image-wrap {
  min-height: min(70vh, 760px);
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #151512;
  cursor: zoom-in;
  touch-action: none;
  user-select: none;
}

.lightbox-image-wrap.is-zoomed {
  cursor: grab;
}

.lightbox-image-wrap.is-zoomed:active {
  cursor: grabbing;
}

.lightbox-image-wrap img {
  max-height: min(86vh, 820px);
  width: 100%;
  object-fit: contain;
  transform-origin: center center;
  will-change: transform;
}

.lightbox-image-wrap img.is-hidden {
  display: none;
}

.lightbox-fallback {
  min-height: min(70vh, 680px);
}

.lightbox-close,
.lightbox-nav {
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.95);
  color: var(--color-text);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.22);
  transition: transform 180ms ease, background 180ms ease;
}

.lightbox-close:hover,
.lightbox-nav:hover {
  transform: translateY(-1px);
  background: #ffffff;
}

.lightbox-close {
  position: absolute;
  top: 22px;
  right: 22px;
  width: 44px;
  height: 44px;
  font-size: 2rem;
  line-height: 1;
}

.lightbox-close span {
  display: block;
  line-height: 1;
  transform: translateY(-1px);
}

.lightbox-nav {
  position: relative;
  width: 50px;
  height: 50px;
  justify-self: center;
  font-size: 0;
  line-height: 1;
}

.lightbox-nav span {
  display: none;
}

.lightbox-nav::before {
  content: "";
  width: 13px;
  height: 13px;
  border-top: 3px solid currentColor;
  border-left: 3px solid currentColor;
}

.lightbox-prev::before {
  transform: translateX(2px) rotate(-45deg);
}

.lightbox-next::before {
  transform: translateX(-2px) rotate(135deg);
}

.lightbox-nav:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

@media (max-width: 760px) {
  :root {
    --container: min(100% - 28px, 1180px);
  }

  .gallery-header {
    align-items: start;
    flex-direction: column;
  }

  .lightbox {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "content content"
      "prev next";
    align-content: center;
    padding: 64px 14px 18px;
  }

  .lightbox-content {
    grid-area: content;
    max-height: calc(100vh - 150px);
  }

  .lightbox-prev {
    grid-area: prev;
    justify-self: end;
  }

  .lightbox-next {
    grid-area: next;
    justify-self: start;
  }

  .lightbox-image-wrap {
    min-height: 320px;
  }

  .lightbox-close {
    top: 14px;
    right: 14px;
  }
}
