/* ==========================================================================
   Design tokens
   ========================================================================== */
:root {
  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI",
    Roboto, Helvetica, Arial, sans-serif;

  --container: 1264px;
  --content: 1200px;

  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 24px;

  --shadow-sm: 0 1px 2px rgba(12, 24, 18, 0.06),
    0 2px 6px rgba(12, 24, 18, 0.06);
  --shadow: 0 14px 34px -16px rgba(12, 24, 18, 0.28);
  --shadow-lg: 0 30px 70px -28px rgba(12, 24, 18, 0.4);

  /* Light theme */
  --bg: #f3f6f4;
  --surface: #ffffff;
  --surface-2: #eaf1ec;
  --text: #11201a;
  --muted: #55665d;
  --accent: #128a5a;
  --accent-2: #0e6f49;
  --accent-contrast: #ffffff;
  --accent-soft: rgba(18, 138, 90, 0.12);
  --border: rgba(17, 32, 26, 0.1);
  --border-strong: rgba(17, 32, 26, 0.18);
  --header-bg: rgba(243, 246, 244, 0.72);
  --ring: rgba(18, 138, 90, 0.4);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b120f;
    --surface: #131e19;
    --surface-2: #182720;
    --text: #e9f2ec;
    --muted: #9cb0a6;
    --accent: #3ddc97;
    --accent-2: #6ce8b0;
    --accent-contrast: #06231a;
    --accent-soft: rgba(61, 220, 151, 0.16);
    --border: rgba(233, 242, 236, 0.12);
    --border-strong: rgba(233, 242, 236, 0.22);
    --header-bg: rgba(11, 18, 15, 0.7);
    --ring: rgba(61, 220, 151, 0.45);
  }
}

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

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

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img,
svg {
  display: block;
  max-width: 100%;
  height: auto;
}

a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
  text-decoration-color: color-mix(in srgb, var(--accent) 45%, transparent);
  transition: color 0.15s ease, text-decoration-color 0.15s ease;
}

a:hover {
  color: var(--accent-2);
  text-decoration-color: currentColor;
}

:focus-visible {
  outline: 3px solid var(--ring);
  outline-offset: 2px;
  border-radius: 4px;
}

::selection {
  background: var(--accent-soft);
}

h1,
h2,
h3 {
  line-height: 1.18;
  letter-spacing: -0.02em;
  font-weight: 800;
}

/* ==========================================================================
   Layout helpers
   ========================================================================== */
.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: clamp(1.1rem, 4vw, 2rem);
}

.content {
  max-width: var(--content);
  margin-inline: auto;
}

main {
  padding-bottom: clamp(3rem, 8vw, 6rem);
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  background: var(--surface);
  color: var(--text);
  padding: 0.7rem 1.1rem;
  border-radius: 0 0 var(--radius-sm) 0;
  box-shadow: var(--shadow);
}

.skip-link:focus {
  left: 0;
}

/* ==========================================================================
   Header / navigation
   ========================================================================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--header-bg);
  backdrop-filter: blur(16px) saturate(160%);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  border-bottom: 1px solid var(--border);
}

.site-header__inner {
  position: relative;
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: 66px;
}

.site-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.site-brand:hover {
  color: var(--text);
}

.site-brand img {
  width: 40px;
  height: 40px;
  object-fit: contain;
  padding: 3px;
  border-radius: 11px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.site-brand__name {
  font-size: 1rem;
}

.site-nav {
  margin-left: auto;
}

.site-nav ul {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-nav a {
  display: inline-block;
  padding: 0.5rem 0.85rem;
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 500;
  text-decoration: none;
  transition: color 0.15s ease, background 0.15s ease;
}

.site-nav a:hover {
  color: var(--text);
  background: var(--surface-2);
}

.site-nav a[aria-current="page"] {
  color: var(--accent-2);
  background: var(--accent-soft);
  font-weight: 700;
}

.nav-toggle {
  display: none;
  margin-left: auto;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.nav-toggle span,
.nav-toggle span::before,
.nav-toggle span::after {
  display: block;
  width: 20px;
  height: 2px;
  margin-inline: auto;
  border-radius: 2px;
  background: currentColor;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.nav-toggle span {
  position: relative;
}

.nav-toggle span::before,
.nav-toggle span::after {
  content: "";
  position: absolute;
  left: 0;
}

.nav-toggle span::before {
  top: -6px;
}

.nav-toggle span::after {
  top: 6px;
}

.nav-toggle[aria-expanded="true"] span {
  background: transparent;
}

.nav-toggle[aria-expanded="true"] span::before {
  transform: translateY(6px) rotate(45deg);
}

.nav-toggle[aria-expanded="true"] span::after {
  transform: translateY(-6px) rotate(-45deg);
}

/* ==========================================================================
   Hero
   ========================================================================== */
