/* ── Tokens ────────────────────────────────────────────────────────────────
   Palette borrowed from mushaf illumination: ink on paper, lapis for the
   headings, gold reserved for hairlines and the ayah marks. Nothing else.   */
:root {
  --paper:      #F5F1E6;
  --paper-sunk: #EDE7D6;
  --rule:       #DCD3BB;
  --ink:        #14171C;
  --ink-soft:   #5C6069;
  --lapis:      #1C3F94;
  --lapis-deep: #12295F;
  --gold:       #B08327;

  --shadow: 0 1px 0 rgba(20,23,28,.04), 0 12px 32px -20px rgba(18,41,95,.35);

  --display: "Aref Ruqaa", serif;
  --sans: "IBM Plex Sans Arabic", system-ui, sans-serif;

  --step: clamp(1rem, .6rem + 1.6vw, 1.5rem);
  --measure: 46rem;
}

[data-theme="night"] {
  --paper:      #0E1119;
  --paper-sunk: #151A25;
  --rule:       #2A3242;
  --ink:        #E9E4D6;
  --ink-soft:   #8D95A6;
  --lapis:      #7EA0F0;
  --lapis-deep: #C8D6F7;
  --gold:       #D9A94A;
  --shadow: 0 12px 40px -24px rgba(0,0,0,.9);
}

/* The eight-point rosette (نجمة الختم) used in mushaf illumination. Drawn, not
   typed: the ۞ character falls back to a gear on most systems. */
:root {
  --rosette: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M12 0l3.2 5.6 6.3-1.2-1.2 6.3L24 12l-5.6 3.2 1.2 6.3-6.3-1.2L12 24l-3.2-5.6-6.3 1.2 1.2-6.3L0 12l5.6-3.2-1.2-6.3 6.3 1.2z'/%3E%3C/svg%3E");
}
.rosette {
  display: inline-block; width: 1em; height: 1em;
  background: var(--gold);
  -webkit-mask: var(--rosette) center / contain no-repeat;
  mask: var(--rosette) center / contain no-repeat;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-weight: 400;
  line-height: 1.6;
  transition: background-color .4s ease, color .4s ease;
}
h1, h2, p, ol, ul, figure { margin: 0; }
ol { padding: 0; list-style: none; }
button, input, select, textarea { font: inherit; color: inherit; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}

:where(a, button, select, textarea, input):focus-visible {
  outline: 2px solid var(--lapis);
  outline-offset: 3px;
  border-radius: 2px;
}

/* ── Chrome ─────────────────────────────────────────────────────────────── */
.bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem;
  max-width: var(--measure); margin-inline: auto;
  padding: 1.25rem var(--step) 0;
}
.brand { display: flex; align-items: center; gap: .5rem; }
.brand__mark { width: .9rem; height: .9rem; }
.brand__name {
  font-family: var(--display); font-size: 1.6rem; font-weight: 700;
  color: var(--lapis-deep); line-height: 1;
}
.bar__actions { display: flex; gap: .4rem; }
.icon-btn {
  border: 1px solid var(--rule); background: transparent; color: var(--ink-soft);
  padding: .35rem .7rem; border-radius: 999px; cursor: pointer;
  font-size: .8rem; line-height: 1.5;
  transition: border-color .2s, color .2s, background-color .2s;
}
.icon-btn:hover { color: var(--lapis); border-color: var(--lapis); }

main {
  max-width: var(--measure);
  margin-inline: auto;
  padding: 0 var(--step) 4rem;
}
main > section + section {
  margin-top: 3.5rem;
  padding-top: 3.5rem;
  border-top: 1px solid var(--rule);
}

.h2 {
  font-family: var(--display); font-weight: 700; font-size: 1.5rem;
  color: var(--lapis-deep); line-height: 1.4;
}
.eyebrow {
  font-size: .8rem; font-weight: 500; letter-spacing: .04em;
  color: var(--ink-soft);
}
.prose { color: var(--ink-soft); font-size: .9rem; max-width: 30ch; }

/* ── Today ─────────────────────────────────────────────────────────────── */
.today { padding-top: 2.5rem; }

.who {
  display: flex; align-items: center; gap: .75rem; flex-wrap: wrap;
  margin: .6rem 0 1.25rem;
}
.who__label {
  font-family: var(--display); font-size: clamp(1.9rem, 1.4rem + 2vw, 2.6rem);
  font-weight: 700; color: var(--ink); line-height: 1.2;
}
.who__field { position: relative; }
.select {
  appearance: none;
  background: transparent;
  border: 0; border-bottom: 2px solid var(--gold);
  color: var(--lapis); cursor: pointer;
  font-family: var(--display); font-weight: 700;
  font-size: clamp(1.9rem, 1.4rem + 2vw, 2.6rem); line-height: 1.2;
  padding: 0 1.4rem .1rem .2rem;
  max-width: 100%;
}
.who__field::after {
  content: "▾";
  position: absolute; inset-inline-start: .1rem; bottom: .55rem;
  pointer-events: none; color: var(--gold); font-size: .75rem;
}

