/* The Arabic Alphabet Trail: 28 clay stepping stones snaking from alif to ya on a dotted path, Noor's balloon over
   the next letter, a star on every traced one. The panel folds away from its header. */

.sg-abc {
    margin: 0 0 26px; padding: 16px clamp(14px, 2.4vw, 24px) 18px; border-radius: 34px;
    background: rgba(255, 255, 255, .62);
    backdrop-filter: blur(16px) saturate(1.2); -webkit-backdrop-filter: blur(16px) saturate(1.2);
    box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, .9), var(--shadow);
}
:root[data-theme="dark"] .sg-abc { background: rgba(46, 40, 108, .62); box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, .12), var(--shadow); }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .sg-abc { background: rgba(46, 40, 108, .62); box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, .12), var(--shadow); }
}

/* ---------- the header: name, how far along, fold ---------- */
.sg-abc-head {
    display: flex; align-items: center; gap: 10px 18px; list-style: none; cursor: pointer;
    margin: -6px -10px; padding: 6px 10px; border-radius: 22px;
}
.sg-abc-head::-webkit-details-marker { display: none; }
.sg-abc-head:focus-visible { outline: 3px solid var(--grape); outline-offset: 2px; }
.sg-abc-title { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.sg-abc-title b { font-family: var(--font-display); font-weight: 700; font-size: clamp(1.2rem, 2.2vw, 1.5rem); color: var(--ink); letter-spacing: -.01em; }
.sg-abc-title [lang="ar"] { font-family: var(--font-arabic); font-weight: 700; font-size: 1.15rem; color: var(--grape-deep); }
:root[data-theme="dark"] .sg-abc-title [lang="ar"] { color: #D9CCFF; }
:root[lang="ar"] .sg-abc-title [lang="ar"] { display: none; }

.sg-abc-count {
    display: flex; align-items: center; gap: 10px; margin-inline-start: auto;
    font-family: var(--font-display); font-weight: 600; font-size: .92rem; color: var(--ink-soft); white-space: nowrap;
}
.sg-abc-bar { position: relative; width: clamp(90px, 14vw, 170px); height: 8px; border-radius: 999px; background: color-mix(in srgb, var(--grape) 16%, transparent); overflow: hidden; }
.sg-abc-bar i { position: absolute; inset-block: 0; inset-inline-start: 0; width: 0; min-width: 8px; border-radius: inherit; background: linear-gradient(90deg, #3FBF9B, #8D72F0); transition: width .8s var(--ease-soft); }

.sg-abc-fold {
    display: inline-flex; align-items: center; gap: 4px; flex: none; height: 34px; padding-inline: 12px 8px; border-radius: 999px;
    font-family: var(--font-display); font-weight: 600; font-size: .85rem; color: var(--ink-soft);
    background: var(--glass); box-shadow: inset 0 0 0 1px var(--glass-edge), var(--shadow-s);
    transition: background .2s, color .2s;
}
.sg-abc-head:hover .sg-abc-fold { color: var(--ink); background: var(--glass-strong); }
.sg-abc-fold svg { width: 18px; height: 18px; transition: transform .35s var(--ease-bounce); }
.sg-abc:not([open]) .sg-abc-fold svg { transform: rotate(-90deg); }
:root[dir="rtl"] .sg-abc:not([open]) .sg-abc-fold svg { transform: rotate(90deg); }
.sg-abc[open] .sg-abc-fold-show, .sg-abc:not([open]) .sg-abc-fold-hide { display: none; }

.sg-abc-hint { margin: 8px 0 0; font-weight: 600; font-size: .92rem; color: var(--ink-faint); }

/* ---------- the board: a dotted path under the stones ---------- */
.sg-abc-board { position: relative; container-type: inline-size; padding: 46px 4px 2px; }
.sg-abc-path { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.sg-abc-path path { fill: none; stroke: #BCA8FF; stroke-width: 4.5; stroke-linecap: round; stroke-dasharray: 0 11; opacity: .85; }

.sg-abc-stones {
    position: relative; z-index: 1;
    display: grid; grid-template-columns: repeat(14, minmax(0, 1fr)); row-gap: 42px;
    margin: 0; padding: 0; list-style: none;
}
.sg-abc-stone { grid-column: var(--c14); grid-row: var(--r14); display: flex; justify-content: center; min-width: 0; transform: translateY(var(--dy, 0)); }
.sg-abc-stone a {
    display: flex; flex-direction: column; align-items: center; gap: 5px; width: 100%; min-width: 0; padding: 4px 1px;
    border-radius: 20px; text-decoration: none; color: var(--ink);
}
.sg-abc-stone a:focus-visible { outline: 3px solid var(--grape); outline-offset: 2px; }

.sg-abc-ball {
    position: relative; display: grid; place-items: center; width: min(58px, 94%); aspect-ratio: 1; border-radius: 50%;
    padding-bottom: .12em; line-height: 1;
    font-family: var(--font-arabic); font-weight: 700; font-size: clamp(18px, 2.3cqi, 30px); color: #fff;
    text-shadow: 0 2px 0 color-mix(in srgb, var(--b) 70%, #000 12%);
    background:
        radial-gradient(circle at 32% 26%, rgba(255, 255, 255, .9) 0 7%, rgba(255, 255, 255, 0) 30%),
        linear-gradient(180deg, var(--a), var(--b));
    box-shadow: inset 0 -5px 0 rgba(0, 0, 0, .12), inset 0 3px 0 rgba(255, 255, 255, .5), 0 10px 16px -8px var(--b);
    transition: transform .35s var(--ease-bounce), box-shadow .35s;
}
.sg-abc-stone a:hover .sg-abc-ball, .sg-abc-stone a:focus-visible .sg-abc-ball { transform: translateY(-4px) scale(1.07); }
.sg-abc-name {
    max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    font-family: var(--font-display); font-weight: 600; font-size: .74rem; color: var(--ink-soft);
}

.sg-abc--coral { --a: #FFB2A3; --b: #F2685A; }
.sg-abc--sky { --a: #BFE6FF; --b: #3E9BE6; }
.sg-abc--sun { --a: #FFE69A; --b: #F2A21A; }
.sg-abc--mint { --a: #A8F0D8; --b: #2FB28D; }
.sg-abc--lilac { --a: #DCD0FF; --b: #8D72F0; }
.sg-abc--rose { --a: #FFC4DA; --b: #E8679A; }

/* A traced letter wears a gold star; the next one waits in a golden ring under Noor's balloon. */
.is-traced .sg-abc-ball::after {
    content: ""; position: absolute; top: -3px; right: -3px; width: 20px; height: 20px;
    background: linear-gradient(180deg, #FFE38F, #F5A31E);
    clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
    filter: drop-shadow(0 1px 1px rgba(180, 110, 0, .5));
    animation: sg-abc-star .5s var(--ease-bounce) both;
}
@keyframes sg-abc-star { from { transform: scale(0) rotate(-40deg); } }
.is-next { z-index: 2; }
.is-next .sg-abc-ball {
    transform: scale(1.16);
    box-shadow: inset 0 -5px 0 rgba(0, 0, 0, .12), inset 0 3px 0 rgba(255, 255, 255, .5), 0 0 0 4px #fff, 0 0 0 7px #FFC84A, 0 14px 22px -8px var(--b);
}
.is-next a:hover .sg-abc-ball, .is-next a:focus-visible .sg-abc-ball { transform: translateY(-4px) scale(1.2); }
.is-next .sg-abc-name { margin-top: 6px; color: var(--ink); }

.sg-abc-balloon {
    position: absolute; z-index: 3; left: 0; top: 0; width: 30px; height: 45px; pointer-events: none;
    --a: #FF8A7A; --b: #FFD45C;
    opacity: 0; transition: transform .7s var(--ease-soft), opacity .4s;
}
.sg-abc-balloon.is-placed { opacity: 1; }
.sg-abc-balloon-svg { width: 100%; height: 100%; filter: drop-shadow(0 6px 6px rgba(91, 63, 208, .25)); animation: sg-abc-bob 3.2s ease-in-out infinite; }
@keyframes sg-abc-bob { 50% { transform: translateY(-6px) rotate(3deg); } }

/* ---------- narrower boards: four rows of seven ---------- */
@container (max-width: 720px) {
    .sg-abc-stones { grid-template-columns: repeat(7, minmax(0, 1fr)); row-gap: 36px; }
    .sg-abc-balloon { width: 24px; height: 36px; }
    .sg-abc-stone { grid-column: var(--c7); grid-row: var(--r7); }
    .sg-abc-ball { width: min(54px, 88%); font-size: clamp(18px, 5cqi, 28px); }
}
@media (max-width: 600px) {
    .sg-abc-head { flex-wrap: wrap; }
    .sg-abc-count { order: 3; flex-basis: 100%; margin-inline-start: 0; }
    .sg-abc-bar { flex: 1; width: auto; }
    .sg-abc-fold { margin-inline-start: auto; }
    .sg-abc-fold-hide, .sg-abc-fold-show { display: none !important; }
    .sg-abc-fold { padding-inline: 8px; }
}

@media (prefers-reduced-motion: reduce) {
    .sg-abc-balloon-svg, .is-traced .sg-abc-ball::after { animation: none; }
    .sg-abc-balloon, .sg-abc-ball, .sg-abc-bar i { transition: none; }
}

/* ================= The Arabic Reading Adventure (Views/Home/_ReadingAdventure) =================
   Eight floating islands over a dawn sky, read right to left, joined by a rope bridge. Each island carries a
   floating clay letter sculpture and its stepping stones (one per level); lit stones glow gold, a lit island wears
   a golden halo, and the next island pulses under Noor's balloon. */
.rd-adventure {
    --sky-a: #FFE9D6; --sky-b: #E9E2FF; --sky-c: #D7F0FF;
    position: relative; margin: 0 0 22px; padding: 18px clamp(14px, 2.4vw, 26px) 22px; border-radius: 34px; overflow: hidden;
    background:
        radial-gradient(60% 50% at 88% 0%, rgba(255, 210, 120, .55), transparent 70%),
        radial-gradient(50% 60% at 6% 100%, rgba(150, 220, 255, .5), transparent 70%),
        linear-gradient(170deg, var(--sky-a), var(--sky-b) 55%, var(--sky-c));
    box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, .9), var(--shadow);
}
.rd-adventure::before {
    /* Tiny stars drifting in the sky. */
    content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .55;
    background-image:
        radial-gradient(2px 2px at 12% 22%, #fff, transparent), radial-gradient(2px 2px at 34% 64%, #fff, transparent),
        radial-gradient(1.5px 1.5px at 58% 18%, #fff, transparent), radial-gradient(2px 2px at 76% 52%, #fff, transparent),
        radial-gradient(1.5px 1.5px at 92% 80%, #fff, transparent), radial-gradient(2px 2px at 48% 90%, #fff, transparent);
}
:root[data-theme="dark"] .rd-adventure { --sky-a: #3A2F7E; --sky-b: #2A2468; --sky-c: #1F2A66; box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, .12), var(--shadow); }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .rd-adventure { --sky-a: #3A2F7E; --sky-b: #2A2468; --sky-c: #1F2A66; box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, .12), var(--shadow); }
}

.rd-adv-head { position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 6px 18px; }
.rd-adv-title { display: flex; align-items: baseline; flex-wrap: wrap; gap: 2px 12px; }
.rd-adv-title h2 { margin: 0; font-family: var(--font-display); font-weight: 700; font-size: clamp(1.3rem, 2.6vw, 1.75rem); color: var(--ink); letter-spacing: -.01em; }
.rd-adv-ar { font-family: var(--font-arabic); font-weight: 700; font-size: 1.15rem; color: var(--grape-deep); }
:root[data-theme="dark"] .rd-adv-ar { color: #D9CCFF; }
:root[lang="ar"] .rd-adv-ar { display: none; }
.rd-adv-intro { margin: 0; font-weight: 600; font-size: .92rem; color: var(--ink-soft); line-height: 1.35; }
.rd-adv-count { display: flex; align-items: center; gap: 10px; font: 600 .9rem var(--font-display); color: var(--ink-soft); white-space: nowrap; }
.rd-adv-bar { position: relative; width: clamp(90px, 12vw, 150px); height: 8px; border-radius: 999px; background: rgba(255, 255, 255, .7); overflow: hidden; }
.rd-adv-bar i { position: absolute; inset-block: 0; inset-inline-start: 0; width: 0; min-width: 8px; border-radius: inherit; background: linear-gradient(90deg, #FFC84A, #F2685A); transition: width .8s var(--ease-soft); }

/* ---------- the map ---------- */
.rd-map { position: relative; container-type: inline-size; margin-top: 8px; padding: 26px 0 4px; }
.rd-bridges { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.rd-bridge-rope { fill: none; stroke: #C99A5B; stroke-width: 3; stroke-linecap: round; opacity: .8; }
.rd-bridge-planks { fill: none; stroke: #B07A35; stroke-width: 11; stroke-linecap: butt; stroke-dasharray: 4 10; opacity: .75; transform: translateY(3px); }
:root[data-theme="dark"] .rd-bridge-rope { stroke: #E2B97A; }

.rd-isles { position: relative; z-index: 1; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); row-gap: 34px; column-gap: 10px; margin: 0; padding: 0; list-style: none; }
.rd-isle { grid-column: var(--c4); grid-row: var(--r4); min-width: 0; transform: translateY(var(--dy, 0)); }
.rd-isle-inner { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; }
.rd-isle.c-lilac { --t: #8D72F0; --td: #5B3FD0; --ts: #EFE8FF; }

.rd-isle-art { position: relative; width: clamp(120px, 15cqi, 168px); aspect-ratio: 1.05; }
.rd-isle-glow { position: absolute; inset: 6% 4% 18%; border-radius: 50%; background: radial-gradient(closest-side, color-mix(in srgb, var(--t) 45%, transparent), transparent); opacity: .6; transition: opacity .4s; }
.rd-isle-rock { position: absolute; inset-inline: 8%; bottom: 6%; height: 40%; }
.rd-isle-rock::before {
    /* The grassy top of the island. */
    content: ""; position: absolute; inset-inline: 0; top: 0; height: 46%; border-radius: 50%; z-index: 1;
    background: radial-gradient(70% 90% at 40% 30%, color-mix(in srgb, var(--t) 35%, #fff), var(--t));
    box-shadow: inset 0 -4px 0 color-mix(in srgb, var(--td) 40%, transparent), inset 0 3px 0 rgba(255, 255, 255, .6);
}
.rd-isle-rock::after {
    /* Its rocky underside, hanging in the air. */
    content: ""; position: absolute; inset-inline: 6%; top: 18%; bottom: -30%;
    background: linear-gradient(180deg, #CDBBE6, #9C86C9 70%, #8A73BD);
    clip-path: polygon(0 0, 100% 0, 86% 38%, 70% 62%, 56% 100%, 40% 70%, 24% 54%, 10% 30%);
}
:root[data-theme="dark"] .rd-isle-rock::after { background: linear-gradient(180deg, #6D5AA8, #4B3C86); }
.rd-isle-sculpt {
    position: absolute; inset-inline: 0; top: -2%; display: grid; place-items: center; z-index: 2;
    font-family: var(--font-arabic); font-weight: 700; font-size: clamp(2.7rem, 6.2cqi, 3.9rem); line-height: 1.4; white-space: nowrap;
    background: linear-gradient(180deg, color-mix(in srgb, var(--t) 55%, #fff), var(--td) 80%);
    -webkit-background-clip: text; background-clip: text; color: transparent;
    filter: drop-shadow(0 2px 0 #fff) drop-shadow(0 8px 6px color-mix(in srgb, var(--td) 40%, transparent));
    animation: rd-isle-bob 4.6s ease-in-out infinite; animation-delay: calc(var(--i, 0) * -.55s);
}
.rd-isle-sculpt.is-book { background: none; color: var(--sun-deep); filter: drop-shadow(0 8px 6px rgba(199, 127, 0, .35)); }
.rd-isle-sculpt.is-book .k-ico { width: 64px; height: 64px; }
@keyframes rd-isle-bob { 50% { transform: translateY(-9px) rotate(-2deg); } }
.rd-isle-num {
    position: absolute; z-index: 3; inset-inline-start: 4%; bottom: 30%; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%;
    background: #fff; color: var(--td); font: 700 .95rem var(--font-display); box-shadow: 0 0 0 3px var(--t), var(--shadow-s);
}
.rd-isle-title { margin: 2px 0 0; font-family: var(--font-display); font-weight: 700; font-size: 1.05rem; line-height: 1.15; color: var(--ink); }
.rd-isle-blurb { margin: 0; max-width: 24ch; font-weight: 600; font-size: .78rem; line-height: 1.25; color: var(--ink-soft); }

/* ---------- stepping stones: one per level ---------- */
.rd-stones { display: flex; flex-direction: column; align-items: center; gap: 2px; margin-top: 4px; }
.rd-game-link { display: inline-block; min-height: 24px; padding: 3px 6px; line-height: 18px; border-radius: 999px; font: 600 .74rem/18px var(--font-display); color: var(--td); text-decoration: none; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
:root[data-theme="dark"] .rd-game-link { color: #fff; }
.rd-game-link:hover { text-decoration: underline; }
.rd-quest-link { display: inline-flex; align-items: center; gap: 4px; margin-top: 4px; padding: 6px 12px; border-radius: 999px; background: var(--sun); color: #5A3D00; font: 700 .8rem var(--font-display); text-decoration: none; box-shadow: 0 4px 0 var(--sun-deep); }
.rd-quest-link .k-ico { width: 18px; height: 18px; }
.rd-stone-row { display: flex; gap: 8px; }
.rd-step { position: relative; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; text-decoration: none; }
.rd-step i {
    width: 30px; height: 24px; border-radius: 50% 50% 46% 46%;
    background: linear-gradient(180deg, rgba(255, 255, 255, .95), color-mix(in srgb, var(--t) 30%, #fff));
    box-shadow: inset 0 -4px 0 color-mix(in srgb, var(--t) 35%, transparent), 0 6px 8px -5px var(--td);
    transition: transform .3s var(--ease-bounce), box-shadow .3s;
}
.rd-step--medium i { width: 32px; height: 26px; }
.rd-step--hard i { width: 34px; height: 28px; }
.rd-step:hover i, .rd-step:focus-visible i { transform: translateY(-4px) scale(1.1); }
.rd-step:focus-visible { outline: 3px solid var(--grape); outline-offset: 0; }
.rd-step.is-lit i {
    background: radial-gradient(circle at 34% 28%, #fff 0 12%, transparent 40%), linear-gradient(180deg, #FFE38F, #F5A31E);
    box-shadow: inset 0 -4px 0 rgba(160, 90, 0, .25), 0 0 14px 4px rgba(255, 200, 74, .75);
    animation: rd-step-glow 2.4s ease-in-out infinite alternate;
}
@keyframes rd-step-glow { to { box-shadow: inset 0 -4px 0 rgba(160, 90, 0, .25), 0 0 20px 7px rgba(255, 200, 74, .9); } }

/* ---------- lit and next islands ---------- */
.rd-isle.is-lit .rd-isle-glow { opacity: 1; background: radial-gradient(closest-side, rgba(255, 205, 90, .85), transparent); }
.rd-isle.is-lit .rd-isle-num { background: linear-gradient(180deg, #FFE38F, #F5A31E); color: #5A3D00; box-shadow: 0 0 0 3px #fff, 0 0 14px 3px rgba(255, 200, 74, .8); }
.rd-isle.is-next .rd-isle-num { animation: rd-next 1.6s ease-in-out infinite; }
@keyframes rd-next { 50% { box-shadow: 0 0 0 3px var(--t), 0 0 0 9px color-mix(in srgb, var(--t) 30%, transparent); } }

.rd-balloon {
    position: absolute; z-index: 3; left: 0; top: 0; width: 30px; height: 45px; pointer-events: none;
    --a: #FF8A7A; --b: #FFD45C;
    opacity: 0; transition: transform .8s var(--ease-soft), opacity .4s;
}
.rd-balloon.is-placed { opacity: 1; }
.rd-balloon-svg { width: 100%; height: 100%; filter: drop-shadow(0 6px 6px rgba(91, 63, 208, .25)); animation: sg-abc-bob 3.2s ease-in-out infinite; }

/* ---------- narrower boards: two islands to a row ---------- */
@container (max-width: 760px) {
    .rd-isles { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 30px; }
    .rd-isle { grid-column: var(--c2); grid-row: var(--r2); }
    .rd-isle-art { width: clamp(118px, 34cqi, 160px); }
    .rd-isle-sculpt { font-size: clamp(2.6rem, 11cqi, 3.6rem); }
}
@media (max-width: 760px) {
    .rd-adv-head { grid-template-columns: minmax(0, 1fr); }
    .rd-adv-bar { flex: 1; width: auto; }
}

@media (prefers-reduced-motion: reduce) {
    .rd-isle-sculpt, .rd-step.is-lit i, .rd-isle.is-next .rd-isle-num, .rd-balloon-svg { animation: none; }
    .rd-balloon, .rd-step i, .rd-adv-bar i { transition: none; }
}
