:root {
  --bg: #121110;
  --surface: #1b1a18;
  --surface-2: #24221f;
  --line: #34312c;
  --text: #ebe6dd;
  --muted: #a29c91;
  --accent: #c8ad7f;
  --ribbon: #050505;
  --caption: #cfc8bc;
  --topbar: rgba(18, 17, 16, 0.94);
  --shadow: rgba(0, 0, 0, 0.45);
  --shadow-soft: rgba(0, 0, 0, 0.4);
  --serif: Georgia, "Times New Roman", "DejaVu Serif", serif;
  --sans: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --maxw: 760px;
  --gutter: 16px;
}

/* світла тема */
:root[data-theme="light"] {
  --bg: #f6f3ee;
  --surface: #ffffff;
  --surface-2: #ece7df;
  --line: #ddd5c8;
  --text: #24211d;
  --muted: #6d665b;
  --accent: #97763f;
  --caption: #4a453d;
  --topbar: rgba(246, 243, 238, 0.94);
  --shadow: rgba(60, 45, 20, 0.16);
  --shadow-soft: rgba(60, 45, 20, 0.12);
  color-scheme: light;
}

:root[data-theme="dark"] { color-scheme: dark; }

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

[hidden] { display: none !important; }

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.7;
}

body.no-scroll { overflow: hidden; }

a { color: inherit; }

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

button { font: inherit; color: inherit; }

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

/* ---------- шапка ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 12px 24px;
  background: var(--topbar);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
  font-family: var(--sans);
  font-size: 15px;
}

.brand {
  text-decoration: none;
  font-family: var(--serif);
  font-size: 16px;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.nav { margin-left: auto; }

.nav__list, .nav__sub { list-style: none; margin: 0; padding: 0; }

.nav__list { display: flex; align-items: center; gap: 4px; }

.nav a, .nav__group-label {
  display: block;
  padding: 6px 10px;
  border-radius: 4px;
  text-decoration: none;
  color: var(--muted);
  white-space: nowrap;
  cursor: pointer;
}

.nav a:hover, .nav__group:hover > .nav__group-label { color: var(--text); }

.nav a[aria-current="page"], .nav__group.is-active > .nav__group-label { color: var(--text); }

.nav a[aria-current="page"] { background: var(--surface-2); }

.nav__group { position: relative; }

.nav__group-label::after {
  content: "";
  display: inline-block;
  margin-left: 6px;
  border: 4px solid transparent;
  border-top-color: currentColor;
  transform: translateY(2px);
}

.nav__sub {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 160px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 10px 30px var(--shadow-soft);
  opacity: 0;
  visibility: hidden;
  transform: translateY(4px);
  transition: opacity .15s, transform .15s, visibility .15s;
}

.nav__group:hover .nav__sub,
.nav__group:focus-within .nav__sub {
  opacity: 1;
  visibility: visible;
  transform: none;
}

.tools { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

.lang { display: flex; gap: 2px; flex-shrink: 0; }

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.theme-toggle:hover { color: var(--text); border-color: var(--muted); }

.theme-toggle svg { width: 16px; height: 16px; }

/* у темній темі показуємо сонце (перемкнути на світлу), у світлій — місяць */
.theme-toggle .icon-moon { display: none; }
:root[data-theme="light"] .theme-toggle .icon-sun { display: none; }
:root[data-theme="light"] .theme-toggle .icon-moon { display: block; }

.lang a {
  display: inline-block;
  text-decoration: none;
  line-height: 1.6;
  padding: 5px 9px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.08em;
  cursor: pointer;
}

.lang a:first-child { border-radius: 4px 0 0 4px; }
.lang a:last-child { border-radius: 0 4px 4px 0; }

.lang a:hover { color: var(--text); }

.lang a[aria-current="true"] {
  background: var(--text);
  border-color: var(--text);
  color: var(--bg);
}

.menu-toggle {
  display: none;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  padding: 6px 10px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
}

.menu-toggle__bars,
.menu-toggle__bars::before,
.menu-toggle__bars::after {
  display: block;
  width: 16px;
  height: 2px;
  background: currentColor;
  position: relative;
}

.menu-toggle__bars::before, .menu-toggle__bars::after { content: ""; position: absolute; left: 0; }
.menu-toggle__bars::before { top: -5px; }
.menu-toggle__bars::after { top: 5px; }