/* The portion card is the page's thesis: a leaf of the mushaf.
   Double rule outside, gold ayah-marks at the corners, nothing else. */
.portion {
  position: relative;
  overflow: hidden;
  background: var(--paper-sunk);
  border: 1px solid var(--rule);
  box-shadow: 0 0 0 1px var(--paper) inset, 0 0 0 4px var(--paper-sunk) inset,
              0 0 0 5px var(--rule) inset, var(--shadow);
  padding: clamp(1.75rem, 1rem + 3vw, 3rem) clamp(1.25rem, .5rem + 3vw, 2.5rem);
}
/* Four rosettes pin the corners, the way an illuminated frame is anchored.
   The far half of the leaf stays empty on purpose. */
.portion::before {
  content: "";
  position: absolute; inset: .5rem;
  pointer-events: none;
  background: var(--gold);
  -webkit-mask-image: var(--rosette), var(--rosette), var(--rosette), var(--rosette);
  -webkit-mask-position: top left, top right, bottom left, bottom right;
  -webkit-mask-size: 9px 9px;
  -webkit-mask-repeat: no-repeat;
  mask-image: var(--rosette), var(--rosette), var(--rosette), var(--rosette);
  mask-position: top left, top right, bottom left, bottom right;
  mask-size: 9px 9px;
  mask-repeat: no-repeat;
}

.seg { display: block; text-decoration: none; color: inherit; }
.seg + .seg {
  margin-top: 1.4rem; padding-top: 1.4rem;
  border-top: 1px dashed var(--rule);
}
.seg__surah {
  font-family: var(--display); font-weight: 700;
  font-size: clamp(2.1rem, 1.5rem + 3vw, 3.4rem);
  color: var(--lapis-deep); line-height: 1.35;
  transition: color .2s;
}
.seg:hover .seg__surah { color: var(--lapis); }
.seg__range {
  display: flex; align-items: baseline; gap: .5rem; flex-wrap: wrap;
  font-size: clamp(1.15rem, .95rem + 1vw, 1.5rem);
  font-weight: 300; color: var(--ink);
  font-variant-numeric: tabular-nums;
  margin-top: .1rem;
}
.seg__range b { font-weight: 600; }
.seg__tail { color: var(--gold); font-size: .8em; font-weight: 500; }
.seg__count {
  margin-top: .75rem;
  font-size: .8rem; color: var(--ink-soft);
}
.seg__count::after {
  content: "↗"; margin-inline-start: .35rem; color: var(--lapis);
  display: inline-block;
  transition: transform .2s;
}
.seg:hover .seg__count::after { transform: translateX(-2px); }

.portion--rest {
  text-align: center;
}
.portion--rest .seg__surah { font-size: clamp(1.6rem, 1.2rem + 2vw, 2.4rem); }

/* ── Marking the day read ──────────────────────────────────────────────── */
.mark {
  display: flex; align-items: center; gap: .9rem; flex-wrap: wrap;
  margin-top: 1.5rem;
}
.mark__btn {
  border: 1px solid var(--lapis); background: transparent; color: var(--lapis);
  cursor: pointer; font-weight: 600; font-size: .95rem;
  padding: .7rem 1.6rem; border-radius: 999px;
  transition: background-color .2s, color .2s, border-color .2s;
}
.mark__btn:hover:not(:disabled) { background: var(--lapis); color: var(--paper); }
.mark__btn--done {
  background: var(--lapis); border-color: var(--lapis); color: var(--paper);
}
.mark__btn--done:hover:not(:disabled) { background: transparent; color: var(--lapis); }
.mark__btn:disabled { opacity: .45; cursor: not-allowed; border-color: var(--rule); color: var(--ink-soft); }
.mark__note { font-size: .8rem; color: var(--ink-soft); }