.hero {
  position: relative;
  margin-top: clamp(1.5rem, 4vw, 2.5rem);
  padding: clamp(2.25rem, 6vw, 4rem);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  overflow: hidden;
  background: radial-gradient(
      1200px 400px at 100% 0%,
      var(--accent-soft),
      transparent 60%
    ),
    linear-gradient(160deg, var(--surface), var(--surface-2));
  box-shadow: var(--shadow);
}

.hero__kicker {
  display: inline-block;
  margin: 0 0 1rem;
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--accent-2);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hero__title {
  margin: 0 0 1.1rem;
  font-size: clamp(2.1rem, 5.5vw, 3.5rem);
  max-width: 16ch;
}

.hero__title em {
  font-style: normal;
  color: var(--accent);
}

.hero__byline {
  margin: 0;
  max-width: 62ch;
  color: var(--muted);
  font-style: italic;
}

.hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.9rem;
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.35rem;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  line-height: 1.2;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease,
    color 0.2s ease, border-color 0.2s ease;
}

.btn--primary {
  background: var(--accent);
  color: var(--accent-contrast);
  box-shadow: var(--shadow-sm);
}

.btn--primary:hover {
  background: var(--accent-2);
  color: var(--accent-contrast);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.btn--ghost {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}

.btn--ghost:hover {
  color: var(--accent-2);
  border-color: var(--accent);
  transform: translateY(-2px);
}

.btn--sm {
  padding: 0.5rem 0.95rem;
  font-size: 0.85rem;
}

.btn--block {
  width: 100%;
}

/* ==========================================================================
   Page heading (inner pages)
   ========================================================================== */
.page-head {
  padding-top: clamp(2.5rem, 6vw, 4rem);
  margin-bottom: clamp(1.5rem, 4vw, 2.5rem);
}

.page-head h1 {
  margin: 0 0 0.85rem;
  font-size: clamp(2rem, 5vw, 3rem);
}

.page-head .lead {
  margin: 0;
  max-width: 62ch;
  font-size: 1.15rem;
  color: var(--muted);
}

/* ==========================================================================
   Sections & prose
   ========================================================================== */
.section {
  margin-top: clamp(2.25rem, 5vw, 3.5rem);
}

.section__title {
  position: relative;
  margin: 0 0 1.05rem;
  padding-top: 1rem;
  font-size: clamp(1.35rem, 3vw, 1.9rem);
}

.section__title::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 46px;
  height: 4px;
  border-radius: 2px;
  background: var(--accent);
}

.subsection-title {
  margin: 2rem 0 0.6rem;
  font-size: 1.15rem;
  font-weight: 700;
}

p {
  margin: 0 0 1.05rem;
}

strong {
  font-weight: 700;
}

/* ==========================================================================
   Figures
   ========================================================================== */
figure {
  margin: 1.9rem 0;
}

figure img {
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

figcaption {
  margin-top: 0.7rem;
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--muted);
}

/* ==========================================================================
   Cards (contact, panels)
   ========================================================================== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: clamp(1.4rem, 4vw, 2.4rem);
  box-shadow: var(--shadow-sm);
  max-width: 560px;
}

.card h2 {
  margin: 0 0 0.75rem;
  font-size: 1.35rem;
}

/* ==========================================================================
   Language library
   ========================================================================== */
.lang-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: clamp(1rem, 2vw, 1.4rem);
  margin: 0;
  padding: 0;
  list-style: none;
}

.lang-card {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: start;
  column-gap: 1rem;
  row-gap: 0.55rem;
  padding: 1.35rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.lang-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow);
  border-color: var(--border-strong);
}

