/*
 * Local @font-face families.
 *
 * Cyrillic coverage (checked with fontTools cmap):
 *   OK  — EB Garamond, Old Standard TT
 *   NO  — Libre Baskerville, Libre Caslon Text, Sorts Mill Goudy
 *         (excluded from the reader typography selector)
 */
@font-face {
  font-family: "EB Garamond";
  src: url("fonts/EBGaramond-VariableFont_wght.ttf") format("truetype");
  font-weight: 400 800;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "EB Garamond";
  src: url("fonts/EBGaramond-Italic-VariableFont_wght.ttf") format("truetype");
  font-weight: 400 800;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: "Old Standard TT";
  src: url("fonts/OldStandardTT-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Old Standard TT";
  src: url("fonts/OldStandardTT-Italic.ttf") format("truetype");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: "Old Standard TT";
  src: url("fonts/OldStandardTT-Bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Sorts Mill Goudy";
  src: url("fonts/SortsMillGoudy-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Sorts Mill Goudy";
  src: url("fonts/SortsMillGoudy-Italic.ttf") format("truetype");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

:root {
  --ink: #1c1611;
  --ink-soft: #3a3128;
  --ink-faint: #6b5c4a;
  --rule: #2a2218;
  --paper: #e6d7b4;
  --paper-deep: #d4c19a;
  --accent: #5c3d28;
  --focus: #8b5a2b;
  --font-display: "UnifrakturMaguntia", "Times New Roman", serif;
  /* Default reader face: Cyrillic-capable (Libre Baskerville has no Cyrillic). */
  --font-body: "EB Garamond", "Palatino Linotype", Palatino, serif;
  /*
   * Poem title font (Sorts Mill Goudy Italic) — English titles only.
   * ROLLBACK: set this to var(--font-display) and remove font-style: italic
   * from .poem-page__title in poem.css.
   */
  --font-poem-title: "Sorts Mill Goudy", Georgia, serif;
  --poem-font: var(--font-body);
  --poem-font-size: 24px;
  --poem-font-weight: 400;
  --max: 68rem;
  --hero-pad: clamp(1.5rem, 4vw, 3.5rem);
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: calc(clamp(1.05rem, 0.95rem + 0.4vw, 1.2rem) - 2pt);
  line-height: 1.45;
  background: var(--paper);
  position: relative;
}

.paper {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-color: var(--paper);
  background-image: url("assets/paper-texture.png");
  background-size: 420px auto;
  background-repeat: repeat;
  opacity: 1;
  pointer-events: none;
}

/* Single book-like fold, always centered — not part of the tiled texture */
.paper::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: min(7rem, 18vw);
  transform: translateX(-50%);
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(70, 48, 24, 0.045) 38%,
    rgba(40, 28, 14, 0.14) 49.2%,
    rgba(30, 22, 12, 0.2) 50%,
    rgba(40, 28, 14, 0.12) 50.8%,
    rgba(90, 70, 40, 0.04) 62%,
    transparent 100%
  );
  pointer-events: none;
}

.paper::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 0%, rgba(90, 60, 30, 0.08), transparent 45%),
    radial-gradient(ellipse at 90% 80%, rgba(60, 40, 20, 0.1), transparent 50%);
  pointer-events: none;
}

@media (max-width: 799px) {
  .paper::before {
    content: none;
  }
}

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

a {
  color: var(--accent);
  text-underline-offset: 0.18em;
}

a:hover {
  color: var(--ink);
}

.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;
}

/* —— Hero: portrait on left page, copy centered on right page —— */

.hero {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  align-items: center;
  padding: var(--hero-pad) 0 3rem;
}

.hero__inner {
  width: 100%;
  display: grid;
  gap: clamp(1.5rem, 3vw, 2.5rem);
  justify-items: center;
  padding-inline: var(--hero-pad);
}

@media (min-width: 860px) {
  .hero__inner {
    grid-template-columns: 1fr 1fr;
    align-items: center;
    gap: 0;
    padding-inline: 0;
  }
}

.portrait {
  margin: 0;
  width: min(100%, 21rem);
  opacity: 0;
  transform: translateY(0.8rem);
  animation: rise 1.1s ease 0.15s forwards;
}

