/* =========================================================
   styles.css — 99 Beautiful Names of Allah
   Aesthetic: Co-Star-inspired — stark white, grayscale,
   elegant serif display (Newsreader) + monospace labels
   (IBM Plex Mono), traditional Arabic (Amiri). Light theme
   only for now; a dark toggle comes later.
   ========================================================= */

:root {
  /* Grayscale palette */
  --bg:          #ffffff;
  --bg-2:        #f2f2f0;
  --surface:     #ffffff;
  --surface-2:   #fafaf8;
  --ink:         #0c0c0c;
  --ink-soft:    #565654;
  --ink-faint:   #9a9a96;
  --line:        rgba(0,0,0,0.13);
  --line-soft:   rgba(0,0,0,0.07);
  --fill:        #f1f1ef;
  --on-ink:      #ffffff;   /* text/colour that sits on top of --ink fills */
  /* quiz feedback — soft pastels with a luminous glow */
  --correct-bg:   #e6f7ec;
  --correct-ink:  #1f7a44;
  --correct-glow: rgba(46, 170, 100, 0.45);
  --wrong-bg:     #fdeae8;
  --wrong-ink:    #b54a44;
  --wrong-glow:   rgba(220, 110, 100, 0.42);

  /* Type */
  --serif:  "Newsreader", Georgia, "Times New Roman", serif;
  --mono:   "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --arabic: "Amiri", "Times New Roman", serif;
  --urdu:   "Noto Nastaliq Urdu", serif;

  --shadow:    0 1px 1px rgba(0,0,0,0.03), 0 10px 30px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 30px rgba(0,0,0,0.10), 0 30px 80px rgba(0,0,0,0.12);
  --radius:    18px;
  --radius-sm: 12px;
  --ease:      cubic-bezier(0.22, 1, 0.36, 1);
  --maxw:      1000px;
}

