/* Полевой журнал — field journal aesthetic */

:root {
  --paper: #e8e2d2;
  --paper-dark: #ddd6c4;
  --ink: #2c2419;
  --ink-muted: #5c5347;
  --accent: #8b2e2e;
  --accent-soft: #a84545;
  --brown: #3d2b1f;
  --brown-light: #5a4335;
  --line: #2c2419;
  --triassic: #3d5c3a;
  --jurassic: #8b2e2e;
  --cretaceous: #3d2b1f;
  --shadow: rgba(44, 36, 25, 0.08);
  --font-serif: "Cormorant Garamond", "Times New Roman", serif;
  --font-sans: "IBM Plex Sans", system-ui, sans-serif;
  --font-hand: "Caveat", cursive;
  --max-width: 1180px;
  --header-h: 72px;
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 18px;
  line-height: 1.55;
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    radial-gradient(ellipse at 20% 0%, rgba(139, 46, 46, 0.04) 0%, transparent 50%),
    url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
  -webkit-font-smoothing: antialiased;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: -100px;
  left: 16px;
  z-index: 2000;
  padding: 10px 16px;
  background: var(--brown);
  color: var(--paper);
  font-family: var(--font-sans);
  font-size: 12px;
  text-decoration: none;
}

.skip-link:focus {
  top: 16px;
}

.page {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 28px 48px;
}

/* Reveal on scroll */
.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* Header */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
  max-width: calc(var(--max-width) + 56px);
  margin: 0 auto;
  min-height: var(--header-h);
  padding: 16px 28px;
  background: rgba(232, 226, 210, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.3s, box-shadow 0.3s;
}

.header--scrolled {
  border-bottom-color: var(--line);
  box-shadow: 0 4px 24px var(--shadow);
}

.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  padding: 8px;
  border: 1px solid var(--line);
  background: var(--paper);
  cursor: pointer;
}

.nav-toggle-bar {
  display: block;
  height: 2px;
  background: var(--ink);
  transition: transform 0.2s, opacity 0.2s;
}

.nav a.is-active {
  color: var(--accent);
  position: relative;
}

.nav a.is-active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -4px;
  height: 1px;
  background: var(--accent);
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
}

.logo-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 2px solid var(--line);
  border-radius: 50%;
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
}

.logo-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.logo-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-family: var(--font-sans);
}

.logo-sub {
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
  font-family: var(--font-sans);
  text-transform: lowercase;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 20px;
}

.nav a {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--ink);
  transition: color 0.2s;
}

.nav a:hover {
  color: var(--accent);
}

.header-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 20px;
  font-family: var(--font-sans);
  font-size: 12px;
}

.header-date {
  letter-spacing: 0.06em;
  color: var(--ink-muted);
}

.header-login {
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
}

.header-login:hover {
  border-bottom-color: var(--ink);
}

/* Hero */
.hero {
  padding: 36px 0 0;
}

