/* ==========================================================================
   predki.info - memorial pages. Mobile-first, no frameworks.
   Tokens, fonts and base components are copied from poststone.by (src/css/style.css), not linked.
   ==========================================================================*/

/* ---------- Fonts (self-hosted, OFL) ---------- */
@font-face { font-family: "Manrope"; src: url("/static/fonts/manrope.woff2") format("woff2"); font-weight: 400 600; font-display: optional; }
@font-face { font-family: "Cormorant"; src: url("/static/fonts/cormorant.woff2") format("woff2"); font-weight: 500 600; font-display: optional; }
@font-face { font-family: "Cormorant"; src: url("/static/fonts/cormorant-italic.woff2") format("woff2"); font-weight: 500; font-style: italic; font-display: optional; }
@font-face { font-family: "Manrope Fallback"; src: local("Arial"), local("Helvetica"), local("Liberation Sans"); size-adjust: 101.5%; ascent-override: 105%; descent-override: 29.6%; line-gap-override: 0%; }
@font-face { font-family: "Cormorant Fallback"; src: local("Georgia"), local("Times New Roman"), local("Liberation Serif"); size-adjust: 87.8%; ascent-override: 105.3%; descent-override: 32.7%; line-gap-override: 0%; }

/* ---------- Tokens (same as poststone.by) ---------- */
:root {
  /* granite */
  --c-bg: #111214;
  --c-bg-alt: #16181b;
  --c-surface: #1d1f23;
  --c-surface-2: #25282d;
  --c-line: #33363c;
  /* text */
  --c-text: #ebe7e0;
  --c-text-muted: #a8a39b;
  --c-text-dim: #958f86;
  /* bronze */
  --c-accent: #b8925a;
  --c-accent-hi: #d6b47e;
  --c-accent-lo: #8a6a3d;
  --c-on-accent: #16120c;

  --f-serif: "Cormorant", "Cormorant Fallback", Georgia, serif;
  --f-sans: "Manrope", "Manrope Fallback", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;

  /* typography: fluid 320px -> 1920px */
  --fs-body: clamp(1.0625rem, 1rem + 0.25vw, 1.1875rem);
  --fs-small: 0.875rem;
  --fs-kicker: 0.8125rem;
  --fs-h1: clamp(2.375rem, 1.6rem + 3.4vw, 4.75rem);
  --fs-h2: clamp(1.875rem, 1.4rem + 2vw, 3.25rem);
  --fs-h3: clamp(1.375rem, 1.2rem + 0.7vw, 1.75rem);
  --lh-body: 1.65;
  --lh-tight: 1.08;

  /* spacing */
  --s-1: 0.25rem;
  --s-2: 0.5rem;
  --s-3: 0.75rem;
  --s-4: 1rem;
  --s-5: 1.5rem;
  --s-6: 2rem;
  --s-7: 3rem;
  --s-8: 4.5rem;
  --s-section: clamp(3.5rem, 2rem + 6vw, 8rem);
  --gutter: clamp(1rem, 0.6rem + 2vw, 2.5rem);
  --container: 78rem;
  --measure: 40rem;

  --radius: 2px;
  --header-h: 4rem;
  --ease: cubic-bezier(.2, .7, .2, 1);
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: calc(var(--header-h) + var(--s-4)); }
body {
  margin: 0;
  min-width: 320px;
  background: var(--c-bg);
  color: var(--c-text);
  font: 400 var(--fs-body)/var(--lh-body) var(--f-sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, svg, video { display: block; max-width: 100%; height: auto; }
picture { display: contents; }
a { color: inherit; text-decoration-color: var(--c-accent-lo); text-underline-offset: .2em; text-decoration-thickness: 1px; }
a:hover { color: var(--c-accent-hi); text-decoration-color: currentColor; }
:focus-visible { outline: 2px solid var(--c-accent-hi); outline-offset: 3px; }
h1, h2, h3 { font-family: var(--f-serif); font-weight: 500; line-height: var(--lh-tight); letter-spacing: -.01em; margin: 0 0 var(--s-4); text-wrap: balance; }
h1 { font-size: var(--fs-h1); }
h2 { font-size: var(--fs-h2); }
h3 { font-size: var(--fs-h3); line-height: 1.2; }
p, ul, ol, dl { margin: 0 0 var(--s-4); }
p { text-wrap: pretty; }
strong { font-weight: 600; color: #fff; }
::selection { background: var(--c-accent); color: var(--c-on-accent); }

/* ---------- Layout ---------- */
.container { width: 100%; max-width: calc(var(--container) + 2 * var(--gutter)); margin-inline: auto; padding-inline: var(--gutter); }
.section { padding-block: var(--s-section); }
.section--alt { background: var(--c-bg-alt); }
.kicker {
  display: flex; align-items: center; gap: var(--s-3);
  margin: 0 0 var(--s-4);
  font: 600 var(--fs-kicker)/1.2 var(--f-sans); letter-spacing: .16em; text-transform: uppercase;
  color: var(--c-accent);
}
.kicker::before { content: ""; width: 2rem; height: 1px; background: currentColor; }
.lead { font-size: clamp(1.125rem, 1.05rem + .35vw, 1.375rem); color: var(--c-text-muted); max-width: var(--measure); }
.prose { max-width: var(--measure); }
.prose p { color: var(--c-text-muted); }

.split { display: grid; gap: var(--s-7); align-items: center; }
@media (min-width: 56em) { .split { grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr); gap: var(--s-8); } .split--rev > :first-child { order: 2; } }
.split > :only-child { grid-column: 1 / -1; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: 3.25rem; padding: 0 var(--s-6);
  border: 1px solid var(--c-accent); border-radius: var(--radius);
  background: var(--c-accent); color: var(--c-on-accent);
  font: 600 1rem/1 var(--f-sans); letter-spacing: .02em; text-decoration: none;
  cursor: pointer; white-space: nowrap; transition: background .2s var(--ease), color .2s var(--ease), border-color .2s var(--ease);
}
.btn:hover { background: var(--c-accent-hi); border-color: var(--c-accent-hi); color: var(--c-on-accent); }
.btn--ghost { background: transparent; color: var(--c-text); border-color: var(--c-line); }
.btn--ghost:hover { background: transparent; border-color: var(--c-accent); color: var(--c-accent-hi); }
.btn-row { display: flex; flex-wrap: wrap; gap: var(--s-3); margin-top: var(--s-6); }
.btn-row .btn { flex: 1 1 14rem; }
@media (min-width: 40em) { .btn-row .btn { flex: 0 0 auto; } }

/* ---------- Header: PostStone logo and page sections (as on poststone.by) ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgb(17 18 20 / .92);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--c-line);
}
.site-header__bar { display: flex; align-items: center; gap: var(--s-4); min-height: var(--header-h); }
.logo { display: block; flex-shrink: 0; margin-right: auto; }
.logo img { display: block; width: auto; height: 2.25rem; }
.nav-toggle {
  display: none; align-items: center; justify-content: center; width: 3rem; height: 3rem;
  border: 1px solid var(--c-line); border-radius: var(--radius); background: transparent; color: var(--c-text); cursor: pointer;
}
.site-header:has(.site-nav li) .nav-toggle { display: inline-flex; }
.nav-toggle svg { width: 1.375rem; }
/* mobile menu: popover API, no JS */
.site-nav[popover] {
  inset: var(--header-h) 0 auto auto; margin: 0; width: min(100%, 24rem); max-height: calc(100dvh - var(--header-h));
  overflow: auto; padding: var(--s-5) var(--gutter) var(--s-6);
  border: 0; border-left: 1px solid var(--c-line); border-bottom: 1px solid var(--c-line);
  background: var(--c-bg); color: var(--c-text);
}
.site-nav[popover]::backdrop { background: rgb(0 0 0 / .55); }
.site-nav ul { list-style: none; margin: 0; padding: 0; }
.site-nav a { display: block; padding: var(--s-3) 0; font-size: 1.125rem; text-decoration: none; border-bottom: 1px solid var(--c-line); }
@media (min-width: 64em) {
  :root { --header-h: 5rem; }
  .site-header:has(.site-nav li) .nav-toggle { display: none; }
  .site-nav[popover] {
    display: block; position: static; inset: auto; width: auto; max-height: none; overflow: visible;
    padding: 0; border: 0; background: none;
  }
  .site-nav ul { display: flex; gap: var(--s-6); }
  .site-nav a { padding: var(--s-2) 0; font-size: .9375rem; white-space: nowrap; border: 0; border-bottom: 1px solid transparent; color: var(--c-text-muted); }
  .site-nav a:hover { color: var(--c-accent-hi); border-bottom-color: var(--c-accent); }
  .logo img { height: 2.625rem; }
}

/* ---------- First screen: main photo, name and dates below it, all within one screen ---------- */
.memorial-hero {
  position: relative; isolation: isolate;
  display: flex; align-items: center;
  min-height: calc(100svh - var(--header-h));
  padding-block: var(--s-5);
  text-align: center;
  background: radial-gradient(120% 80% at 50% 0%, var(--c-surface-2), var(--c-bg) 70%);
  border-bottom: 1px solid var(--c-line);
}
.memorial-hero--bg::before {
  content: ""; position: absolute; inset: 0; z-index: -2;
  background: var(--hero-bg) center / cover no-repeat;
}
.memorial-hero--bg::after {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: linear-gradient(180deg, rgb(17 18 20 / .6) 0%, rgb(17 18 20 / .8) 60%, var(--c-bg) 100%);
}
.memorial-hero__body { display: flex; flex-direction: column; align-items: center; }
/* without a main photo the name alone does not need a whole screen */
.memorial-hero--text { min-height: min(60svh, 34rem); }
.memorial-hero__photo { position: relative; margin: var(--s-3) var(--s-3) var(--s-5); }
.memorial-hero__photo img {
  /* whole photo in its own proportions; height is capped by the screen so the name and dates fit below */
  width: auto; height: auto; max-width: 100%; max-height: min(52svh, 40rem);
  background: var(--c-surface);
  box-shadow: 0 1.5rem 3rem rgb(0 0 0 / .45);
}
.memorial-hero__photo::before {
  content: ""; position: absolute; inset: calc(-1 * var(--s-3)); z-index: -1;
  border: 1px solid var(--c-accent-lo);
}
.memorial-hero h1 { margin-bottom: var(--s-3); font-size: clamp(2rem, 1.5rem + 2.6vw, 3.75rem); }
.memorial-hero__last { display: block; }
.memorial-hero__first { display: block; font-style: italic; color: var(--c-accent-hi); }
.memorial-hero__dates {
  display: flex; align-items: center; justify-content: center; gap: var(--s-4);
  margin: 0;
  font: 500 clamp(1.375rem, 1.15rem + .9vw, 2rem)/1 var(--f-serif); color: var(--c-text);
  font-variant-numeric: lining-nums;
}
.memorial-hero__dates span { width: 2.5rem; height: 1px; background: var(--c-accent); }

/* ---------- Epitaph ---------- */
.epitaph { padding-block: var(--s-7) 0; text-align: center; }
.epitaph p {
  max-width: var(--measure); margin: 0 auto;
  font: italic 500 clamp(1.375rem, 1.15rem + .8vw, 1.875rem)/1.4 var(--f-serif); color: var(--c-text-muted);
}
.epitaph p::before, .epitaph p::after { content: ""; display: block; width: 2.5rem; height: 1px; margin: var(--s-5) auto; background: var(--c-accent); }

/* ---------- Portrait, facts ---------- */
.portrait { position: relative; margin: 0 var(--s-4) var(--s-4) 0; max-width: 36rem; }
.portrait img { width: auto; max-width: 100%; max-height: 80svh; background: var(--c-surface); }
.portrait::before {
  content: ""; position: absolute; inset: var(--s-4) calc(-1 * var(--s-4)) calc(-1 * var(--s-4)) var(--s-4);
  border: 1px solid var(--c-accent-lo); z-index: -1;
}
.split .portrait { justify-self: center; }
.facts { display: grid; gap: var(--s-4) var(--s-6); grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr)); margin: 0 0 var(--s-6); padding: var(--s-5) 0; border-block: 1px solid var(--c-line); }
.facts:not(:has(div)) { display: none; }
.facts dt { font-size: var(--fs-small); color: var(--c-text-dim); }
.facts dd { margin: 0; font: 500 1.5rem/1.2 var(--f-serif); color: var(--c-accent-hi); }

