:root {
  --ink: #1c1a18;
  --muted: #6b645c;
  --accent: #a41f1f;
  --gold: #c8952a;
  --paper: #fbf9f6;
  --rule: #e3ddd4;
  --measure: 42rem;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0 1.25rem 4rem;
  background: var(--paper);
  color: var(--ink);
  font: 1.0625rem/1.65 Georgia, "Times New Roman", serif;
}

main, header, footer { max-width: var(--measure); margin: 0 auto; }

p { margin: 0 0 .55rem; text-align: justify; hyphens: auto; }
/* Списки — по левому краю: пункты короткие, при выключке строки рвутся дырами. */
li { hyphens: auto; }

.hero {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 2.5rem 0 1.5rem;
}
.logo { width: 96px; height: auto; flex: none; }
.hero-text { min-width: 0; }
h1 {
  margin: 0 0 .3rem;
  font-size: clamp(1.5rem, 4.5vw, 2.25rem);
  line-height: 1.15;
  text-wrap: balance;
}
.epigraph { color: var(--muted); font-style: italic; margin: 0; text-align: left; }
.epigraph span { font-style: normal; font-size: .8125rem; margin-left: .5rem; }

.portrait {
  float: right;
  width: 200px;
  margin: 0 0 .75rem 1.25rem;
}
.portrait img { width: 100%; height: auto; display: block; border: 1px solid var(--rule); }
.portrait figcaption {
  margin-top: .35rem;
  font-size: .8125rem;
  color: var(--muted);
  text-align: center;
}

section { padding: 1.5rem 0; border-top: 1px solid var(--rule); }
section::after { content: ""; display: table; clear: both; }
h2 {
  font-size: 1.1875rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 .75rem;
}

ul { margin: 0 0 .55rem; }
.directions { padding-left: 1.1rem; }
.directions li { margin-bottom: .25rem; }

.materials { list-style: none; margin: 0; padding: 0; }
.material { padding: .85rem 0; border-bottom: 1px solid var(--rule); }
.material-title { border-bottom: 1px solid var(--gold); }
.material-note { margin: .35rem 0 0; color: var(--muted); font-size: .9375rem; }
.materials-all { margin-top: 1.25rem; }

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: .75rem;
}
.tile {
  padding: 0;
  border: 1px solid var(--rule);
  background: #fff;
  cursor: pointer;
  line-height: 0;
}
.tile img { width: 100%; height: 100%; object-fit: cover; aspect-ratio: 3 / 4; }
.tile:hover { border-color: var(--gold); }

a { color: var(--accent); }
.open { font-weight: bold; }

footer {
  padding-top: 2rem;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: .875rem;
  text-align: center;
}

/* Атрибут hidden обязан побеждать display:flex ниже, иначе лайтбокс не закрыть. */
.lightbox[hidden] { display: none; }

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(20, 18, 16, .92);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 1rem;
  padding: 2rem;
  z-index: 10;
}
.lightbox img { max-width: 100%; max-height: 80vh; object-fit: contain; }
.lightbox-caption { color: #f4efe8; font-size: .9375rem; text-align: center; }
.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: 0;
  color: #f4efe8;
  font-size: 2.5rem;
  cursor: pointer;
  padding: 1rem;
}
.lightbox-prev { left: 0; }
.lightbox-next { right: 0; }
.lightbox-close {
  position: absolute;
  top: .5rem;
  right: 1rem;
  background: none;
  border: 0;
  color: #f4efe8;
  font-size: 2rem;
  cursor: pointer;
}
