/* ==========================================================================
   آية اليوم (Daily Ayah): styles. Mobile first.

   Theming:
     data-palette      : (none) black & white | "green" green & gold
     data-color-scheme : (none) light | "dark"
     data-text-scale   : "sm" | (none) | "lg"
   The page itself stays a clean white (or black in dark mode); the palette only
   tints buttons and accents.
   ========================================================================== */

:root {
  --bg: #FFFFFF;
  --surface: #F7F7F7;
  --text: #0A0A0A;
  --muted: #6B6B6B;
  --border: #E5E5E5;
  --border-strong: #999999;
  --accent: #0A0A0A;
  --on-accent: #FFFFFF;
  --g: #1B7F3B; --g-50: #E8F5EC; --g-line: #9FD1AE;
  --a: #9A5B00; --a-50: #FFF4DE; --a-line: #F0C77A;
  --r: #B3261E; --r-50: #FCEBEA; --r-line: #EDA9A4;
  --font-ar: "Amiri", "Noto Naskh Arabic", "Scheherazade New", "Geeza Pro", "Traditional Arabic", serif;
  --font-en: "Inter", "Source Sans 3", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius: 14px;
  --zoom: 1;
  color-scheme: light;
}
:root[data-palette="green"] { --accent: #0B3D2E; --on-accent: #FFFFFF; }
:root[data-color-scheme="dark"] {
  --bg: #0A0A0A;
  --surface: #171717;
  --text: #F0F0F0;
  --muted: #9A9A9A;
  --border: #2A2A2A;
  --border-strong: #555555;
  --accent: #F5F5F5; --on-accent: #0A0A0A;
  --g: #7DD89A; --g-50: #10261A; --g-line: #2E6B44;
  --a: #F2BE6A; --a-50: #2B200E; --a-line: #6E5320;
  --r: #F39A92; --r-50: #2E1513; --r-line: #6E302B;
  color-scheme: dark;
}
:root[data-color-scheme="dark"][data-palette="green"] { --accent: #7FC7A4; --on-accent: #0A0A0A; }
:root[data-text-scale="sm"] { --zoom: 0.9; }
:root[data-text-scale="lg"] { --zoom: 1.15; }

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 400 1rem/1.55 var(--font-en);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
.icon { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- skip link ---------- */
.skip-link {
  position: absolute; left: .5rem; top: -4rem; z-index: 100;
  padding: .75rem 1rem; background: var(--surface); color: var(--text); font-weight: 600;
  border: 2px solid var(--text); border-radius: 10px;
}
.skip-link:focus { top: .5rem; }

/* ---------- top bar: menu button, the title in the middle ---------- */
.top {
  display: grid; grid-template-columns: 40px 1fr 40px; align-items: center;
  padding: calc(env(safe-area-inset-top, 0px) + .5rem) .75rem .5rem;
  border-bottom: 1px solid var(--border);
}
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 50%;
  color: var(--muted); background: none; border: 0; cursor: pointer; text-decoration: none;
}
.icon-btn:hover { color: var(--text); background: var(--surface); }
.top-title {
  justify-self: center; display: inline-flex; align-items: baseline; gap: .5rem;
  color: var(--text); text-decoration: none; white-space: nowrap; line-height: 1.6;
}
.brand { font: 700 1.2rem var(--font-en); letter-spacing: -.01em; }
.brand-ar { font: 700 1.2rem var(--font-ar); color: var(--muted); }
.menu-tagline { margin: auto 0 0; padding: 1rem 1.5rem .5rem; color: var(--muted); font-size: .875rem; }

/* ---------- menu: slides in from the left ---------- */
.scrim { position: fixed; inset: 0; z-index: 65; background: rgba(0, 0, 0, .35); }
.menu {
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 70;
  width: min(80vw, 18rem); display: flex; flex-direction: column;
  background: var(--bg); color: var(--text); border-right: 1px solid var(--border);
  box-shadow: 0 0 40px rgba(0, 0, 0, .18);
  padding: env(safe-area-inset-top, 0px) 0 calc(env(safe-area-inset-bottom, 0px) + 1rem) env(safe-area-inset-left, 0px);
  overflow-y: auto; overscroll-behavior: contain;
  transform: translateX(-102%); visibility: hidden;
  transition: transform .24s ease, visibility 0s linear .24s;
}
.menu.is-open { transform: none; visibility: visible; transition: transform .24s ease; }
.menu-head { display: flex; align-items: center; padding: .5rem .75rem; }
.menu-list { list-style: none; margin: .25rem 0 0; padding: 0; }
.menu-list a, .menu-list button {
  display: block; width: 100%; text-align: left; padding: .8rem 1.5rem; border: 0; border-left: 3px solid transparent;
  background: none; color: var(--text); font: 500 1rem var(--font-en); text-decoration: none; cursor: pointer;
}
.menu-list [lang="ar"] { font-family: var(--font-ar); font-size: 1.15rem; font-weight: 700; line-height: 1.5; padding-block: .6rem; }
.menu-list a:hover, .menu-list button:hover { background: var(--surface); }
.menu-list a[aria-current="page"] { background: var(--surface); border-left-color: var(--accent); font-weight: 600; }
.menu :focus-visible { outline: 2px solid var(--accent); outline-offset: -3px; }
body.menu-open { overflow: hidden; }
@media (prefers-reduced-motion: reduce) { .menu, .menu.is-open { transition: none; } }

/* ---------- layout ---------- */
.view { max-width: 40rem; margin: 0 auto; padding: 1rem 1.25rem calc(env(safe-area-inset-bottom, 0px) + 3rem); outline: none; }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .75rem; margin: 1rem 0 0; color: var(--muted); font-size: .875rem; }
.meta .date { font-weight: 500; }
.pill {
  display: inline-flex; align-items: center; gap: .3rem; font-size: .75rem; font-weight: 600;
  padding: .15rem .55rem; border-radius: 999px; border: 1px solid var(--border); color: var(--muted);
}
.pill-part { border-color: var(--border-strong); color: var(--text); }
.streak { margin-left: auto; font-weight: 600; color: var(--text); }

/* ---------- the verse ---------- */
.verse {
  margin: 3.25rem 0 2.5rem;
  font-family: var(--font-ar);
  font-size: calc(2.1rem * var(--zoom));
  line-height: 2.05;
  text-align: center;
  direction: rtl;
  color: var(--text);
}
.verse .w { display: inline-block; opacity: 0; animation: drop .7s cubic-bezier(.2, .7, .2, 1) forwards; }
.verse .mark { font-size: .7em; margin-inline: .05em; }
.verse .ell { color: var(--muted); }
.verse .ctx { color: var(--muted); opacity: .45; }
.ref { display: block; text-align: center; color: var(--muted); font-size: .875rem; margin-top: -1.25rem; }
@keyframes drop {
  from { opacity: 0; transform: translateY(-14px); filter: blur(2px); }
  to { opacity: 1; transform: none; filter: none; }
}

/* ---------- the answer box ---------- */
.answer-wrap { margin: 2rem auto 0; max-width: 34rem; animation: float 7s ease-in-out infinite; }
.answer-wrap:focus-within { animation-play-state: paused; }
@keyframes float {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  25% { transform: translate(2px, -4px) rotate(.15deg); }
  50% { transform: translate(-1px, -6px) rotate(-.1deg); }
  75% { transform: translate(-2px, -3px) rotate(.1deg); }
}
.answer {
  display: block; width: 100%; min-height: 6.5rem; resize: vertical;
  font: 400 calc(1.0625rem * var(--zoom))/1.5 var(--font-en); color: var(--text);
  background: var(--bg); border: 1px solid var(--border); border-radius: 18px;
  padding: 1rem 1.1rem;
  box-shadow: 0 18px 40px -22px rgba(0, 0, 0, .28), 0 2px 6px -2px rgba(0, 0, 0, .06);
  transition: box-shadow .2s ease, border-color .2s ease;
}
.answer:focus { outline: none; border-color: var(--border-strong); box-shadow: 0 22px 48px -22px rgba(0, 0, 0, .32), 0 0 0 3px color-mix(in srgb, var(--accent) 12%, transparent); }
.answer-actions { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: .9rem; }
.btn {
  font: 600 .9375rem var(--font-en); color: var(--on-accent); background: var(--accent);
  border: 0; border-radius: 999px; padding: .65rem 1.4rem; cursor: pointer;
}
.btn:disabled { opacity: .35; cursor: default; }
.btn-ghost { color: var(--text); background: none; border: 1px solid var(--border); }
.given { margin: 1.5rem auto 0; max-width: 34rem; padding: .9rem 1.1rem; border-left: 3px solid var(--border-strong); color: var(--text); font-size: calc(1.0625rem * var(--zoom)); }
.given small { display: block; color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; margin-bottom: .2rem; }

/* ---------- results ---------- */
.section-h { font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 2.25rem 0 .75rem; }
.phrases { display: grid; gap: .6rem; }
.ph { border: 1px solid var(--border); border-radius: var(--radius); padding: .75rem .9rem; background: var(--bg); opacity: 0; animation: rise .45s ease forwards; }
.ph.green { background: var(--g-50); border-color: var(--g-line); }
.ph.amber { background: var(--a-50); border-color: var(--a-line); }
.ph.red { background: var(--r-50); border-color: var(--r-line); }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.ph-head { display: flex; align-items: center; gap: .6rem; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--muted); }
.green .dot { background: var(--g); } .amber .dot { background: var(--a); } .red .dot { background: var(--r); }
.ph-status { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.green .ph-status { color: var(--g); } .amber .ph-status { color: var(--a); } .red .ph-status { color: var(--r); }
.ph-ar { flex: 1; font-family: var(--font-ar); font-size: calc(1.4rem * var(--zoom)); direction: rtl; text-align: right; line-height: 1.7; }
.ph-why { margin: .35rem 0 0; font-size: .875rem; }
.ph-acc { margin: .35rem 0 0; font-size: .875rem; color: var(--muted); }
.ph-acc b { color: var(--text); font-weight: 500; }
.meant {
  margin-top: .5rem; font: 600 .8125rem var(--font-en); color: var(--text); background: var(--bg);
  border: 1px solid var(--border); border-radius: 999px; padding: .3rem .8rem; cursor: pointer;
}

/* ---------- tarkeeb ---------- */
.tark { list-style: none; margin: 0; padding: 0; direction: rtl; text-align: right; font-family: var(--font-ar); font-size: calc(1.3rem * var(--zoom)); line-height: 1.9; }
.tark li { padding: .3rem 0; border-bottom: 1px solid var(--border); }
.tark li:last-child { border-bottom: 0; }
.tark .tw { font-weight: 700; }
.tark .eq { color: var(--muted); margin: 0 .35em; }
.tark .td { display: block; color: var(--muted); font-size: .8em; line-height: 1.7; }
.tark li.hid, .tark li.hid .tw { color: var(--muted); font-weight: 400; }
.tark li.note { color: var(--muted); font-size: .8em; border-bottom: 0; padding-top: .6rem; }
.report { text-align: center; margin: 1.25rem 0 0; font-size: .8125rem; }
.report a { color: var(--muted); text-decoration: underline; text-underline-offset: .15em; }

/* ---------- lists & pages ---------- */
.page-h { font-size: 1.35rem; font-weight: 700; margin: 1.5rem 0 .25rem; }
.page-sub { color: var(--muted); margin: 0 0 1.25rem; font-size: .9375rem; }
.days { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.days a {
  display: grid; grid-template-columns: 1fr auto; gap: .1rem 1rem; align-items: center;
  text-decoration: none; border: 1px solid var(--border); border-radius: var(--radius); padding: .7rem .9rem;
}
.days a:hover { border-color: var(--border-strong); }
.days .d { font-weight: 600; font-size: .9375rem; }
.days .r { color: var(--muted); font-size: .8125rem; }
.days .ar { grid-column: 1 / -1; font-family: var(--font-ar); direction: rtl; text-align: right; font-size: 1.15rem; line-height: 1.8; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.days .st { font-size: .8125rem; font-weight: 600; color: var(--muted); }
.days .st.done { color: var(--g); }
.prose { font-size: .9375rem; }
.prose h3 { font-size: 1rem; margin: 1.5rem 0 .25rem; }
.prose p { margin: .25rem 0 .75rem; }
.prose ul { padding-left: 1.2rem; margin: .25rem 0 .75rem; }
.empty { color: var(--muted); text-align: center; margin: 3rem 0; }

/* ---------- practice ---------- */
.next-wrap { display: flex; justify-content: center; margin: 2rem 0 1rem; }
.next-wrap a.btn[lang="ar"] { font-family: var(--font-ar); font-size: 1.05rem; font-weight: 700; }
.next-wrap a.btn { text-decoration: none; }

/* ---------- appearance sheet ---------- */
.sheet { border: 0; border-radius: 20px; padding: 0; width: min(26rem, calc(100vw - 2rem)); background: var(--bg); color: var(--text); }
.sheet::backdrop { background: rgba(0, 0, 0, .35); }
.sheet-inner { padding: 1.25rem; display: grid; gap: 1rem; }
.sheet h2 { margin: 0; font-size: 1.125rem; }
.seg { border: 0; margin: 0; padding: 0; display: flex; gap: .4rem; flex-wrap: wrap; }
.seg legend { font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: .35rem; }
.seg label { flex: 1; }
.seg input { position: absolute; opacity: 0; }
.seg span { display: block; text-align: center; padding: .55rem .5rem; border: 1px solid var(--border); border-radius: 12px; cursor: pointer; font-size: .875rem; }
.seg input:checked + span { border-color: var(--text); font-weight: 600; }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.ts-sm { font-size: .75rem !important; } .ts-lg { font-size: 1.15rem !important; }

@media (prefers-reduced-motion: reduce) {
  .verse .w, .ph { animation: none; opacity: 1; }
  .answer-wrap { animation: none; }
}
@media (min-width: 48rem) {
  .verse { font-size: calc(2.6rem * var(--zoom)); }
}
