/* ==========================================================================
   Sakina
   A quiet corner of the internet. Warm paper, one green, generous air.
   ========================================================================== */

/* --- tokens ------------------------------------------------------------- */

:root {
  color-scheme: light;

  --paper:        #f7f4ec;
  --paper-warm:   #f2eee3;
  --card:         #fbf9f4;
  --card-raised:  #ffffff;

  --ink:          #23261e;
  --ink-2:        #5c6154;
  --ink-3:        #8b9084;

  --line:         #e2ddd0;
  --line-soft:    #ebe6da;

  --green:        #4a6741;
  --green-deep:   #3a5233;
  --green-tint:   #eef1e8;
  --gold:         #9a7b3f;

  --shadow-sm: 0 1px 2px rgba(35, 38, 30, .05);
  --shadow-md: 0 1px 2px rgba(35, 38, 30, .04), 0 8px 24px -12px rgba(35, 38, 30, .16);
  --shadow-lg: 0 1px 3px rgba(35, 38, 30, .05), 0 18px 48px -20px rgba(35, 38, 30, .22);

  --serif: "Cormorant Garamond", "Iowan Old Style", Palatino, Georgia, serif;
  --sans:  "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --quran: "Amiri Quran", "Scheherazade New", "Traditional Arabic", serif;
  --urdu:  "Noto Nastaliq Urdu", "Jameel Noori Nastaleeq", "Amiri", serif;

  --radius:    14px;
  --radius-lg: 20px;
  --measure:   64ch;
  --page:      min(100% - 2.5rem, 62rem);
  --narrow:    min(100% - 2.5rem, 44rem);
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --paper:        #14170f;
  --paper-warm:   #191d13;
  --card:         #1c2016;
  --card-raised:  #212619;

  --ink:          #ece9dd;
  --ink-2:        #a8ac9c;
  --ink-3:        #7c8173;

  --line:         #2f342a;
  --line-soft:    #272c22;

  --green:        #a3bd90;
  --green-deep:   #b9cfa8;
  --green-tint:   #232a1d;
  --gold:         #c9a86a;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
  --shadow-md: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px -12px rgba(0, 0, 0, .6);
  --shadow-lg: 0 1px 3px rgba(0, 0, 0, .3), 0 18px 48px -20px rgba(0, 0, 0, .7);
}

