/* Components layered on the base styles in index.html: language menu, reader, sticky audio drawer, print booklets.
   Uses the same tokens (--bg, --ink, --rose, ...) so light and dark follow the site theme. */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
body { padding-bottom: var(--drawer-h, 64px); }
html[dir="rtl"] body, html[dir="rtl"] .btn, html[dir="rtl"] .listen, html[dir="rtl"] .mood, html[dir="rtl"] .read-here { font-family: var(--body), "Noto Naskh Arabic", serif; }
html[dir="rtl"] h1, html[dir="rtl"] h2, html[dir="rtl"] h3, html[dir="rtl"] .hero .lede, html[dir="rtl"] .invite h3 { font-family: var(--display), "Noto Naskh Arabic", serif; line-height: 1.45; }
html[dir="rtl"] .eyebrow, html[dir="rtl"] .nav, html[dir="rtl"] .btn, html[dir="rtl"] .book .tag { letter-spacing: 0; }
html[dir="rtl"] .listen .txt { text-align: right; }
html[lang="zh-Hans"] .eyebrow, html[lang="zh-Hans"] .nav { letter-spacing: 0.08em; }
.hero h1 em { font-style: italic; }
html[dir="rtl"] .hero h1 em, html[lang="zh-Hans"] .hero h1 em, html[dir="rtl"] .hero .lede, html[dir="rtl"] .invite h3 { font-style: normal; }