/* ---------- Roles, creative work ---------- */
.roles { max-width: 52rem; margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--c-line); }
.roles li { padding: var(--s-3) 0; border-bottom: 1px solid var(--c-line); color: var(--c-text-muted); }

/* ---------- Album ---------- */
/* masonry columns: portrait and landscape photos are shown whole, never cropped */
.album { columns: 3 16rem; column-gap: var(--s-5); margin: var(--s-6) 0 0; padding: 0; list-style: none; }
.album li { break-inside: avoid; margin-bottom: var(--s-6); }
.album figure { margin: 0; }
.album a { display: block; overflow: hidden; background: var(--c-surface); cursor: zoom-in; }
.album img, .album video { width: 100%; height: auto; background: var(--c-surface); transition: transform .6s var(--ease); }
.album video { cursor: auto; }
@media (prefers-reduced-motion: no-preference) { .album a:hover img { transform: scale(1.035); } }
.album figcaption { padding-top: var(--s-3); font-size: .9375rem; }
.album figcaption strong { display: block; font: 500 1.25rem/1.25 var(--f-serif); color: var(--c-text); }
.album figcaption span { color: var(--c-text-muted); }

/* ---------- Lightbox (dialog, progressive enhancement) ---------- */
.lightbox { width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: rgb(8 8 9 / .96); color: var(--c-text); }
.lightbox::backdrop { background: transparent; }
.lightbox[open] { display: flex; align-items: center; justify-content: center; }
.lightbox img { width: 94vw; height: 86dvh; object-fit: contain; }
.lightbox button { position: absolute; display: grid; place-items: center; width: 3rem; height: 3rem; background: rgb(29 31 35 / .8); color: var(--c-text); border: 1px solid var(--c-line); font-size: 1.5rem; cursor: pointer; }
.lightbox [data-close] { top: var(--s-4); right: var(--s-4); }
.lightbox [data-prev] { left: var(--s-3); top: 50%; translate: 0 -50%; }
.lightbox [data-next] { right: var(--s-3); top: 50%; translate: 0 -50%; }
.lightbox p { position: absolute; bottom: var(--s-4); left: 0; right: 0; margin: 0; text-align: center; font-size: var(--fs-small); color: var(--c-text-muted); }

