/* ============================================================
   Мемориальная страница — оформление
   Все цвета и размеры собраны в :root, менять удобнее здесь.
   ============================================================ */

:root {
  --paper:        #f7f4ef;
  --paper-alt:    #efeae2;
  --ink:          #241f1b;
  --ink-soft:     #5e564d;
  --ink-faint:    #8c8277;
  --line:         #ddd5c9;
  --accent:       #9a7b45;
  --hero-bg:      #1d1a17;
  --hero-ink:     #f2ede5;

  --serif: "Cormorant Garamond", "Georgia", "Times New Roman", serif;
  --sans:  "Inter", -apple-system, "Segoe UI", system-ui, sans-serif;

  --measure: 34rem;
  --gutter: clamp(1.25rem, 5vw, 4rem);
}

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

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-weight: 300;
  font-size: 17px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

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

a { color: var(--accent); text-decoration: none; border-bottom: 1px solid currentColor; }
a:hover { color: var(--ink); }

.wrap {
  width: 100%;
  max-width: 68rem;
  margin: 0 auto;
  padding-inline: var(--gutter);
}
.wrap--narrow { max-width: calc(var(--measure) + var(--gutter) * 2); }

/* ============================================================
   ШАПКА
   ============================================================ */

.hero {
  position: relative;
  background: var(--hero-bg);
  color: var(--hero-ink);
  padding: clamp(4rem, 10vh, 7rem) var(--gutter) clamp(5rem, 12vh, 8rem);
  overflow: hidden;
}

/* мягкое свечение за портретом */
.hero::before {
  content: "";
  position: absolute;
  inset: -20% -10% auto -10%;
  height: 90%;
  background: radial-gradient(ellipse at 30% 40%, rgba(154, 123, 69, .18), transparent 65%);
  pointer-events: none;
}

.hero__inner {
  position: relative;
  max-width: 62rem;
  margin: 0 auto;
  display: grid;
  gap: clamp(2rem, 5vw, 4.5rem);
  grid-template-columns: 1fr;
  align-items: center;
  justify-items: center;
  text-align: center;
}

@media (min-width: 820px) {
  .hero__inner {
    grid-template-columns: auto 1fr;
    text-align: left;
    justify-items: start;
  }
}

.portrait {
  position: relative;
  margin: 3rem 0 1.4rem;
  padding: .7rem;
  background: rgba(255, 255, 255, .05);
  border: 1px solid rgba(242, 237, 229, .16);
  box-shadow: 0 30px 70px -30px rgba(0, 0, 0, .8);
}

.portrait > img {
  width: clamp(14.5rem, 34vw, 21rem);
  aspect-ratio: 3 / 4;
  object-fit: cover;
  object-position: 50% 20%;
}

/* герб над рамкою */
.portrait__emblem {
  position: absolute;
  top: -2.8rem;
  left: 50%;
  translate: -50% 0;
  display: block;
  line-height: 0;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, .55));
}
.portrait__emblem {
  padding: .55rem .7rem .5rem;
  background: var(--paper);
  border: 1px solid rgba(154, 123, 69, .55);
  border-radius: 50% 50% 48% 48% / 40% 40% 60% 60%;
}
.portrait__emblem img { width: 3.2rem; height: auto; }

