@font-face {
  font-family: "Tahrir";
  src: url("../fonts/tahrir.woff2") format("woff2");
  font-display: swap;
}
@font-face {
  font-family: "Vazirmatn";
  src: url("../fonts/vazirmatn-var.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --bg: #e6e6e5;
  --ink: #0e0b09;
  --ink-2: #332e2a;
  --ink-3: #6b625c;
  --red: #971d1f;
  --line: rgba(23, 19, 16, .18);
  --stage-h: 70svh;      /* قاب عینک؛ خود عینک در ثلث بالای آن می‌افتد */
  --text-y: 55svh;       /* جایی که متن‌ها ظاهر و محو می‌شوند */
  --pad: 8vw;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Tahrir", Tahoma, sans-serif;
  line-height: 1.9;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
img { display: block; max-width: 100%; }
h1, h2, h3 { margin: 0; font-weight: 400; }
p, dl, dd, ol { margin: 0; padding: 0; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

/* ---------- خط‌های سقوط: تمام‌صفحه و همیشه رو به پایین ---------- */
.streaks {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  overflow: hidden;
}
.sk { position: absolute; inset-inline: 0; top: 0; height: 200%; will-change: transform; }
.sk img { width: 100%; height: 50%; object-fit: cover; }
.sk1 { animation: rise 3.4s linear infinite; opacity: .3; }
.sk2 { animation: rise2 5.4s linear infinite; opacity: .16; transform: scaleX(-1); inset-inline-start: 12%; }
@keyframes rise { from { transform: translateY(0); } to { transform: translateY(-50%); } }

@keyframes rise2 { from { transform: translateY(0) scaleX(-1); } to { transform: translateY(-50%) scaleX(-1); } }

/* ---------- صحنه: فریم‌های مرکب ---------- */
.stage {
  position: fixed;
  top: 0;
  left: 0;
  width: min(86vw, calc(100svh * .45));
  aspect-ratio: 400 / 760;
  z-index: 1;
  pointer-events: none;
}
.stage-in { position: absolute; inset: 0; will-change: transform; }
.stage-in img {
  position: absolute;
  visibility: hidden;
  image-rendering: auto;
}
.stage-in img.on { visibility: visible; }

/* ---------- متن‌ها: سر جایشان می‌آیند و می‌روند ---------- */
.panel {
  position: fixed;
  top: 0; left: 0;
  width: 100%;
  height: 100svh;
  z-index: 3;
  pointer-events: none;
}
/* بلوک‌ها راست‌چین می‌مانند */
.b {
  position: absolute;
  top: var(--text-y);
  bottom: 9svh;
  overflow: hidden;
  inset-inline: var(--pad);
  max-width: 38rem;
  margin-inline-start: 0;
  margin-inline-end: auto;
  opacity: 0;
  text-align: start;
}
.b.live { pointer-events: auto; }

/* عنوان */
.title { width: 58%; margin-inline-start: 0; margin-inline-end: auto; }
.title img { margin-inline-start: 0; margin-inline-end: auto; }
.title img + img { margin-top: -1.2%; }
.title img:nth-child(1) { width: 100%; }
.title img:nth-child(2) { width: 62.2%; }
.title img:nth-child(3) { width: 81.1%; }
.title img:nth-child(4) { width: 90%; }
.eqt { width: 58%; margin: 7% 0 0 0; margin-inline-end: auto; }

h2 { color: var(--red); font-size: 1.35rem; margin-bottom: .9em; }

.cr { margin-bottom: 1em; }
.cr:last-child { margin-bottom: 0; }
/* تیتر نقش: قرمز و دو شماره کوچک‌تر از اسم */
.cr dt {
  font-family: "Tahrir", Tahoma, sans-serif;
  font-size: 1.25rem; line-height: 1.5; color: var(--red);
}
.cr dd { font-size: clamp(1.75rem, 7.4vw, 2.2rem); line-height: 1.4; }
.crs.tight .cr { margin-bottom: .55em; }
.crs.tight .cr dd { font-size: clamp(1.6rem, 6.6vw, 1.95rem); }

.names { font-size: clamp(1.5rem, 6.2vw, 1.9rem); line-height: 1.8; color: var(--ink-2); }
.names.close { border: 0; color: var(--ink); font-size: clamp(1.65rem, 6.8vw, 2.1rem); line-height: 1.85; }

.path { list-style: none; border-inline-start: 1px solid var(--line); padding-inline-start: 18px; }
.path li { position: relative; margin-bottom: 1.3em; }
.path li:last-child { margin-bottom: 0; }
.path li::before {
  content: ""; position: absolute; inset-inline-start: -22px; top: .8em;
  width: 7px; height: 7px; border-radius: 50%; background: var(--line);
}
.path li.now::before { background: var(--red); }
.path span { display: block; }
.yr { color: var(--red); font-size: 1.3rem; }
.pl { font-size: clamp(1.5rem, 6vw, 1.8rem); line-height: 1.4; }
.cst, .nt {
  font-family: "Tahrir", Tahoma, sans-serif;
  font-size: 1.1rem; line-height: 1.8; color: var(--ink-3);
}
.aw {
  font-size: 1.2rem;
  margin-top: .5em; padding-inline-start: 12px;
  border-inline-start: 2px solid var(--red);
  color: var(--red); font-size: 1rem; line-height: 1.75;
}

.b.wide { inset-inline: 0; max-width: none; margin-inline: 0; }
.motif { width: 62%; max-width: 330px; margin-inline: auto; }

.prompt { font-size: clamp(1.4rem, 5.6vw, 1.7rem); line-height: 1.8; margin-bottom: 1em; }

.note {
  font-family: "Tahrir", Tahoma, sans-serif;
  font-size: clamp(1.35rem, 5.6vw, 1.6rem);
  line-height: 2; color: var(--ink-2);
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.note::before {
  content: ""; display: block; width: 22px; height: 1px;
  background: var(--red); margin-bottom: 12px;
}

/* ---------- جعبه‌ی یادگاری: کاغذ کهنه ---------- */
.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: 1.1rem; }
.link-btn:focus-visible, .send:focus-visible, .close:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--red); outline-offset: 3px;
}
.lbl {
  display: block; font-family: "Tahrir", Tahoma, sans-serif;
  font-size: 1.05rem; color: var(--ink-3); margin-bottom: 10px;
}
.sheetpaper {
  position: relative;
  padding: 22px 26px 20px;
  font-size: 1.1rem;
  background:
    repeating-linear-gradient(transparent 0 calc(2em - 1px), rgba(23,19,16,.14) calc(2em - 1px) 2em) center 30px / calc(100% - 52px) auto no-repeat,
    url("../svg/paper.svg") 0 0 / 100% 100% no-repeat;
  filter: drop-shadow(2px 3px 0 rgba(23,19,16,.07));
}
.sheetpaper textarea {
  width: 100%;
  display: block;
  border: 0; background: transparent; resize: none; overflow: hidden;
  font-family: "Tahrir", Tahoma, sans-serif;
  font-size: 1em; line-height: 2em;
  color: #1d1712; outline: none; padding: 0;
  min-height: 6em;
}
.sheetpaper textarea::placeholder { color: rgba(36,28,22,.38); }
.hp { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; clip-path: inset(50%); pointer-events: none; }
.wf { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; gap: 14px; }
.counter { font-family: "Tahrir", Tahoma, sans-serif; font-size: .8rem; color: var(--ink-3); }
.send {
  background: url("../svg/pill-red.svg") center / 100% 100% no-repeat;
  color: #efeeec;
  padding: .7em 1.8em;
  font-family: "Tahrir", Tahoma, sans-serif;
  font-size: 1.35rem;
  line-height: 1;
}
.send[disabled] { opacity: .5; cursor: default; }
.send-state { margin-top: 10px; font-family: "Tahrir", Tahoma, sans-serif; font-size: .85rem; color: var(--ink-2); min-height: 1.4em; }

/* ---------- پایان ---------- */
.outro {
  position: fixed;
  left: 0; right: 0;
  bottom: 5svh;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3.5svh;
  opacity: 0;
  pointer-events: none;
}
.outro.live { pointer-events: auto; }
.showinfo { width: 70%; max-width: 330px; }
.ticket { display: block; width: 40%; max-width: 175px; }

/* ارتفاع اسکرول را جاوااسکریپت می‌سازد */
.scroller { position: relative; z-index: 0; }

/* ---------- همه‌ی یادگاری‌ها ---------- */
.sheet { position: fixed; inset: 0; z-index: 50; }
.sheet-back { position: absolute; inset: 0; background: rgba(23,19,16,.5); }
.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, 0px);
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.sheet-head h3 { font-size: 1.1rem; }
.close { color: var(--ink-2); font-size: .95rem; border-bottom: 1px solid var(--line); }
.sheet-scroll { overflow-y: auto; padding: 22px 20px 36px; -webkit-overflow-scrolling: touch; }
.sheet-scroll .note { margin-bottom: 28px; }
body.locked { overflow: hidden; }