/* ── Progress ribbon ───────────────────────────────────────────────────── */
.ribbon { margin-top: 1.75rem; }
.ribbon__track {
  height: 3px; background: var(--rule); position: relative; overflow: hidden;
}
.ribbon__fill {
  position: absolute; inset-block: 0; inset-inline-start: 0;
  width: 0; background: var(--lapis);
  transition: width .7s cubic-bezier(.2,.7,.2,1);
}
.ribbon__caption {
  margin-top: .5rem; font-size: .78rem; color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

/* ── Day nav ───────────────────────────────────────────────────────────── */
.daynav { display: flex; gap: .5rem; margin-top: 1.75rem; }
.daynav__step, .daynav__now {
  border: 1px solid var(--rule); background: transparent; cursor: pointer;
  padding: .5rem .9rem; border-radius: 999px; font-size: .82rem;
  color: var(--ink-soft);
  transition: border-color .2s, color .2s;
}
.daynav__step:hover, .daynav__now:hover { color: var(--lapis); border-color: var(--lapis); }
.daynav__now { margin-inline-start: auto; color: var(--lapis); border-color: var(--lapis); }

/* ── The dial: the signature ───────────────────────────────────────────── */
.dial {
  display: grid; gap: 2rem;
  grid-template-columns: 1fr;
  align-items: center;
}
@media (min-width: 46rem) {
  .dial { grid-template-columns: 1fr 1.25fr; }
}
.dial__wheel { max-width: 24rem; width: 100%; margin-inline: auto; }
#wheel { width: 100%; height: auto; overflow: visible; }

.wheel__ring { fill: none; stroke: var(--rule); stroke-width: 1; }
.wheel__tick { stroke: var(--rule); stroke-width: 1; }
.wheel__name {
  font-family: var(--sans); font-size: 13px; font-weight: 400;
  fill: var(--ink-soft);
  transition: fill .5s ease, font-weight .5s ease;
}
.wheel__slot { transition: transform .8s cubic-bezier(.4,.1,.2,1); }
.wheel__name--first { fill: var(--gold); font-weight: 600; }
.wheel__name--me { fill: var(--lapis); font-weight: 700; }
.wheel__dot { fill: var(--rule); transition: fill .5s ease, r .5s ease; }
.wheel__dot--first { fill: var(--gold); }
.wheel__dot--me { fill: var(--lapis); }
.wheel__pointer { fill: var(--gold); }
.wheel__hub {
  font-family: var(--display); font-weight: 700; fill: var(--lapis-deep);
  text-anchor: middle;
}
.wheel__hub--sub {
  font-family: var(--sans); font-size: 12px; font-weight: 400; fill: var(--ink-soft);
}

/* ── Roster ────────────────────────────────────────────────────────────── */
.roster__head {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  margin-bottom: 1.25rem;
}
.roster__list { border-top: 1px solid var(--rule); }
.row {
  display: grid;
  grid-template-columns: 2.25rem minmax(6rem, auto) 1fr auto;
  gap: .75rem;
  align-items: baseline;
  padding: .8rem .25rem;
  border-bottom: 1px solid var(--rule);
}
.row__read, .row__wait { font-size: .75rem; white-space: nowrap; }
.row__read { color: var(--lapis); font-weight: 600; }
.row__wait { color: var(--ink-soft); opacity: .7; }
.row--me { background: color-mix(in srgb, var(--lapis) 7%, transparent); }
.row__n {
  font-size: .75rem; color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}
.row--me .row__n { color: var(--lapis); }
.row__name { font-weight: 600; }
.row--me .row__name { color: var(--lapis); }
.row__what {
  font-size: .9rem; color: var(--ink-soft); text-align: start;
  font-variant-numeric: tabular-nums;
}
.row__what .s { color: var(--ink); font-weight: 500; }
@media (max-width: 30rem) {
  .row { grid-template-columns: 1.75rem 1fr auto; }
  .row__what { grid-column: 2 / -1; }
}

/* ── Tracking ──────────────────────────────────────────────────────────── */
.behind { margin: 1.5rem 0 2.5rem; }
.behind__none { font-size: .9rem; color: var(--ink-soft); }
.behind__label {
  font-size: .8rem; font-weight: 600; color: var(--ink-soft);
  letter-spacing: .04em; margin-bottom: .6rem;
}
.behind__list { display: flex; flex-wrap: wrap; gap: .5rem; }
.behind__item {
  display: flex; align-items: baseline; gap: .5rem;
  border: 1px solid var(--rule); border-radius: 999px;
  padding: .35rem .85rem;
}
.behind__name { font-weight: 600; font-size: .85rem; }
.behind__count {
  font-size: .75rem; color: var(--gold); font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.grid-fig { margin: 0; }
.grid-fig__cap { font-size: .8rem; color: var(--ink-soft); margin-bottom: .9rem; }
.grid-scroll { overflow-x: auto; padding-bottom: .25rem; }
.grid { border-collapse: separate; border-spacing: 2px; }
.grid__corner { border: 0; }
.grid__day {
  font-size: .7rem; font-weight: 400; color: var(--ink-soft);
  padding-bottom: .35rem; text-align: center;
  font-variant-numeric: tabular-nums;
}
.grid__day--now { color: var(--lapis); font-weight: 700; }
.grid__who {
  font-size: .8rem; font-weight: 500; text-align: start;
  padding-inline-end: .75rem; white-space: nowrap;
}
.grid__row--me .grid__who { color: var(--lapis); font-weight: 700; }
.grid__cell { padding: 0; }

/* Status, not magnitude: four named states, each with a glyph or a shape —
   never colour alone. */
.cell {
  display: grid; place-items: center;
  width: 18px; height: 18px; border-radius: 3px;
  font-size: 11px; line-height: 1;
}
.cell__i { color: var(--paper); font-weight: 700; }
.cell--read   { background: var(--lapis); }
.cell--missed { background: transparent; box-shadow: inset 0 0 0 1px var(--gold); opacity: .85; }
.cell--due    { background: transparent; box-shadow: inset 0 0 0 1px var(--lapis); }
.cell--future { background: var(--paper-sunk); box-shadow: inset 0 0 0 1px var(--rule); }
.cell--none   { background: transparent; }

.legend {
  display: flex; flex-wrap: wrap; gap: 1rem;
  margin-top: 1.1rem; font-size: .75rem; color: var(--ink-soft);
}
.legend li { display: flex; align-items: center; gap: .4rem; }

/* ── Buttons ───────────────────────────────────────────────────────────── */
.btn {
  border: 1px solid var(--rule); background: transparent; cursor: pointer;
  padding: .55rem 1.1rem; border-radius: 999px; font-size: .85rem; font-weight: 500;
  color: var(--ink);
  transition: border-color .2s, color .2s, background-color .2s;
}
.btn:hover { border-color: var(--lapis); color: var(--lapis); }
.btn--solid {
  background: var(--lapis); border-color: var(--lapis); color: #fff;
}
.btn--solid:hover { background: var(--lapis-deep); border-color: var(--lapis-deep); color: #fff; }
[data-theme="night"] .btn--solid { color: #0E1119; }
[data-theme="night"] .btn--solid:hover { color: #0E1119; }
.btn--ghost { color: var(--ink-soft); }

/* ── Settings sheet ────────────────────────────────────────────────────── */
.sheet {
  border: 1px solid var(--rule);
  background: var(--paper);
  color: var(--ink);
  padding: 0;
  width: min(34rem, calc(100vw - 2rem));
  box-shadow: 0 40px 80px -40px rgba(0,0,0,.5);
}
.sheet::backdrop { background: color-mix(in srgb, var(--lapis-deep) 55%, transparent); }
.sheet__body { padding: clamp(1.25rem, 1rem + 2vw, 2rem); display: grid; gap: 1.25rem; }
.field { display: grid; gap: .35rem; }
.field__label { font-size: .85rem; font-weight: 600; }
.field__hint { font-size: .75rem; color: var(--ink-soft); }
.field-row { display: grid; gap: 1.25rem; grid-template-columns: 1fr 1fr; }
.input {
  background: var(--paper-sunk);
  border: 1px solid var(--rule);
  padding: .55rem .7rem;
  font-size: .9rem;
  border-radius: 2px;
  width: 100%;
}
textarea.input { resize: vertical; line-height: 1.9; }
.note { font-size: .78rem; color: var(--ink-soft); margin: -.5rem 0 0; }
.sheet__actions { display: flex; gap: .5rem; justify-content: flex-start; flex-wrap: wrap; }
.sheet__actions .btn--solid { margin-inline-start: auto; }

/* ── Toast ─────────────────────────────────────────────────────────────── */
.toast {
  position: fixed; inset-block-end: 1.25rem; inset-inline: 0;
  margin-inline: auto; width: fit-content; max-width: calc(100vw - 2rem);
  background: var(--lapis-deep); color: #fff;
  padding: .55rem 1.1rem; font-size: .85rem; border-radius: 999px;
  opacity: 0; transform: translateY(.5rem); pointer-events: none;
  transition: opacity .25s, transform .25s;
}
[data-theme="night"] .toast { color: #0E1119; background: var(--lapis); }
.toast--on { opacity: 1; transform: none; }

/* ── Foot ──────────────────────────────────────────────────────────────── */
.foot {
  max-width: var(--measure); margin-inline: auto;
  padding: 0 var(--step) 3rem;
  font-size: .75rem; color: var(--ink-soft);
}

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