.hero-label {
  margin: 0 0 28px;
  text-align: center;
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.hero-grid {
  display: grid;
  grid-template-columns: 1fr 1.05fr;
  gap: 40px 48px;
  align-items: start;
}

.hero-annotation {
  margin: 0 0 4px;
  font-family: var(--font-hand);
  font-size: 28px;
  color: var(--accent);
  transform: rotate(-2deg);
  transform-origin: left center;
}

.hero-title {
  margin: 0 0 20px;
  font-size: clamp(2.8rem, 5vw, 4.2rem);
  font-weight: 700;
  line-height: 0.95;
  letter-spacing: -0.02em;
}

.hero-title-dark {
  color: var(--ink);
}

.hero-title-accent {
  color: var(--accent);
}

.hero-title-species {
  display: block;
  font-style: italic;
  font-weight: 600;
  font-size: 0.92em;
  margin-top: 0.05em;
}

.hero-desc {
  margin: 0 0 24px;
  max-width: 38ch;
  font-size: 1.05rem;
  color: var(--ink-muted);
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px 16px;
  margin: 0 0 28px;
  padding: 16px 0 0;
  border-top: 1px solid var(--line);
}

.hero-stats dt {
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin: 0;
  grid-row: 1;
}

.hero-stats dd {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
  grid-row: 2;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.btn {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 14px 22px;
  border: 1px solid var(--brown);
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  appearance: none;
}

.btn-primary {
  background: var(--brown);
  color: var(--paper);
  text-decoration: none;
}

.btn-primary:hover {
  background: var(--brown-light);
}

.btn-outline {
  background: transparent;
  color: var(--ink);
}

.btn-outline:hover {
  background: var(--paper-dark);
}

.btn-time {
  font-weight: 400;
  opacity: 0.85;
}

/* Sketch frame */
.hero-visual {
  position: relative;
}

.sketch-frame {
  position: relative;
  margin: 0;
  padding: 0;
  background: #1a1612;
  border: 1px solid var(--line);
  box-shadow: 4px 4px 0 var(--shadow);
  overflow: hidden;
}

.sketch-frame-photo,
.sketch-frame-video {
  display: block;
  width: 100%;
  height: auto;
  min-height: 280px;
  object-fit: cover;
  object-position: center 35%;
}

.sketch-frame-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
  opacity: 0;
  transition: opacity 0.4s ease;
  pointer-events: none;
}

.sketch-frame:hover .sketch-frame-video,
.sketch-frame:focus-within .sketch-frame-video {
  opacity: 1;
}

.sketch-frame:hover .sketch-frame-photo,
.sketch-frame:focus-within .sketch-frame-photo {
  opacity: 0;
}

.sketch-frame-photo {
  transition: opacity 0.4s ease;
}

.sketch-play-badge {
  position: absolute;
  bottom: 16px;
  left: 16px;
  z-index: 2;
  padding: 8px 14px;
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: rgba(44, 36, 25, 0.85);
  color: var(--paper);
  border: 1px solid rgba(255, 255, 255, 0.2);
  transition: opacity 0.3s;
}

.sketch-frame:hover .sketch-play-badge,
.sketch-frame:focus-within .sketch-play-badge {
  opacity: 0;
}

.stamp {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 2;
  padding: 6px 12px;
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  border: 2px solid var(--accent);
  transform: rotate(8deg);
  opacity: 0.9;
}

.habitat-card {
  margin: 16px 0 0 24px;
  max-width: 280px;
  padding: 14px 18px;
  background: #f0ebe0;
  border: 1px solid var(--line);
  transform: rotate(-1.5deg);
  box-shadow: 2px 3px 8px var(--shadow);
}

.habitat-label {
  display: block;
  font-family: var(--font-hand);
  font-size: 22px;
  color: var(--accent);
  margin-bottom: 6px;
}

.habitat-card p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--ink-muted);
}

.divider {
  border: none;
  margin: 48px 0 40px;
}

.divider-dashed {
  height: 0;
  border-top: 3px dashed var(--ink);
  opacity: 0.85;
}

/* Encounter — T. rex vs Ankylosaurus */
.encounter {
  margin: 48px 0 0;
}

.encounter-label {
  margin: 0 0 12px;
  text-align: center;
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.encounter-title {
  margin: 0 0 14px;
  text-align: center;
  font-size: clamp(1.8rem, 4vw, 2.4rem);
  font-weight: 700;
  font-style: italic;
}

.encounter-desc {
  margin: 0 auto 24px;
  max-width: 52ch;
  text-align: center;
  font-size: 1.05rem;
  color: var(--ink-muted);
  line-height: 1.6;
}

.encounter-figure {
  position: relative;
  margin: 0 0 20px;
  border: 1px solid var(--line);
  background: #1a1612;
  box-shadow: 6px 6px 0 var(--shadow);
  overflow: hidden;
}

.encounter-photo,
.encounter-video {
  display: block;
  width: 100%;
  height: auto;
  object-fit: cover;
}

.encounter-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.4s ease;
  pointer-events: none;
}

.encounter-figure:hover .encounter-video,
.encounter-figure:focus-within .encounter-video {
  opacity: 1;
}

.encounter-figure:hover .encounter-photo,
.encounter-figure:focus-within .encounter-photo {
  opacity: 0;
}

.encounter-photo {
  transition: opacity 0.4s ease;
}

.encounter-play-badge {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 2;
  padding: 8px 14px;
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: rgba(44, 36, 25, 0.85);
  color: var(--paper);
  border: 1px solid rgba(255, 255, 255, 0.2);
  transition: opacity 0.3s;
}

.encounter-figure:hover .encounter-play-badge,
.encounter-figure:focus-within .encounter-play-badge {
  opacity: 0;
}