/* ---------- header: nav + language menu ---------- */
.top-right { display: flex; align-items: center; gap: clamp(12px, 2.4vw, 26px); min-width: 0; }
.nav { flex-wrap: wrap; justify-content: flex-end; row-gap: 4px; }
.lang-menu { position: relative; flex: none; }
.lang-toggle { display: inline-flex; align-items: center; gap: 7px; min-height: 40px; padding: 6px 12px 6px 10px; border: 1px solid var(--line); border-radius: 999px; background: transparent; color: var(--ink); font: 500 var(--step--1) var(--body); cursor: pointer; }
.lang-toggle:hover, .lang-toggle[aria-expanded="true"] { border-color: var(--rose); color: var(--rose-ink); }
.lang-toggle .chev { width: 10px; height: 10px; transition: transform .2s; }
.lang-toggle[aria-expanded="true"] .chev { transform: rotate(180deg); }
.lang-list { position: absolute; inset-inline-end: 0; top: calc(100% + 8px); z-index: 50; list-style: none; margin: 0; padding: 6px; width: min(17rem, calc(100vw - 32px)); max-height: min(70vh, 30rem); overflow: auto; background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 18px 40px -18px rgba(43, 20, 40, 0.45); display: grid; grid-template-columns: 1fr 1fr; gap: 2px; }
.lang-list[hidden] { display: none; }
.lang-list a { display: grid; gap: 0; padding: 8px 10px; border-radius: 9px; text-decoration: none; color: var(--ink); line-height: 1.3; }
.lang-list a .n { font-size: 1rem; }
.lang-list a small { color: var(--ink-soft); font-size: 0.76rem; letter-spacing: 0.04em; }
.lang-list a:hover, .lang-list a:focus-visible { background: color-mix(in srgb, var(--rose) 10%, transparent); outline: none; }
.lang-list a[aria-current="true"] { background: color-mix(in srgb, var(--rose) 16%, transparent); color: var(--rose-ink); }
.lang-list a[dir="rtl"] { text-align: right; }
.langs a[aria-current] { font-weight: 600; }
@media (max-width: 640px) {
  .top .wrap { flex-wrap: wrap; row-gap: 4px; padding-block: 8px 6px; }
  .top-right { display: contents; }
  .lang-menu { margin-inline-start: auto; }
  .nav { order: 3; flex-basis: 100%; flex-wrap: nowrap; justify-content: space-between; gap: 8px; font-size: 0.74rem; letter-spacing: 0.08em; white-space: nowrap; }
  .lang-toggle .lang-cur { max-width: 6.5em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
@media (max-width: 420px) { .lang-toggle .lang-cur { display: none; } .lang-toggle { padding: 6px 10px; } }

/* ---------- cards: read here ---------- */
.read-here { display: inline-flex; align-items: center; min-height: 36px; padding: 5px 16px; border: 1px solid var(--rose); border-radius: 999px; background: var(--rose); color: var(--bg); font: 400 var(--step--1) var(--body); letter-spacing: 0.06em; cursor: pointer; transition: background .2s, color .2s; }
.read-here:hover { background: transparent; color: var(--rose-ink); }

/* ---------- reader ---------- */
html.reader-open { overflow: hidden; }
.reader { position: fixed; inset: 0 0 var(--drawer-h, 64px) 0; z-index: 30; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; background: var(--bg); color: var(--ink); }
.reader[hidden] { display: none; }
.rd-top, .rd-foot { display: flex; align-items: center; gap: 10px; padding: 10px clamp(12px, 3vw, 28px); background: color-mix(in srgb, var(--bg) 92%, transparent); }
.rd-top { border-bottom: 1px solid var(--line); flex-wrap: wrap; padding-top: calc(10px + env(safe-area-inset-top, 0px)); }
.rd-foot { justify-content: center; border-top: 1px solid var(--line); gap: 18px; }
.rd-head { display: grid; min-width: 0; flex: 1 1 10rem; line-height: 1.2; }
.rd-title { font-family: var(--display); font-size: 1.35rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rd-ed { color: var(--ink-soft); font-size: 0.8rem; letter-spacing: 0.04em; }
.rd-tools { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.rd-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 50%; background: transparent; color: var(--ink); cursor: pointer; text-decoration: none; font: 500 0.95rem var(--display); padding: 0; }
.rd-btn svg { width: 18px; height: 18px; }
.rd-btn:hover:not(:disabled) { border-color: var(--rose); color: var(--rose-ink); }
.rd-btn:disabled { opacity: .35; cursor: default; }
.rd-btn .big { font-size: 1.15rem; }
.rd-btn sup { font-size: .7em; }
.rd-btn[aria-pressed="true"] { background: var(--rose); border-color: var(--rose); color: var(--bg); }
.rd-btn[hidden] { display: none; }
[dir="rtl"] .rd-prev svg, [dir="rtl"] .rd-next svg { transform: scaleX(-1); }
.rd-lang select { min-height: 40px; max-width: 9.5rem; padding: 6px 30px 6px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5L6 8l3.5-3.5' fill='none' stroke='%23999' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right 11px center / 11px; color: var(--ink); font: 500 0.9rem var(--body); appearance: none; -webkit-appearance: none; cursor: pointer; }
[dir="rtl"] .rd-lang select { padding: 6px 12px 6px 30px; background-position: left 11px center; }
.rd-scroll { overflow-y: auto; overscroll-behavior: contain; padding: 22px 16px 40px; outline: none; scroll-padding-top: 12px; }
.rd-pages { display: grid; justify-items: center; gap: 22px; }
.rd-page { width: var(--rd-w, 520px); max-width: 100%; aspect-ratio: 2 / 3; background: var(--bg-2); border-radius: 4px; box-shadow: 0 1px 0 var(--line), 0 18px 40px -22px rgba(43, 20, 40, 0.5); overflow: hidden; }
.rd-page canvas { display: block; width: 100%; height: 100%; }
.reader.is-dark .rd-page canvas { filter: brightness(.86) contrast(1.04); }
.rd-status { text-align: center; color: var(--ink-soft); font-family: var(--display); font-style: italic; font-size: 1.2rem; margin-top: 18vh; }
.rd-status[hidden] { display: none; }
.rd-status a { color: var(--rose-ink); }
/* text editions (text/<Slug>/<lang>.json): live type at the same page width, A−/A+ scale the type */
.rd-page.rd-text { aspect-ratio: auto; min-height: calc(var(--rd-w, 520px) * 1.2); display: flex; flex-direction: column; justify-content: center; gap: calc(0.9em * var(--rd-z, 1)); padding: clamp(28px, 7%, 64px) clamp(22px, 9%, 72px); font: 400 calc(1.12rem * var(--rd-z, 1)) / 1.65 var(--display); color: var(--ink); overflow-wrap: break-word; }
.rd-text p, .rd-text h2, .rd-text blockquote, .rd-text ul { margin: 0; }
.rd-text .rt-p { display: grid; gap: 0.35em; }
.rd-text .rt-h1 { font-size: 2.6em; font-weight: 500; letter-spacing: .01em; line-height: 1.05; }
.rd-text .rt-h2 { font-size: 1.35em; font-style: italic; color: var(--ink-soft); }
.rd-text .rt-h3 { font: 500 .78em var(--body); letter-spacing: .16em; text-transform: uppercase; color: var(--rose-ink); }
.rd-text .rt-h4 { font-size: 1.55em; font-weight: 500; line-height: 1.2; }
.rd-text .rt-h4[data-n]::before { content: attr(data-n); display: block; font: 500 .5em var(--body); letter-spacing: .2em; color: var(--rose-ink); margin-bottom: .5em; }
.rd-text .rt-quote { font-size: 1.2em; font-style: italic; border-inline-start: 2px solid var(--gold); padding-inline-start: 1em; }
.rd-text .rt-prompt { margin-top: .6em; padding-top: .9em; border-top: 1px solid var(--line); font-style: italic; color: var(--ink-soft); }
.rd-text .rt-prompt em { font-style: normal; }
.rd-text .rt-label { font: 500 .72em var(--body); font-style: normal; letter-spacing: .14em; text-transform: uppercase; color: var(--rose-ink); }
.rd-text .rt-list { padding-inline-start: 1.1em; display: grid; gap: .4em; font-size: .9em; color: var(--ink-soft); }
.rd-text.rt-front, .rd-text.rt-part { text-align: center; }
.rd-text.rt-front .rt-quote { border: 0; padding: 0; }
.rd-text.rt-part .rt-h2 { font: 500 .78em var(--body); font-style: normal; letter-spacing: .2em; color: var(--rose-ink); }
.rd-text.rt-part .rt-h3 { font: 500 2em var(--display); letter-spacing: 0; text-transform: none; color: var(--ink); }
.rd-text.rt-part .rt-h2:only-child { font: 500 1.9em var(--display); letter-spacing: .02em; color: var(--ink); }
.rd-text.rt-matter:last-child { font-size: calc(.95rem * var(--rd-z, 1)); justify-content: flex-start; }
/* picture-book layout (text/<Slug>/edition.json "style": "kids"): art on top, big friendly type, DO IT! as a bright action card */
.rd-text.rt-style-kids { font: 500 calc(1.28rem * var(--rd-z, 1)) / 1.5 var(--body); justify-content: flex-start; text-align: center; padding: clamp(14px, 3.5%, 26px) clamp(16px, 6%, 44px) clamp(22px, 6%, 40px); min-height: 0; border-radius: 22px; }
.rd-text.rt-style-kids:not(.has-art) { min-height: calc(var(--rd-w, 520px) * .8); justify-content: center; }
.rd-text.rt-style-kids .rt-art { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 16px; box-shadow: 0 10px 24px -14px rgba(43, 20, 40, .55); background: var(--bg); }
.reader.is-dark .rt-style-kids .rt-art { filter: brightness(.9); }
.rd-text.rt-style-kids .rt-h1 { font: 600 2.3em var(--display); }
.rd-text.rt-style-kids .rt-h4 { font: 600 .72em var(--body); letter-spacing: .14em; text-transform: uppercase; color: var(--ink-soft); }
.rd-text.rt-style-kids .rt-h4[data-n]::before { display: none; }
.rd-text.rt-style-kids .rt-p { gap: .2em; font-size: 1.08em; }
.rd-text.rt-style-kids .rt-prompt { --kid: #E8964B; position: relative; margin-top: .4em; padding: 1.15em 1em .9em; border: 3px dashed color-mix(in srgb, var(--kid) 70%, transparent); border-radius: 20px; background: color-mix(in srgb, var(--kid) 14%, var(--bg-2)); color: var(--ink); font: 500 .92em / 1.45 var(--body); font-style: normal; text-align: center; }
.rd-text.rt-style-kids .rt-prompt .rt-label { position: absolute; top: 0; left: 50%; transform: translate(-50%, -55%) rotate(-3deg); padding: .3em .9em; border-radius: 999px; background: var(--kid); color: #fff; font: 800 .82em var(--body); letter-spacing: .12em; box-shadow: 0 4px 0 color-mix(in srgb, var(--kid) 60%, #000); white-space: nowrap; }
.rd-text.rt-style-kids:nth-of-type(4n+1) .rt-prompt { --kid: #E5677F; }
.rd-text.rt-style-kids:nth-of-type(4n+2) .rt-prompt { --kid: #3A8FD9; }
.rd-text.rt-style-kids:nth-of-type(4n+3) .rt-prompt { --kid: #3BA776; }
.rd-text.rt-style-kids .rt-p strong { display: inline-block; margin-top: .25em; color: var(--rose-ink); font-weight: 700; font-size: 1.08em; }
.rd-text.rt-style-kids .rt-list { text-align: start; }
.rd-text.rt-style-kids.rt-matter { font-size: calc(1.05rem * var(--rd-z, 1)); }
#rt-closing-activity.rt-style-kids .rt-p { font: 600 1.5em var(--display); }
@media (prefers-reduced-motion: no-preference) { .rd-text.rt-style-kids .rt-prompt .rt-label { animation: rt-wiggle 2.8s ease-in-out infinite; } }
@keyframes rt-wiggle { 0%, 88%, 100% { transform: translate(-50%, -55%) rotate(-3deg); } 92% { transform: translate(-50%, -62%) rotate(3deg); } 96% { transform: translate(-50%, -55%) rotate(-5deg); } }
.rd-count { min-width: 9em; text-align: center; font-size: 0.88rem; color: var(--ink-soft); letter-spacing: 0.04em; font-variant-numeric: tabular-nums; }
@media (max-width: 640px) {
  .rd-top { gap: 8px; }
  .rd-head { order: 0; flex: 1 1 0; }
  .rd-tools { order: 2; flex-basis: 100%; justify-content: space-between; }
  .rd-scroll { padding: 14px 10px 30px; }
  .rd-pages { gap: 14px; }
}

/* ---------- sticky audio drawer ---------- */
.drawer { position: fixed; z-index: 40; inset-inline: 0; bottom: 0; background: color-mix(in srgb, var(--card) 94%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-top: 1px solid var(--line); box-shadow: 0 -10px 30px -22px rgba(43, 20, 40, 0.5); padding-bottom: env(safe-area-inset-bottom, 0px); color: var(--ink); }
.dr-progress { position: absolute; inset-inline: 0; top: -1px; height: 2px; }
.dr-progress span { display: block; height: 100%; width: 0; background: var(--gold); transition: width .25s linear; }
.dr-row { display: flex; align-items: center; gap: 12px; padding-block: 9px; }
.dr-play { flex: none; width: 44px; height: 44px; border-radius: 50%; border: 0; display: grid; place-items: center; background: var(--rose); color: var(--bg); cursor: pointer; }
.dr-play svg { width: 14px; height: 14px; }
@media (prefers-reduced-motion: no-preference) { .drawer.is-playing .dr-play { animation: breathe 5.5s ease-in-out infinite; } }
.dr-now { display: grid; min-width: 0; flex: 1 1 0; line-height: 1.25; }
.dr-eyebrow { font-size: 0.7rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--rose-ink); font-weight: 500; }
html[dir="rtl"] .dr-eyebrow { letter-spacing: 0; }
.dr-title { font-family: var(--display); font-size: 1.12rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dr-sub { color: var(--ink-soft); font-size: 0.8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dr-sub:empty { display: none; }
.dr-more { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.dr-track select { min-height: 38px; max-width: 15rem; padding: 6px 30px 6px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5L6 8l3.5-3.5' fill='none' stroke='%23999' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right 11px center / 11px; color: var(--ink); font: 400 0.88rem var(--body); appearance: none; -webkit-appearance: none; cursor: pointer; }
[dir="rtl"] .dr-track select { padding: 6px 12px 6px 30px; background-position: left 11px center; }
.dr-vol input { width: 110px; accent-color: var(--rose); vertical-align: middle; }
.dr-mute, .dr-expand { flex: none; width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line); background: transparent; color: var(--ink); display: grid; place-items: center; cursor: pointer; padding: 0; }
.dr-mute svg { width: 19px; height: 19px; }
.dr-expand svg { width: 12px; height: 12px; transition: transform .2s; }
.dr-mute:hover, .dr-expand:hover { border-color: var(--rose); color: var(--rose-ink); }
.dr-mute[aria-pressed="true"] { color: var(--rose-ink); border-color: var(--rose); }
.drawer.is-open .dr-expand svg { transform: rotate(180deg); }
.dr-expand { display: none; }
@media (max-width: 900px) {
  .dr-row { flex-wrap: wrap; row-gap: 8px; }
  .dr-expand { display: grid; }
  .dr-more { order: 5; flex-basis: 100%; display: none; padding-bottom: 4px; }
  .drawer.is-open .dr-more { display: flex; }
  .dr-track { flex: 1 1 12rem; } .dr-track select { width: 100%; max-width: none; }
}

/* ---------- print booklets ---------- */
.print-sec { padding-block: clamp(64px, 9vw, 110px); border-top: 1px solid var(--line); }
.print-sec header { display: grid; gap: 14px; max-width: 44rem; }
.print-sec h2 { font-size: var(--step-2); }
.print-sec header p { color: var(--ink-soft); }
.print-steps { list-style: none; counter-reset: s; margin: 26px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr)); gap: 12px; max-width: 52rem; }
.print-steps li { counter-increment: s; display: flex; gap: 12px; align-items: center; padding: 12px 16px; border: 1px solid var(--line); border-radius: 14px; background: color-mix(in srgb, var(--card) 70%, transparent); font-size: 0.98rem; }
.print-steps li::before { content: counter(s); flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--rose); color: var(--bg); font-size: 0.85rem; }
.print-edition { margin: 26px 0 14px; font-size: var(--step--1); letter-spacing: 0.06em; color: var(--rose-ink); }
.print-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 16.5rem), 1fr)); gap: 14px; }
.pc { display: grid; grid-template-columns: 3.4rem minmax(0, 1fr); gap: 14px; align-items: center; padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; background: color-mix(in srgb, var(--card) 70%, transparent); }
.pc img { width: 100%; height: auto; aspect-ratio: 5 / 8; object-fit: cover; border-radius: 2px 5px 5px 2px; box-shadow: 0 8px 16px -10px rgba(43, 20, 40, 0.5); }
.pc-body { display: grid; gap: 6px; min-width: 0; }
.pc h3 { font-size: 1.25rem; }
.pc-dl { display: flex; flex-wrap: wrap; gap: 6px; }
.pc-dl a { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 4px 12px; border: 1px solid var(--rose); border-radius: 999px; color: var(--rose-ink); text-decoration: none; font-size: 0.84rem; letter-spacing: 0.03em; }
.pc-dl a::before { content: "↓"; font-size: 0.95em; line-height: 1; }
.pc-dl a:hover { background: var(--rose); color: var(--bg); }
.pc-dl a[aria-busy="true"] { opacity: .6; cursor: progress; }
.pc-note { color: var(--ink-soft); font-size: 0.8rem; min-height: 1.2em; }
