@font-face {
  font-family: "Amiri";
  src: url("/assets/fonts/amiri-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Amiri";
  src: url("/assets/fonts/amiri-700.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --paper: #f7f1e6;
  --card: #fffdf7;
  --ink: #2c2218;
  --ink-soft: #55483a;
  --muted: #8a7761;
  --brown: #8a5a2b;
  --brown-deep: #6b4420;
  --line: #e5d8c2;
  --gold: #c2a06a;
  --ui: "Segoe UI", Tahoma, "Noto Sans Arabic", "Helvetica Neue", Arial, sans-serif;
  --book: "Amiri", "Noto Naskh Arabic", "Traditional Arabic", serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  background-image:
    radial-gradient(circle at 50% -10%, rgba(194, 160, 106, 0.16), transparent 60%),
    radial-gradient(circle at 50% 120%, rgba(138, 90, 43, 0.08), transparent 55%);
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--ui);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: 44rem;
  margin: 0 auto;
  padding: 0 1.1rem 3rem;
}

a { color: var(--brown-deep); }

/* ---------- header ---------- */
.site-head {
  padding: 1.6rem 1.1rem 0.6rem;
  text-align: center;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: var(--ink);
}
.brand-mark {
  width: 2.1rem;
  height: 2.1rem;
  fill: none;
  stroke: var(--gold);
  stroke-width: 1.6;
  stroke-linejoin: round;
  flex: none;
}
.brand-text { display: flex; flex-direction: column; text-align: right; }
.brand-name {
  font-family: var(--book);
  font-weight: 700;
  font-size: 1.35rem;
  line-height: 1.2;
}
.brand-sub {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 0.1rem;
}

/* ---------- home ---------- */
.hero {
  text-align: center;
  padding: 1.8rem 0 1.4rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 1.6rem;
}
.hero h1 {
  font-family: var(--book);
  font-weight: 700;
  font-size: clamp(1.7rem, 7vw, 2.3rem);
  line-height: 1.45;
  margin: 0 0 0.6rem;
  color: var(--brown-deep);
}
.hero p {
  margin: 0 auto;
  max-width: 32rem;
  color: var(--ink-soft);
  font-size: 1rem;
}

.story-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 1.1rem; }

.story-card a {
  display: block;
  position: relative;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 1.35rem 1.3rem 1.2rem;
  text-decoration: none;
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(80, 60, 30, 0.05), 0 12px 24px -18px rgba(80, 60, 30, 0.35);
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}
.story-card a:hover,
.story-card a:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 2px 4px rgba(80, 60, 30, 0.06), 0 18px 30px -18px rgba(80, 60, 30, 0.4);
}
.card-num {
  position: absolute;
  top: 1.1rem;
  left: 1.2rem;
  font-family: var(--book);
  font-size: 0.95rem;
  color: var(--gold);
  border: 1px solid var(--line);
  border-radius: 50%;
  width: 1.9rem;
  height: 1.9rem;
  display: grid;
  place-items: center;
  background: var(--paper);
}
.card-title {
  font-family: var(--book);
  font-weight: 700;
  font-size: 1.55rem;
  line-height: 1.35;
  margin: 0 0 0.15rem;
  color: var(--brown-deep);
}
.card-sub {
  margin: 0 0 0.7rem;
  color: var(--brown);
  font-size: 0.95rem;
}
.card-sum {
  margin: 0 0 1rem;
  color: var(--ink-soft);
  font-size: 0.95rem;
  line-height: 1.85;
}
.card-meta {
  display: flex;
  gap: 0.9rem;
  font-size: 0.82rem;
  color: var(--muted);
  padding-bottom: 0.9rem;
  border-bottom: 1px dashed var(--line);
}
.card-cta {
  display: inline-block;
  margin-top: 0.9rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--brown-deep);
}

/* ---------- story page ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.7rem 1.1rem;
  background: rgba(247, 241, 230, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar-back {
  font-size: 0.85rem;
  text-decoration: none;
  color: var(--brown);
  white-space: nowrap;
}
.topbar-title {
  font-family: var(--book);
  font-size: 1rem;
  color: var(--ink-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.titleblock { text-align: center; padding: 2rem 0 1.4rem; }
.story-page .wrap { padding-bottom: 6.5rem; }
.kicker {
  margin: 0 0 0.5rem;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  color: var(--gold);
  text-transform: uppercase;
}
.titleblock h1 {
  font-family: var(--book);
  font-weight: 700;
  font-size: clamp(2rem, 9vw, 2.9rem);
  line-height: 1.3;
  margin: 0 0 0.4rem;
  color: var(--brown-deep);
}
.lede {
  margin: 0 0 0.7rem;
  font-family: var(--book);
  font-size: 1.25rem;
  color: var(--brown);
}
.story-meta { margin: 0; font-size: 0.85rem; color: var(--muted); }

/* player */
.player {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 0.95rem 1rem;
  box-shadow: 0 10px 24px -20px rgba(80, 60, 30, 0.5);
}
.play-btn,
.mini-play {
  flex: none;
  width: 3.2rem;
  height: 3.2rem;
  border-radius: 50%;
  border: 0;
  background: var(--brown);
  color: #fff8ec;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
}
.play-btn:hover, .mini-play:hover { background: var(--brown-deep); }
.play-btn:active, .mini-play:active { transform: scale(0.96); }
.play-btn svg, .mini-play svg { width: 1.5rem; height: 1.5rem; fill: currentColor; }
.ico-pause { display: none; }
.is-playing .ico-play { display: none; }
.is-playing .ico-pause { display: block; }