/* ---------- دسکتاپ ---------- */
@media (min-width: 820px) {
  :root { --pad: 6vw; --text-y: 55svh; }
  .outro { bottom: 5svh; gap: 2.5svh; }
  .showinfo { max-width: 360px; }
  .ticket { max-width: 175px; }
  .b { max-width: 32rem; }
  .cr dd { font-size: 1.7rem; }
  .motif { max-width: 300px; }
}

@media (prefers-reduced-motion: reduce) {
  .layer { transition: none; }
}

/* ---------- نشانه‌ی اسکرول ---------- */
.hint {
  position: fixed;
  bottom: calc(2.5svh + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 4;
  color: var(--red);
  opacity: .45;
  pointer-events: none;
  transition: opacity .4s ease;
}
.hint .ring { opacity: 0; transition: opacity .4s ease; }
.hint .chev { transition: transform .4s ease; transform-origin: 12px 13px; }
.hint.up { pointer-events: auto; cursor: pointer; opacity: .7; left: auto; right: 6vw; transform: none; }
.hint.up .ring { opacity: .5; }
.hint.up .chev { transform: rotate(180deg); }
.hint.gone { opacity: 0; }

/* ---------- تب‌ها ---------- */
.tabs {
  position: fixed;
  top: 44svh;
  left: 0; right: 0;
  z-index: 5;
  display: flex;
  justify-content: center;
  padding: 0 4vw;
  opacity: 0;
  transition: opacity .35s ease;
  pointer-events: none;
}
.tabs.live { opacity: 1; pointer-events: auto; }
.tabbar {
  position: relative;
  display: flex;
  width: 100%;
  max-width: 34rem;
  background: url("../svg/pill-black.svg") center / 100% 100% no-repeat;
  padding: .45em 1.7em;
}
.tabbar .pill {
  position: absolute;
  top: .4em; bottom: .4em;
  background: url("../svg/pill-red.svg") center / 100% 100% no-repeat;
  transition: right .28s cubic-bezier(.4,0,.2,1), width .28s cubic-bezier(.4,0,.2,1);
  pointer-events: none;
}
.tabs button {
  position: relative;
  flex: 1 1 0;
  border: 0;
  background: none;
  cursor: pointer;
  font-family: "Tahrir", Tahoma, sans-serif;
  font-size: clamp(1.42rem, 5.5vw, 1.75rem);
  line-height: 1;
  color: #efeeec;
  padding: .7em .1em;
  white-space: nowrap;
}

.tabs button:active { transform: scale(.97); }

/* فلش اسکرول: تکان می‌خورد */
.hint svg { animation: nudge 1.9s ease-in-out infinite; }
.hint.up svg { animation: none; }
@keyframes nudge {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(5px); }
}