/* ---------- Home, 404 ---------- */
.intro { padding-top: clamp(4rem, 2rem + 10vw, 10rem); }
.features { display: grid; gap: var(--s-6); grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr)); list-style: none; margin: 0; padding: 0; }
.features li { padding-top: var(--s-5); border-top: 1px solid var(--c-accent-lo); }
.features h2 { font-size: 1.625rem; margin-bottom: var(--s-2); }
.features p { margin: 0; color: var(--c-text-muted); }
.features a { color: var(--c-accent-hi); }

/* ---------- Ad page ---------- */
.ad { background: var(--c-bg) url("/static/img/ad-bg.webp") center / cover no-repeat fixed; }
.ad-page { display: flex; min-height: 100svh; background: linear-gradient(180deg, rgb(17 18 20 / .55), rgb(17 18 20 / .9) 70%); }
.ad-page__body { display: flex; flex-direction: column; justify-content: center; padding-block: var(--s-7); }
.ad-page__logo { display: inline-block; margin-bottom: var(--s-7); }
.ad-page__logo img { width: auto; height: 3.5rem; }
.ad-page h1 { max-width: 14em; }
.ad-page .lead { color: var(--c-text); }
.ad-page__address { margin-top: var(--s-7); font-style: normal; }
.ad-page__address a { font-weight: 600; }
.ad-page__address span { display: block; font-size: var(--fs-small); color: var(--c-text-dim); }