.lang-card__flag {
  grid-row: 1;
  align-self: start;
  width: 56px;
  height: 38px;
  object-fit: cover;
  border-radius: 7px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.lang-card__name {
  grid-column: 2;
  align-self: center;
  margin: 0;
  font-size: 1.08rem;
  font-weight: 700;
}

.lang-card__actions {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.lang-card__actions .btn {
  max-width: 100%;
}

/* ==========================================================================
   References
   ========================================================================== */
.references {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.85rem;
}

.references li {
  position: relative;
  padding-left: 1.35rem;
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--muted);
  word-break: break-word;
}

.references li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.62em;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.7;
}

/* ==========================================================================
   Page hero banners
   ========================================================================== */
.lead {
  max-width: 62ch;
  font-size: 1.15rem;
  color: var(--muted);
}

.byline {
  max-width: 62ch;
  margin: 0.6rem 0 0;
  color: var(--muted);
  font-style: italic;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.75rem;
}

.page-hero {
  position: relative;
  display: flex;
  align-items: flex-end;
  min-height: clamp(300px, 46vh, 480px);
  overflow: hidden;
  background-color: var(--surface-2);
  background-size: cover;
  background-position: center 40%;
}

.page-hero__inner {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: none;
  margin-inline: 0;
  padding-block: clamp(1.75rem, 6vw, 3.25rem);
}

.page-hero h1 {
  margin: 0;
  color: #fff;
  font-size: clamp(1.9rem, 5vw, 3.25rem);
  text-shadow:
    -1.5px -1.5px 0 #000,
     1.5px -1.5px 0 #000,
    -1.5px  1.5px 0 #000,
     1.5px  1.5px 0 #000,
    -1.5px  0     0 #000,
     1.5px  0     0 #000,
     0     -1.5px 0 #000,
     0      1.5px 0 #000,
     0 2px 20px rgba(0, 0, 0, 0.5);
}

.page-hero + .container {
  padding-top: clamp(2rem, 5vw, 3rem);
}

.page-hero--home {
  background-image: url("../images/background/cave-podillia.jpg");
}

.page-hero--library {
  background-image: url("../images/background/cave-krizna.jpg");
  background-position: center;
}

.page-hero--contact {
  background-image: url("../images/background/bat-myotis-capaccinii.jpg");
}

.page-hero--projects {
  background-image: url("../images/background/cave-urushka-maara.jpg");
}

.page-hero--wnd {
  background-image: url("../images/background/wnd-banner.jpg");
  background-position: center bottom;
}

/* ==========================================================================
   Footer
   ========================================================================== */
.site-footer {
  margin-top: clamp(3rem, 8vw, 5rem);
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.site-footer__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.5rem;
  padding-block: 1.75rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.site-footer p {
  margin: 0;
}

.site-footer nav {
  margin-left: auto;
  display: flex;
  gap: 1.1rem;
}

.site-footer nav a {
  color: var(--muted);
  text-decoration: none;
}

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

/* ==========================================================================
   Scroll reveal
   ========================================================================== */
.reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.reveal.is-visible {
  opacity: 1;
  transform: none;
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 900px) {
  .nav-toggle {
    display: block;
  }

  .site-nav {
    position: absolute;
    top: calc(100% + 1px);
    left: 0;
    right: 0;
    margin: 0;
    padding: 0.6rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0 0 var(--radius) var(--radius);
    box-shadow: var(--shadow-lg);
    display: none;
  }

  .site-nav.is-open {
    display: block;
  }

  .site-nav ul {
    flex-direction: column;
    align-items: stretch;
    gap: 0.15rem;
  }

  .site-nav a {
    display: block;
    padding: 0.8rem 0.9rem;
    border-radius: 10px;
  }
}

@media (max-width: 600px) {
  body {
    font-size: 16px;
  }

  .site-brand__name {
    font-size: 0.92rem;
  }

  .hero {
    border-radius: var(--radius);
  }

  .hero__actions .btn {
    width: 100%;
  }
}

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

  .reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }

  .btn:hover,
  .lang-card:hover {
    transform: none;
  }
}
