/* ==========================================================================
   آية اليوم (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: 88px 1fr 88px; 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: 44px; height: 44px; 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-actions { justify-self: end; display: flex; }
.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; }
.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 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 { position: relative; 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: none; overflow: hidden;
  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); }
/* "Did you mean": sits in the gap above the box, so showing it moves nothing */
.suggest-bar { position: absolute; left: 0; right: 0; bottom: calc(100% + .15rem); display: flex; justify-content: center; z-index: 1; }
.suggest-bar[hidden] { display: none; }
.suggest-chip {
  position: relative; font: 500 calc(.875rem * var(--zoom))/1.2 var(--font-en); color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: 999px; padding: .25rem .9rem; min-height: 1.7rem; cursor: pointer;
}
.suggest-chip::before { content: ""; position: absolute; inset: -.5rem -.4rem; }   /* a larger tap area than the pill */
.suggest-chip b { font-weight: 700; }
.suggest-chip:hover, .suggest-chip:focus-visible { border-color: var(--accent); }
.answer-note { flex: 1; color: var(--muted); font-size: .8125rem; }
.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 .gl { display: block; color: var(--muted); font-family: var(--font-en); font-size: .62em; line-height: 1.5; text-align: left; }
.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 { text-decoration: none; }
.next-wrap[hidden] { display: none; }

/* ---------- start screen (the site root) ---------- */
body[data-view="start"] .top { border-bottom-color: transparent; }
body[data-view="start"] .top-title { visibility: hidden; }
.start {
  min-height: calc(100dvh - 9rem); display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 1rem 0 2rem; animation: rise .5s ease both;
}
.start-icon { width: 72px; height: 72px; border-radius: 18px; box-shadow: 0 10px 28px -12px rgba(0, 0, 0, .35); }
:root[data-color-scheme="dark"] .start-icon { box-shadow: 0 0 0 1px var(--border-strong); }
.start-title { margin: 1.25rem 0 0; display: flex; flex-direction: column; align-items: center; line-height: 1.15; }
.start-en { font: 700 2.5rem var(--font-en); letter-spacing: -.03em; }
.start-ar { font: 700 1.9rem/1.6 var(--font-ar); color: var(--muted); }
.start-tag { margin: .35rem 0 2.25rem; max-width: 21rem; text-wrap: balance; font-size: 1.0625rem; color: var(--text); }
.start-go { display: block; width: min(100%, 17rem); padding: .95rem 1.4rem; font-size: 1.0625rem; text-decoration: none; }
.start-more { display: flex; gap: .6rem; width: min(100%, 17rem); margin-top: .75rem; }
.start-more .btn { flex: 1; padding-inline: .5rem; font-size: .9375rem; text-decoration: none; }
.start-date { margin: 2.25rem 0 0; color: var(--muted); font-size: .875rem; font-weight: 500; }

/* ---------- How to play ---------- */
.howto { gap: .65rem; font-size: .9375rem; }
.howto p { margin: 0; }
.howto-keys { list-style: none; margin: 0; padding: 0; display: grid; gap: .45rem; }
.howto-keys li { display: flex; align-items: baseline; gap: .6rem; }
.howto-keys .dot { position: relative; top: .05rem; }
.howto .btn { margin-top: .5rem; }
.sheet h2:focus { outline: none; }