@media (min-width: 860px) {
  .portrait {
    width: min(92%, 26rem);
    justify-self: end;
    margin-right: clamp(0.75rem, 2vw, 1.75rem);
  }
}

.portrait__frame {
  padding: 0.45rem;
  border: 1px solid var(--rule);
  box-shadow: inset 0 0 0 0.28rem var(--paper), inset 0 0 0 calc(0.28rem + 1px) var(--rule);
  background: color-mix(in srgb, var(--paper) 70%, white);
}

.portrait__frame img {
  width: 100%;
  display: block;
  filter: contrast(1.05) sepia(0.12);
}

.hero__copy {
  width: min(100%, 34rem);
  text-align: center;
  display: grid;
  justify-items: center;
}

@media (min-width: 860px) {
  .hero__copy {
    justify-self: start;
    width: min(92% - var(--hero-pad), 36rem);
    margin-left: clamp(0.75rem, 2vw, 1.75rem);
  }
}

.brand {
  margin: 0;
  width: min(100%, 30rem);
  display: grid;
  gap: 0.35rem;
  justify-items: center;
  text-align: center;
  color: var(--ink);
  opacity: 0;
  transform: translateY(0.6rem);
  animation: rise 1s ease 0.35s forwards;
}

.brand__name {
  font-family: var(--font-poem-title);
  font-size: clamp(2.35rem, 1.6rem + 3.2vw, 3.55rem);
  font-weight: 600;
  font-style: normal;
  font-variant-caps: small-caps;
  font-feature-settings: "smcp" 1;
  line-height: 1.05;
  letter-spacing: 0.04em;
}

.brand__born {
  font-family: var(--font-body);
  font-size: clamp(1.05rem, 0.92rem + 0.55vw, 1.35rem);
  font-style: italic;
  font-weight: 400;
  line-height: 1.25;
  color: var(--ink);
}

.brand__motto {
  max-width: 28rem;
  margin-top: 0.15rem;
  font-family: var(--font-body);
  font-size: clamp(0.68rem, 0.58rem + 0.35vw, 0.82rem);
  font-weight: 600;
  font-style: normal;
  line-height: 1.35;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.signature {
  width: min(60%, 16rem);
  margin: 1.15rem auto 0;
  opacity: 0;
  filter: drop-shadow(0 0 0 transparent);
  animation: signature-in 1.2s ease 0.7s forwards;
}

.hero__lede {
  margin: 1.35rem 0 0;
  max-width: 30rem;
  color: var(--ink-soft);
  font-size: 1.28em;
  font-style: italic;
  opacity: 0;
  animation: rise 0.9s ease 0.9s forwards;
}

.hero__cta {
  display: inline-block;
  margin-top: 1.65rem;
  margin-right: 1.25rem;
  padding: 0.35rem 0;
  font-family: var(--font-body);
  font-size: 1.2em;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--ink);
  border-bottom: 1px solid var(--rule);
  opacity: 0;
  animation: rise 0.9s ease 1.05s forwards;
}

.hero__cta:hover {
  border-bottom-color: var(--accent);
  color: var(--accent);
}

.hero__cta--secondary {
  font-weight: 400;
  letter-spacing: 0.03em;
  animation-delay: 1.15s;
}

@keyframes rise {
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes signature-in {
  from {
    opacity: 0;
    transform: translateY(0.4rem) scale(0.98);
  }
  to {
    opacity: 0.92;
    transform: none;
  }
}

/* —— Index —— */

.index {
  width: min(100% - 2rem, 46rem);
  margin: 0 auto 4rem;
  padding-top: 1rem;
  scroll-margin-top: 1.5rem;
}

.index__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.85rem;
  border-top: 1px solid color-mix(in srgb, var(--rule) 55%, transparent);
  padding-top: 1.75rem;
}

.index__title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2rem, 1.4rem + 2vw, 2.75rem);
  font-weight: 400;
  letter-spacing: 0.02em;
}

.index__count {
  margin: 0;
  color: var(--ink-faint);
  font-size: 0.95em;
  font-variant-numeric: oldstyle-nums;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: center;
  margin-bottom: 1.25rem;
}

.toolbar__search {
  flex: 1 1 12rem;
}