.encounter-caption {
  margin: 0;
  padding: 10px 16px;
  font-family: var(--font-sans);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-align: center;
  color: var(--ink-muted);
  background: rgba(255, 255, 255, 0.25);
  border-top: 1px solid var(--line);
}

.encounter-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-bottom: 40px;
}

.encounter .divider {
  margin-top: 0;
}

/* Eras */
.section-title {
  margin: 0 0 28px;
  font-size: 1.75rem;
  font-weight: 600;
  font-style: italic;
}

.era-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.era-card {
  padding: 24px 22px 20px;
  background: rgba(255, 255, 255, 0.25);
  border: 1px solid var(--line);
  cursor: pointer;
  font: inherit;
  color: inherit;
  text-align: left;
  transition: transform 0.2s, box-shadow 0.2s;
}

.era-card:hover,
.era-card.is-active {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px var(--shadow);
}

.era-card.is-active {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.era-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.era-link {
  display: inline-block;
  margin-top: 8px;
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--ink-muted);
  transition: color 0.2s;
}

.era-card:hover .era-link {
  color: var(--accent);
}

.era-card--triassic .era-name { color: var(--triassic); }
.era-card--jurassic .era-name { color: var(--jurassic); }
.era-card--cretaceous .era-name { color: var(--cretaceous); }

.era-name {
  margin: 0 0 6px;
  font-size: 1.65rem;
  font-weight: 700;
}

.era-dates {
  margin: 0 0 14px;
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--ink-muted);
}

.era-desc {
  margin: 0 0 14px;
  font-size: 0.95rem;
  color: var(--ink-muted);
}

.era-includes {
  margin: 0 0 16px;
  font-size: 0.88rem;
}

.era-includes span {
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  display: block;
  margin-bottom: 4px;
  color: var(--ink-muted);
}

/* Stats strip */
.stats-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin: 48px 0;
  padding: 24px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.stat-item {
  text-align: center;
}

.stat-value {
  display: block;
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.1;
}

.stat-label {
  display: block;
  margin-top: 6px;
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

/* Catalog */
.catalog {
  margin-top: 52px;
}

.catalog-header {
  margin-bottom: 28px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.catalog-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 16px;
}

.search-wrap {
  flex: 1;
  min-width: 200px;
  max-width: 320px;
}

.search-input {
  width: 100%;
  padding: 12px 16px;
  font-family: var(--font-sans);
  font-size: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.35);
  color: var(--ink);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(139, 46, 46, 0.15);
}

.search-input::placeholder {
  color: var(--ink-muted);
  opacity: 0.7;
}

.catalog-empty {
  text-align: center;
  padding: 48px 24px;
  font-style: italic;
  color: var(--ink-muted);
}

