/* KTI Reading Club: base. Tokens, reset, typography and the page shell. */
:root {
  --emerald: #064E3B;
  --emerald-deep: #043D2E;
  --green: #15803D;
  --mint: #DCFCE7;
  --gold: #D4AF37;
  --gold-ink: #1B1606;
  --ivory: #FAF8F1;
  --night: #071A15;
  --night-surface: #102820;

  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Arabic", "Noto Sans", Tahoma, sans-serif;
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, "Noto Naskh Arabic", "Book Antiqua", Georgia, serif;
  --font-read: Georgia, "Iowan Old Style", "Noto Naskh Arabic", "Times New Roman", serif;

  --side-w: 256px;
  --tabbar-h: 0px;
  --bar-h: 76px;
  --radius: 14px;
  --radius-lg: 22px;
  --gutter: clamp(16px, 3.2vw, 48px);
  --read-size: 1.25rem;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: 16px; }
body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-wrap: anywhere;
  -webkit-font-smoothing: antialiased;
}
body.no-scroll { overflow: hidden; }
img, svg { display: block; max-width: 100%; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
a { color: var(--link); text-decoration-thickness: 1px; text-underline-offset: 3px; }
h1, h2, h3, p, ul, ol { margin: 0; }
ul, ol { padding: 0; list-style: none; }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.2; letter-spacing: -0.005em; }
h1 { font-size: clamp(1.9rem, 3.6vw, 2.7rem); font-weight: 700; }
h2 { font-size: clamp(1.25rem, 2vw, 1.55rem); font-weight: 700; }
h3 { font-size: 1.15rem; font-weight: 700; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }

.sr {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip {
  position: fixed; top: 8px; inset-inline-start: 8px; z-index: 200;
  background: var(--gold); color: var(--gold-ink); padding: 10px 16px; border-radius: 10px; font-weight: 700;
  transform: translateY(-200%);
}
.skip:focus { transform: none; }

/* ---------- page shell ---------- */
.app { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }
.content { min-width: 0; }
.mbar, .tabbar { display: none; }
main {
  padding: clamp(20px, 3vw, 40px) var(--gutter) 64px;
  max-width: 1500px;
  outline: none;
}
body.has-player main { padding-bottom: calc(var(--bar-h) + 48px); }

.view { animation: view-in .28s ease both; }
@keyframes view-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.loading { display: flex; align-items: center; justify-content: center; gap: 12px; min-height: 40vh; color: var(--text-2); }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--green); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.empty { display: grid; gap: 14px; justify-items: start; padding: 32px 0; max-width: 46ch; }
.empty p { color: var(--text-2); }

.page-head { display: grid; gap: 6px; margin-bottom: 20px; }
.page-sub { color: var(--text-2); }

.toast {
  position: fixed; z-index: 300; inset-inline: 0; margin-inline: auto; width: max-content; max-width: min(92vw, 520px);
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 20px);
  background: #0c1f19; color: #fff; padding: 12px 18px; border-radius: 12px; font-size: .95rem;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .35); border: 1px solid rgba(212, 175, 55, .45);
  opacity: 0; transform: translateY(8px); pointer-events: none; transition: opacity .2s, transform .2s;
}
body.has-player .toast { bottom: calc(var(--tabbar-h) + var(--bar-h) + env(safe-area-inset-bottom, 0px) + 20px); }
.toast.show { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}