/* ---------- основна частина ---------- */

.view {
  flex: 1;
  width: 100%;
  max-width: calc(var(--maxw) + 2 * var(--gutter));
  margin: 0 auto;
  padding: 48px var(--gutter) 64px;
  outline: none;
}

.muted { color: var(--muted); font-style: italic; }

/* ---------- головна ---------- */

.home { text-align: center; }

.portrait { margin: 0 auto 32px; width: min(320px, 78vw); }

.portrait__frame {
  position: relative;
  aspect-ratio: 4 / 5;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: 0 20px 50px var(--shadow);
}

.portrait__frame img { width: 100%; height: 100%; object-fit: cover; }

/* заглушка, поки немає фото */
.portrait__frame--empty::before {
  content: "";
  position: absolute;
  inset: 22% 30% auto;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--surface-2);
}

.portrait__frame--empty::after {
  content: "";
  position: absolute;
  left: 15%;
  right: 15%;
  bottom: -10%;
  height: 40%;
  border-radius: 50% 50% 0 0;
  background: var(--surface-2);
}

/* траурна стрічка в кутку */
.portrait__ribbon {
  position: absolute;
  top: 0;
  right: 0;
  width: 90px;
  height: 90px;
  overflow: hidden;
  pointer-events: none;
  z-index: 2;
}