/* --- reset -------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.65;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* The warm bloom behind the top of the page. */
body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto 0;
  height: 60vh;
  background:
    radial-gradient(120% 70% at 50% 0%, var(--paper-warm) 0%, transparent 70%),
    radial-gradient(60% 40% at 82% 8%, color-mix(in oklab, var(--green) 8%, transparent) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

h1, h2, h3 { margin: 0; font-weight: 400; line-height: 1.2; text-wrap: balance; }
p  { margin: 0; text-wrap: pretty; }
ul { margin: 0; padding: 0; list-style: none; }

a { color: var(--green); text-decoration-color: color-mix(in oklab, var(--green) 35%, transparent); text-underline-offset: .2em; }
a:hover { text-decoration-color: currentColor; }

button, input { font: inherit; color: inherit; }

svg { width: 1em; height: 1em; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

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

.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: 50%; top: .5rem; transform: translate(-50%, -200%);
  z-index: 100; padding: .6rem 1.1rem; border-radius: 999px;
  background: var(--card-raised); box-shadow: var(--shadow-md); text-decoration: none;
}
.skip-link:focus { transform: translate(-50%, 0); }

/* --- header ------------------------------------------------------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .85rem max(1.25rem, (100% - 62rem) / 2);
  background: color-mix(in oklab, var(--paper) 82%, transparent);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  border-bottom: 1px solid transparent;
  transition: border-color .3s ease, background .3s ease;
}
.site-header[data-scrolled="true"] { border-bottom-color: var(--line-soft); }

.brand {
  display: inline-flex; align-items: center; gap: .6rem;
  color: var(--ink); text-decoration: none;
}
.brand-mark {
  width: .7rem; height: .7rem; border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 4px color-mix(in oklab, var(--green) 12%, transparent);
  transition: box-shadow .35s ease;
}
.brand:hover .brand-mark { box-shadow: 0 0 0 6px color-mix(in oklab, var(--green) 16%, transparent); }
.brand-name { font-family: var(--serif); font-size: 1.45rem; letter-spacing: .01em; }

.header-tools { display: flex; align-items: center; gap: .5rem; }

.lang-switch {
  display: inline-flex; align-items: center; gap: .15rem;
  padding: .2rem;
  background: var(--card-raised);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
}
.lang-switch button {
  padding: .3rem .75rem;
  border: 0; border-radius: 999px;
  background: transparent; color: var(--ink-3);
  font-size: .8rem; font-weight: 500; line-height: 1.5;
  cursor: pointer;
  transition: background .2s ease, color .2s ease;
}
.lang-switch button:hover { color: var(--ink); }
/* A tinted pill is invisible against the switch's own light ground, so the
   selected language gets the solid fill. */
.lang-switch button[aria-pressed="true"] {
  background: var(--green);
  color: #fbf9f4;
}
:root[data-theme="dark"] .lang-switch button[aria-pressed="true"] { color: #14170f; }
.lang-switch button[aria-pressed="true"]:hover { color: #fbf9f4; }
:root[data-theme="dark"] .lang-switch button[aria-pressed="true"]:hover { color: #14170f; }
.lang-switch button[lang="ur"] {
  font-family: var(--urdu);
  font-size: .95rem;
  padding-block: .1rem;
}

.icon-btn {
  display: grid; place-items: center;
  width: 2.4rem; height: 2.4rem; padding: 0;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--card-raised); color: var(--ink-2);
  cursor: pointer; font-size: 1.05rem;
  box-shadow: var(--shadow-sm);
  transition: color .2s ease, border-color .2s ease, transform .2s ease;
}
.icon-btn:hover { color: var(--ink); border-color: var(--ink-3); transform: translateY(-1px); }
.icon-btn svg { grid-area: 1 / 1; }
.icon-moon { display: none; }
:root[data-theme="dark"] .icon-sun  { display: none; }
:root[data-theme="dark"] .icon-moon { display: block; }

/* --- layout ------------------------------------------------------------- */

main {
  position: relative;
  z-index: 1;
  flex: 1;
  width: var(--page);
  margin-inline: auto;
  padding-block: clamp(2.5rem, 7vw, 5rem) 4rem;
}
main:focus { outline: none; }

.view-enter { animation: rise .5s cubic-bezier(.22, 1, .36, 1) both; }
@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

/* --- hero --------------------------------------------------------------- */

.hero { text-align: center; max-width: var(--narrow); margin-inline: auto; }

.eyebrow {
  font-size: .72rem; font-weight: 500;
  letter-spacing: .22em; text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 1.4rem;
}

.hero-title {
  font-family: var(--serif);
  font-size: clamp(2.5rem, 7.5vw, 4rem);
  font-weight: 300;
  letter-spacing: -.015em;
  margin-bottom: .8rem;
}

.hero-sub {
  font-size: clamp(1rem, 2.4vw, 1.1rem);
  color: var(--ink-2);
  max-width: 34ch;
  margin-inline: auto;
}

.seek {
  display: flex; align-items: center; gap: .4rem;
  margin: 2.4rem auto 0;
  padding: .4rem .4rem .4rem 1.3rem;
  background: var(--card-raised);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow-md);
  transition: border-color .25s ease, box-shadow .25s ease;
}
.seek:focus-within {
  border-color: color-mix(in oklab, var(--green) 45%, var(--line));
  box-shadow: var(--shadow-lg), 0 0 0 4px color-mix(in oklab, var(--green) 10%, transparent);
}
.seek-input {
  flex: 1; min-width: 0;
  padding: .7rem 0;
  border: 0; background: none; outline: none;
  font-size: .95rem;
}
.seek-input::placeholder { color: var(--ink-3); }
.seek-btn { flex: none; }

.seek-note {
  margin-top: 1rem;
  font-size: .85rem;
  color: var(--ink-3);
  min-height: 1.4em;
}
.seek-note[data-state="miss"] { color: var(--gold); }

/* --- buttons ------------------------------------------------------------ */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .62rem 1.15rem;
  border: 1px solid transparent; border-radius: 999px;
  font-size: .875rem; font-weight: 500; line-height: 1.2;
  text-decoration: none; white-space: nowrap; cursor: pointer;
  transition: background .2s ease, color .2s ease, border-color .2s ease, transform .2s ease;
}
.btn .icon { font-size: 1em; opacity: .85; }
.btn:active { transform: translateY(1px); }

.btn-primary { background: var(--green); color: #fbf9f4; }
.btn-primary:hover { background: var(--green-deep); }
:root[data-theme="dark"] .btn-primary { color: #14170f; }

.btn-ghost {
  background: transparent; color: var(--ink-2); border-color: var(--line);
}
.btn-ghost:hover { color: var(--ink); border-color: var(--ink-3); background: var(--card-raised); }
.btn-ghost[aria-pressed="true"] {
  color: var(--green); border-color: color-mix(in oklab, var(--green) 40%, var(--line));
  background: var(--green-tint);
}

.btn-quiet {
  background: var(--card-raised); color: var(--ink-2); border-color: var(--line);
  box-shadow: var(--shadow-sm);
}
.btn-quiet:hover { color: var(--ink); border-color: var(--ink-3); }

.link-btn {
  padding: 0; border: 0; background: none; cursor: pointer;
  color: var(--green); font-size: inherit;
  text-decoration: underline; text-underline-offset: .2em;
  text-decoration-color: color-mix(in oklab, var(--green) 35%, transparent);
}
.link-btn:hover { text-decoration-color: currentColor; }

/* --- rule heading ------------------------------------------------------- */

.rule-heading {
  display: flex; align-items: center; gap: 1.1rem;
  margin: clamp(3rem, 8vw, 4.5rem) 0 1.6rem;
  font-size: .7rem; font-weight: 500;
  letter-spacing: .2em; text-transform: uppercase;
  color: var(--ink-3);
}
.rule-heading::before, .rule-heading::after {
  content: ""; flex: 1; height: 1px;
  background: linear-gradient(90deg, transparent, var(--line), transparent);
}
.rule-heading span { flex: none; }

/* --- feeling grid ------------------------------------------------------- */

.feeling-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: .8rem;
}

.feeling-card {
  display: block;
  height: 100%;
  padding: 1.05rem 1.2rem 1.15rem;
  background: var(--card);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  text-decoration: none; color: inherit;
  box-shadow: var(--shadow-sm);
  transition: transform .22s cubic-bezier(.22, 1, .36, 1), box-shadow .22s ease, border-color .22s ease, background .22s ease;
}
.feeling-card:hover {
  transform: translateY(-2px);
  background: var(--card-raised);
  border-color: color-mix(in oklab, var(--green) 30%, var(--line));
  box-shadow: var(--shadow-md);
}
.feeling-card b {
  display: block;
  font-family: var(--serif);
  font-size: 1.3rem; font-weight: 500; line-height: 1.25;
  letter-spacing: .005em;
}
.feeling-card span {
  display: block; margin-top: .3rem;
  font-size: .82rem; color: var(--ink-3);
}
.feeling-card.is-match {
  border-color: var(--green);
  box-shadow: var(--shadow-md), 0 0 0 3px color-mix(in oklab, var(--green) 14%, transparent);
}

/* --- carried tally ------------------------------------------------------ */

.carried-list { display: flex; flex-wrap: wrap; gap: .5rem; }
.carried-list li {
  display: inline-flex; align-items: baseline; gap: .5rem;
  padding: .38rem .5rem .38rem .85rem;
  background: var(--card); border: 1px solid var(--line-soft);
  border-radius: 999px; font-size: .85rem; color: var(--ink-2);
}
.carried-list a { color: inherit; text-decoration: none; }
.carried-list a:hover { color: var(--green); }
.carried-list .count {
  display: inline-grid; place-items: center;
  min-width: 1.5rem; height: 1.5rem; padding: 0 .35rem;
  background: var(--green-tint); border-radius: 999px;
  font-size: .75rem; font-variant-numeric: tabular-nums; color: var(--green);
}
.carried-note { margin-top: .9rem; font-size: .8rem; color: var(--ink-3); }

/* --- feeling page ------------------------------------------------------- */

.crumb { margin-bottom: 1.6rem; font-size: .85rem; }
.crumb a { color: var(--ink-3); text-decoration: none; }
.crumb a:hover { color: var(--green); }

.feeling-title, .page-title {
  font-family: var(--serif);
  font-size: clamp(1.9rem, 5vw, 2.8rem);
  font-weight: 300;
  text-align: center;
  letter-spacing: -.01em;
  margin-bottom: 2rem;
}
.feeling-title em { font-style: italic; color: var(--green); }
.page-title { text-align: left; margin-bottom: 1.5rem; }

/* --- the passage card --------------------------------------------------- */

.passage {
  max-width: var(--narrow);
  margin-inline: auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.passage-head {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: start;
  gap: .5rem 1rem;
  padding: 1.4rem 1.6rem 1.2rem;
  background: var(--card-raised);
  border-bottom: 1px solid var(--line-soft);
}
.surah-ar {
  grid-column: 1 / -1;
  font-family: var(--quran);
  font-size: 1.4rem; line-height: 1.9;
  color: var(--ink-2);
}
.surah-meta { min-width: 0; }
.surah-en {
  font-family: var(--serif);
  font-size: 1.45rem; font-weight: 500; letter-spacing: .005em;
}
.surah-sub { font-size: .82rem; color: var(--ink-3); }
.ref-badge {
  align-self: center;
  padding: .3rem .7rem;
  background: var(--green-tint);
  border-radius: 999px;
  font-size: .8rem; font-variant-numeric: tabular-nums;
  color: var(--green); white-space: nowrap;
}

.passage-body { padding: 2rem 1.6rem 1.6rem; }

.arabic {
  font-family: var(--quran);
  font-size: clamp(1.5rem, 4.3vw, 1.95rem);
  line-height: 2.5;
  text-align: center;
  color: var(--ink);
}
.arabic .ayah-sep {
  display: inline-block;
  margin: 0 .35em;
  font-family: var(--sans);
  font-size: .5em;
  font-variant-numeric: tabular-nums;
  color: var(--green);
  vertical-align: .35em;
}
.arabic .ayah-sep::before { content: "\FD3F"; margin-inline-end: -.15em; opacity: .55; }
.arabic .ayah-sep::after  { content: "\FD3E"; margin-inline-start: -.15em; opacity: .55; }

.translation {
  margin-top: 1.8rem;
  padding-top: 1.6rem;
  border-top: 1px solid var(--line-soft);
  font-family: var(--serif);
  font-size: 1.2rem;
  line-height: 1.65;
  color: var(--ink-2);
  text-align: center;
  max-width: 52ch;
  margin-inline: auto;
}

/* Nastaliq sits on a steep diagonal and needs far more leading than a Latin
   face at the same size, or the descenders of one line collide with the next. */
.translation.is-rtl {
  font-family: var(--urdu);
  font-size: 1.05rem;
  line-height: 2.6;
  max-width: 46ch;
}
.snippet.is-rtl {
  font-family: var(--urdu);
  font-size: .8rem;
  line-height: 2.3;
  text-align: right;
}

.why {
  margin: 0 1.6rem 1.6rem;
  padding: 1.1rem 1.3rem;
  background: var(--green-tint);
  border-radius: var(--radius);
  border: 1px solid color-mix(in oklab, var(--green) 12%, transparent);
}
.why-heading {
  font-size: .68rem; font-weight: 600;
  letter-spacing: .18em; text-transform: uppercase;
  color: var(--green); margin-bottom: .5rem;
}
.why p { font-size: .93rem; color: var(--ink-2); }

.passage-foot {
  display: flex; flex-wrap: wrap; align-items: center;
  justify-content: space-between; gap: .8rem;
  padding: 1rem 1.6rem 1.3rem;
  border-top: 1px solid var(--line-soft);
}
.actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.attrib { font-size: .75rem; color: var(--ink-3); }

.passage-nav {
  display: flex; flex-wrap: wrap; justify-content: center; gap: .6rem;
  margin-top: 1.4rem;
}

/* --- more list ---------------------------------------------------------- */

.more-list { display: grid; gap: .55rem; }
.more-list > li { min-width: 0; }
.more-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  gap: .3rem 1rem;
  width: 100%;
  min-width: 0;
  padding: .95rem 1.15rem;
  background: var(--card);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  text-align: left; cursor: pointer;
  transition: background .2s ease, border-color .2s ease, transform .2s ease;
}
.more-item:hover {
  transform: translateY(-1px);
  background: var(--card-raised);
  border-color: color-mix(in oklab, var(--green) 28%, var(--line));
}
.more-item[aria-current="true"] {
  border-color: color-mix(in oklab, var(--green) 45%, var(--line));
  background: var(--green-tint);
}
.more-item .name {
  font-family: var(--serif); font-size: 1.15rem; font-weight: 500;
}
.more-item .ref {
  font-size: .78rem; font-variant-numeric: tabular-nums; color: var(--ink-3);
}
.more-item .name { min-width: 0; overflow-wrap: anywhere; }
.more-item .snippet {
  grid-column: 1 / -1;
  min-width: 0;
  font-size: .85rem; color: var(--ink-2);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  line-clamp: 2; overflow: hidden;
  overflow-wrap: anywhere;
}

.safety {
  max-width: var(--narrow);
  margin: 3rem auto 0;
  padding-top: 1.4rem;
  border-top: 1px solid var(--line-soft);
  font-size: .84rem; color: var(--ink-3); text-align: center;
}

/* --- prose (about) ------------------------------------------------------ */

.prose { max-width: var(--measure); }
.prose p { margin-bottom: 1.1rem; color: var(--ink-2); }
.prose h2 {
  font-family: var(--serif);
  font-size: 1.5rem; font-weight: 500;
  margin: 2.2rem 0 .6rem;
  color: var(--ink);
}

/* --- footer ------------------------------------------------------------- */

.site-footer {
  position: relative; z-index: 1;
  width: var(--page);
  margin: 0 auto;
  padding: 2.5rem 0 3rem;
  border-top: 1px solid var(--line-soft);
  text-align: center;
}
.disclaimer {
  max-width: 56ch; margin: 0 auto 1.1rem;
  font-size: .84rem; color: var(--ink-3);
}
.footer-nav {
  display: flex; justify-content: center; gap: .7rem;
  font-size: .85rem; color: var(--ink-3);
}
.footer-nav a { text-decoration: none; }
.footer-nav a:hover { text-decoration: underline; }
.credits {
  max-width: 56ch; margin: 1.1rem auto 0;
  font-size: .74rem; line-height: 1.6; color: var(--ink-3);
}
.credits a { color: inherit; }

/* --- small screens ------------------------------------------------------ */

@media (max-width: 34rem) {
  .seek {
    flex-direction: column; align-items: stretch;
    gap: .55rem; padding: .9rem; border-radius: var(--radius-lg);
  }
  .seek-input { padding: .35rem .4rem; text-align: center; }
  .seek-btn { width: 100%; padding-block: .75rem; }

  .passage-head, .passage-body, .passage-foot { padding-inline: 1.15rem; }
  .why { margin-inline: 1.15rem; }
  .passage-foot { justify-content: center; }
  .actions { justify-content: center; width: 100%; }
  .attrib { width: 100%; text-align: center; }
  .arabic { line-height: 2.3; }
}

@media print {
  .site-header, .passage-nav, .actions, .skip-link, .more, .carried { display: none; }
  body::before { display: none; }
  .passage { box-shadow: none; border-color: #ccc; }
}
