/* Similar Āyāt side by side (build 3, public/similar.js).

   Two parts. The first is the portal's own: the pop-up the cards open in, on the portal's tokens.
   The second is NOT the portal's look and must not be "tidied" onto its tokens: it is the Similar Āyāt guide's
   own card, copied from the guide (content/css/cards.css, the card rules of content/css/guide.css, and the
   guide's Indo-Pak font settings), because the rule is that Arabic on screen copies the guide's fonts and spacing.
   Every rule of it sits under .sim so it cannot touch anything else. If the guide's card changes, copy the change
   here; do not restyle the Arabic. */

/* ---------- the portal's part ---------- */
.sim-dialog { width: min(1000px, calc(100vw - 24px)); max-width: none; max-height: calc(100dvh - 24px); padding: 0; border: 1px solid var(--line); border-radius: var(--r-card);
  background: var(--bg); color: var(--tx); box-shadow: var(--shadow-up); overflow: auto; overscroll-behavior: contain; }
.sim-dialog::backdrop { background: rgba(10, 16, 30, .6); }
.sim-top { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 18px;
  background: var(--card); border-bottom: 1px solid var(--line); }
.sim-top h2 { font-size: 1.35rem; }
.sim-body { display: flex; flex-direction: column; gap: 16px; padding: 16px 18px 22px; }
.sim-note { border-left: 3px solid var(--mk-mixup); padding: 2px 0 2px 12px; }
.sim-turn { display: none; }
.sim-key { display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: center; font-size: .88rem; color: var(--tx-2); }
.sim-key span { display: inline-flex; align-items: center; gap: 8px; }
.sim-key i { display: inline-block; width: 22px; height: 14px; flex: none; }
.sim-key .box { background: #fff3cd; border: 2px solid #e6a817; border-radius: 4px; }
.sim-key .line { border-bottom: 3px solid #e53935; height: 9px; }
.sim-go { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 8px; }
.sim .sim-go .btn { font-family: var(--body); white-space: normal; text-align: left; height: auto; padding-top: 8px; padding-bottom: 8px; }
.sim-open { align-self: flex-start; }
@media (max-width: 600px) {
  .sim-dialog { width: 100vw; height: 100dvh; max-height: none; margin: 0; border: 0; border-radius: 0; }
  .sim-top { padding: 10px 14px; }
  .sim-body { padding: 14px 12px 20px; }
  .sim-turn { display: block; }
}

/* ---------- the guide's card, as the guide draws it ---------- */
.sim {
  --g-label: #8a6a10; --g-rule: #e9dfc6; --g-line: #d9cba2; --g-chip: 4px;
  --g-util: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --g-display: 'Cormorant Garamond', 'Georgia', serif;
  --g-arabic: 'DigitalKhatt IndoPak', 'Scheherazade New', serif;
  --g-green: linear-gradient(180deg, #2f5f2f 0%, #1e431e 46%, #122f12 100%);
  --g-green-edge: inset 0 1px 0 rgba(232, 213, 163, 0.22), inset 0 -1px 0 rgba(0, 0, 0, 0.32);
  --g-shadow: 0 1px 2px rgba(58, 44, 10, 0.05), 0 10px 24px -18px rgba(58, 44, 10, 0.3);
}
/* Safari, and every browser on an iPhone or iPad, cannot place the Indo-Pak font's dots and vowel signs. There the
   words are drawn from the guide's "SAG IndoPak Words" font (one ready-made shape per word; public/similar.js swaps
   them in). Until that is ready, or if it cannot load, the Arabic shows in Scheherazade New, never broken. */
html.sim-hb .sim { --g-arabic: 'SAG IndoPak Words', 'Scheherazade New', serif; }
html.sim-hb.sim-hb-fail .sim { --g-arabic: 'Scheherazade New', serif; }
html.sim-hb .sim .sim-miss { font-family: 'Scheherazade New', serif; }
html.sim-hb .sim .sim-on { unicode-bidi: isolate-override; direction: rtl; }

.sim .pair-card { background: #fff; border: 1px solid #dccfa7; border-radius: 6px; overflow: hidden; box-shadow: var(--g-shadow);
  font-family: 'Georgia', serif; font-size: 16px; line-height: normal; color: #1a1a1a; text-align: left; }
.sim .pair-card-header { background: #f7f2e5; border-bottom: 1px solid var(--g-rule); padding: 12px 20px 11px; display: flex; justify-content: space-between;
  align-items: baseline; flex-wrap: wrap; gap: 3px 18px; }
.sim .pair-num { font-family: var(--g-util); font-size: 0.7rem; font-weight: 700; letter-spacing: 0.18em; color: var(--g-label); white-space: nowrap; text-transform: uppercase; }
.sim .pair-surah { margin-left: auto; text-align: right; font-family: var(--g-display); font-weight: 600; font-size: 1.08rem; line-height: 1.3; letter-spacing: 0.005em;
  color: #3f3a2c; font-variant-numeric: lining-nums; }
.sim .ayah-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--g-rule); }
.sim .ayah-panel { background: #fff; padding: 16px 20px; min-width: 0; }
.sim .ayah-panel:last-child:nth-child(odd) { grid-column: 1 / -1; }
.sim .ayah-grid.ayah-grid-stacked { grid-template-columns: 1fr; }
.sim .ayah-meta { display: flex; gap: 0; margin-bottom: 12px; flex-wrap: wrap; align-items: center; }
.sim .meta-badge { font-family: var(--g-util); font-size: 0.66rem; font-weight: 600; letter-spacing: 0.03em; line-height: 1; padding: 4px 7px; border-radius: var(--g-chip);
  font-variant-numeric: tabular-nums; }
.sim .badge-ayah { background: var(--g-green); box-shadow: var(--g-green-edge); font-weight: 700; letter-spacing: 0.05em; padding: 4px 9px; border: 1px solid #16331a;
  color: #e2c46c; margin-right: 8px; }
.sim .badge-juz, .sim .badge-quarter, .sim .badge-page { background: transparent; color: #756d58; border: 1px solid var(--g-line); border-radius: 0; padding: 4px 8px; }
.sim .badge-juz { border-radius: var(--g-chip) 0 0 var(--g-chip); }
.sim .badge-quarter { border-left: 0; }
.sim .badge-page { border-left: 0; border-radius: 0 var(--g-chip) var(--g-chip) 0; }
.sim .arabic-text { font-family: var(--g-arabic); font-size: 1.25rem; line-height: 2.75; direction: rtl; text-align: right; color: #1a1a1a; }
.sim .highlight-underline { color: #c0210f; font-weight: bold; text-decoration: underline; text-decoration-color: #e53935; text-decoration-thickness: 3px;
  text-underline-offset: 0.78em; text-decoration-skip-ink: none; }
.sim .highlight-circle { display: inline; background: #fff3cd; border: 2px solid #e6a817; border-radius: 4px; padding: 0.07em 3px 0.32em; color: #7a4800; font-weight: bold; }
/* A yellow box is never split across two lines, unless it is longer than a line of its panel on this screen (similar.js). */
.sim .arabic-text .highlight-circle { white-space: nowrap; }
.sim .arabic-text .highlight-circle.fit-wrap { white-space: normal; }
.sim .ayah-end-mark { color: #b8934a; font-size: 0.85em; font-weight: normal; margin: 0 0.15em; font-family: 'Scheherazade New', serif; }
.sim .pause-mark { display: inline-block; margin: 0 0.55em; vertical-align: middle; transform: translateY(0.60em); font-size: 0.95em; line-height: 1; color: #1a1a1a;
  font-family: 'Scheherazade New', serif; }
.sim .pause-mark + .pause-mark, .sim .pause-mark:has(+ .pause-mark) { text-decoration: none; }
.sim .pause-mark[title*="small low meem"] { transform: translateY(0em); }
.sim .pause-mark[title^="قف --"], .sim .pause-mark[title^="۵ --"] { font-size: 0.36em; transform: translateY(-0.15em); }
.sim .pause-mark[title^="قف --"]::before { content: "\0642\0641"; }
.sim .pause-mark[title^="۵ --"]::before { content: "\06F5"; }
.sim .pause-mark[title*="; ۵ --"] { position: relative; }
.sim .pause-mark[title*="; ۵ --"]::after { content: "\06F5"; position: absolute; left: 50%; top: 0.62em; transform: translateX(-50%); font-size: 0.42em; line-height: 1; }
.sim .key-diff, .sim .memory-tip { display: flex; align-items: baseline; gap: 16px; padding: 13px 20px; }
.sim .key-diff { background: #f7f2e5; border-top: 1px solid var(--g-rule); }
.sim .memory-tip { background: #e8f0e8; border-top: 1px solid #b0ccb0; padding-top: 12px; }
.sim .key-diff-label, .sim .tip-label { flex: 0 0 auto; min-width: 92px; margin-top: 0; font-family: var(--g-util); font-size: 0.62rem; font-weight: 700; letter-spacing: 0.15em; white-space: nowrap; }
.sim .key-diff-label { color: var(--g-label); }
.sim .tip-label { color: #33653a; }
.sim .key-diff-text { font-size: 0.84rem; line-height: 1.65; color: #36332b; }
.sim .tip-text { font-size: 0.82rem; line-height: 1.6; color: #26382a; font-style: italic; }
.sim .arabic-inline { font-family: var(--g-arabic); font-size: 1rem; direction: rtl; display: inline; unicode-bidi: isolate; }
/* The guide thins the Indo-Pak font a little where it sits small inside the English lines (the filters are added to the page by similar.js). */
.sim .key-diff-text .arabic-inline, .sim .tip-text .arabic-inline { filter: url(#sim-ip-thin); }
:root[data-theme="night"] .sim .key-diff-text .arabic-inline, :root[data-theme="night"] .sim .tip-text .arabic-inline { filter: url(#sim-ip-thin-night); }
@media (min-resolution: 1.2dppx) {
  .sim .key-diff-text .arabic-inline, .sim .tip-text .arabic-inline { filter: url(#sim-ip-thin-1x5); }
}
@media (min-resolution: 1.75dppx) {
  .sim .key-diff-text .arabic-inline, .sim .tip-text .arabic-inline { filter: url(#sim-ip-thin-2x); }
  :root[data-theme="night"] .sim .key-diff-text .arabic-inline, :root[data-theme="night"] .sim .tip-text .arabic-inline { filter: url(#sim-ip-thin-night-2x); }
}
@media (min-resolution: 3.5dppx) {
  .sim .key-diff-text .arabic-inline, .sim .tip-text .arabic-inline { filter: url(#sim-ip-thin-4x); }
  :root[data-theme="night"] .sim .key-diff-text .arabic-inline, :root[data-theme="night"] .sim .tip-text .arabic-inline { filter: url(#sim-ip-thin-night-4x); }
}
@media (max-width: 600px) {
  .sim .ayah-grid { grid-template-columns: 1fr; }
  .sim .ayah-panel { padding: 14px 14px; }
  .sim .key-diff, .sim .memory-tip { flex-direction: column; gap: 4px; padding: 12px 16px; }
  .sim .pair-card-header { flex-direction: column; align-items: flex-start; gap: 2px; padding: 11px 14px 10px; }
  .sim .pair-surah { margin-left: 0; text-align: left; font-size: 1rem; }
}
/* The guide's own night colours, on the portal's Night setting. */
:root[data-theme="night"] .sim .pair-card { background: #18191c; border-color: #34363b; box-shadow: inset 0 1px 0 rgba(255,255,255,0.035), 0 14px 30px -20px rgba(0,0,0,0.95); }
:root[data-theme="night"] .sim .pair-card-header { background: linear-gradient(180deg, #1f2125 0%, #1a1c1f 100%); border-color: #2c2e32; }
:root[data-theme="night"] .sim .key-diff { background: #1c1e21; border-color: #2c2e32; }
:root[data-theme="night"] .sim .ayah-grid { background: #2c2e32; }
:root[data-theme="night"] .sim .ayah-panel { background: #18191c; }
:root[data-theme="night"] .sim .arabic-text, :root[data-theme="night"] .sim .pause-mark { color: #f6f4ef; }
:root[data-theme="night"] .sim .pair-surah { color: #b8b6b0; }
:root[data-theme="night"] .sim .key-diff-text { color: #d9d7d1; }
:root[data-theme="night"] .sim .memory-tip { background: #141c18; border-color: #2b3d33; }
:root[data-theme="night"] .sim .tip-text { color: #d5e3d9; }
:root[data-theme="night"] .sim .tip-label { color: #9cc7aa; }
:root[data-theme="night"] .sim .highlight-circle { background: #3b2f08; border-color: #ffc21a; color: #ffd75e; box-shadow: 0 0 0 1px rgba(255,194,26,0.18); }
:root[data-theme="night"] .sim .highlight-underline { color: #ff6f61; text-decoration-color: #ff3b30; }
:root[data-theme="night"] .sim .badge-juz, :root[data-theme="night"] .sim .badge-quarter, :root[data-theme="night"] .sim .badge-page { background: transparent; color: #a3a19b; border-color: #34363b; }
:root[data-theme="night"] .sim .badge-ayah { border-color: transparent; color: #e6c873; }
:root[data-theme="night"] .sim-key .box { background: #3b2f08; border-color: #ffc21a; }
:root[data-theme="night"] .sim-key .line { border-color: #ff3b30; }

/* The portal's two additions inside a card: which side the teacher's mark is on, and the way to that page. */
.sim .ayah-panel.sim-here { box-shadow: inset 4px 0 0 var(--mk-mixup); }
.sim .sim-tag { margin-left: 8px; font-family: var(--g-util); font-size: 0.66rem; font-weight: 700; line-height: 1; padding: 4px 8px; border-radius: 99px;
  color: #fff; background: var(--mk-mixup); }

/* The demo switch while staff see the portal as a learner (Umar, 18 Nov). */
.sim-demo { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 10px; padding: 8px 10px; border: 1px dashed var(--line-strong); border-radius: 10px; }

/* ---------- build 17: the portal's part again (tools, font switch, folding, locked card) ----------
   The tools copy the look of the guide's own app (its card-tools: Save and Note as one control, Shaky as another,
   hairlines between, a star and a pencil, a ring for Shaky; colours from the guide). The guide's text is not copied. */
.sim-fonts { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; }
.sim .card-tools, .sim-tools .card-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 10px;
  padding: 10px 20px 12px; border-top: 1px solid #ebe3cc; background: #fff; font-family: var(--g-util, var(--body)); font-size: 0.8rem; }
.sim .ct-acts, .sim .ct-marks { display: inline-flex; align-items: stretch; background: #fff; border: 1px solid #dccfa7; border-radius: 8px; overflow: hidden;
  box-shadow: 0 1px 0 rgba(58, 44, 10, 0.05); }
.sim .ct-marks { margin-left: auto; }
.sim .card-tools .ct { display: inline-flex; align-items: center; gap: 7px; min-height: 38px; padding: 0 13px; font: 500 0.8rem/1 var(--g-util, var(--body));
  letter-spacing: 0.01em; background: transparent; color: #45402f; border: 0; border-radius: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
.sim .card-tools .ct + .ct { border-left: 1px solid #ebe3cc; }
.sim .card-tools .ct:hover:not(:disabled) { background: #faf6ea; }
.sim .card-tools .ct:focus-visible { outline: 2px solid #b8934a; outline-offset: -3px; }
.sim .card-tools .ct:disabled { cursor: default; color: #6b6450; }
.sim .ct-ico { width: 15px; height: 15px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linejoin: round; stroke-linecap: round; }
.sim .ct-save[aria-pressed="true"] { background: #fbf2d4; color: #6a4a00; }
.sim .ct-save[aria-pressed="true"] .ct-ico { fill: #b8934a; stroke: #b8934a; }
.sim .ct-note.has-note::after { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #b8934a; }
.sim .ct-ring { width: 9px; height: 9px; border-radius: 50%; flex: none; box-shadow: inset 0 0 0 1.5px #b4553f; }
.sim .ct-mark[aria-pressed="true"] { background: #f9e6df; color: #8a2a1c; font-weight: 600; }
.sim .ct-mark[aria-pressed="true"] .ct-ring { background: #b4553f; box-shadow: none; }
/* L-Q13b: Solid, the guide's green (its --solid, --solid-tint, --solid-ink). */
.sim .ct-mark[data-mark="solid"][aria-pressed="true"] { background: #e7f0e2; color: #1f4a1f; }
.sim .ct-mark[data-mark="solid"] .ct-ring { box-shadow: inset 0 0 0 1.5px #3d7a38; }
.sim .ct-mark[data-mark="solid"][aria-pressed="true"] .ct-ring { background: #3d7a38; box-shadow: none; }
.sim .card-tools.ro .ct[aria-pressed="false"] { opacity: .7; }
.sim .card-note { display: none; padding: 0 14px 14px; background: #fff; }
.sim .card-note.open { display: block; }
.sim .card-note textarea { display: block; width: 100%; box-sizing: border-box; resize: vertical; padding: 10px 12px; min-height: 62px; font: 0.95rem/1.55 var(--body);
  color: #1a1a1a; background: #fdfbf5; border: 1px solid #dccfa7; border-radius: 8px; }
.sim .card-note textarea::placeholder { color: #8f8770; font-style: italic; }
.sim .card-note textarea:focus { outline: none; border-color: #b8934a; box-shadow: 0 0 0 3px rgba(184, 147, 74, .25); background: #fff; }
.sim .ct-noterow { justify-content: space-between; align-items: center; margin-top: 8px; gap: 8px; }
.sim .ct-say { padding: 0 20px 10px; margin: 0; color: #6b6450; background: #fff; min-height: 0; }
.sim .ct-say:empty { display: none; }
/* Night: the card stays the guide's paper, so the tools do too. */
@media (max-width: 560px) {
  .sim .card-tools { padding: 10px 12px 12px; flex-wrap: nowrap; }
  .sim .ct-acts, .sim .ct-marks { flex: 1 1 0; min-width: 0; margin-left: 0; }
  .sim .card-tools .ct { flex: 1 1 0; justify-content: center; gap: 6px; padding: 0 6px; min-width: 0; min-height: 40px; }
}
/* The font switch: the guide's other two fonts (the Indo-Pak one is the card's own, above). Thinning is for Indo-Pak only. */
.sim-body.sim-f-sch .sim { --g-arabic: 'Scheherazade New', serif; }
.sim-body.sim-f-amiri .sim { --g-arabic: 'Amiri Quran', 'Scheherazade New', serif; }
.sim-body.sim-f-sch .sim .key-diff-text .arabic-inline, .sim-body.sim-f-sch .sim .tip-text .arabic-inline,
.sim-body.sim-f-amiri .sim .key-diff-text .arabic-inline, .sim-body.sim-f-amiri .sim .tip-text .arabic-inline { filter: none; }
/* A word and its pause sign stay on one line (3d). */
.sim .sim-nb { white-space: nowrap; }
/* A long family folded to the two āyāt nearest the mark (3d). */
.sim .ayah-panel.sim-folded { display: none !important; }
.sim .sim-showall { margin: 10px 0 0; }
/* The locked card (3e): calm gold, never the error red. */
.sim-locked { display: grid; gap: 6px; justify-items: start; padding: 16px 18px; border: 1px solid #e3cf9c; border-left: 4px solid var(--gold); border-radius: var(--r-card, 12px);
  background: #fbf5e6; color: var(--tx, #1a1a1a); }
.sim-locked p { margin: 0; }
.sim-locked .sim-lk-title { font-size: 1.02rem; }
.sim-locked .eyebrow { color: var(--gold-tx); }
.sim-locked .btn { margin-top: 6px; }
:root[data-theme="night"] .sim-locked { background: #1d1708; border-color: #4d3c14; }

/* A33 (Umar, 24 Nov): the teacher's line over each card, "Free for the learner", how many of the 3 are chosen, one button. */
.sim-free { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 0 0 10px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--card-bg, #fff); }
.sim-free > span:first-child { margin-right: auto; }
.sim-free.on { border-color: #e3cf9c; border-left: 4px solid var(--gold); }
.sim-free [role="status"]:empty { display: none; }
p.sim-free { display: block; }