.catalog-title {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 600;
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.catalog-count {
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-muted);
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter {
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 8px 14px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.filter:hover {
  background: var(--paper-dark);
}

.filter.is-active {
  background: var(--brown);
  color: var(--paper);
  border-color: var(--brown);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.species-card {
  display: flex;
  flex-direction: column;
  padding: 18px 18px 16px;
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid var(--line);
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
  transition: opacity 0.25s, transform 0.2s, box-shadow 0.2s;
}

.species-card.is-hidden {
  display: none;
}

.species-card:hover {
  box-shadow: 0 6px 20px var(--shadow);
  transform: translateY(-2px);
}

.species-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.species-card-hint {
  margin-top: auto;
  padding-top: 10px;
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  opacity: 0;
  transition: opacity 0.2s;
}

.species-card:hover .species-card-hint,
.species-card:focus-visible .species-card-hint {
  opacity: 1;
}

.species-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.species-card-num {
  font-family: var(--font-sans);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.species-diet {
  font-family: var(--font-sans);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 3px 8px;
  border: 1px solid var(--line);
}

.species-name {
  margin: 0 0 12px;
  font-size: 1.35rem;
  font-weight: 700;
}

.species-figure {
  position: relative;
  margin: 0 0 14px;
  padding: 0;
  background: #1a1612;
  border: 1px solid var(--line);
  overflow: hidden;
  aspect-ratio: 8 / 5;
}

.species-figure-photo,
.species-figure-video {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 30%;
}

.species-figure-video {
  opacity: 0;
  transition: opacity 0.35s ease;
  pointer-events: none;
}

.species-card--has-video:hover .species-figure-video,
.species-card--has-video:focus-within .species-figure-video {
  opacity: 1;
}

.species-card--has-video:hover .species-figure-photo,
.species-card--has-video:focus-within .species-figure-photo {
  opacity: 0;
}

.species-card:not(.species-card--has-video):hover .species-figure-photo {
  transform: scale(1.04);
}

.species-figure-photo {
  transition: opacity 0.35s ease, transform 0.45s ease;
}

.species-video-badge {
  position: absolute;
  z-index: 3;
  bottom: 10px;
  right: 10px;
  padding: 5px 10px;
  font-family: var(--font-sans);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: rgba(44, 36, 25, 0.85);
  color: var(--paper);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.species-meta {
  display: grid;
  grid-template-columns: auto 1fr auto 1fr;
  gap: 4px 16px;
  margin: 0 0 10px;
  font-family: var(--font-sans);
  font-size: 11px;
}

.species-meta dt {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin: 0;
  grid-row: 1;
}

.species-meta dd {
  margin: 0;
  font-weight: 500;
  grid-row: 2;
}

.species-fact {
  margin: 0;
  font-size: 0.95rem;
  font-style: italic;
  color: var(--accent);
}

/* Footer */
.footer {
  display: grid;
  grid-template-columns: 1fr 1.5fr 1fr;
  gap: 16px;
  align-items: center;
  margin-top: 56px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  font-family: var(--font-sans);
  font-size: 11px;
  color: var(--ink-muted);
}

.footer-copy,
.footer-issue {
  margin: 0;
  letter-spacing: 0.04em;
}

.footer-issue {
  text-align: right;
}

.footer-quote {
  margin: 0;
  text-align: center;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 13px;
  color: var(--ink);
  letter-spacing: 0.02em;
}

/* Responsive */
@media (max-width: 960px) {
  .header {
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    padding: 12px 16px;
  }

  .logo {
    grid-column: 1;
  }

  .nav-toggle {
    display: flex;
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
  }

  .header-meta {
    display: none;
  }

  .nav {
    display: none;
    grid-column: 1 / -1;
    flex-direction: column;
    padding: 12px 0;
    border-top: 1px solid var(--line);
    gap: 12px;
  }

  .nav.nav--open {
    display: flex;
  }

  .stats-strip {
    grid-template-columns: repeat(2, 1fr);
  }

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

  .hero-visual {
    order: -1;
  }

  .era-grid,
  .card-grid {
    grid-template-columns: 1fr;
  }

  .hero-stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .footer {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .footer-issue {
    text-align: center;
  }
}

@media (max-width: 600px) {
  .page {
    padding: 0 16px 32px;
  }

  .nav {
    gap: 6px 12px;
  }

  .nav a {
    font-size: 10px;
  }

  .catalog-tools {
    flex-direction: column;
    align-items: stretch;
  }

  .search-wrap {
    max-width: none;
  }

  .filters {
    justify-content: flex-start;
  }
}

/* Modal — карточка вида */
body.modal-open {
  overflow: hidden;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.modal[hidden] {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(44, 36, 25, 0.65);
  backdrop-filter: blur(3px);
}

.modal-dialog {
  position: relative;
  width: min(920px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.25);
  animation: modal-in 0.3s ease;
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  background: var(--paper);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  color: var(--ink);
  transition: background 0.2s, color 0.2s;
}

.modal-close:hover {
  background: var(--brown);
  color: var(--paper);
}

.modal-nav {
  display: flex;
  justify-content: space-between;
  padding: 0 12px 8px;
  gap: 12px;
}

.modal-nav-btn {
  flex: 1;
  max-width: 120px;
  padding: 10px;
  font-family: var(--font-sans);
  font-size: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.3);
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s;
}

.modal-nav-btn:hover:not(:disabled) {
  background: var(--brown);
  color: var(--paper);
}

.modal-nav-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.back-to-top {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 90;
  width: 48px;
  height: 48px;
  border: 1px solid var(--line);
  background: var(--paper);
  font-size: 20px;
  cursor: pointer;
  box-shadow: 0 4px 16px var(--shadow);
  transition: background 0.2s, transform 0.2s;
}

.back-to-top:hover {
  background: var(--brown);
  color: var(--paper);
  transform: translateY(-2px);
}

.modal-content {
  padding: 28px 32px 32px;
}

.modal-header {
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.modal-label {
  margin: 0 0 6px;
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.modal-title {
  margin: 0 0 4px;
  font-size: 2.2rem;
  font-weight: 700;
  line-height: 1.1;
}

.modal-latin {
  margin: 0;
  font-style: italic;
  color: var(--accent);
  font-size: 1.1rem;
}

.modal-body {
  display: grid;
  grid-template-columns: 1fr 1.1fr;
  gap: 28px;
  align-items: start;
}

.modal-figure {
  position: relative;
  margin: 0;
  border: 1px solid var(--line);
  overflow: hidden;
  background: #1a1612;
}

.modal-figure img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 420px;
  object-fit: cover;
  object-position: center 30%;
  background: #1a1612;
}

/* Видео в модалке — в 2 раза крупнее, пропорции сохраняются */
.modal-body--has-video {
  grid-template-columns: 1.25fr 1fr;
}

.modal-figure--video .modal-video {
  display: block;
  width: 100%;
  height: auto;
  max-height: min(840px, 72vh);
  object-fit: contain;
  object-position: center;
  background: #1a1612;
}

.modal-diet {
  position: absolute;
  top: 12px;
  left: 12px;
  padding: 6px 12px;
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  background: var(--paper);
  border: 1px solid var(--line);
}

.modal-desc {
  margin: 0 0 16px;
  font-size: 1.05rem;
  line-height: 1.6;
  color: var(--ink-muted);
}

.modal-fact {
  margin: 0 0 20px;
  padding: 12px 16px;
  border-left: 3px solid var(--accent);
  font-style: italic;
  font-size: 1.1rem;
  color: var(--accent);
  background: rgba(139, 46, 46, 0.06);
}

.modal-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px 20px;
  margin: 0 0 24px;
  padding: 16px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.modal-stats > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.modal-stats dt {
  font-family: var(--font-sans);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.modal-stats dd {
  margin: 0;
  font-weight: 600;
  font-size: 0.95rem;
}

.modal-section {
  margin-bottom: 20px;
}

.modal-section h3 {
  margin: 0 0 10px;
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.modal-section p {
  margin: 0;
  color: var(--ink-muted);
  font-size: 0.95rem;
}

.modal-list {
  margin: 0;
  padding-left: 1.2rem;
  color: var(--ink-muted);
  font-size: 0.95rem;
}

.modal-list li + li {
  margin-top: 6px;
}

.modal-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.modal-tag {
  font-family: var(--font-sans);
  font-size: 11px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.3);
}

@media (max-width: 768px) {
  .modal-body,
  .modal-body--has-video {
    grid-template-columns: 1fr;
  }

  .modal-figure--video .modal-video {
    max-height: min(480px, 55vh);
  }

  .modal-content {
    padding: 20px 18px 24px;
  }

  .modal-title {
    font-size: 1.75rem;
    padding-right: 36px;
  }

  .modal-stats {
    grid-template-columns: 1fr;
  }
}

/* ——— Logo, header actions, theme ——— */

.logo-img {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.lang-switcher-wrap {
  flex-shrink: 0;
}

.lang-select {
  font-family: var(--font-sans);
  font-size: 0.8rem;
  padding: 6px 28px 6px 10px;
  border: 1px solid var(--ink-muted);
  border-radius: 4px;
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  max-width: 9rem;
}

[dir="rtl"] .lang-select {
  padding: 6px 10px 6px 28px;
}

body.is-rtl .nav {
  direction: rtl;
}

.theme-toggle {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.25);
  font-size: 18px;
  cursor: pointer;
  border-radius: 50%;
  color: var(--ink);
}

.theme-toggle:hover {
  background: var(--paper-dark);
}

[data-theme="dark"] {
  --paper: #1e1b16;
  --paper-dark: #2a261f;
  --ink: #e8e2d2;
  --ink-muted: #b5ad9e;
  --line: #6a6256;
  --shadow: rgba(0, 0, 0, 0.35);
  --brown: #c9b89a;
  --brown-light: #a89880;
}

[data-theme="dark"] body {
  background-image:
    radial-gradient(ellipse at 20% 0%, rgba(168, 69, 69, 0.08) 0%, transparent 50%),
    url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.06'/%3E%3C/svg%3E");
}

[data-theme="dark"] .header {
  background: rgba(30, 27, 22, 0.92);
  border-color: var(--line);
}

[data-theme="dark"] .species-card,
[data-theme="dark"] .era-card,
[data-theme="dark"] .dict-card,
[data-theme="dark"] .quiz-box {
  background: rgba(255, 255, 255, 0.04);
}

/* ——— Catalog tools ——— */

.sort-wrap {
  display: flex;
  align-items: center;
}

.sort-select {
  font-family: var(--font-sans);
  font-size: 12px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.35);
  color: var(--ink);
  min-width: 160px;
}

.filter--video.is-active {
  border-color: var(--accent);
  color: var(--accent);
}

.species-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
}

.species-page-link {
  font-family: var(--font-sans);
  font-size: 11px;
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
}

.species-page-link:hover {
  text-decoration: underline;
}

.species-card.is-video-playing .species-figure-photo {
  opacity: 0;
}

.species-card.is-video-playing .species-figure-video {
  opacity: 1;
}

/* ——— Skeleton ——— */

.species-card--skeleton {
  pointer-events: none;
  min-height: 320px;
}

.skeleton-line,
.skeleton-block {
  background: linear-gradient(90deg, var(--paper-dark) 25%, var(--paper) 50%, var(--paper-dark) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.2s ease infinite;
  border-radius: 2px;
}

.skeleton-line {
  height: 12px;
  margin-bottom: 10px;
}

.skeleton-line--short {
  width: 40%;
}

.skeleton-line--title {
  height: 20px;
  width: 70%;
}

.skeleton-block {
  height: 140px;
  margin: 16px 0;
}

@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ——— Modal toolbar ——— */

.modal-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 11px;
}

.modal-share-feedback {
  font-family: var(--font-sans);
  font-size: 11px;
  color: var(--accent);
}

/* ——— Feature sections ——— */

.feature-section {
  margin-top: 56px;
  padding-top: 32px;
  border-top: 2px solid var(--line);
}

.section-lead {
  margin: -8px 0 24px;
  color: var(--ink-muted);
  font-size: 1rem;
}

.compare-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-end;
  margin-bottom: 24px;
}

.compare-controls label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-family: var(--font-sans);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.compare-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
  margin-bottom: 20px;
}

.compare-table th,
.compare-table td {
  border: 1px solid var(--line);
  padding: 10px 12px;
  text-align: left;
}

.compare-table th {
  font-family: var(--font-sans);
  font-size: 10px;
  text-transform: uppercase;
  background: rgba(0, 0, 0, 0.04);
}

.compare-images {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.compare-images img {
  width: 100%;
  height: auto;
  border: 1px solid var(--line);
}

.map-period-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

.map-period-tab[data-map-period="gondwana"].is-active {
  border-color: var(--triassic);
  background: rgba(61, 92, 58, 0.12);
  box-shadow: inset 0 0 0 1px var(--triassic);
}

.map-period-tab {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 10px 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.25);
  font-family: var(--font-sans);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.map-period-tab:hover {
  border-color: var(--accent);
}

.map-period-tab.is-active {
  border-color: var(--accent);
  background: rgba(139, 46, 46, 0.1);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.map-period-tab-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.map-period-tab-age {
  font-size: 10px;
  color: var(--ink-muted);
}

.map-layout {
  display: grid;
  grid-template-columns: 1fr minmax(220px, 280px);
  gap: 24px;
  align-items: start;
}

.find-map {
  position: relative;
  aspect-ratio: 2 / 1;
  max-height: min(72vh, 640px);
  background: #e8eef0;
  border: 2px solid var(--line);
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(44, 36, 25, 0.08);
}

.ancient-map-base {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  pointer-events: none;
  user-select: none;
}

/* ——— SEO FAQ (AEO) ——— */

.seo-faq {
  border-top: 2px solid var(--line);
}

.faq-list {
  max-width: 720px;
}

.faq-item {
  border: 1px solid var(--line);
  margin-bottom: 8px;
  background: rgba(255, 255, 255, 0.2);
}

.faq-question {
  padding: 14px 16px;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}

.faq-question::-webkit-details-marker {
  display: none;
}

.faq-question::after {
  content: "+";
  float: right;
  font-weight: 400;
  opacity: 0.5;
}

.faq-item[open] .faq-question::after {
  content: "−";
}

.faq-answer {
  margin: 0;
  padding: 0 16px 14px;
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--ink-muted);
}

.breadcrumb {
  margin: 0 0 20px;
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--ink-muted);
}

.breadcrumb a {
  color: var(--accent);
  text-decoration: none;
}

.breadcrumb a:hover {
  text-decoration: underline;
}

.species-page-meta-line {
  margin: 0 0 16px;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  color: var(--ink-muted);
}

.map-attribution {
  margin: 10px 0 0;
  font-family: var(--font-sans);
  font-size: 10px;
  line-height: 1.45;
  color: var(--ink-muted);
  max-width: 52rem;
}

.map-pins-layer {
  position: absolute;
  inset: 0;
}

.map-pin {
  position: absolute;
  z-index: 2;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
  transition: transform 0.15s, box-shadow 0.15s;
}

.map-pin::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 100%;
  width: 2px;
  height: 8px;
  margin-left: -1px;
  background: var(--accent);
  opacity: 0.7;
}

.map-pin:hover,
.map-pin.is-active {
  transform: scale(1.2);
  box-shadow: 0 0 0 3px rgba(139, 46, 46, 0.35);
}

.map-pin.is-active {
  background: var(--brown);
}

.map-panel-era {
  margin: 0 0 4px;
  font-family: var(--font-sans);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
}

.map-empty-note {
  margin: 0 0 12px;
  font-size: 0.9rem;
  color: var(--ink-muted);
  font-style: italic;
}

[data-theme="dark"] .find-map {
  background: #2a3238;
}

[data-theme="dark"] .ancient-map-base {
  opacity: 0.95;
  filter: brightness(0.88) contrast(1.05);
}

.map-panel {
  padding: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.25);
}

.map-panel h3 {
  margin: 0 0 8px;
  font-size: 1.25rem;
}

.map-species-list {
  margin: 0 0 12px;
  padding-left: 1.2rem;
  font-size: 0.9rem;
}

.quiz-box {
  max-width: 640px;
  padding: 24px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.2);
}

.quiz-progress {
  font-family: var(--font-sans);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-muted);
}

