/* ---------- шрифты (локально, без внешних сервисов) ---------- */
@font-face { font-family: 'Alegreya'; font-weight: 400; font-style: normal; font-display: swap;
  src: url(/fonts/alegreya-cyrillic-400-normal.woff2) format('woff2'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'Alegreya'; font-weight: 400; font-style: normal; font-display: swap;
  src: url(/fonts/alegreya-latin-400-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Alegreya'; font-weight: 500; font-style: normal; font-display: swap;
  src: url(/fonts/alegreya-cyrillic-500-normal.woff2) format('woff2'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'Alegreya'; font-weight: 500; font-style: normal; font-display: swap;
  src: url(/fonts/alegreya-latin-500-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+2000-206F; }
@font-face { font-family: 'Alegreya'; font-weight: 400; font-style: italic; font-display: swap;
  src: url(/fonts/alegreya-latin-400-italic.woff2) format('woff2'); unicode-range: U+0000-00FF, U+2000-206F; }
@font-face { font-family: 'Alegreya'; font-weight: 400; font-style: italic; font-display: swap;
  src: url(/fonts/alegreya-cyrillic-400-italic.woff2) format('woff2'); unicode-range: U+0400-045F; }
@font-face { font-family: 'Onest'; font-weight: 400; font-display: swap;
  src: url(/fonts-ui/onest-cyrillic-400-normal.woff2) format('woff2'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'Onest'; font-weight: 400; font-display: swap;
  src: url(/fonts-ui/onest-latin-400-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+2000-206F, U+2212; }
@font-face { font-family: 'Onest'; font-weight: 500; font-display: swap;
  src: url(/fonts-ui/onest-cyrillic-500-normal.woff2) format('woff2'); unicode-range: U+0400-045F, U+2116; }
@font-face { font-family: 'Onest'; font-weight: 500; font-display: swap;
  src: url(/fonts-ui/onest-latin-500-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+2000-206F; }

/* ---------- токены ----------
   Ельник в пасмурный день: тёмная хвоя, светлое небо, лишайник.
   Единственный цветной акцент — янтарь глаза ястреба-тетеревятника, главного героя съёмок. */
:root {
  --spruce: #1d2420;      /* фон: тень под елями */
  --spruce-2: #252e29;    /* приподнятые поверхности */
  --sky: #e6e8e1;         /* основной текст: пасмурное небо */
  --lichen: #9aa497;      /* второстепенный текст */
  --moss: #3b463f;        /* линии и рамки */
  --amber: #d6a645;       /* акцент: глаз ястреба */
  --serif: 'Alegreya', 'Georgia', serif;
  --sans: 'Onest', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --gutter: clamp(16px, 4vw, 56px);
  --row-h: 300px;
  --gap: 6px;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--spruce);
  color: var(--sky);
  font: 400 17px/1.55 var(--sans);
  font-kerning: normal;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
img { display: block; max-width: 100%; }
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: .2em; }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 3px; }
.skip { position: absolute; left: -9999px; top: 8px; background: var(--sky); color: var(--spruce); padding: 8px 12px; z-index: 100; }
.skip:focus { left: 8px; }

/* ---------- шапка ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: baseline; justify-content: space-between; gap: 24px;
  padding: 14px var(--gutter);
  background: color-mix(in srgb, var(--spruce) 88%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.is-home .topbar { position: fixed; left: 0; right: 0; background: transparent; backdrop-filter: none; transition: background .3s; }
.is-home .topbar.solid { background: color-mix(in srgb, var(--spruce) 88%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.brand { font: 500 1.3rem/1 var(--serif); text-decoration: none; letter-spacing: .01em; }
.nav { display: flex; gap: clamp(14px, 3vw, 32px); font-size: .9rem; }
.nav a { text-decoration: none; color: var(--lichen); padding: 4px 0; }
.nav a:hover, .nav a[aria-current] { color: var(--sky); }
.nav a[aria-current] { box-shadow: inset 0 -1px 0 var(--amber); }

/* ---------- герой ---------- */
.hero { position: relative; height: 100svh; min-height: 520px; overflow: hidden; background: var(--hero-color, var(--spruce)); }
.hero-img, .hero-img img { position: absolute; inset: 0; width: 100%; height: 100%; }
.hero-img img { object-fit: cover; background-size: cover; animation: focus-pull 2.2s cubic-bezier(.2,.7,.2,1) both; }
@keyframes focus-pull {
  from { filter: blur(18px) saturate(.7); transform: scale(1.05); }
  to   { filter: none; transform: none; }
}
.hero::after { content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(to top, rgb(29 36 32 / .92) 0%, rgb(29 36 32 / .35) 34%, transparent 60%),
              linear-gradient(to bottom, rgb(29 36 32 / .55), transparent 18%); }
.hero-text { position: absolute; left: var(--gutter); bottom: clamp(28px, 7vh, 72px); z-index: 2; max-width: min(760px, 70vw); }
.hero-name { margin: 0; font: 400 clamp(3.2rem, 10vw, 8.5rem)/.88 var(--serif); letter-spacing: -.02em; }
.hero-tagline { margin: .9em 0 0; color: var(--sky); opacity: .82; font-size: clamp(1rem, 1.5vw, 1.2rem); max-width: 36ch; }
.hero-empty { height: 60vh; }

/* «этикетка» к кадру — как подпись к экспонату в музее */
.label { display: grid; gap: 2px; text-decoration: none; padding-left: 14px; border-left: 2px solid var(--amber); }
.label-name { font: 500 1.25rem/1.15 var(--serif); text-decoration: none; }
.label-latin { font: italic 400 1rem/1.2 var(--serif); color: var(--lichen); }
.label-meta, .label-note { font-size: .82rem; color: var(--lichen); margin-top: 4px; }
.hero-label { position: absolute; right: var(--gutter); bottom: clamp(28px, 7vh, 72px); z-index: 2; max-width: 260px; }
.hero-label .label-latin, .hero-label .label-meta { color: var(--sky); opacity: .75; }

/* ---------- секции ---------- */
.section-title { margin: 0; font: 400 clamp(2.4rem, 5.5vw, 4.6rem)/.95 var(--serif); letter-spacing: -.015em; }
.atlas-lead { color: var(--lichen); max-width: 62ch; margin: 18px 0 0; }
.atlas-wrap, .featured, .gallery, .about, .notfound { padding: clamp(56px, 9vw, 120px) var(--gutter) 0; }
.featured { padding-bottom: 24px; }
.featured .section-title, .gallery-head { margin-bottom: clamp(24px, 4vw, 44px); }

.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 22px; }
.chip {
  font: 500 .85rem/1 var(--sans); color: var(--lichen); background: transparent;
  border: 1px solid var(--moss); border-radius: 999px; padding: 9px 14px; cursor: pointer; text-decoration: none;
}
.chip:hover { color: var(--sky); border-color: var(--lichen); }
.chip[aria-pressed='true'], .chip[aria-current] { color: var(--spruce); background: var(--sky); border-color: var(--sky); }

/* ---------- атлас: индекс названий, как в старом определителе ---------- */
.atlas {
  list-style: none; margin: clamp(32px, 5vw, 56px) 0 0; padding: 0;
  font: 400 clamp(1.55rem, 2.9vw, 2.65rem)/1.28 var(--serif);
}
.atlas li { display: inline-block; }
.atlas li[hidden] { display: none; }
.atlas a { text-decoration: none; margin-right: .5em; white-space: nowrap; transition: color .2s; }
.atlas a:hover .atlas-name { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: .15em; }
.atlas-count { font: 500 .8rem/1 var(--sans); color: var(--amber); vertical-align: super; margin-left: .2em; letter-spacing: .02em; }
.atlas-thumb { display: none; }
@media (hover: hover) and (min-width: 701px) {
  .atlas:hover a { color: var(--lichen); }
  .atlas:hover a:hover { color: var(--sky); }
}
.atlas-preview {
  position: fixed; left: 0; top: 0; z-index: 25; width: 300px; pointer-events: none;
  opacity: 0; transform: translate3d(0,0,0) scale(.96); transition: opacity .18s, transform .18s;
  box-shadow: 0 30px 60px -20px rgb(0 0 0 / .7);
}
.atlas-preview.on { opacity: 1; transform: translate3d(var(--x), var(--y), 0); }
.atlas-preview img { width: 100%; height: auto; }

/* ---------- выровненная по строкам сетка ---------- */
.jgrid { display: flex; flex-wrap: wrap; gap: var(--gap); }
.jgrid::after { content: ''; flex-grow: 1e6; }
.jg-item {
  position: relative; display: block; overflow: hidden;
  flex-grow: calc(var(--ar) * 100); flex-basis: calc(var(--ar) * var(--row-h));
  background: var(--spruce-2);
}
.jg-item picture { display: block; padding-bottom: calc(100% / var(--ar)); }
.jg-item img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background-size: cover; transition: transform .6s cubic-bezier(.2,.7,.2,1); }
.jg-cap {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 28px 14px 12px;
  display: grid; gap: 2px; opacity: 0; transition: opacity .25s;
  background: linear-gradient(to top, rgb(16 20 18 / .78), transparent);
}
.jg-name { font: 500 1.05rem/1.2 var(--serif); }
.jg-status { font-size: .75rem; color: var(--amber); }
@media (hover: hover) {
  .jg-item:hover .jg-cap, .jg-item:focus-visible .jg-cap { opacity: 1; }
  .jg-item:hover img { transform: scale(1.025); }
}
.empty { color: var(--lichen); }

/* ---------- страница вида ---------- */
.species { padding: clamp(28px, 5vw, 64px) var(--gutter) 0; }
.species-head { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: clamp(24px, 4vw, 64px); align-items: end; margin-bottom: clamp(32px, 5vw, 64px); }
.species-group { margin: 0 0 14px; font-size: .9rem; }
.species-group a { color: var(--lichen); text-decoration: none; }
.species-group a:hover { color: var(--sky); }
.species-name { margin: 0; font: 400 clamp(2.6rem, 6.5vw, 5.6rem)/.92 var(--serif); letter-spacing: -.02em; hyphens: manual; text-wrap: balance; overflow-wrap: break-word; }
.species-latin { margin: 12px 0 0; font: italic 400 clamp(1.15rem, 1.8vw, 1.5rem)/1.2 var(--serif); color: var(--lichen); }
.species-desc { margin: 26px 0 0; font: 400 1.18rem/1.6 var(--serif); max-width: 46ch; }
.facts { display: grid; gap: 10px; margin: 28px 0 0; padding-top: 18px; border-top: 1px solid var(--moss); }
.facts div { display: grid; grid-template-columns: 8.5em 1fr; gap: 12px; }
.facts dt { color: var(--lichen); font-size: .88rem; }
.facts dd { margin: 0; font-size: .95rem; }
.species-cover { display: block; position: relative; }
.species-cover img { width: 100%; height: auto; max-height: 78vh; object-fit: cover; background-size: cover; }
.species-nav { display: flex; justify-content: space-between; gap: 24px; padding: clamp(48px, 7vw, 96px) 0 0; }
.species-nav a { display: grid; gap: 6px; text-decoration: none; font: 400 clamp(1.4rem, 2.6vw, 2.2rem)/1.05 var(--serif); }
.species-nav a span { font: 400 .85rem/1 var(--sans); color: var(--lichen); }
.species-nav .next { text-align: right; }
.species-nav a:hover { color: var(--amber); }

/* ---------- отдельная фотография ---------- */
.photo-page { display: grid; grid-template-columns: minmax(0, 1fr) 320px; min-height: calc(100svh - 56px); }
.photo-stage { position: relative; margin: 0; display: grid; place-items: center; padding: 16px; background: #141a17; }
.photo-stage img { max-width: 100%; max-height: calc(100svh - 90px); width: auto; height: auto; background-size: cover; }
.stage-nav { position: absolute; top: 0; bottom: 0; width: 30%; }
.stage-prev { left: 0; cursor: w-resize; } .stage-next { right: 0; cursor: e-resize; }
.photo-info { padding: 32px 28px; display: grid; align-content: start; gap: 28px; }
.photo-meta { display: grid; gap: 14px; margin: 0; font-size: .92rem; }
.photo-meta dt { color: var(--lichen); font-size: .8rem; }
.photo-meta dd { margin: 2px 0 0; }
.back-link { color: var(--sky); }
.back-link:hover { color: var(--amber); }

/* ---------- об авторе ---------- */
.about-text { margin-top: 32px; max-width: 60ch; font: 400 1.3rem/1.6 var(--serif); }
.about-text p { margin: 0 0 1em; }
.about-facts { max-width: 60ch; }
.about-sub { font: 400 1.6rem/1.2 var(--serif); margin: 48px 0 12px; }

/* ---------- подвал ---------- */
.footer { margin-top: clamp(80px, 12vw, 160px); padding: 40px var(--gutter) 48px; border-top: 1px solid var(--moss); display: grid; gap: 14px; color: var(--lichen); font-size: .88rem; }
.footer-name { margin: 0; font: 400 1.6rem/1 var(--serif); color: var(--sky); }
.footer-name span { font: 400 .85rem/1 var(--sans); color: var(--lichen); margin-left: 12px; }
.contacts { display: flex; flex-wrap: wrap; gap: 20px; margin: 0; }
.contacts a { color: var(--sky); }
.footer-copy { margin: 0; }

/* ---------- лайтбокс ---------- */
.lb { position: fixed; inset: 0; z-index: 50; display: grid; grid-template-rows: 1fr auto; background: #0e1210; color: var(--sky);
  opacity: 0; visibility: hidden; transition: opacity .25s, visibility 0s .25s; touch-action: none; }
.lb.open { opacity: 1; visibility: visible; transition: opacity .25s; }
.lb-stage { position: relative; overflow: hidden; display: grid; place-items: center; }
.lb-track { position: absolute; inset: 16px; will-change: transform; }
.lb-track picture { display: contents; }
.lb-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; user-select: none; -webkit-user-drag: none; transition: opacity .25s; }
.lb-img.loading { opacity: .6; }
.lb-bar { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 32px; padding: 14px var(--gutter) max(16px, env(safe-area-inset-bottom)); }
.lb-bar .label-name { font-size: 1.35rem; }
.lb-bar .label-name a { text-decoration: none; } .lb-bar .label-name a:hover { color: var(--amber); }
.lb-meta { display: grid; gap: 4px; font-size: .82rem; color: var(--lichen); text-align: right; }
.lb-status { color: var(--amber); }
.lb-btn { position: absolute; z-index: 3; width: 48px; height: 48px; display: grid; place-items: center; border: 0; border-radius: 50%; cursor: pointer;
  background: rgb(29 36 32 / .55); color: var(--sky); }
.lb-btn:hover { background: rgb(29 36 32 / .9); }
.lb-btn svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.6; }
.lb-close { top: max(12px, env(safe-area-inset-top)); right: 12px; }
.lb-prev { left: 12px; top: 50%; translate: 0 -50%; } .lb-next { right: 12px; top: 50%; translate: 0 -50%; }
.lb-count { position: absolute; top: max(24px, calc(env(safe-area-inset-top) + 12px)); left: var(--gutter); z-index: 3; font-size: .82rem; color: var(--lichen); font-variant-numeric: tabular-nums; }
.lb[data-zoom='1'] .lb-img { inset: auto; left: 50%; top: 50%; translate: -50% -50%; width: auto; height: auto; max-width: none; cursor: grab; }
body.lb-lock { overflow: hidden; }

/* ---------- адаптив ---------- */
@media (max-width: 1100px) { :root { --row-h: 240px; } }
@media (max-width: 900px) {
  .species-head { grid-template-columns: 1fr; }
  .species-cover { order: -1; margin: 0 calc(var(--gutter) * -1); }
  .species-cover img { max-height: 70svh; }
  .photo-page { grid-template-columns: 1fr; }
  .photo-stage img { max-height: 75svh; }
}
@media (max-width: 700px) {
  :root { --row-h: 150px; --gap: 4px; }
  body { font-size: 16px; }
  .topbar { padding-top: 10px; padding-bottom: 10px; flex-wrap: wrap; row-gap: 4px; }
  .nav a { white-space: nowrap; }
  .brand { font-size: 1.15rem; }
  .nav { font-size: .82rem; gap: 14px; }
  .hero-text { right: var(--gutter); max-width: none; bottom: 150px; }
  .hero-label { left: var(--gutter); right: auto; bottom: 36px; }
  /* на телефоне атлас — список с миниатюрами */
  .atlas { font-size: 1.45rem; line-height: 1.15; display: grid; grid-template-columns: 1fr; }
  .atlas li { display: block; border-bottom: 1px solid var(--moss); }
  .atlas a { display: grid; grid-template-columns: 64px 1fr auto; align-items: center; gap: 14px; padding: 8px 0; margin: 0; white-space: normal; }
  .atlas-thumb { display: block; width: 64px; height: 64px; object-fit: cover; }
  .atlas-count { vertical-align: baseline; font-size: .85rem; }
  .atlas-preview { display: none; }
  .filters { flex-wrap: nowrap; overflow-x: auto; margin-left: calc(var(--gutter) * -1); margin-right: calc(var(--gutter) * -1); padding: 0 var(--gutter); scrollbar-width: none; }
  .filters::-webkit-scrollbar { display: none; }
  .chip { white-space: nowrap; }
  .facts div { grid-template-columns: 7em 1fr; }
  .lb-prev, .lb-next { display: none; }
  .lb-bar { flex-direction: column; align-items: flex-start; }
  .lb-meta { text-align: left; }
  .species-nav { flex-direction: column; }
  .species-nav .next { text-align: left; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