/* ---------- حالت نوشتن (مخصوص موبایل) ---------- */
html.writing .b { opacity: 0 !important; visibility: hidden !important; }
html.writing .tabs, html.writing .hint, html.writing .outro { opacity: 0 !important; pointer-events: none; }
html.writing .stage { opacity: 0; }
html.writing .b.writer {
  opacity: 1 !important;
  visibility: visible !important;
  position: fixed;
  top: 6svh;
  bottom: auto;
  overflow: visible;
  pointer-events: auto;
  z-index: 8;
}
html.writing .b.writer .prompt { font-size: 1.1rem; margin-bottom: .6em; }
html.writing .streaks { opacity: .4; }
.writer-done {
  display: none;
  margin-top: 12px;
  font-size: .95rem;
  color: var(--ink-2);
  background: none; border: 0; border-bottom: 1px solid var(--line);
  cursor: pointer; font-family: inherit;
}
html.writing .writer-done { display: inline-block; }

/* هیرو از قید نوار متن آزاد است */
.b.hero-b { top: 42svh; bottom: auto; overflow: visible; }
.b.writer { top: 46svh; bottom: auto; overflow: visible; }
.b.writer .prompt { font-size: clamp(1.15rem, 4.6vw, 1.35rem); line-height: 1.7; }
.sheetpaper textarea { min-height: 4.5em; }
@media (min-width: 820px) { .b.hero-b { top: 42svh; } }

.names.small { font-size: clamp(1.45rem, 5.8vw, 1.75rem); line-height: 1.7; }
.sheetpaper textarea { font-size: 1.15rem; }
.outro { top: auto; }