.quiz-question {
  font-size: 1.35rem;
  font-weight: 600;
  margin: 12px 0 20px;
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.quiz-opt {
  text-align: left;
  padding: 12px 16px;
  border: 1px solid var(--line);
  background: var(--paper);
  font-family: var(--font-serif);
  font-size: 1rem;
  cursor: pointer;
}

.quiz-opt:hover:not(:disabled) {
  border-color: var(--accent);
}

.quiz-opt.is-correct {
  border-color: #3d5c3a;
  background: rgba(61, 92, 58, 0.15);
}

.quiz-opt.is-wrong {
  border-color: var(--accent);
  opacity: 0.7;
}

.quiz-hint {
  margin-top: 12px;
  font-style: italic;
  color: var(--ink-muted);
  font-size: 0.9rem;
}

.quiz-result {
  max-width: 480px;
}

.quiz-score {
  font-size: 1.5rem;
  font-weight: 700;
}

.dict-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.dict-card {
  padding: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.2);
}

.dict-term {
  margin: 0 0 4px;
  font-size: 1.2rem;
}

.dict-latin {
  margin: 0 0 8px;
  font-style: italic;
  color: var(--accent);
  font-size: 0.9rem;
}

.dict-def {
  margin: 0;
  font-size: 0.9rem;
  color: var(--ink-muted);
}

/* ——— Species page ——— */

.species-page {
  padding-top: 24px;
}

.species-page-article {
  max-width: 720px;
}

.species-page-title {
  font-size: 2.5rem;
  margin: 0 0 8px;
}

.species-page-actions-top {
  display: flex;
  gap: 12px;
  margin: 16px 0 24px;
  flex-wrap: wrap;
}

.species-page-figure {
  position: relative;
  margin: 0 0 24px;
  border: 1px solid var(--line);
}

.species-page-img,
.species-page-video {
  display: block;
  width: 100%;
  height: auto;
}

.species-page-loading {
  padding: 48px 0;
  text-align: center;
}

@media (max-width: 768px) {
  .map-layout {
    grid-template-columns: 1fr;
  }

  .compare-images {
    grid-template-columns: 1fr;
  }

  .catalog-tools {
    flex-direction: column;
    align-items: stretch;
  }

  .header-actions .header-date {
    display: none;
  }
}