/* ---------- Forms (as on poststone.by, larger: many authors are elderly) ---------- */
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.link-arrow { display: inline-flex; gap: var(--s-2); align-items: center; font-weight: 600; color: var(--c-accent-hi); text-decoration: none; }
.link-arrow::after { content: "→"; transition: transform .2s var(--ease); }
.link-arrow:hover::after { transform: translateX(4px); }
.form { display: grid; gap: var(--s-5); }
.form label { display: grid; gap: var(--s-2); font-size: 1.0625rem; color: var(--c-text); }
.form input, .form textarea {
  width: 100%; min-height: 3.5rem; padding: var(--s-3) var(--s-4);
  background: var(--c-bg); color: var(--c-text); border: 1px solid var(--c-line); border-radius: var(--radius);
  font: inherit; font-size: 1.125rem; line-height: 1.5;
}
.form textarea { resize: vertical; }
.form input:focus, .form textarea:focus { outline: none; border-color: var(--c-accent); box-shadow: 0 0 0 1px var(--c-accent); }
.form input::placeholder { color: var(--c-text-dim); }
.form__row { display: grid; gap: var(--s-5); }
@media (min-width: 40em) { .form__row { grid-template-columns: 1fr 1fr; } }
.form__hint { display: block; font-size: var(--fs-small); color: var(--c-text-muted); }
.btn--small { min-height: 2.75rem; padding: 0 var(--s-4); font-size: .9375rem; }
.btn--danger:hover { border-color: #b4574b; color: #e09a90; }

/* ---------- Notices ---------- */
.notice { margin: 0 0 var(--s-5); padding: var(--s-4) var(--s-5); background: var(--c-surface); border-left: 2px solid var(--c-line); }
.notice p { margin: 0; }
.notice--accent { border-left-color: var(--c-accent); }
.notice--error { border-left-color: #b4574b; }
.notice a { color: var(--c-accent-hi); }

/* ---------- New page ---------- */
.steps-list { max-width: var(--measure); margin: var(--s-6) 0; padding-left: 1.3em; color: var(--c-text-muted); }
.steps-list li { margin-bottom: var(--s-3); }
.steps-list li::marker { color: var(--c-accent); font-weight: 600; }

/* ---------- Editor: one column, big fields, save always at hand ---------- */
.editor__body { max-width: calc(46rem + 2 * var(--gutter)); padding-block: var(--s-7) 0; }
.editor__head h1 { font-size: var(--fs-h2); }
.editor__status { color: var(--c-text-muted); max-width: var(--measure); }
.editor__status a { color: var(--c-accent-hi); white-space: nowrap; }
.editor__form { margin-top: var(--s-6); }
.editor__block { display: grid; gap: var(--s-5); margin: 0; padding: var(--s-5); border: 1px solid var(--c-line); background: var(--c-bg-alt); scroll-margin-top: calc(var(--header-h) + var(--s-4)); }
.editor__block legend { padding: 0 var(--s-2); font: 500 1.5rem/1.2 var(--f-serif); color: var(--c-accent-hi); }
.editor__block--add { border-style: dashed; }
.editor__tools { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.editor__save {
  position: sticky; bottom: 0; z-index: 20;
  display: flex; flex-wrap: wrap; gap: var(--s-3);
  margin-inline: calc(-1 * var(--gutter)); padding: var(--s-4) var(--gutter) calc(var(--s-4) + env(safe-area-inset-bottom));
  background: rgb(17 18 20 / .96); border-top: 1px solid var(--c-line);
}
.editor__save .btn { flex: 1 1 12rem; }

/* ---------- Preview bar over a draft ---------- */
.preview-bar { background: var(--c-accent); color: var(--c-on-accent); }
.preview-bar__body { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-3); padding-block: var(--s-3); }
.preview-bar p { margin: 0; font-weight: 600; }
.preview-bar .btn--ghost { color: var(--c-on-accent); border-color: var(--c-on-accent); min-height: 2.75rem; }
.preview-bar .btn--ghost:hover { background: var(--c-on-accent); color: var(--c-accent-hi); }

/* ---------- Footer: workshop logo and credit line, quiet and small ---------- */
.site-footer { padding-block: var(--s-7); border-top: 1px solid var(--c-line); background: #0c0d0e; }
.site-footer__bar { display: flex; justify-content: center; }
.site-footer__brand { display: flex; flex-direction: column; align-items: center; gap: var(--s-3); text-decoration: none; font-size: var(--fs-small); color: var(--c-text-dim); text-align: center; }
.site-footer__brand img { width: auto; height: 2rem; opacity: .8; transition: opacity .2s var(--ease); }
.site-footer__brand:hover img { opacity: 1; }

/* ---------- Print: families print memorial pages ---------- */
@media print {
  .site-header, .lightbox, .site-footer__brand img { display: none !important; }
  body { background: #fff; color: #000; }
  .memorial-hero, .section--alt { background: none; min-height: 0; }
  .memorial-hero--bg::before, .memorial-hero--bg::after { content: none; }
  .prose p, .facts dd, .memorial-hero__first { color: #000; }
}