/* Dark theme — toggled by adding .dark to <body> */
body.dark {
  --bg:          #0d0e0f;
  --bg-2:        #141618;
  --surface:     #161819;
  --surface-2:   #1d2023;
  --ink:         #f1f1ef;
  --ink-soft:    #a7a8a4;
  --ink-faint:   #70726e;
  --line:        rgba(255,255,255,0.13);
  --line-soft:   rgba(255,255,255,0.06);
  --fill:        #1f2123;
  --on-ink:      #0d0e0f;
  --correct-bg:   rgba(70, 190, 120, 0.16);
  --correct-ink:  #8fe6b0;
  --correct-glow: rgba(70, 210, 130, 0.40);
  --wrong-bg:     rgba(230, 110, 100, 0.16);
  --wrong-ink:    #f2aaa4;
  --wrong-glow:   rgba(235, 110, 100, 0.38);
  --shadow:      0 1px 1px rgba(0,0,0,0.4), 0 10px 30px rgba(0,0,0,0.5);
  --shadow-lg:   0 10px 30px rgba(0,0,0,0.55), 0 30px 80px rgba(0,0,0,0.6);
}
body.dark .bg-glow {
  background:
    radial-gradient(55% 45% at 50% -8%, rgba(255,255,255,0.05), transparent 70%),
    linear-gradient(180deg, #0d0e0f, var(--bg-2));
}
body.dark .modal-backdrop { background: rgba(0,0,0,0.6); }

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: var(--serif);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

/* Soft grayscale ambience */
.bg-glow {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(55% 45% at 50% -8%, rgba(0,0,0,0.05), transparent 70%),
    linear-gradient(180deg, #ffffff, var(--bg-2));
}

/* Mono label helper */
.mono-label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

/* ---------- Top column (heading / tabs / date) ---------- */
.topcol {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 26px 24px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}
/* layout-b (default): heading → tabs → date.  layout-a: date → heading → tabs. */
body.layout-b .masthead { order: 1; }
body.layout-b .tabs     { order: 2; }
body.layout-b .topdate  { order: 3; }
body.layout-a .topdate  { order: 1; }
body.layout-a .masthead { order: 2; }
body.layout-a .tabs     { order: 3; }

.topdate {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
  white-space: nowrap;
}
.tabs {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
}
.tab {
  border: 0;
  background: transparent;
  color: var(--ink-faint);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 7px 18px;
  border-radius: 999px;
  cursor: pointer;
  transition: color .25s var(--ease), background .25s var(--ease);
}
.tab.is-active { background: var(--ink); color: var(--on-ink); }

/* ---------- Masthead ---------- */
.masthead {
  text-align: center;
}
.masthead-title {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(22px, 3.4vw, 32px);
  line-height: 1.1;
  letter-spacing: -0.01em;
}
.masthead-sub {
  font-family: var(--arabic);
  font-size: clamp(20px, 4vw, 30px);
  color: var(--ink-soft);
  margin-top: 8px;
  letter-spacing: 0.02em;
}

/* ---------- Layout ---------- */
main { max-width: var(--maxw); margin: 0 auto; padding: 24px; }
.view { display: none; animation: fade .5s var(--ease); }
.view.is-active { display: block; }

/* ---------- Hero (name of the day) ---------- */
.hero {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 26px;
  box-shadow: var(--shadow-lg);
  text-align: center;
  padding: 46px 28px 38px;
  margin: 30px auto 44px;
  max-width: 680px;
  position: relative;
  overflow: hidden;
  animation: rise .7s var(--ease) both;
}
.hero::before {
  content: "";
  position: absolute;
  top: -45%; left: 50%; transform: translateX(-50%);
  width: 520px; height: 520px;
  background: radial-gradient(circle, rgba(0,0,0,0.045), transparent 65%);
  z-index: 0; pointer-events: none;
}
.hero > * { position: relative; z-index: 1; }

.hero-badge {
  display: inline-block;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 16px;
  margin-bottom: 26px;
  max-width: 320px;
  line-height: 1.5;
}
.hero-arabic {
  font-family: var(--arabic);
  font-weight: 400;
  font-size: clamp(64px, 15vw, 120px);
  line-height: 1.1;
  margin-bottom: 16px;
}
.hero-translit {
  font-family: var(--serif);
  font-size: clamp(26px, 5vw, 38px);
  font-weight: 400;
  letter-spacing: -0.01em;
  margin-bottom: 8px;
}
.hero-english {
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(17px, 2.8vw, 22px);
  color: var(--ink-soft);
  margin-bottom: 8px;
}
.hero-urdu {
  font-family: var(--urdu);
  font-size: clamp(20px, 3.4vw, 26px);
  line-height: 2.1;
  color: var(--ink);
  margin-bottom: 16px;
}
.hero-ref, .modal-ref { margin: 6px 0 2px; min-height: 1px; }
.ref-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink);
  background: var(--fill);
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  padding: 6px 14px;
  text-decoration: none;
  transition: transform .2s var(--ease), background .2s var(--ease);
}
.ref-pill:hover { transform: translateY(-1px); background: #e9e9e6; }

.hero-actions, .modal-actions {
  margin-top: 22px;
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

/* Download button */
.dl-btn {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border: 1px solid var(--line);
  background: var(--fill);
  color: var(--ink);
  border-radius: 999px;
  padding: 12px 20px;
  cursor: pointer;
  transition: all .22s var(--ease);
}
.dl-btn:hover { background: #e9e9e6; transform: translateY(-1px); }

/* Footer stamped onto downloaded card images (not shown on screen) */
.dl-foot {
  margin-top: 26px;
  padding-top: 16px;
  border-top: 1px solid var(--line-soft);
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
}
.dl-foot .dl-num   { font-family: var(--mono); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink); }
.dl-foot .dl-date  { font-family: var(--mono); font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-soft); }
.dl-foot .dl-brand { font-family: var(--mono); font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-faint); }

/* Learn button */
.learn-btn {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border: 1px solid var(--ink);
  background: transparent;
  color: var(--ink);
  border-radius: 999px;
  padding: 12px 22px;
  cursor: pointer;
  transition: all .22s var(--ease);
}
.learn-btn:hover { background: var(--fill); }
.learn-btn.is-learned {
  background: var(--ink);
  color: var(--on-ink);
}
.learn-btn.is-learned::before { content: "✓ "; }

