/* Word meanings in the reader. Tokens come from maqraa.css (light, dark, and the system dark setting);
   logical properties only, so it mirrors in Arabic and English. Spacing 4/8/12/16/24; controls 8px, panel 18px;
   tap targets 44px (design kit: Brand floors). Text is --text / --text-muted, never gold, on every ground. */

/* ------------------------------------------------------------ marked words */
.mushaf-reader:not(.gh-off) .w.gh-has {
  cursor: pointer; border-radius: 6px;
  text-decoration: underline dotted var(--accent); text-decoration-thickness: 2px; text-underline-offset: .32em;
  padding-block: .45em; margin-block: -.45em;   /* taller hit area, same line height */
  transition: background-color .12s ease;
}
.mushaf-reader:not(.gh-off) .w.gh-has:hover { background: var(--accent-soft); }
.mushaf-reader:not(.gh-off) .w.gh-has:active { background: color-mix(in srgb, var(--accent) 28%, transparent); }
.mushaf-reader .w.gh-has:focus-visible { outline: 3px solid var(--gold-500); outline-offset: 2px; }
.mushaf-reader .w.gh-open { background: var(--accent-soft); text-decoration-style: solid; }

.gh-verse-btn {
  display: inline-flex; align-items: center; justify-content: center; vertical-align: middle;
  inline-size: 44px; block-size: 44px; margin-block: -14px; margin-inline: -8px;   /* 44px target, no extra line height */
  padding: 0; border: 0; background: transparent; color: var(--accent); cursor: pointer; border-radius: 8px;
}
.gh-verse-btn:hover { color: var(--text); }
.gh-verse-btn:active { transform: scale(.94); }
.gh-verse-btn:focus-visible { outline: 3px solid var(--gold-500); outline-offset: -4px; }
.gh-verse-btn[hidden] { display: none; }

/* ------------------------------------------------------------ switch in the toolbar */
.gh-switch { gap: .5rem; align-items: center; min-inline-size: 0; }
.gh-switch[hidden] { display: none; }
.gh-toggle {
  display: inline-flex; align-items: center; gap: .5rem; min-block-size: 44px; padding: 0 .9rem;
  font: inherit; font-size: .95rem; font-weight: 600; color: var(--text); cursor: pointer;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 8px;
  transition: background-color .12s ease, transform .05s ease;
}
.gh-toggle:hover { background: var(--accent-soft); }
.gh-toggle:active { transform: translateY(1px); }
.gh-toggle:focus-visible { outline: 3px solid var(--gold-500); outline-offset: 2px; }
.gh-toggle-dot {
  inline-size: 14px; block-size: 14px; border-radius: 50%; flex: none;
  border: 2px solid var(--text-muted); background: transparent;
}
.gh-toggle[aria-pressed="true"] .gh-toggle-dot { border-color: var(--primary); background: var(--primary); }
.gh-hint { max-inline-size: 22rem; }
@media (max-width: 600px) {
  .gh-hint { position: absolute; inline-size: 1px; block-size: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}

/* ------------------------------------------------------------ popover and sheet */
.gh-pop {
  position: absolute; inset-block-start: var(--gh-y, 0); inset-inline-start: auto; left: var(--gh-x, 0);
  z-index: 60; inline-size: min(22rem, calc(100vw - 16px)); max-block-size: min(60vh, 26rem); overflow: auto;
  background: var(--bg-elevated); color: var(--text); border: 1px solid var(--border-strong);
  border-radius: 18px; box-shadow: var(--shadow); padding: .75rem 1rem 1rem;
  opacity: 0; transform: translateY(4px);
}
.gh-pop[hidden] { display: none; }
.gh-pop.gh-in { opacity: 1; transform: none; transition: opacity .14s ease, transform .14s ease; }
.gh-pop.gh-above { transform: translateY(-4px); }
.gh-pop.gh-above.gh-in { transform: none; }
.gh-pop:focus { outline: none; }
.gh-pop:focus-visible { outline: 3px solid var(--gold-500); outline-offset: 2px; }

.gh-pop-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.gh-pop-title { margin: 0; font-size: .9rem; font-weight: 700; color: var(--text-muted); letter-spacing: 0; }
.gh-close {
  flex: none; inline-size: 44px; block-size: 44px; margin-inline-end: -.5rem; display: grid; place-items: center;
  font: inherit; font-size: 1.6rem; line-height: 1; color: var(--text); background: transparent; border: 0;
  border-radius: 8px; cursor: pointer;
}
.gh-close:hover { background: var(--accent-soft); }
.gh-close:active { transform: scale(.94); }
.gh-close:focus-visible { outline: 3px solid var(--gold-500); outline-offset: -3px; }

.gh-entry + .gh-entry { margin-block-start: 1rem; padding-block-start: 1rem; border-block-start: 1px solid var(--border); }
.gh-phrase { margin: 0 0 .25rem; font-family: "Muqraa Quran", var(--font-quran); font-size: 1.5rem; line-height: 1.9; color: var(--text); }
.gh-meaning { margin: 0 0 .5rem; font-family: var(--font-ui); font-size: 1.05rem; line-height: 1.8; color: var(--text); }
.gh-book { margin: 0; font-size: .85rem; color: var(--text-muted); }
.gh-book cite { font-style: normal; font-weight: 600; }

/* ------------------------------------------------------------ tafsir in the verse sheet */
.gh-tafsir { margin-block-start: 1rem; padding-block-start: 1rem; border-block-start: 1px solid var(--border); }
.gh-pop-body > .gh-tafsir:first-child { margin-block-start: 0; padding-block-start: 0; border-block-start: 0; }
.gh-tafsir-title { margin: 0 0 .5rem; font-size: .9rem; font-weight: 700; color: var(--text-muted); letter-spacing: 0; }
.gh-tafsir-pick {
  inline-size: 100%; min-block-size: 44px; padding: .4rem .75rem; font: inherit; font-size: 1rem; color: var(--text);
  background: var(--bg-elevated); border: 1px solid var(--border-strong); border-radius: 12px;
}
.gh-tafsir-pick:focus-visible, .gh-source:focus-visible { outline: 3px solid var(--gold-500); outline-offset: 2px; }
.gh-tafsir-text { margin: .75rem 0 .5rem; font-family: var(--font-ui); font-size: 1.1rem; line-height: 1.9; color: var(--text); }
.gh-source { display: inline-block; min-block-size: 44px; line-height: 44px; font-weight: 600; color: var(--accent); }

/* Phones: a bottom sheet, thumb-reachable, full width. */
@media (max-width: 600px) {
  .gh-pop {
    position: fixed; inset-block: auto 0; inset-inline: 0; left: 0; inline-size: auto; max-block-size: 55vh;
    border-radius: 18px 18px 0 0; border-block-end: 0;
    padding-block-end: calc(1rem + env(safe-area-inset-bottom, 0px));
    transform: translateY(24px);
  }
  .gh-pop.gh-above { transform: translateY(24px); }
}
@media (prefers-reduced-motion: reduce) {
  .gh-pop, .gh-pop.gh-in, .gh-toggle, .mushaf-reader .w.gh-has { transition: none; }
  .gh-pop { transform: none; }
}
@media print { .gh-pop, .gh-switch, .gh-verse-btn { display: none !important; } .w.gh-has { text-decoration: none; } }