/* ---------- settings 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; }

/* ---------- the grammar questions ---------- */
.stage { transition: opacity .2s ease; }
.stage.is-out { opacity: 0; }
.q { max-width: 34rem; margin: 2rem auto 0; }
.q-text { margin: 0 0 2.4rem; font-size: calc(1.125rem * var(--zoom)); font-weight: 600; line-height: 1.7; }   /* the gap holds the suggestion bar */
.q-ar { font-family: var(--font-ar); font-size: 1.3em; font-weight: 400; }
.q-in { white-space: nowrap; }
/* the grammar answer is the translation box (.answer), on one line */
.answer-line { min-height: 0; overflow: visible; }
.answer-line[readonly] { background: var(--surface); }
.answer-line.ok { border-color: var(--g-line); }
.answer-line.bad { border-color: var(--r-line); }
.q-hint { margin: .55rem 0 0; color: var(--muted); font-size: .8125rem; }
.q-fb { margin: 1rem 0 0; font-size: .9375rem; }
.q-fb:empty { display: none; }
.q-fb.ok { display: flex; align-items: center; gap: .55rem; color: var(--g); font-weight: 600; }
.q-fb.bad { padding: .7rem .95rem; background: var(--r-50); border: 1px solid var(--r-line); border-radius: var(--radius); }
.tick { display: inline-grid; place-items: center; width: 1.6rem; height: 1.6rem; border-radius: 50%; background: var(--g); color: var(--bg); font-size: .9rem; }
.verse.tap .w[data-i] { cursor: pointer; border-radius: 10px; padding-inline: .08em; transition: background-color .15s ease; }
.verse.tap .w[data-i]:hover { background: var(--surface); }
.verse.tap .w[data-i]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.verse .w.picked.ok, .verse .w.is-answer { color: var(--g); background: var(--g-50); border-radius: 10px; }
.verse .w.picked.bad { color: var(--r); background: var(--r-50); border-radius: 10px; }
.score { margin: 0 0 1.25rem; font-size: calc(2.75rem * var(--zoom)); font-weight: 700; line-height: 1.1; text-align: center; }
.score-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.score-list li { display: flex; align-items: flex-start; gap: .7rem; padding: .7rem .9rem; border: 1px solid var(--border); border-radius: var(--radius); }
.sl-mark { flex: none; display: grid; place-items: center; width: 1.4rem; height: 1.4rem; margin-top: .15rem; border-radius: 50%; font-size: .8rem; font-weight: 700; color: var(--bg); }
.sl-mark.ok { background: var(--g); }
.sl-mark.bad { background: var(--r); }
.sl-body { display: grid; gap: .2rem; min-width: 0; }
.sl-q { font-size: .9375rem; line-height: 1.6; }
.sl-a { color: var(--muted); font-size: .875rem; line-height: 1.6; overflow-wrap: anywhere; }

/* ---------- settings: on / off ---------- */
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; border-top: 1px solid var(--border); padding-top: 1rem; }
.switch-row label { display: grid; gap: .1rem; cursor: pointer; }
.sw-title { font-weight: 600; font-size: .9375rem; }
.sw-sub { color: var(--muted); font-size: .8125rem; }
.switch-row input {
  appearance: none; -webkit-appearance: none; flex: none; position: relative; width: 2.9rem; height: 1.7rem; margin: 0;
  border-radius: 999px; background: var(--border-strong); cursor: pointer; transition: background-color .2s ease;
}
.switch-row input::before {
  content: ""; position: absolute; top: .2rem; left: .2rem; width: 1.3rem; height: 1.3rem; border-radius: 50%;
  background: var(--bg); transition: transform .2s ease;
}
.switch-row input:checked { background: var(--accent); }
.switch-row input:checked::before { transform: translateX(1.2rem); }
.switch-row input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

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

/* ---------- #/tester ---------- */
.tester-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin: 1rem 0 .5rem; }
.tester-actions a.btn { text-decoration: none; }
.t-note { color: var(--muted); font-size: .8125rem; margin: 0 0 1rem; }
.t-list { list-style: none; margin: 0; padding: 0; }
.t-list li { padding: .75rem 0; border-bottom: 1px solid var(--border); display: grid; gap: .2rem; }
.t-list .d { color: var(--muted); font-size: .8125rem; }
.t-ans { font-size: .9375rem; }
.t-marks { display: flex; gap: .3rem; }
.dot-s { width: .6rem; height: .6rem; border-radius: 50%; background: var(--muted); }
.dot-s.green { background: var(--g); }
.dot-s.amber { background: var(--a); }
.dot-s.red { background: var(--r); }
.dot-s.meant { outline: 2px solid var(--g); outline-offset: 1px; }
.t-quiz { display: flex; flex-wrap: wrap; gap: .25rem .75rem; font-size: .8125rem; }
.t-quiz .ok { color: var(--g); }
.t-quiz .bad { color: var(--r); }
.t-score { font-size: .8125rem; font-weight: 600; }