/* ---------- Progress ---------- */
.progress {
  display: flex;
  align-items: center;
  gap: 18px;
  max-width: 680px;
  margin: 0 auto 52px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 22px;
}
.progress-ring {
  --pct: 0;
  width: 64px; height: 64px;
  flex: 0 0 64px;
  border-radius: 50%;
  display: grid;
  place-content: center;
  text-align: center;
  background:
    radial-gradient(closest-side, var(--surface) 76%, transparent 77%),
    conic-gradient(var(--ink) calc(var(--pct) * 1%), var(--line) 0);
  line-height: 1;
}
.progress-ring span { font-family: var(--serif); font-size: 21px; }
.progress-ring small { font-family: var(--mono); font-size: 10px; color: var(--ink-faint); display: block; }
.progress-label { display: flex; flex-direction: column; gap: 4px; }
.progress-label strong { font-family: var(--mono); font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; font-weight: 500; }
.progress-label span { font-size: 15px; color: var(--ink-soft); }

/* ---------- Grid of all 99 (flows RIGHT-to-LEFT) ---------- */
.grid-heading {
  text-align: center;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 22px;
}
.grid {
  direction: rtl;                /* name 1 starts top-right, flows leftward */
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  padding-bottom: 40px;
}
.card {
  direction: ltr;
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 16px 14px;
  text-align: center;
  cursor: pointer;
  color: var(--ink);                       /* iOS paints button text blue without this */
  -webkit-tap-highlight-color: transparent;
  transition: transform .2s var(--ease), box-shadow .25s var(--ease), border-color .25s var(--ease);
}
/* Belt-and-braces: never let Arabic render in a system link colour */
.hero-arabic, .card-arabic, .modal-arabic, .masthead-sub, .quiz-arabic {
  color: var(--ink);
  -webkit-text-fill-color: var(--ink);
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--ink); }
.card-num { font-family: var(--mono); font-size: 10.5px; color: var(--ink-faint); letter-spacing: 0.06em; }
.card-arabic {
  font-family: var(--arabic);
  font-size: 34px;
  font-weight: 400;
  margin: 6px 0 8px;
  direction: rtl;
}
.card-translit { font-family: var(--serif); font-size: 16px; }
.card-english { font-size: 11.5px; color: var(--ink-soft); margin-top: 2px; }
.card.is-today { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink) inset; }
.card.is-today .card-num::after { content: " · today"; color: var(--ink); }
.card.is-learned::before {
  content: "✓";
  position: absolute;
  top: 8px; left: 10px;
  font-size: 10px;
  color: var(--on-ink);
  background: var(--ink);
  width: 17px; height: 17px;
  border-radius: 50%;
  display: grid; place-content: center;
}

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; }
.modal[hidden] { display: none; }
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(255,255,255,0.6);
  backdrop-filter: blur(7px);
  animation: fade .3s var(--ease);
}
.modal-card {
  position: relative;
  z-index: 1;
  width: min(440px, 100%);
  background: var(--surface);
  border: 1px solid var(--ink);
  border-radius: 24px;
  box-shadow: var(--shadow-lg);
  padding: 42px 28px 30px;
  text-align: center;
  animation: pop .35s var(--ease);
}
.modal-close {
  position: absolute; top: 14px; right: 18px;
  border: 0; background: transparent;
  font-size: 26px; line-height: 1;
  color: var(--ink-faint);
  cursor: pointer;
}
.modal-index { font-family: var(--mono); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-faint); }
.modal-arabic {
  font-family: var(--arabic);
  font-weight: 400;
  font-size: clamp(56px, 18vw, 88px);
  margin: 10px 0 12px;
}
.modal-translit { font-family: var(--serif); font-size: 26px; }
.modal-english { font-family: var(--serif); font-style: italic; color: var(--ink-soft); margin: 4px 0 8px; }
.modal-urdu { font-family: var(--urdu); font-size: 22px; line-height: 2; margin-bottom: 14px; }
.modal-card .learn-btn { margin-top: 16px; }

