:root {
  --night: #121c2f;
  --night-deep: #0b1220;
  --sky: #1c2d4a;
  --star: #f3c56a;
  --star-soft: #ffe7a8;
  --lantern: #f0a45a;
  --cream: #f6ead7;
  --paper: #fff6e9;
  --clay: #e8c9a4;
  --earth: #6a402b;
  --ink: #2c2118;
  --muted: #7a6553;
  --mary: #4e6d89;
  --line: rgba(106, 64, 43, 0.16);
  --soon: #b79d86;
  --ok: #2f7a55;
  --shadow: 0 18px 40px rgba(18, 12, 8, 0.22);
  --radius: 1.35rem;
  --tap: 4.35rem;
  --font: "Segoe UI", "Tahoma", "Geeza Pro", "Noto Naskh Arabic", "Noto Sans Arabic",
    "Apple Color Emoji", system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

html {
  background: var(--night-deep);
}

body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--night-deep);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
a {
  font-family: inherit;
  touch-action: manipulation;
}

button {
  cursor: pointer;
}

img {
  max-width: 100%;
  display: block;
}

#app {
  width: min(28.5rem, 100%);
  height: 100dvh;
  height: 100svh;
  margin-inline: auto;
  position: relative;
  background: var(--cream);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.04), var(--shadow);
  overflow: hidden;
}

