:root {
  --ink: #302b23;
  --paper: #e9dfc8;
  --red: #79352d;
  --gold: #e1bd83;
  --line: #a68e67;
  font: 100%/1.6 system-ui, sans-serif;
  color: var(--ink);
  background: #d3c3a6;
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; cursor: pointer; }
button, summary { min-height: 44px; }
a { color: var(--red); text-underline-offset: .2em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid #92512d; outline-offset: 4px; }
.entrance :focus-visible, .site-header :focus-visible { outline-color: var(--gold); }
.skip { position: fixed; top: .5rem; left: .5rem; z-index: 20; padding: .6rem 1rem; background: var(--paper); transform: translateY(-150%); }
.skip:focus { transform: none; }
h1, h2, h3 { font-family: Georgia, 'Times New Roman', serif; line-height: 1.07; margin: 0 0 .45em; }
p { margin: 0 0 .85rem; }
.eyebrow { font-size: .875rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; }
.entrance {
  overflow-x: clip;
  min-height: 100svh;
  display: grid;
  grid-template-rows: auto 1fr;
  padding: 0 clamp(1.15rem, 5vw, 5rem);
  color: #f7e9cc;
  background: radial-gradient(ellipse at 68% 48%, #251b0c13, #100e0bea), #211710 url('../assets/images/desk.webp') center / cover;
}
.entry-header {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 1.15rem 0;
  font-size: .875rem;
  letter-spacing: .12em;
  font-weight: 650;
  text-transform: uppercase;
  color: #e9d8b8;
}
.entry-header { border-bottom: 1px solid #e1bd835c; }
.archive-sign { display: grid; place-items: center; border: 1px solid #e1bd8388; width: 2.15rem; height: 2.15rem; color: var(--gold); }
.desk {
  position: relative;
  min-height: clamp(32rem, 70vh, 49rem);
  display: grid;
  align-items: center;
}
.entry-copy { width: 44%; z-index: 1; pointer-events: none; transition: opacity .25s; }
.entry-copy h1 { font-size: clamp(3rem, 5.3vw, 6rem); font-weight: 500; text-wrap: balance; }
.entry-description { color: #ead9bc; max-width: 33ch; font-size: clamp(1rem, 1.65vw, 1.28rem); }
.primary {
  background: var(--red);
  color: #fff3da;
  border: 1px solid #a5634e;
  padding: .7rem 1.3rem;
  font-weight: 700;
}
.primary:hover { background: #91473a; }
.folder-scene {
  --leaf: min(29vw, 27rem, 52vh);
  --angle: 0deg;
  position: absolute;
  top: 50%;
  left: 50%;
  width: calc(2 * var(--leaf));
  height: calc(var(--leaf) / .70);
  transform: translate(-15%, -50%);
  perspective: 1300px;
  pointer-events: none;
  transition: transform .68s cubic-bezier(.22,.7,.25,1);
}
.entrance.is-opening .folder-scene { transform: translate(-50%, -50%); }
.entrance.is-opening .entry-copy { opacity: 0; visibility: hidden; }
.board, .folder-cover { position: absolute; width: var(--leaf); height: 100%; }
.board { border-radius: 2.5% 2% 2% 2.5%; overflow: hidden; }
.board img { width: 100%; height: 100%; display: block; position: absolute; user-select: none; pointer-events: none; }
.board.fallback { background: linear-gradient(115deg,#ddc28e,#b38a54); border: 2px solid #85613d; }
.board img.failed { visibility: hidden; }
.folder-front.fallback::after { content: 'Исторический архив'; position: absolute; inset: 14% 12%; padding: 10%; border: 1px solid var(--red); color: var(--red); font: bold clamp(1rem,3vw,2.4rem)/1.1 Georgia,serif; }
.folder-base { box-shadow: 0 20px 36px #0009; }
.folder-cover {
  transform-style: preserve-3d;
  transform-origin: right center;
  transform: rotateY(var(--angle));
  transition: transform .68s cubic-bezier(.22,.7,.25,1);
  pointer-events: auto;
  touch-action: pan-y;
  cursor: grab;
}
.folder-cover.dragging { transition: none; cursor: grabbing; }
.folder-front, .folder-inner { backface-visibility: hidden; }
.folder-inner { transform: rotateY(180deg); }
.folder-label {
  position: absolute;
  inset: 18% 16% auto 13%;
  display: grid;
  gap: clamp(.3rem,1vw,.8rem);
  color: #46341f;
  border: 1px solid #8e6e44;
  padding: 11% 6%;
  text-align: center;
  font: 700 clamp(1rem,2.25vw,2rem)/1.12 Georgia,serif;
}
.folder-label small { font: 600 clamp(.58rem,1.1vw,.85rem)/1.25 system-ui,sans-serif; text-transform: uppercase; }
.site-header { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .6rem max(1rem, calc((100% - 74rem) / 2)); background: #251f17; color: #fff2d6; }
.site-header a { color: inherit; text-decoration: none; }
.brand { font: bold 1.14rem/1.15 Georgia,serif; }
nav { display: flex; align-items: center; gap: .3rem; flex-wrap: wrap; }
nav a { display: inline-flex; align-items: center; min-height: 44px; padding: .35rem .55rem; font-size: .875rem; }
nav a:hover, nav a[aria-current] { color: #f6cf8f; text-decoration: underline; }
#menu-button { color: inherit; background: transparent; border: 1px solid #ab9774; padding: 0 .7rem; }
main { width: min(74rem, calc(100% - 2rem)); margin: 1.2rem auto; display: grid; gap: 1.15rem; }
.paper { scroll-margin-top: 6rem; padding: clamp(1.15rem,4vw,3.8rem); background: var(--paper); border: 1px solid #a8926e; box-shadow: 0 .2rem .65rem #39271117; overflow-wrap: anywhere; }
.intro { border-top: 5px solid var(--red); }
.intro h2 { font-size: clamp(2.1rem,5.7vw,5rem); max-width: 15ch; overflow-wrap: normal; text-wrap: balance; }
.intro h2:focus { outline-offset: .35rem; }
.intro .eyebrow { color: var(--red); }
.lead { font: clamp(1.15rem,2.4vw,1.55rem)/1.45 Georgia,serif; max-width: 52ch; }
h2 { font-size: clamp(1.9rem,4.7vw,3.4rem); }
h3 { font-size: 1.45rem; }
.cards { display: grid; grid-template-columns: repeat(auto-fit,minmax(min(100%, 15rem),1fr)); gap: 1rem; }
.cards article { background: #f1e7d0; border: 1px solid #a99573; border-top: 3px solid var(--red); padding: 1.15rem; display: flex; flex-direction: column; align-items: start; }
.cards article :is(a,button):last-child { margin-top: auto; }
.filters { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
.filters button, .detail, .map-list button, .close, #reopen, .answer {
  color: var(--ink); background: #f6ecd7; border: 1px solid #9a805a; padding: .5rem .85rem;
}
button[aria-pressed="true"], .filters button:hover, .answer:hover, .detail:hover { background: var(--red); color: white; }
details { border-bottom: 1px solid var(--line); padding: .2rem 0 .35rem; }
summary { cursor: pointer; padding: .55rem 0; font-weight: 700; }
summary time { color: var(--red); margin-right: .55rem; }
details p { padding-left: 1.15rem; }
.map-layout { display: grid; grid-template-columns: 1.5fr 1fr; gap: 1rem; }
.map-canvas { position: relative; min-height: 260px; background: repeating-linear-gradient(90deg, transparent 0 31px, #725e3822 31px 32px), repeating-linear-gradient(0deg,#e1d3b2 0 31px,#cabb97 31px 32px); border: 1px solid var(--line); }
.map-canvas svg { position: absolute; width: 100%; height: 100%; }
.pin { position: absolute; transform: translate(-50%,-50%); width: 44px; height: 44px; color: #fff7df; background: #542721; border: 2px solid #f8efd9; border-radius: 50%; font-weight: 750; }
.pin[aria-pressed="true"] { background: #302b23; outline: 2px solid #302b23; }
.map-list { list-style: none; margin: 0 0 1rem; padding: 0; display: flex; flex-wrap: wrap; gap: .4rem; }
.quiz-options { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .85rem; }
.answer:disabled { cursor: default; opacity: .8; }
.answer.correct { background: #33553a; color: #fff; opacity: 1; }
.site-footer { background: #30271d; color: var(--paper); display: flex; justify-content: center; flex-wrap: wrap; gap: 1.25rem; align-items: center; padding: 1.4rem; }
.site-footer a { color: var(--paper); }
dialog { background: var(--paper); color: var(--ink); border: 1px solid var(--line); width: min(38rem,calc(100% - 2rem)); max-height: 85dvh; padding: clamp(1rem,4vw,2rem); }
dialog::backdrop { background: #0e0b08c9; }
dialog form { display: flex; justify-content: end; margin-bottom: .75rem; }
@media (max-width: 870px) {
  .site-header { flex-wrap: wrap; }
  nav { flex-basis: 100%; }
}
@media (max-width: 700px) {
  .entrance { background-position: 55% center; }
  .entry-header { letter-spacing: .07em; padding: .75rem 0; }
  .desk { min-height: 0; display: flex; flex-direction: column; justify-content: center; gap: .6rem; padding: 1.1rem 0 1.25rem; }
  .entry-copy { width: 100%; text-align: center; }
  .entry-copy h1 { font-size: clamp(2.35rem, 9.5vw, 4rem); max-width: 12ch; margin-inline: auto; }
  .entry-description { max-width: 35ch; margin-inline: auto; }
  .folder-scene { --leaf: min(42vw, 12.5rem); position: relative; top: auto; left: auto; transform: translateX(25%); }
  .entrance.is-opening .folder-scene { transform: translateX(0); }
  .map-layout { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0s !important; }
}
.intro { display: grid; grid-template-columns: 1.3fr 1fr; align-items: center; gap: clamp(1.4rem,4vw,4rem); }
.historical-photo { margin: 0; padding: .65rem; background: #f4e9d1; border: 1px solid var(--line); box-shadow: .2rem .35rem .7rem #3c2d222b; }
.photo-preview { display: block; }
.photo-preview img, #photo-dialog img { display: block; width: 100%; height: auto; }
.photo-preview span, figcaption { display: block; padding: .4rem .1rem .1rem; font-size: .875rem; }
#photo-dialog { width: min(63rem,calc(100% - 2rem)); }
#photo-dialog h2 { font-size: clamp(1.45rem,3vw,2.1rem); }
#photo-dialog p { margin: .7rem 0 0; }
@media (max-width: 760px) {
  .intro { grid-template-columns: 1fr; }
}

.folder-hint { color: #e0cba9; margin-top: 1.15rem; font-size: .875rem; }
.touch-hint { display: none; }
.folder-trigger {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  border-radius: 2.5%;
  background: transparent;
  cursor: inherit;
  touch-action: pan-y;
  backface-visibility: hidden;
  transform: translateZ(1px);
}
.folder-trigger:focus-visible { outline-offset: 6px; }
.entrance.is-zooming .folder-scene {
  transform: translate(-50%, -50%) scale(4.5);
  transform-origin: 25% 44%;
  transition: transform .5s cubic-bezier(.49, .01, .79, .44);
}
.entrance.is-zooming { animation: desk-departure .5s ease-in both; }
.portal-arrival { animation: portal-arrival .32s ease-out both; }
@keyframes desk-departure { 0%, 62% { opacity: 1; } 100% { opacity: 0; } }
@keyframes portal-arrival { from { opacity: .35; } to { opacity: 1; } }
@media (pointer: coarse) {
  .mouse-hint { display: none; }
  .touch-hint { display: inline; }
}
@media (max-width: 700px) {
  .entrance.is-zooming .folder-scene { transform: scale(5.5); }
}
@media (prefers-reduced-motion: reduce) {
  .portal-arrival { animation: none; }
}

.folder-drag-area {
  --drag-margin: clamp(24px, 5vw, 72px);
  position: absolute;
  inset: calc(-1 * var(--drag-margin)) auto calc(-1 * var(--drag-margin)) calc(-1 * var(--drag-margin));
  width: calc(var(--leaf) + 2 * var(--drag-margin));
  pointer-events: auto;
  touch-action: pan-y;
}
