@font-face {
  font-family: "Vazirmatn";
  src: url("../fonts/vazirmatn-var.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "Naskh";
  src: url("../fonts/naskh-400.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Naskh";
  src: url("../fonts/naskh-600.woff2") format("woff2");
  font-weight: 600;
  font-display: swap;
}
/* جای فونت ماشین تحریر:
@font-face { font-family: "Tahrir"; src: url("../fonts/tahrir.woff2") format("woff2"); font-display: swap; }
سپس --font-display: "Tahrir", "Naskh", serif;  */

:root {
  --bg: #e6e6e5;
  --ink: #1a1614;
  --ink-2: #57504c;
  --ink-3: #8b827c;
  --red: #971d1f;
  --line: rgba(26, 22, 20, .16);
  --font-display: "Naskh", serif;
  --gutter-x: 16vw;      /* the channel the glasses falls down */
  --glasses-w: 28vw;
  color-scheme: light;
}
@media (min-width: 860px) {
  :root { --gutter-x: 18vw; --glasses-w: 16vw; }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: auto; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Vazirmatn", Tahoma, sans-serif;
  line-height: 1.95;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
img { display: block; max-width: 100%; }
h1, h2, h3 { margin: 0; font-weight: 600; }
p { margin: 0; }

/* ---------- the falling glasses ---------- */
.faller {
  position: fixed;
  top: 0;
  left: var(--gutter-x);
  width: var(--glasses-w);
  aspect-ratio: 1;
  transform: translate(-50%, 12vh);
  z-index: 0;
  pointer-events: none;
  will-change: transform;
}
.faller > div { position: absolute; inset: 0; }
.faller img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  visibility: hidden;
}
.faller img.on { visibility: visible; }
.faller.landed { display: none; }

/* ---------- layout ---------- */
main { position: relative; z-index: 1; }
.screen {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 12vh 6vw 12vh calc(var(--gutter-x) + var(--glasses-w) * .42);
  position: relative;
}
@media (min-width: 860px) {
  .screen { padding-left: calc(var(--gutter-x) + var(--glasses-w) * .6); padding-right: 22vw; }
}
.flow {
  padding: 14vh 0;
  position: relative;
}
.wrap {
  padding: 0 6vw 0 calc(var(--gutter-x) + var(--glasses-w) * .42);
  max-width: 900px;
}
@media (min-width: 860px) {
  .wrap { padding-left: calc(var(--gutter-x) + var(--glasses-w) * .6); padding-right: 22vw; max-width: none; }
}

/* ---------- hero ---------- */
.hero { justify-content: center; }
.title { width: min(58vw, 340px); align-self: flex-start; }
.title img { width: 100%; }
.cue {
  margin-top: 8vh;
  font-size: .82rem;
  color: var(--ink-3);
  text-align: start;
}
.cue::after {
  content: "";
  display: block;
  width: 1px;
  height: 46px;
  margin: 10px auto 0 0;
  background: linear-gradient(var(--ink-3), transparent);
}
.cue.gone { opacity: 0; transition: opacity .4s; }

/* ---------- full-screen info cards ---------- */
.card .kicker { color: var(--red); font-size: .95rem; }
.card .big {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 6vw, 3rem);
  line-height: 1.5;
}
.card .latin {
  font-size: .9rem;
  color: var(--ink-3);
  direction: ltr;
  text-align: right;
  margin-top: 10px;
}
.motif {
  position: absolute;
  inset-inline-end: 4vw;
  bottom: 6vh;
  width: min(34vw, 260px);
  opacity: .16;
  pointer-events: none;
}
.motif-side { top: 10vh; bottom: auto; }

/* ---------- flow sections ---------- */
.flow h2 {
  font-family: var(--font-display);
  font-size: clamp(1.4rem, 4vw, 1.9rem);
  color: var(--red);
  margin-bottom: 8vh;
}
.chunk { margin-bottom: 9vh; }
.chunk:last-child { margin-bottom: 0; }
.chunk.center { text-align: center; }

.credits { margin: 0; }
.credit { padding: 10px 0; }
.credit dt { color: var(--ink-3); font-size: .82rem; line-height: 1.6; }
.credit dd { margin: 0; font-size: clamp(1.05rem, 3.4vw, 1.35rem); font-family: var(--font-display); }

.names {
  font-family: var(--font-display);
  font-size: clamp(1.05rem, 3.6vw, 1.3rem);
  line-height: 2.4;
  color: var(--ink-2);
}
.names.close { color: var(--ink); }

.ev { font-size: clamp(1.05rem, 3.6vw, 1.3rem); font-family: var(--font-display); }
.yr { color: var(--red); margin-inline-end: 14px; }
.ev-cast { color: var(--ink-2); font-size: .95rem; margin-top: 6px; }
.ev-note { color: var(--ink-3); font-size: .85rem; margin-top: 4px; }
.awards {
  margin-top: 16px;
  padding: 14px 18px;
  border: 1px solid var(--red);
  color: var(--red);
  max-width: 40ch;
}
.awards p { font-size: .95rem; line-height: 2; }

/* ---------- notes ---------- */
.prompt {
  font-family: var(--font-display);
  font-size: clamp(1.1rem, 3.8vw, 1.4rem);
  line-height: 2.1;
  max-width: 34ch;
  margin-bottom: 10vh;
}
.note-list { display: block; }
.note {
  margin-bottom: 7vh;
  max-width: 46ch;
  font-family: var(--font-display);
  font-size: clamp(1rem, 3.4vw, 1.2rem);
  line-height: 2.2;
  color: var(--ink-2);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.note::before {
  content: "";
  display: block;
  width: 26px;
  height: 1px;
  background: var(--red);
  margin-bottom: 14px;
}
.note-state { color: var(--ink-3); font-size: .9rem; }

.link-btn, .send, .close {
  font: inherit;
  cursor: pointer;
  background: none;
  border: 0;
}
.link-btn {
  color: var(--red);
  border-bottom: 1px solid var(--red);
  padding: 4px 0;
  font-size: .95rem;
}
.link-btn:focus-visible, .send:focus-visible, .close:focus-visible,
textarea:focus-visible { outline: 2px solid var(--red); outline-offset: 3px; }

.writer { max-width: 46ch; position: relative; }
.lbl { display: block; font-size: .82rem; color: var(--ink-3); margin-bottom: 10px; }
.paper {
  font-size: 1.05rem;
  background: rgba(255, 255, 255, .45);
  border: 1px solid var(--line);
  padding: 16px 18px;
}
.paper:focus-within { border-color: var(--red); }
.paper textarea {
  width: 100%;
  border: 0;
  background: transparent;
  resize: vertical;
  font-family: var(--font-display);
  font-size: 1em;
  line-height: 2.1;
  color: var(--ink);
  outline: none;
  padding: 0;
}
.hp {              /* تله‌ی ربات — در RTL نباید با left منفی مخفی شود */
  position: absolute;
  width: 1px; height: 1px;
  opacity: 0;
  overflow: hidden;
  clip-path: inset(50%);
  pointer-events: none;
}
.writer-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
  gap: 16px;
}
.counter { font-size: .78rem; color: var(--ink-3); }
.send {
  background: var(--red);
  color: #efeeec;
  padding: 10px 22px;
  font-size: .95rem;
}
.send[disabled] { opacity: .5; cursor: default; }
.send-state { margin-top: 12px; font-size: .88rem; color: var(--ink-2); min-height: 1.4em; }

/* ---------- bottom sheet ---------- */
.sheet { position: fixed; inset: 0; z-index: 50; }
.sheet-back { position: absolute; inset: 0; background: rgba(26, 22, 20, .45); }
.sheet-body {
  position: absolute;
  inset: auto 0 0 0;
  max-height: 86svh;
  background: var(--bg);
  border-top: 2px solid var(--ink);
  display: flex;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
@media (min-width: 860px) {
  .sheet-body { inset: 6vh 50% 6vh auto; transform: translateX(-50%); width: min(720px, 90vw); border: 2px solid var(--ink); max-height: 88vh; }
}
.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px;
  border-bottom: 1px solid var(--line);
}
.sheet-head h3 { font-family: var(--font-display); font-size: 1.1rem; }
.close { color: var(--ink-2); font-size: .9rem; border-bottom: 1px solid var(--line); }
.sheet-scroll { overflow-y: auto; padding: 24px 22px 40px; -webkit-overflow-scrolling: touch; }
.sheet-scroll .note { margin-bottom: 34px; max-width: none; }
body.locked { overflow: hidden; }

/* ---------- ending ---------- */
.ending {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  padding-bottom: 8vh;
}
.ending { position: relative; }
.set-pos {                      /* کتاب دقیقاً زیر مسیر سقوط عینک */
  position: absolute;
  left: 50%;
  bottom: 30vh;
  width: 78vw;
  max-width: 520px;
  transform: translateX(-50%);
}
@media (min-width: 860px) {
  .set-pos { width: 32vw; bottom: 26vh; }
}
.set {
  position: relative;
  width: 100%;
  aspect-ratio: 1200 / 830;
}
.set img.book { position: absolute; inset: 0; width: 100%; height: 100%; }
.book-cracked { visibility: hidden; }
.set.cracked .book-intact { visibility: hidden; }
.set.cracked .book-cracked { visibility: visible; }
.rest { position: absolute; width: 48%; left: 25%; top: -19%; visibility: hidden; }
.set.cracked .rest { visibility: visible; }
.set.hit { animation: shake .3s steps(4) 1; }
@keyframes shake {
  0% { transform: translate(0, 0); }
  30% { transform: translate(-1.2%, 1.4%); }
  60% { transform: translate(.9%, -.7%); }
  100% { transform: translate(0, 0); }
}
.logos { margin-top: auto; width: min(52vw, 220px); opacity: .9; }

/* ---------- reveal on scroll ---------- */
.js .reveal { opacity: 0; transform: translateY(18px); }
.js .reveal.in {
  opacity: 1;
  transform: none;
  transition: opacity .7s ease, transform .7s ease;
}
.js .reveal.out { opacity: 0; transition: opacity .5s ease; }

@media (prefers-reduced-motion: reduce) {
  .js .reveal, .js .reveal.in, .js .reveal.out { opacity: 1; transform: none; transition: none; }
  .set.hit { animation: none; }
}