.screen {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.boot,
.error-screen {
  height: 100%;
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 2rem 1.4rem;
  text-align: center;
  background:
    radial-gradient(circle at 80% 12%, rgba(243, 197, 106, 0.35), transparent 28%),
    linear-gradient(180deg, var(--sky), var(--night-deep));
  color: var(--cream);
}

.boot p,
.error-screen p {
  margin: 0.85rem 0 0;
  line-height: 1.5;
}

.star {
  width: 3.1rem;
  height: 3.1rem;
  color: var(--star);
  filter: drop-shadow(0 0 12px rgba(243, 197, 106, 0.65));
}

/* Language picker */
.lang-screen {
  overflow-y: auto;
  background:
    radial-gradient(circle at 78% 10%, rgba(243, 197, 106, 0.55), transparent 26%),
    radial-gradient(circle at 12% 22%, rgba(240, 164, 90, 0.18), transparent 24%),
    radial-gradient(1.5px 1.5px at 18% 30%, var(--star-soft), transparent),
    radial-gradient(1.5px 1.5px at 72% 38%, var(--star-soft), transparent),
    radial-gradient(1.2px 1.2px at 40% 16%, #fff, transparent),
    radial-gradient(1.2px 1.2px at 88% 22%, #fff, transparent),
    radial-gradient(1px 1px at 30% 48%, #fff, transparent),
    linear-gradient(180deg, #1a2b48 0%, var(--night) 48%, #241914 100%);
  color: var(--cream);
  padding: calc(1.4rem + env(safe-area-inset-top)) 1.15rem
    calc(1.4rem + env(safe-area-inset-bottom));
}

.lang-hero {
  text-align: center;
  padding: 0.4rem 0.5rem 1.15rem;
}

.lang-hero h1 {
  margin: 0.85rem 0 0;
  font-size: clamp(1.7rem, 7vw, 2.15rem);
  font-weight: 750;
  letter-spacing: 0.01em;
  line-height: 1.2;
}

.lang-list {
  display: grid;
  gap: 0.75rem;
  margin-top: auto;
}

.lang-btn {
  min-height: var(--tap);
  width: 100%;
  border: 0;
  border-radius: 1.2rem;
  background: rgba(255, 246, 233, 0.96);
  color: var(--earth);
  font-size: 1.55rem;
  font-weight: 750;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.22);
  padding: 0.7rem 1rem;
}

.lang-btn:active {
  transform: translateY(1px) scale(0.99);
}

.lang-btn:focus-visible {
  outline: 3px solid var(--star);
  outline-offset: 3px;
}

.lang-btn[aria-current="true"] {
  box-shadow: 0 0 0 3px var(--star), 0 10px 24px rgba(0, 0, 0, 0.22);
}

/* Shared chrome */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: calc(0.7rem + env(safe-area-inset-top)) 1rem 0.35rem;
}

.ghost {
  border: 0;
  background: transparent;
  color: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  min-height: 2.6rem;
  padding: 0.3rem 0.45rem;
  border-radius: 999px;
}

.ghost:focus-visible {
  outline: 3px solid var(--lantern);
  outline-offset: 2px;
}

.story-scroll,
.library-screen,
.lang-screen {
  scrollbar-width: none;
}

.story-scroll::-webkit-scrollbar,
.library-screen::-webkit-scrollbar,
.lang-screen::-webkit-scrollbar {
  display: none;
}

.story-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  scroll-snap-stop: always;
  scroll-behavior: smooth;
}

.panel {
  height: 100%;
  min-height: 100%;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  padding: 0.5rem 1.25rem 1.1rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.panel.has-art {
  justify-content: center;
}

.panel.has-art .kicker,
.panel.has-art h2,
.panel.has-art > p:not(.kicker) {
  flex-shrink: 0;
}

.panel h2 {
  margin: 0 0 0.8rem;
  font-size: clamp(1.7rem, 7vw, 2.2rem);
  line-height: 1.2;
  font-weight: 800;
}

.panel p {
  margin: 0;
  font-size: clamp(1.2rem, 4.6vw, 1.38rem);
  line-height: 1.55;
  color: var(--earth);
}

.kicker {
  margin: 0 0 0.45rem;
  font-size: 0.82rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--mary);
  font-weight: 800;
}

.panel-art {
  border-radius: 1.2rem;
  overflow: hidden;
  margin: 0 auto 0.95rem;
  box-shadow: var(--shadow);
  width: min(100%, calc(min(42vh, 16rem) * 16 / 9));
  max-width: 100%;
  max-height: min(42vh, 16rem);
  aspect-ratio: 16 / 9;
  flex: 0 1 auto;
  background: #1a2438;
}

.panel-art img {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: min(42vh, 16rem);
  aspect-ratio: 16 / 9;
  object-fit: cover;
  object-position: center;
}

.dock {
  display: grid;
  gap: 0.7rem;
  padding: 0.85rem 1.15rem calc(1rem + env(safe-area-inset-bottom));
  background: var(--cream);
  border-top: 1px solid var(--line);
}

.dots {
  display: flex;
  justify-content: center;
  gap: 0.4rem;
}

.dots span {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 999px;
  background: rgba(106, 64, 43, 0.25);
}

.dots span.on {
  background: var(--earth);
  width: 1.15rem;
}

.primary {
  min-height: 3.5rem;
  border: 0;
  border-radius: 1.15rem;
  background: var(--earth);
  color: var(--paper);
  font-size: 1.15rem;
  font-weight: 800;
  box-shadow: 0 10px 20px rgba(106, 64, 43, 0.28);
}

.primary:focus-visible {
  outline: 3px solid var(--star);
  outline-offset: 3px;
}

.primary:active {
  transform: translateY(1px);
}

.primary.gold {
  background: linear-gradient(180deg, #e8b45a, #c8882e);
  color: #2c2118;
}

.hint {
  margin: 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

/* Intro night-to-cream */
.intro-screen {
  background:
    radial-gradient(circle at 85% 0%, rgba(243, 197, 106, 0.28), transparent 30%),
    var(--cream);
}

.intro-screen .topbar {
  color: var(--earth);
}

/* Library */
.library-screen {
  overflow-y: auto;
  background:
    radial-gradient(circle at 10% 0%, rgba(243, 197, 106, 0.22), transparent 28%),
    var(--cream);
}

.library-head {
  padding: 0 1.2rem 0.4rem;
}

.library-head h1 {
  margin: 0 0 0.35rem;
  font-size: clamp(1.7rem, 7vw, 2.1rem);
  line-height: 1.2;
}

.library-head p {
  margin: 0;
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.45;
}

.cards {
  display: grid;
  gap: 0.9rem;
  padding: 1rem 1.15rem 1.4rem;
}

.card {
  display: block;
  width: 100%;
  text-align: start;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  overflow: hidden;
  box-shadow: 0 10px 24px rgba(80, 48, 28, 0.08);
  color: inherit;
  padding: 0;
}

.card:focus-visible {
  outline: 3px solid var(--lantern);
  outline-offset: 3px;
}

.card.soon {
  cursor: default;
  opacity: 0.88;
}

.card-art {
  aspect-ratio: 16 / 9;
  background: #1a2438;
}

.card-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-placeholder {
  aspect-ratio: 16 / 9;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 70% 30%, rgba(243, 197, 106, 0.35), transparent 32%),
    linear-gradient(180deg, #24344f, #1a2438);
  color: var(--star-soft);
  font-size: 2rem;
}

.card-body {
  padding: 0.95rem 1rem 1.05rem;
}

.card-body h2 {
  margin: 0 0 0.25rem;
  font-size: 1.22rem;
}

.card-body p {
  margin: 0;
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.4;
}

.badge {
  display: inline-block;
  margin-top: 0.65rem;
  padding: 0.22rem 0.55rem;
  border-radius: 999px;
  background: rgba(183, 157, 134, 0.22);
  color: var(--earth);
  font-size: 0.78rem;
  font-weight: 800;
}

.badge.live {
  background: rgba(47, 122, 85, 0.14);
  color: var(--ok);
}

.site-footer {
  margin-top: auto;
  padding: 0.4rem 1.2rem calc(1.1rem + env(safe-area-inset-bottom));
  color: var(--soon);
  font-size: 0.78rem;
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.site-footer a {
  color: var(--mary);
  text-decoration: none;
}

.site-footer a:hover,
.site-footer a:focus-visible {
  text-decoration: underline;
}

.marker {
  font-family: ui-monospace, "IBM Plex Mono", monospace;
  letter-spacing: 0.02em;
}

/* Episode / prayer */
.episode-screen {
  background: var(--cream);
}

.prayer-panel {
  text-align: center;
  padding-inline: 1.4rem;
}

.prayer-panel .candle {
  width: 3.4rem;
  height: 3.4rem;
  margin: 0 auto 0.9rem;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #fff6d8, #f0a45a 42%, #6a402b);
  box-shadow: 0 0 28px rgba(240, 164, 90, 0.55);
}

.prayer-panel h2 {
  font-size: clamp(1.55rem, 6vw, 1.95rem);
}

.prayer-panel p {
  font-size: clamp(1.12rem, 4.2vw, 1.28rem);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(1.2rem + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--paper);
  padding: 0.7rem 1rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.95rem;
  box-shadow: var(--shadow);
  z-index: 20;
  animation: pop 0.25s ease;
}

@keyframes pop {
  from {
    transform: translateX(-50%) translateY(8px);
    opacity: 0;
  }
  to {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
  }
}

[dir="rtl"] .card-body,
[dir="rtl"] .library-head,
[dir="rtl"] .panel {
  text-align: start;
}

@media (max-height: 700px) {
  .panel-art {
    width: min(100%, calc(min(34vh, 13.25rem) * 16 / 9));
    max-height: min(34vh, 13.25rem);
    margin-bottom: 0.7rem;
  }

  .panel-art img {
    max-height: min(34vh, 13.25rem);
  }

  .panel.has-art h2 {
    font-size: clamp(1.45rem, 6.2vw, 1.9rem);
    margin-bottom: 0.5rem;
  }

  .panel.has-art > p:not(.kicker) {
    font-size: clamp(1.08rem, 4.2vw, 1.22rem);
  }
}

@media (min-width: 720px) {
  body {
    display: grid;
    place-items: center;
    padding: 1.5rem 0;
  }

  #app {
    height: min(56rem, 100dvh);
    border-radius: 1.6rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