/* стрічка кольорів прапора під рамкою */
.portrait__ribbon {
  position: absolute;
  left: -1px;
  right: -1px;
  bottom: -1.05rem;
  height: 1.05rem;
  background: linear-gradient(to bottom, #0057b8 50%, #ffd500 50%);
  box-shadow: 0 10px 24px -10px rgba(0, 0, 0, .7);
}

/* орнамент у стилі вишивки внизу шапки */
.ornament {
  --tile: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='26' viewBox='0 0 32 26'%3E%3Cpath d='M0 3h32M0 23h32' stroke='%23b3261e' stroke-width='1.5'/%3E%3Cpath d='M16 3l11 10-11 10-11-10z' fill='none' stroke='%23c8352c' stroke-width='2'/%3E%3Cpath d='M16 8l6 5-6 5-6-5z' fill='%23c8352c'/%3E%3Cpath d='M14.5 11.5h3v3h-3z' fill='%23f2ede5'/%3E%3Cpath d='M0 11h3v4H0zM29 11h3v4h-3z' fill='%23c8352c'/%3E%3C/svg%3E");
  height: 26px;
  background: var(--tile) repeat-x center / 32px 26px;
}
.ornament--hero {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #14110f;
}

.hero__eyebrow {
  margin: 0 0 1.1rem;
  font-size: .85rem;
  letter-spacing: .32em;
  text-transform: uppercase;
  color: #c9a45e;
}

.hero__name {
  margin: 0;
  font-family: var(--serif);
  font-weight: 300;
  font-size: clamp(3rem, 8vw, 5.4rem);
  line-height: .98;
  letter-spacing: -.01em;
}

.hero__dates {
  margin: 1.4rem 0 0;
  font-family: var(--serif);
  font-size: 1.2rem;
  color: rgba(242, 237, 229, .72);
}
.hero__dates .dash { margin: 0 .5rem; color: var(--accent); }

.hero__epitaph {
  margin: 1.8rem 0 0;
  max-width: 30rem;
  font-style: italic;
  font-family: var(--serif);
  font-size: 1.22rem;
  line-height: 1.6;
  color: rgba(242, 237, 229, .62);
}

.hero__scroll {
  position: absolute;
  left: 50%;
  bottom: 2.6rem;
  translate: -50% 0;
  width: 1px;
  height: 3rem;
  border: 0;
  background: linear-gradient(to bottom, transparent, rgba(242, 237, 229, .45));
}

/* ============================================================
   СЕКЦИИ
   ============================================================ */

.section { padding: clamp(4rem, 11vh, 7.5rem) 0; }
.section--alt { background: var(--paper-alt); }

.section__label {
  margin: 0 0 .8rem;
  font-size: .7rem;
  letter-spacing: .3em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.section__title {
  margin: 0 0 2.6rem;
  font-family: var(--serif);
  font-weight: 300;
  font-size: clamp(2rem, 4.5vw, 2.9rem);
  line-height: 1.15;
}

/* ---- текст биографии ---- */

.prose { max-width: var(--measure); }
.prose p { margin: 0 0 1.35rem; color: var(--ink-soft); }
.prose strong { font-weight: 500; color: var(--ink); }

.prose__closing {
  margin-top: 2.2rem;
  padding-top: 1.6rem;
  border-top: 1px solid var(--line);
  font-family: var(--serif);
  font-size: 1.22rem;
  font-style: italic;
  color: var(--ink);
}

/* ---- вехи ---- */

.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0;
  border-top: 1px solid var(--line);
}

.timeline__item {
  display: grid;
  gap: .25rem 2.5rem;
  padding: 1.7rem 0;
  border-bottom: 1px solid var(--line);
}

@media (min-width: 680px) {
  .timeline__item {
    grid-template-columns: 7rem 1fr;
  }
  .timeline__year { grid-row: span 2; }
}

.timeline__year {
  font-family: var(--serif);
  font-size: 1.6rem;
  color: var(--accent);
  line-height: 1.2;
}

.timeline__head {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 500;
  letter-spacing: .01em;
}

.timeline__body { margin: 0; color: var(--ink-soft); max-width: var(--measure); }

/* ---- галерея ---- */

.gallery {
  display: grid;
  gap: clamp(1rem, 2.5vw, 1.8rem);
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr));
}

.gallery__item { margin: 0; }

.gallery__item img {
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  background: var(--paper-alt);
  transition: transform .5s ease;
}

.gallery__link { display: block; cursor: zoom-in; overflow: hidden; }
.gallery__item:hover img { transform: scale(1.03); }

.gallery__item figcaption {
  margin-top: .7rem;
  font-size: .82rem;
  letter-spacing: .02em;
  color: var(--ink-faint);
}

/* ---- воспоминания ---- */

.memories {
  display: grid;
  gap: clamp(1rem, 2.5vw, 1.6rem);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr));
}

.memory {
  margin: 0;
  padding: 1.9rem 1.8rem;
  background: var(--paper);
  border: 1px solid var(--line);
}

.memory p {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.16rem;
  line-height: 1.6;
  color: var(--ink);
}

.memory footer {
  margin-top: 1.2rem;
  font-size: .82rem;
  letter-spacing: .04em;
  color: var(--ink-faint);
}

/* ============================================================
   СВЕЧА
   ============================================================ */

.candle-section { text-align: center; }
.candle-section .section__label,
.candle-section .section__title { text-align: center; }

.candle-section__text { margin: 0 0 2.5rem; color: var(--ink-soft); }

.candle {
  appearance: none;
  border: 0;
  background: none;
  cursor: pointer;
  display: inline-grid;
  justify-items: center;
  gap: .4rem;
  padding: 1rem 1.5rem;
  font: inherit;
  color: var(--ink-faint);
}