.portrait__ribbon::before {
  content: "";
  position: absolute;
  top: 22px;
  right: -34px;
  width: 140px;
  height: 16px;
  background: var(--ribbon);
  transform: rotate(45deg);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

.home__name {
  margin: 0 0 8px;
  font-weight: normal;
  font-size: clamp(26px, 5vw, 38px);
  line-height: 1.25;
  letter-spacing: 0.01em;
}

.home__dates {
  margin: 0 0 40px;
  color: var(--muted);
  font-size: 17px;
  letter-spacing: 0.03em;
}

.home__intro {
  max-width: 600px;
  margin: 0 auto 48px;
  padding-top: 32px;
  border-top: 1px solid var(--line);
  font-size: 19px;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.card {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 84px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  text-decoration: none;
  transition: border-color .2s, background .2s;
}

.card:hover { border-color: var(--accent); background: var(--surface-2); }

.card__title { font-size: 18px; }

/* ---------- розділи ---------- */

.section__title {
  margin: 0 0 32px;
  font-weight: normal;
  font-size: clamp(28px, 5vw, 40px);
  line-height: 1.2;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.prose p { margin: 0 0 1.1em; }

.prose h3 {
  margin: 1.8em 0 0.6em;
  font-weight: normal;
  font-size: 23px;
  color: var(--accent);
}

.prose hr {
  border: 0;
  height: 1px;
  background: var(--line);
  margin: 2em auto;
  width: 40%;
}

.home .prose { text-align: center; }

/* ---------- стрічка розділу: фото й тексти по черзі ---------- */

.section__intro { margin-bottom: 48px; }

.flow { display: flex; flex-direction: column; gap: 48px; }

/* розділювач між блоками: лінія — ромб — лінія */
.flow__sep {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

.flow__sep::before,
.flow__sep::after {
  content: "";
  width: 110px;
  height: 1px;
  background: linear-gradient(to right, transparent, var(--accent));
  opacity: .75;
}

.flow__sep::after { background: linear-gradient(to left, transparent, var(--accent)); }

.flow__sep span {
  width: 8px;
  height: 8px;
  background: var(--accent);
  transform: rotate(45deg);
}

.flow__photo { margin: 0; }

.flow__photo button {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  cursor: zoom-in;
}

.flow__photo img {
  display: block;
  max-width: 100%;
  max-height: 85vh;
  width: auto;
  height: auto;
  margin: 0 auto;
  border: 1px solid var(--line);
  box-shadow: 0 12px 36px var(--shadow);
}

.flow__caption {
  max-width: 640px;
  margin: 16px auto 0;
  font-size: 16px;
  line-height: 1.6;
  color: var(--caption);
  text-align: center;
}

.flow__caption .prose p { margin-bottom: .6em; }
.flow__caption .prose p:last-child { margin-bottom: 0; }
.flow__caption .prose h3 { margin: 0 0 .4em; font-size: 18px; }
.flow__caption .entry__author { text-align: center; margin-top: 6px; }

.flow__text .prose p:last-child { margin-bottom: 0; }
.flow__text .prose h3:first-child { margin-top: 0; }

.flow__text .entry__author,
.entry__author {
  margin: 14px 0 0;
  color: var(--muted);
  font-style: italic;
  text-align: right;
}

/* картки (спогади) */
.flow--cards { gap: 20px; }

.entry {
  margin: 0;
  padding: 24px 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 2px solid var(--accent);
  border-radius: 4px;
}

.entry .prose p:last-child { margin-bottom: 0; }

.entry .prose h3:first-child { margin-top: 0; }

.flow--cards .flow__photo { margin: 12px 0; }

/* цитата на головній */
.quote {
  max-width: 600px;
  margin: 0 auto 48px;
  transition: opacity .6s;
}

.quote.is-fading { opacity: 0; }

.quote .entry {
  background: transparent;
  border: 0;
  padding: 0 12px;
  font-size: 21px;
  font-style: italic;
  line-height: 1.6;
}

.quote .entry::before {
  content: "\201C";
  display: block;
  font-size: 64px;
  line-height: .6;
  color: var(--accent);
  margin-bottom: 8px;
}

.quote .entry__author { text-align: center; font-size: 17px; }

/* ---------- lightbox ---------- */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.94);
  padding: 56px 64px;
}

.lightbox[hidden] { display: none; }

.lightbox__figure {
  margin: 0;
  max-width: 100%;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.lightbox__figure img {
  max-width: 100%;
  max-height: calc(100vh - 150px);
  object-fit: contain;
}

.lightbox__figure figcaption {
  margin-top: 12px;
  color: var(--muted);
  text-align: center;
  font-size: 16px;
}

.lightbox__figure figcaption:empty { display: none; }

.lightbox__close, .lightbox__nav {
  position: absolute;
  background: transparent;
  border: 0;
  color: var(--text);
  cursor: pointer;
  opacity: .7;
  line-height: 1;
}

.lightbox__close:hover, .lightbox__nav:hover { opacity: 1; }

.lightbox__close { top: 10px; right: 16px; font-size: 40px; padding: 4px 10px; }

.lightbox__nav { top: 50%; transform: translateY(-50%); font-size: 56px; padding: 10px 14px; }
.lightbox__nav--prev { left: 4px; }
.lightbox__nav--next { right: 4px; }
.lightbox__nav[hidden] { display: none; }

.lightbox__counter {
  position: absolute;
  top: 18px;
  left: 20px;
  font-family: var(--sans);
  font-size: 13px;
  color: var(--muted);
}

/* ---------- футер ---------- */

.footer {
  padding: 32px var(--gutter);
  border-top: 1px solid var(--line);
  text-align: center;
  color: var(--muted);
}

.footer p { margin: 0; }

.footer__eternal { font-size: 18px; color: var(--text); letter-spacing: 0.04em; }

.footer__dates { font-size: 14px; margin-top: 4px !important; }

.noscript { text-align: center; padding: 24px; }

/* ---------- мобільні ---------- */

@media (max-width: 860px) {
  .topbar { flex-wrap: wrap; gap: 12px; padding: 10px var(--gutter); }

  .brand { flex: 1 1 100%; order: 0; text-align: center; font-size: 15px; }

  .menu-toggle { display: inline-flex; margin-left: 0; order: 1; }

  .tools { order: 2; margin-left: auto; }

  .nav { display: none; order: 3; flex: 1 1 100%; margin: 0; }

  body.menu-open .nav { display: block; }

  .nav__list { flex-direction: column; align-items: stretch; gap: 0; padding: 6px 0; }

  .nav a, .nav__group-label { padding: 10px 8px; font-size: 16px; }

  .nav__group-label { cursor: default; color: var(--text); }
  .nav__group-label::after { display: none; }

  .nav__sub {
    position: static;
    opacity: 1;
    visibility: visible;
    transform: none;
    background: transparent;
    border: 0;
    box-shadow: none;
    padding: 0 0 0 16px;
  }

  .view { padding-top: 32px; }

  body { font-size: 17px; }

  .flow { gap: 36px; }
  .entry { padding: 18px 18px; }
  .lightbox { padding: 48px 8px; }
  .lightbox__nav { font-size: 44px; top: auto; bottom: 8px; transform: none; }
}