/* ---------- Quiz ---------- */
.quiz { max-width: 620px; margin: 30px auto 0; }
.quiz-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 26px;
  box-shadow: var(--shadow-lg);
  padding: 40px 30px 34px;
  text-align: center;
  animation: rise .6s var(--ease) both;
}
.quiz-eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 14px;
}
.quiz-title { font-family: var(--serif); font-weight: 400; font-size: clamp(24px, 4.4vw, 34px); margin-bottom: 10px; }
.quiz-lead { color: var(--ink-soft); font-size: 17px; margin-bottom: 18px; }
.quiz-best { font-family: var(--mono); font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-soft); margin-bottom: 22px; }

.quiz-primary {
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--on-ink);
  border-radius: 999px;
  padding: 14px 30px;
  cursor: pointer;
  transition: opacity .2s var(--ease), transform .2s var(--ease);
}
.quiz-primary:hover { opacity: .88; transform: translateY(-1px); }

.quiz-meta {
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 12px;
}
.quiz-bar { height: 3px; background: var(--line); border-radius: 999px; overflow: hidden; margin-bottom: 26px; }
.quiz-bar-fill { height: 100%; background: var(--ink); transition: width .4s var(--ease); }

.quiz-prompt-label { font-family: var(--mono); font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-faint); }
.quiz-arabic { font-family: var(--arabic); font-size: clamp(56px, 14vw, 88px); line-height: 1.5; margin: 18px 0; padding-bottom: 6px; }
.quiz-translit { font-family: var(--serif); font-size: 20px; color: var(--ink-soft); margin: 8px 0 28px; }

.quiz-options { display: grid; gap: 10px; }
.quiz-option {
  font-family: var(--serif);
  font-size: 17px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 15px 18px;
  cursor: pointer;
  transition: all .18s var(--ease);
}
.quiz-option:hover:not(:disabled) { border-color: var(--ink); transform: translateY(-1px); }
.quiz-option:disabled { cursor: default; }
.quiz-option.is-correct {
  background: var(--correct-bg);
  color: var(--correct-ink);
  -webkit-text-fill-color: var(--correct-ink);
  border-color: transparent;
  box-shadow: 0 0 0 1.5px var(--correct-glow), 0 0 22px var(--correct-glow);
}
.quiz-option.is-wrong {
  background: var(--wrong-bg);
  color: var(--wrong-ink);
  -webkit-text-fill-color: var(--wrong-ink);
  border-color: transparent;
  box-shadow: 0 0 0 1.5px var(--wrong-glow), 0 0 22px var(--wrong-glow);
}

#quiz-next { margin-top: 22px; }

.quiz-score { font-family: var(--serif); font-size: clamp(56px, 14vw, 84px); line-height: 1; margin-bottom: 6px; }
.quiz-score span { color: var(--ink-faint); font-size: 0.42em; }

/* Result: stamp + actions */
.quiz-stamp { margin-top: 22px; }
.quiz-actions { margin-top: 22px; display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* Theme toggle (above footer) */
.theme-row { text-align: center; padding: 10px 20px 0; }
.theme-toggle {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 999px;
  padding: 11px 22px;
  cursor: pointer;
  transition: all .22s var(--ease);
}
.theme-toggle:hover { background: var(--fill); transform: translateY(-1px); }

/* ---------- Footer ---------- */
.site-footer {
  text-align: center;
  padding: 34px 20px 56px;
  border-top: 1px solid var(--line-soft);
  margin-top: 20px;
}
.footer-main { font-size: 16px; color: var(--ink); }
.footer-main .heart { color: var(--ink); }
.footer-sub { font-family: var(--mono); font-size: 11px; letter-spacing: 0.06em; color: var(--ink-faint); margin-top: 8px; }
.site-footer a { color: var(--ink); text-decoration: underline; text-underline-offset: 2px; }

/* ---------- Animations ---------- */
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(16px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes pop  { from { opacity: 0; transform: translateY(10px) scale(.96); } to { opacity: 1; transform: none; } }

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

@media (max-width: 560px) {
  .topcol { padding-top: 20px; }
  .topdate { white-space: normal; text-align: center; font-size: 10px; line-height: 1.7; max-width: 90%; }
  .hero { padding: 38px 20px 32px; border-radius: 22px; }
}