.player-body { flex: 1 1 auto; min-width: 0; }
.player-label {
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 0.45rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.seek {
  position: relative;
  height: 8px;
  border-radius: 99px;
  background: #ece0cb;
  cursor: pointer;
  touch-action: none;
}
.seek-fill {
  position: absolute;
  inset: 0 0 0 auto;
  width: 0%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--brown), var(--gold));
}
.seek-fill::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border-radius: 50%;
  background: var(--brown-deep);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}
.times {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.35rem;
  font-variant-numeric: tabular-nums;
}
.speed-btn {
  flex: none;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink-soft);
  border-radius: 10px;
  padding: 0.4rem 0.55rem;
  font-size: 0.78rem;
  font-family: var(--ui);
  cursor: pointer;
  min-width: 2.9rem;
}

/* toc */
.toc {
  margin-top: 0.9rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0 1rem;
}
.toc summary {
  cursor: pointer;
  padding: 0.85rem 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--brown-deep);
  list-style: none;
}
.toc summary::-webkit-details-marker { display: none; }
.toc summary::before { content: "☰"; margin-left: 0.5rem; color: var(--gold); }
.toc ul { list-style: none; margin: 0; padding: 0 0 0.5rem; }
.toc-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  border: 0;
  background: transparent;
  padding: 0.55rem 0;
  border-top: 1px solid var(--line);
  font-family: var(--ui);
  font-size: 0.92rem;
  color: var(--ink-soft);
  text-align: right;
  cursor: pointer;
}
.toc-num {
  flex: none;
  width: 1.6rem;
  height: 1.6rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--line);
  font-family: var(--book);
  font-size: 0.8rem;
  color: var(--brown);
}
.toc-title { flex: 1 1 auto; }
.toc-time { flex: none; font-size: 0.78rem; color: var(--muted); font-variant-numeric: tabular-nums; }

/* chapters */
.chapters { margin-top: 1.8rem; }
.chapter { margin-bottom: 2.4rem; scroll-margin-top: 4.5rem; }
.ch-head {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-family: var(--book);
  font-weight: 700;
  font-size: 1.32rem;
  line-height: 1.5;
  color: var(--brown-deep);
  margin: 0 0 1rem;
  padding-bottom: 0.55rem;
  border-bottom: 1px solid var(--line);
}
.ch-num {
  flex: none;
  width: 2rem;
  height: 2rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--gold);
  color: var(--brown);
  font-size: 0.95rem;
  background: var(--card);
}
.ch-title { flex: 1 1 auto; }
.ch-listen {
  flex: none;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--brown);
  font-size: 0.7rem;
  cursor: pointer;
  line-height: 1;
}
.ch-listen:hover { border-color: var(--gold); color: var(--brown-deep); }

.chapter p {
  font-family: var(--book);
  font-size: clamp(1.16rem, 4.6vw, 1.3rem);
  line-height: 2.1;
  margin: 0 0 1.15em;
  color: var(--ink);
}
.chapter.is-active .ch-num { background: var(--brown); color: #fff8ec; border-color: var(--brown); }

/* watch */
.watch {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 1.2rem 1.2rem 0.9rem;
  margin-top: 2rem;
}
.watch h2 {
  font-family: var(--book);
  font-size: 1.2rem;
  margin: 0 0 0.8rem;
  color: var(--brown-deep);
}
.watch-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  text-decoration: none;
  padding: 0.75rem 0;
  border-top: 1px solid var(--line);
  color: var(--ink);
}
.watch-link::after {
  content: "↗";
  flex: none;
  color: var(--gold);
  font-size: 1rem;
}
.watch-link:hover .watch-name { color: var(--brown-deep); }
.watch-kind { flex: none; font-size: 0.78rem; color: var(--gold); white-space: nowrap; }
.watch-name { flex: 1 1 auto; font-size: 0.95rem; line-height: 1.6; }

/* pager */
.pager { display: grid; gap: 0.8rem; margin-top: 1.6rem; }
.pager-link {
  display: block;
  text-decoration: none;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.9rem 1rem;
  color: var(--ink);
}
.pager-dir { display: block; font-size: 0.78rem; color: var(--muted); margin-bottom: 0.2rem; }
.pager-name { display: block; font-family: var(--book); font-size: 1.15rem; color: var(--brown-deep); }

/* footer */
.site-foot {
  text-align: center;
  padding: 2rem 1.1rem 2.4rem;
  color: var(--muted);
  font-size: 0.85rem;
}
.site-foot p { margin: 0.25rem 0; }
.site-foot a { color: var(--brown); }
.foot-note { font-size: 0.78rem; opacity: 0.85; }

/* mini player */
.mini {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.6rem 0.9rem calc(0.6rem + env(safe-area-inset-bottom));
  background: rgba(255, 253, 247, 0.96);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  box-shadow: 0 -8px 24px -18px rgba(80, 60, 30, 0.6);
}
.mini[hidden] { display: none; }
.mini-play { width: 2.6rem; height: 2.6rem; }
.mini-play svg { width: 1.2rem; height: 1.2rem; }
.mini-body { flex: 1 1 auto; min-width: 0; }
.mini-title {
  font-family: var(--book);
  font-size: 0.95rem;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 0.3rem;
}
.mini-bar { height: 4px; border-radius: 99px; background: #ece0cb; overflow: hidden; }
.mini-fill { height: 100%; width: 0%; background: var(--brown); }
.mini-time { flex: none; font-size: 0.75rem; color: var(--muted); font-variant-numeric: tabular-nums; }

@media (min-width: 720px) {
  .wrap { padding: 0 1.5rem 3rem; }
  .card-title { font-size: 1.7rem; }
  .chapter p { font-size: 1.32rem; }
  .mini { left: 50%; transform: translateX(-50%); max-width: 44rem; border-radius: 16px 16px 0 0; border: 1px solid var(--line); border-bottom: 0; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