.candle__flame {
  width: 14px;
  height: 22px;
  border-radius: 50% 50% 46% 46% / 62% 62% 38% 38%;
  background: radial-gradient(circle at 50% 70%, #fff6d8, #f0b03f 55%, rgba(240, 176, 63, 0) 72%);
  opacity: 0;
  transform-origin: 50% 100%;
  transition: opacity .6s ease;
}

.candle__body {
  width: 26px;
  height: 72px;
  border-radius: 3px 3px 2px 2px;
  background: linear-gradient(to right, #e4d9c6, #fbf7ef 45%, #ddd1bb);
  box-shadow: 0 10px 24px -14px rgba(0, 0, 0, .5);
}

.candle__label {
  margin-top: .6rem;
  font-size: .72rem;
  letter-spacing: .26em;
  text-transform: uppercase;
}

/* горящее состояние */
.candle.is-lit .candle__flame {
  opacity: 1;
  animation: flicker 2.4s ease-in-out infinite;
}
.candle.is-lit .candle__body {
  box-shadow: 0 -10px 40px -6px rgba(240, 176, 63, .45),
              0 10px 24px -14px rgba(0, 0, 0, .5);
}
.candle.is-lit { color: var(--accent); }

@keyframes flicker {
  0%, 100% { transform: scale(1) rotate(-1deg); opacity: 1; }
  50%      { transform: scale(1.07, 1.12) rotate(1.5deg); opacity: .88; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .candle.is-lit .candle__flame { animation: none; }
  .gallery__item img { transition: none; }
}

.candle-section__count {
  margin: 1.6rem 0 0;
  min-height: 1.6em;
  font-family: var(--serif);
  font-size: 1.1rem;
  font-style: italic;
  color: var(--ink-soft);
}

/* ============================================================
   ПОДВАЛ
   ============================================================ */

.footer {
  padding: 3.5rem 0 4rem;
  background: var(--hero-bg);
  color: rgba(242, 237, 229, .6);
  text-align: center;
}

.footer__name {
  margin: 0 0 .7rem;
  font-family: var(--serif);
  font-size: 1.3rem;
  color: var(--hero-ink);
}

.footer__note { margin: 0; font-size: .88rem; }
.footer a { color: var(--accent); }
.footer a:hover { color: var(--hero-ink); }

/* появление секций при прокрутке */
.reveal { opacity: 0; transform: translateY(18px); }
.reveal.is-visible {
  opacity: 1;
  transform: none;
  transition: opacity .9s ease, transform .9s ease;
}
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; }
}

/* ============================================================
   СПОГАДИ: форма додавання й порожній стан
   ============================================================ */

.memory p { overflow-wrap: anywhere; }

.memories-empty {
  margin: 0 0 1rem;
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.25rem;
  color: var(--ink-soft);
}

.memory-share {
  max-width: 42rem;
  margin-top: 3rem;
  padding-top: 2.4rem;
  border-top: 1px solid var(--line);
}
.memories-empty + .memory-share { margin-top: 1.5rem; border-top: 0; padding-top: 0; }

.memory-share__title {
  margin: 0 0 1.4rem;
  font-family: var(--serif);
  font-weight: 400;
  font-size: 1.8rem;
}
.memory-share__closed { margin: 0; color: var(--ink-soft); }

.memory-form { display: grid; gap: 1.15rem; }
.memory-form__row {
  display: grid;
  gap: 1.15rem;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
}

.field { display: block; }
.field__label {
  display: block;
  margin-bottom: .35rem;
  font-size: .72rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.field input,
.field textarea {
  width: 100%;
  padding: .75rem .9rem;
  font: inherit;
  font-size: 1rem;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 0;
}
.field textarea { resize: vertical; line-height: 1.6; }
.field input:focus,
.field textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }

/* пастка для ботів: людина це поле не бачить */
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

.btn {
  justify-self: start;
  padding: .8rem 1.8rem;
  font: inherit;
  font-size: .8rem;
  font-weight: 500;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--paper);
  background: var(--hero-bg);
  border: 1px solid var(--hero-bg);
  cursor: pointer;
  transition: background .3s ease, border-color .3s ease;
}
.btn:hover { background: var(--accent); border-color: var(--accent); }
.btn[disabled] { opacity: .55; cursor: wait; }

.memory-form__note { margin: 0; font-size: .86rem; color: var(--ink-faint); }
.memory-form__msg {
  margin: 0;
  min-height: 1.5em;
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.2rem;
  color: var(--ink-soft);
}
.memory-form__msg.is-error { color: #9b3a2e; }


/* ---- перегляд фотографії на весь екран ---- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 3.5rem 1rem 2rem;
  background: rgba(12, 10, 8, .94);
}
.lightbox[hidden] { display: none; }
.lightbox__img {
  max-width: min(94vw, 70rem);
  max-height: 78vh;
  width: auto;
  height: auto;
  box-shadow: 0 30px 80px -30px #000;
}
.lightbox__cap {
  margin: 0;
  min-height: 1.4em;
  max-width: 40rem;
  text-align: center;
  font-family: var(--serif);
  font-size: 1.15rem;
  color: rgba(242, 237, 229, .8);
}
.lightbox__btn {
  position: absolute;
  display: grid;
  place-items: center;
  width: 3rem;
  height: 3rem;
  border: 1px solid rgba(242, 237, 229, .3);
  border-radius: 50%;
  background: rgba(20, 17, 15, .6);
  color: #f2ede5;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}
.lightbox__btn:hover, .lightbox__btn:focus-visible { border-color: #c9a45e; color: #c9a45e; outline: none; }
.lightbox__close { top: 1rem; right: 1rem; }
.lightbox__prev  { left: 1rem; top: 50%; translate: 0 -50%; }
.lightbox__next  { right: 1rem; top: 50%; translate: 0 -50%; }
@media (max-width: 600px) {
  .lightbox__prev, .lightbox__next { top: auto; bottom: 1rem; translate: none; }
}
body.has-lightbox { overflow: hidden; }