.toolbar__search input,
.toolbar__translator select {
  width: 100%;
  padding: 0.45rem 0.65rem;
  border: 1px solid color-mix(in srgb, var(--rule) 45%, transparent);
  background: color-mix(in srgb, var(--paper) 55%, white);
  color: var(--ink);
  font: inherit;
  font-style: italic;
}

.toolbar__search input::placeholder {
  color: var(--ink-faint);
}

.toolbar__search input:focus,
.toolbar__translator select:focus {
  outline: 2px solid color-mix(in srgb, var(--focus) 55%, transparent);
  outline-offset: 1px;
}

.toolbar__translator {
  flex: 1 1 11rem;
  min-width: 10rem;
}

.toolbar__translator select {
  font-style: normal;
  cursor: pointer;
}

.toolbar__sorts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.sort {
  appearance: none;
  border: 1px solid color-mix(in srgb, var(--rule) 40%, transparent);
  background: transparent;
  color: var(--ink-soft);
  font: inherit;
  font-size: 0.92em;
  letter-spacing: 0.03em;
  padding: 0.3rem 0.65rem;
  cursor: pointer;
  transition: background 160ms ease, color 160ms ease, border-color 160ms ease;
}

.sort:hover {
  border-color: var(--rule);
  color: var(--ink);
}

.sort.is-active {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}

.sort__dir {
  display: inline-block;
  min-width: 0.75em;
  font-style: normal;
}

.sort__dir[hidden] {
  display: none;
}

.toolbar__filter {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--ink-soft);
  font-size: 0.95em;
  cursor: pointer;
  user-select: none;
}

.toolbar__filter input {
  accent-color: var(--accent);
}

.poem-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.poem-list__item {
  border-bottom: 1px solid color-mix(in srgb, var(--rule) 22%, transparent);
  opacity: 0;
  transform: translateY(0.35rem);
  animation: rise 0.45s ease forwards;
}

.poem-list__link {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.35rem 1rem;
  align-items: baseline;
  padding: 0.7rem 0.15rem;
  text-decoration: none;
  color: inherit;
  transition: background 140ms ease, padding-left 140ms ease;
}

.poem-list__link:hover {
  background: color-mix(in srgb, var(--paper-deep) 35%, transparent);
  padding-left: 0.35rem;
}

.poem-list__title {
  font-size: 1.12em;
  font-weight: 600;
}

.poem-list__meta {
  color: var(--ink-faint);
  font-size: 0.92em;
  font-variant-numeric: oldstyle-nums;
  white-space: nowrap;
}

.poem-list__ru {
  grid-column: 1 / -1;
  font-size: 0.95em;
  color: var(--ink-soft);
  font-style: italic;
}

.poem-list__translator {
  grid-column: 1 / -1;
  font-size: 0.9em;
  color: var(--ink-faint);
  font-style: italic;
}

.poem-list__badge {
  grid-column: 1 / -1;
  font-size: 0.88em;
  color: var(--accent);
  font-style: italic;
}

.poem-list__empty {
  padding: 2rem 0;
  color: var(--ink-faint);
  font-style: italic;
  text-align: center;
}

.site-footer {
  width: min(100% - 2rem, 46rem);
  margin: 0 auto 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid color-mix(in srgb, var(--rule) 35%, transparent);
  color: var(--ink-faint);
  font-size: 0.95em;
  font-style: italic;
  text-align: center;
}

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

.site-footer a:hover {
  text-decoration: underline;
}

.site-footer__license {
  margin: 0.65rem 0 0;
  font-size: 0.78em;
  font-style: normal;
  letter-spacing: 0.04em;
  opacity: 0.45;
}

.site-footer__license a {
  color: inherit;
}

.site-footer__license a:hover {
  opacity: 1;
  text-decoration: none;
  color: var(--ink-faint);
}

.site-footer__credit {
  margin: 0.35rem 0 0;
  font-size: 0.65em;
  font-style: normal;
  letter-spacing: 0.02em;
  opacity: 0.28;
  line-height: 1.3;
}

.site-footer__credit a {
  color: inherit;
  text-decoration: none;
}

.site-footer__credit a:hover {
  opacity: 1;
  color: var(--ink-faint);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .portrait,
  .brand,
  .signature,
  .hero__lede,
  .hero__cta,
  .poem-list__item {
    opacity: 1;
    transform: none;
  }
}
