/* Story shelf and the read-along reader. */

.k-shelf { display: grid; gap: 26px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); }
.k-book {
    display: flex; flex-direction: column; text-decoration: none; color: var(--ink);
    border-radius: 10px 24px 24px 10px; background: var(--paper); overflow: hidden;
    box-shadow: inset 0 -5px 0 color-mix(in srgb, var(--t) 22%, transparent), 0 18px 28px -18px color-mix(in srgb, var(--td) 80%, rgba(76, 52, 150, .6));
    transition: transform .35s var(--ease-bounce), box-shadow .3s;
}
:root[dir="rtl"] .k-book { border-radius: 24px 10px 10px 24px; }
.k-book[hidden] { display: none; }
.k-book:hover { transform: translateY(-10px) rotate(-1.2deg); box-shadow: inset 0 -5px 0 color-mix(in srgb, var(--t) 22%, transparent), 0 28px 34px -18px color-mix(in srgb, var(--td) 80%, rgba(76, 52, 150, .6)); }

/* ---------- The cloud shelves ---------- */
.sg-shelf { position: relative; margin-bottom: 26px; }
.sg-shelf[hidden] { display: none; }
.sg-shelf-title { display: flex; align-items: baseline; gap: 10px; margin: 6px 4px 12px; font-size: 1.35rem; font-weight: 600; }
.sg-shelf-title small { font-size: .85rem; font-weight: 600; color: var(--ink-faint); }
.sg-shelf-row {
    position: relative; z-index: 1;
    display: grid; grid-auto-flow: column; grid-auto-columns: minmax(200px, 220px); grid-template-columns: none; gap: 16px;
    overflow-x: auto; padding: 8px 6px 18px; scroll-snap-type: x proximity; scrollbar-width: thin; overscroll-behavior-x: contain;
}
.sg-shelf-row .k-book { scroll-snap-align: start; }
.sg-shelf-row .k-book-body strong { font-size: 1.05rem; }
.sg-shelf-row .k-book-body > span:not(.k-book-meta) { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: .88rem; }
.sg-shelf-cloud {
    position: relative; height: 22px; margin: -14px 0 0; border-radius: 999px;
    background: linear-gradient(180deg, #FFFFFF, #EFE6FF); box-shadow: 0 14px 22px -12px rgba(91, 63, 208, .45), inset 0 -3px 0 rgba(141, 114, 240, .12);
}
.sg-shelf-cloud::before, .sg-shelf-cloud::after { content: ""; position: absolute; top: 8px; width: 34%; height: 30px; border-radius: 999px; background: rgba(255, 255, 255, .7); filter: blur(4px); }
.sg-shelf-cloud::before { inset-inline-start: 6%; }
.sg-shelf-cloud::after { inset-inline-end: 8%; }
:root[data-theme="dark"] .sg-shelf-cloud { background: linear-gradient(180deg, rgba(255, 255, 255, .2), rgba(255, 255, 255, .06)); }
:root[data-theme="dark"] .sg-shelf-cloud::before, :root[data-theme="dark"] .sg-shelf-cloud::after { background: rgba(255, 255, 255, .06); }
.sg-keep-reading {
    display: flex; align-items: center; gap: 14px; padding: 14px; border-radius: 28px; text-decoration: none; color: #fff;
    background: linear-gradient(160deg, #8E74F2, #5940C2); box-shadow: 0 24px 40px -22px rgba(91, 63, 208, .8);
    transition: transform .35s var(--ease-bounce);
}
.sg-keep-reading:hover { transform: translateY(-4px); }
.sg-keep-reading img { flex: none; width: 64px; height: 84px; object-fit: cover; border-radius: 6px 12px 12px 6px; box-shadow: 0 8px 14px -6px rgba(30, 10, 80, .6); }
.sg-keep-reading small { display: block; font-family: var(--font-display); font-weight: 600; font-size: .8rem; letter-spacing: .1em; text-transform: uppercase; opacity: .85; }
.sg-keep-reading b { display: block; font-family: var(--font-display); font-weight: 700; font-size: 1.2rem; line-height: 1.1; }
.sg-keep-reading .k-btn { margin-inline-start: auto; flex: none; }
.k-book-cover { position: relative; aspect-ratio: 3 / 2; overflow: hidden; background: var(--ts); }
.k-book-cover::before {
    content: ""; position: absolute; inset-block: 0; inset-inline-start: 0; width: 14px; z-index: 1;
    background: linear-gradient(90deg, rgba(0, 0, 0, .22), rgba(255, 255, 255, .25) 55%, transparent);
}
.k-book-cover img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .6s ease; }
.k-book:hover .k-book-cover img { transform: scale(1.06); }
.k-book-age { position: absolute; inset-inline-end: 12px; top: 12px; padding: 4px 12px; border-radius: 999px; background: rgba(255, 255, 255, .92); color: #2B2350; font-size: .8rem; font-weight: 800; }
.k-book-body { display: flex; flex-direction: column; gap: 4px; padding: 16px 18px 18px; }
.k-book-body strong { font-size: 1.25rem; line-height: 1.2; }
.k-book-body > span { color: var(--ink-soft); font-family: var(--font-read); font-size: .95rem; }
.k-book-meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 6px; font-size: .85rem !important; font-weight: 700; }

/* ---------- Reader ---------- */
:where(.k-reader) { --t: var(--grape); --td: var(--grape-deep); --ts: var(--grape-soft); }
.k-reader { max-width: 1180px; margin: 0 auto; }
.k-reader-top { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; margin-bottom: 14px; }
.k-reader-top .k-crumbs { margin: 0; }
.k-reader-title { font-size: clamp(1.4rem, 3vw, 2.1rem); font-weight: 800; margin: 0; flex: 1 1 260px; }

.k-stage { position: relative; perspective: 2200px; }
.k-spread {
    display: grid; grid-template-columns: 1.25fr 1fr;
    min-height: min(68vh, 600px);
    border-radius: 34px; overflow: hidden;
    background: var(--paper);
    box-shadow: 0 10px 0 color-mix(in srgb, var(--t) 35%, var(--paper)), var(--shadow-l);
    transform-origin: 0 50%;
}
[dir="rtl"] .k-spread { transform-origin: 100% 50%; }
.k-spread[hidden] { display: none; }
.k-spread.is-turn-in { animation: page-in .55s cubic-bezier(.2, .7, .3, 1) both; }
.k-spread.is-turn-back { animation: page-back .55s cubic-bezier(.2, .7, .3, 1) both; }
@keyframes page-in { 0% { transform: rotateY(-28deg) translateX(40px); opacity: 0; filter: brightness(.85); } 100% { transform: none; opacity: 1; filter: none; } }
@keyframes page-back { 0% { transform: rotateY(28deg) translateX(-40px); opacity: 0; filter: brightness(.85); } 100% { transform: none; opacity: 1; filter: none; } }

/* The turning leaf (reader.js): the lifted half of the book swings over the spine; its back is plain paper. */
.k-leaf { position: absolute; z-index: 6; pointer-events: none; transform-style: preserve-3d; will-change: transform; animation: k-leaf .8s cubic-bezier(.45, .05, .3, 1) forwards; }
.k-leaf.is-right { transform-origin: 0 50%; --to: -180deg; border-radius: 0 34px 34px 0; }
.k-leaf.is-left { transform-origin: 100% 50%; --to: 180deg; border-radius: 34px 0 0 34px; }
.k-leaf > * { position: absolute; inset: 0; margin: 0; overflow: hidden; border-radius: inherit; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.k-leaf-back { transform: rotateY(180deg); background: linear-gradient(90deg, #F3EBDD, #FFFCF4 30%, #FFF8EA); box-shadow: inset 0 0 40px rgba(120, 90, 40, .12); }
.k-leaf.is-left .k-leaf-back { background: linear-gradient(270deg, #F3EBDD, #FFFCF4 30%, #FFF8EA); }
.k-leaf-shade { background: linear-gradient(90deg, rgba(43, 35, 80, .32), rgba(43, 35, 80, 0) 60%); opacity: 0; animation: k-leaf-shade .8s ease forwards; }
.k-leaf.is-left .k-leaf-shade { background: linear-gradient(270deg, rgba(43, 35, 80, .32), rgba(43, 35, 80, 0) 60%); }
@keyframes k-leaf { 0% { transform: rotateY(0); } 100% { transform: rotateY(var(--to)); } }
@keyframes k-leaf-shade { 50% { opacity: 1; } 100% { opacity: 0; } }
.k-spread.is-under { animation: k-under .8s ease both; }
@keyframes k-under { 0% { opacity: .82; } 100% { opacity: 1; } }

.k-spread-art { margin: 0; position: relative; background: var(--ts); overflow: hidden; }
.k-spread-art img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
/* Each picture drifts gently while its page is open, like a camera in a storybook film. */
.k-spread:not([hidden]) .k-spread-art > img { animation: k-art-drift 14s ease-out both; }
@keyframes k-art-drift { from { transform: scale(1.09) translate(1.5%, 1%); } to { transform: scale(1.01); } }
.k-spread-art::after {
    content: ""; position: absolute; inset-block: 0; inset-inline-end: 0; width: 34px;
    background: linear-gradient(270deg, rgba(43, 35, 80, .18), transparent);
}
[dir="rtl"] .k-spread-art::after { background: linear-gradient(90deg, rgba(43, 35, 80, .18), transparent); }

.k-spread-text {
    position: relative; display: flex; flex-direction: column; justify-content: center; gap: 22px;
    padding: clamp(24px, 4vw, 52px);
    background: #FFFCF4; color: #2B2350;
}
.k-spread-text.bg-ocean, .k-spread-text.bg-sky { background: linear-gradient(160deg, #F2FAFF, #DDF1FD); }
.k-spread-text.bg-sunrise, .k-spread-text.bg-desert { background: linear-gradient(160deg, #FFF8E8, #FFEBC7); }
.k-spread-text.bg-garden, .k-spread-text.bg-meadow { background: linear-gradient(160deg, #F4FCEF, #E1F5D6); }
.k-spread-text.bg-night { background: linear-gradient(160deg, #2E2870, #1F1B4D); color: #F4F1FF; }
.k-spread-text.bg-rose { background: linear-gradient(160deg, #FFF3F6, #FFDCE6); }

.k-story { font-family: "Andika", var(--font-read); font-size: clamp(1.3rem, 2.3vw, 1.75rem); line-height: 1.65; margin: 0; letter-spacing: .01em; }
.k-story .w { border-radius: 8px; padding: 0 2px; transition: background .15s, color .15s, transform .2s var(--ease-bounce); }
.k-story .w.is-now { background: var(--sun); color: #2B2350; box-shadow: 0 0 0 3px var(--sun); }
.k-story .w.is-read { color: inherit; opacity: .78; }

.k-verse {
    margin: 0; padding: 16px 18px; border-radius: 20px;
    background: rgba(255, 255, 255, .7); border: 2px solid rgba(124, 92, 255, .2);
    color: #2B2350;
}
.bg-night .k-verse { background: rgba(255, 255, 255, .1); color: #F4F1FF; border-color: rgba(255, 255, 255, .2); }
.k-verse figcaption { font-size: .8rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; opacity: .7; margin-bottom: 6px; font-family: var(--font-display); }
.k-verse-ar { margin: 0 0 8px; font-family: var(--font-quran); font-size: 1.6rem; line-height: 2; text-align: right; }
.k-verse-tr { margin: 0 0 6px; font-family: var(--font-read); font-style: italic; font-size: 1rem; }
.k-verse cite { font-style: normal; font-size: .82rem; opacity: .75; font-family: var(--font-display); }
.k-page-no { position: absolute; bottom: 16px; inset-inline-end: 22px; font-weight: 800; opacity: .45; }

.k-spread-end {
    position: relative; grid-template-columns: 1fr;
    background: linear-gradient(180deg, #3B3489 0%, #5B4BB5 34%, color-mix(in srgb, var(--t) 18%, #FFF4EC) 62%, var(--paper) 100%);
}
.k-end { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; padding: 34px 24px; }
.k-end > h2 { color: #fff; text-shadow: 0 0 26px rgba(255, 210, 120, .7), 0 3px 0 rgba(40, 30, 110, .5); }
.k-end > .k-mascot-svg { filter: drop-shadow(0 0 30px rgba(255, 210, 110, .95)); }
.k-end-sky { position: absolute; inset: 0 0 45%; pointer-events: none; overflow: hidden; }
.k-end-moon { position: absolute; top: 34px; inset-inline-end: 12%; width: 74px; height: 74px; border-radius: 50%; box-shadow: inset -18px -6px 0 0 #FFE7A0; transform: rotate(-20deg); filter: drop-shadow(0 0 18px rgba(255, 220, 140, .7)); }
.k-end-twinkle i { position: absolute; width: 6px; height: 6px; border-radius: 50%; background: #fff; box-shadow: 0 0 8px 2px rgba(255, 255, 255, .8); animation: k-twinkle 2.6s ease-in-out infinite; }
.k-end-twinkle i:nth-child(1) { left: 8%; top: 18%; } .k-end-twinkle i:nth-child(2) { left: 18%; top: 46%; animation-delay: .4s; }
.k-end-twinkle i:nth-child(3) { left: 27%; top: 12%; animation-delay: 1.1s; } .k-end-twinkle i:nth-child(4) { left: 36%; top: 34%; animation-delay: .7s; }
.k-end-twinkle i:nth-child(5) { left: 62%; top: 16%; animation-delay: 1.5s; } .k-end-twinkle i:nth-child(6) { left: 70%; top: 44%; animation-delay: .2s; }
.k-end-twinkle i:nth-child(7) { left: 78%; top: 60%; animation-delay: 1.8s; } .k-end-twinkle i:nth-child(8) { left: 90%; top: 30%; animation-delay: .9s; }
.k-end-twinkle i:nth-child(9) { left: 48%; top: 8%; animation-delay: 1.3s; } .k-end-twinkle i:nth-child(10) { left: 4%; top: 64%; animation-delay: 2s; }
@keyframes k-twinkle { 0%, 100% { opacity: .25; transform: scale(.6); } 50% { opacity: 1; transform: scale(1.2); } }
.k-end-lanterns i {
    position: absolute; bottom: -40px; width: 16px; height: 24px; border-radius: 6px 6px 8px 8px;
    background: linear-gradient(180deg, #FFF3C2, #FFB04A); box-shadow: 0 0 16px 4px rgba(255, 180, 80, .65);
    animation: k-lantern-up 9s linear infinite; opacity: 0;
}
.k-end-lanterns i:nth-child(1) { left: 12%; } .k-end-lanterns i:nth-child(2) { left: 30%; animation-delay: 2.2s; }
.k-end-lanterns i:nth-child(3) { left: 66%; animation-delay: 4.1s; } .k-end-lanterns i:nth-child(4) { left: 84%; animation-delay: 1.2s; }
.k-end-lanterns i:nth-child(5) { left: 48%; animation-delay: 6s; }
@keyframes k-lantern-up { 0% { opacity: 0; transform: translateY(0); } 15% { opacity: 1; } 85% { opacity: .9; } 100% { opacity: 0; transform: translateY(-420px) translateX(20px); } }
.k-next-title { margin: 10px 0 0; font-size: 1.05rem; font-weight: 700; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .08em; }
:root[lang="ar"] .k-next-title, :root[lang="ur"] .k-next-title { text-transform: none; letter-spacing: 0; font-size: 1.2rem; }
.k-story .w { display: inline-block; }
.k-story .w.is-now { transform: translateY(-2px) scale(1.06); }
.k-end .k-mascot-svg { width: 120px; height: 150px; }
.k-end h2 { font-size: clamp(2rem, 5vw, 3rem); font-weight: 800; margin: 0; }
.k-end-stars { display: flex; gap: 10px; }
.k-end-stars i {
    width: 56px; height: 56px; display: block;
    background: linear-gradient(180deg, #FFE27A, #FFB400);
    clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
    animation: star-pop .6s var(--ease-bounce) both;
}
.k-end-stars i:nth-child(2) { animation-delay: .2s; width: 70px; height: 70px; margin-top: -10px; }
.k-end-stars i:nth-child(3) { animation-delay: .4s; }
@keyframes star-pop { 0% { transform: scale(0) rotate(-40deg); } 100% { transform: scale(1) rotate(0); } }
.k-moral { max-width: 560px; padding: 16px 22px; border-radius: 22px; background: var(--paper); box-shadow: var(--shadow-s); }
.k-moral strong { display: block; color: var(--ink-soft); font-size: .85rem; text-transform: uppercase; letter-spacing: .08em; }
.k-moral p { margin: 6px 0 0; font-family: var(--font-read); font-size: 1.2rem; }
.k-end-actions { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; margin-top: 6px; }
.k-more { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; margin-top: 10px; }
.k-more-book { width: 170px; text-decoration: none; color: var(--ink); font-weight: 700; font-size: .9rem; }
.k-more-book img { width: 100%; aspect-ratio: 3 / 2; object-fit: cover; border-radius: 14px; display: block; margin-bottom: 4px; box-shadow: var(--shadow-s); }

.k-controls { display: flex; justify-content: center; align-items: center; gap: 14px; margin: 22px 0 8px; }
.k-ctl {
    display: inline-flex; align-items: center; justify-content: center; gap: 10px;
    min-width: 64px; height: 64px; padding: 0 18px; border: 0; border-radius: 999px; cursor: pointer;
    background: var(--paper); color: var(--ink); font-weight: 800; font-size: 1.1rem;
    box-shadow: 0 5px 0 color-mix(in srgb, var(--t) 40%, var(--paper)), var(--shadow-s);
    transition: transform .15s;
}
.k-ctl > span[aria-hidden] { font-size: 2.4rem; line-height: 1; margin-top: -6px; }
.k-ctl:active { transform: translateY(4px); box-shadow: 0 1px 0 color-mix(in srgb, var(--t) 40%, var(--paper)); }
.k-ctl[disabled] { opacity: .4; cursor: default; }
.k-ctl-play { background: var(--t); color: #2B2350; min-width: 190px; box-shadow: 0 5px 0 var(--td), var(--shadow); }
/* Dark text on the light story colours, white on the deep purple one: both pass WCAG AA. */
.c-night .k-ctl-play, .c-grape .k-ctl-play { background: var(--grape-deep); color: #fff; }
.k-ctl-play svg { width: 28px; height: 28px; }
.k-ctl-play .i-pause, .k-ctl-play[aria-pressed="true"] .i-play { display: none; }
.k-ctl-play[aria-pressed="true"] .i-pause { display: block; }
.k-dots { display: flex; justify-content: center; gap: 6px; flex-wrap: wrap; }
.k-dots i { width: 10px; height: 10px; border-radius: 50%; background: color-mix(in srgb, var(--ink) 18%, transparent); transition: all .3s; }
.k-dots i.is-on { width: 28px; border-radius: 6px; background: var(--t); }
.k-page-label { text-align: center; color: var(--ink-soft); font-weight: 700; margin: 8px 0 0; }

.k-grownups { margin: 30px auto 0; max-width: 760px; padding: 14px 20px; border-radius: 18px; background: var(--paper); box-shadow: var(--shadow-s); font-family: var(--font-read); color: var(--ink-soft); }
.k-grownups summary { cursor: pointer; font-weight: 800; color: var(--ink); font-family: var(--font-display); }

@media (max-width: 860px) {
    .k-spread { grid-template-columns: 1fr; min-height: 0; }
    .k-spread-art { aspect-ratio: 3 / 2; }
    .k-spread-art::after { display: none; }
    .k-spread-text { padding: 22px 22px 40px; }
    .k-ctl-play { min-width: 64px; }
    .k-ctl-play [data-play-label] { display: none; }
    .k-ctl { height: 58px; min-width: 58px; }
    .page-reader .k-tabbar { display: none; }
    .k-controls {
        position: sticky; bottom: 10px; z-index: 30;
        padding: 10px; margin-inline: -6px; border-radius: 999px;
        background: color-mix(in srgb, var(--paper) 88%, transparent);
        backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
        box-shadow: var(--shadow);
    }
}

/* =====================================================================================================
   Storybook Adventure Library: kinds of story, the sixteen shelves, tap-a-word, bookmarks, speeds,
   carrying on, age-sized text and the end-of-book challenge.
   ===================================================================================================== */

/* ---------- Kind of story: a story to learn from (fiction), retold from the Quran, learning about Islam ---------- */
.k-kind {
    display: inline-flex; align-items: center; gap: 6px; padding-block: 5px 5px; padding-inline: 8px 12px; border-radius: 999px;
    font-family: var(--font-display); font-weight: 700; font-size: .85rem; line-height: 1.1; white-space: nowrap;
    background: var(--sun-soft); color: #6B4A00; box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--sun-deep) 40%, transparent);
}
.k-kind .k-ico { width: 22px; height: 22px; flex: none; }
.k-kind--quran { background: var(--mint-soft); color: #0F5F49; box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--mint-deep) 40%, transparent); }
.k-kind--learn { background: var(--sky-soft); color: #134E7E; box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--sky-deep) 40%, transparent); }
:root[data-theme="dark"] .k-kind { color: #FFE7A6; }
:root[data-theme="dark"] .k-kind--quran { color: #B9F3DF; }
:root[data-theme="dark"] .k-kind--learn { color: #CFE7FF; }
.k-age-tag { padding: 5px 12px; border-radius: 999px; background: var(--glass); box-shadow: inset 0 0 0 1px var(--glass-edge); font-weight: 800; font-size: .85rem; }
.k-reader-top .k-reader-title { flex-basis: 220px; }

/* ---------- Reading progress ribbon and the welcome-back bar ---------- */
.k-read-progress { position: relative; height: 8px; margin: 0 4px 12px; border-radius: 999px; overflow: hidden; background: color-mix(in srgb, var(--ink) 10%, transparent); }
.k-read-progress i {
    position: absolute; inset-block: 0; inset-inline-start: 0; width: 0; border-radius: inherit;
    background: linear-gradient(90deg, var(--t), color-mix(in srgb, var(--t) 60%, #FFE27A)); transition: width .5s cubic-bezier(.2, .7, .3, 1);
}
.k-resume {
    display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin: 0 0 12px; padding: 10px 14px; border-radius: 20px;
    background: var(--glass-strong); box-shadow: inset 0 0 0 1px var(--glass-edge), var(--shadow-s); font-weight: 700;
    animation: k-resume-in .45s var(--ease-bounce) both;
}
.k-resume > span { flex: 1 1 200px; }
.k-resume .k-ico { width: 28px; height: 28px; }
@keyframes k-resume-in { from { opacity: 0; transform: translateY(-8px); } }

/* ---------- Age-sized story text: one big line for 3-5, roomy for 6-8, a fuller page for 9-12 ---------- */
.k-reader[data-age="3-5"] .k-story { font-size: clamp(1.6rem, 3.2vw, 2.4rem); line-height: 1.5; font-weight: 600; }
.k-reader[data-age="9-12"] .k-story { font-size: clamp(1.02rem, 1.55vw, 1.22rem); line-height: 1.7; letter-spacing: 0; }
.k-reader[data-age="9-12"] .k-spread-text { justify-content: flex-start; padding-block: clamp(22px, 3vw, 40px) 48px; }
.k-reader[data-age="9-12"] .k-spread[data-kind="page"] { grid-template-columns: 1fr 1.05fr; }

/* ---------- Tap a word ---------- */
.k-story .w.is-gloss {
    cursor: pointer; position: relative;
    text-decoration: underline dotted color-mix(in srgb, var(--t) 85%, #2B2350); text-decoration-thickness: 3px; text-underline-offset: 6px;
}
.k-story .w.is-gloss:hover, .k-story .w.is-gloss:focus-visible, .k-story .w.is-gloss.is-open { background: color-mix(in srgb, var(--t) 28%, transparent); outline: none; }
.k-story .w.is-gloss:focus-visible { box-shadow: 0 0 0 3px var(--t); }
.bg-night .k-story .w.is-gloss { text-decoration-color: #FFE27A; }
.k-reader { position: relative; }
.k-gloss-pop {
    position: absolute; z-index: 40; width: min(320px, calc(100% - 16px)); padding: 14px 16px 12px; border-radius: 22px;
    background: var(--paper); color: var(--ink); box-shadow: 0 0 0 3px color-mix(in srgb, var(--t) 60%, transparent), var(--shadow-l);
    animation: k-pop-in .25s var(--ease-bounce) both;
}
@keyframes k-pop-in { from { opacity: 0; transform: translateY(6px) scale(.96); } }
.k-gloss-kicker { display: block; font-family: var(--font-display); font-size: .75rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-faint); }
:root[lang="ar"] .k-gloss-kicker, :root[lang="ur"] .k-gloss-kicker { text-transform: none; letter-spacing: 0; font-size: .9rem; }
.k-gloss-pop strong { display: block; font-size: 1.5rem; line-height: 1.2; margin: 2px 0 4px; }
.k-gloss-pop p { margin: 0 0 10px; font-family: var(--font-read); font-size: 1.05rem; line-height: 1.5; }
.k-gloss-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.k-gloss-tip { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 4px 0 0; color: var(--ink-soft); font-size: .9rem; font-weight: 600; }
.k-gloss-tip .k-ico { width: 22px; height: 22px; }

/* ---------- Bookmarks: a ribbon on every page, one in the toolbar, chips under the dots ---------- */
.k-page-mark {
    position: absolute; top: -2px; inset-inline-end: 22px; width: 38px; height: 52px; padding: 0; border: 0; cursor: pointer;
    background: none; color: color-mix(in srgb, currentColor 22%, transparent); transition: transform .25s var(--ease-bounce), color .2s;
}
.k-page-mark svg, .k-ctl-mark svg, .k-marks-title svg { width: 100%; height: 100%; fill: currentColor; }
.k-page-mark:hover { transform: translateY(4px); color: color-mix(in srgb, var(--coral) 70%, transparent); }
.k-page-mark[aria-pressed="true"] { color: var(--coral); transform: translateY(6px); filter: drop-shadow(0 6px 6px rgba(224, 80, 63, .35)); }
.k-page-mark:focus-visible { outline: 3px solid var(--t); outline-offset: 2px; border-radius: 8px; }
.k-ctl-mark { min-width: 58px; padding: 0 14px; color: var(--ink-soft); }
.k-ctl-mark svg { width: 26px; height: 26px; }
.k-ctl-mark[aria-pressed="true"] { color: var(--coral-deep); background: var(--coral-soft); }
.k-dots i.is-marked { box-shadow: 0 0 0 3px var(--coral); }
.k-marks { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; margin: 10px auto 0; max-width: 760px; }
.k-marks-title { display: inline-flex; align-items: center; gap: 6px; font-weight: 800; color: var(--coral-deep); }
.k-marks-title svg { width: 18px; height: 22px; }
.k-marks small { flex-basis: 100%; text-align: center; color: var(--ink-faint); font-weight: 600; }
.k-marks-list { display: contents; }
.k-mark-chip {
    min-height: 40px; padding: 6px 14px; border: 0; border-radius: 999px; cursor: pointer; font-family: var(--font-display); font-weight: 700;
    background: var(--coral-soft); color: var(--ink); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--coral) 50%, transparent);
}
.k-mark-chip.is-on { background: var(--coral); color: #fff; }

/* ---------- Reading speed: slow, normal, quick ---------- */
.k-speed {
    display: inline-flex; align-items: stretch; height: 64px; padding: 5px; gap: 4px; border-radius: 999px;
    background: var(--paper); box-shadow: 0 5px 0 color-mix(in srgb, var(--t) 40%, var(--paper)), var(--shadow-s);
}
.k-speed button {
    display: inline-flex; align-items: center; gap: 6px; padding: 0 12px; border: 0; border-radius: 999px; cursor: pointer;
    background: transparent; color: var(--ink-soft); font-family: var(--font-display); font-weight: 700; font-size: .95rem;
}
.k-speed button[aria-checked="true"] { background: var(--t); color: #2B2350; box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .12); }
.c-night .k-speed button[aria-checked="true"], .c-grape .k-speed button[aria-checked="true"] { background: var(--grape-deep); color: #fff; }
.k-speed button:focus-visible { outline: 3px solid var(--t); outline-offset: 1px; }
/* Three little bars: one lit for slow, two for normal, three for quick. */
.k-speed-ico { display: inline-flex; align-items: flex-end; gap: 2px; width: 16px; height: 16px; background: linear-gradient(currentColor, currentColor) 0 100% / 4px 6px no-repeat, linear-gradient(currentColor, currentColor) 6px 100% / 4px 10px no-repeat, linear-gradient(currentColor, currentColor) 12px 100% / 4px 15px no-repeat; opacity: .35; }
.k-speed-ico.is-1 { background: linear-gradient(currentColor, currentColor) 0 100% / 4px 6px no-repeat, linear-gradient(color-mix(in srgb, currentColor 30%, transparent), color-mix(in srgb, currentColor 30%, transparent)) 6px 100% / 4px 10px no-repeat, linear-gradient(color-mix(in srgb, currentColor 30%, transparent), color-mix(in srgb, currentColor 30%, transparent)) 12px 100% / 4px 15px no-repeat; opacity: 1; }
.k-speed-ico.is-2 { background: linear-gradient(currentColor, currentColor) 0 100% / 4px 6px no-repeat, linear-gradient(currentColor, currentColor) 6px 100% / 4px 10px no-repeat, linear-gradient(color-mix(in srgb, currentColor 30%, transparent), color-mix(in srgb, currentColor 30%, transparent)) 12px 100% / 4px 15px no-repeat; opacity: 1; }
.k-speed-ico.is-3 { opacity: 1; }

/* ---------- The end page: a dense grid of what we learned ---------- */
.k-end-actions--top:empty { display: none; }
.k-end-grid { display: grid; gap: 14px; width: min(100%, 980px); grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); align-items: start; }
.k-end-grid > * { max-width: none; margin: 0; }
.k-end-grid .k-words { padding: 16px 22px; border-radius: 22px; background: var(--paper); box-shadow: var(--shadow-s); text-align: start; }
.k-end-grid .k-words > strong { display: block; color: var(--ink-soft); font-size: .85rem; text-transform: uppercase; letter-spacing: .08em; }
.k-end-grid .k-words dl { margin: 8px 0 0; display: grid; gap: 8px; }
.k-end-grid .k-words dl div { display: flex; flex-wrap: wrap; gap: 2px 10px; align-items: baseline; }
.k-end-grid .k-words dt { font-weight: 800; color: color-mix(in srgb, var(--t) 70%, var(--ink)); }
.k-end-grid .k-words dd { margin: 0; font-family: var(--font-read); }
.k-story-duas { width: min(100%, 980px); padding: 18px; border-radius: 26px; background: var(--paper); box-shadow: var(--shadow-s); text-align: start; }
.k-story-duas h3 { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 1.2rem; }
.k-story-duas h3 .k-ico { width: 30px; height: 30px; }
.k-story-duas-help { margin: 4px 0 12px; color: var(--ink-soft); font-size: .9rem; }
.k-story-duas-list { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); margin-bottom: 12px; }
.k-story-dua { margin: 0; padding: 14px 16px; border-radius: 20px; background: color-mix(in srgb, var(--mint) 12%, var(--paper)); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--mint) 35%, transparent); }
.k-story-dua figcaption { font-weight: 800; font-size: .95rem; }
.k-story-dua .k-verse-ar { font-size: 1.45rem; line-height: 1.9; margin: 6px 0; }
.k-story-dua p { margin: 0 0 6px; font-family: var(--font-read); font-size: .98rem; }
.k-story-dua cite { font-style: normal; font-size: .8rem; color: var(--ink-faint); font-weight: 700; }
.k-talk { width: min(100%, 980px); padding: 12px 18px; border-radius: 22px; background: color-mix(in srgb, var(--grape) 10%, var(--paper)); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--grape) 30%, transparent); text-align: start; }
.k-talk summary { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; cursor: pointer; font-family: var(--font-display); font-weight: 800; }
.k-talk summary .k-ico { width: 28px; height: 28px; }
.k-talk summary small { font-weight: 600; color: var(--ink-faint); }
.k-talk ul { margin: 10px 0 2px; padding-inline-start: 22px; font-family: var(--font-read); display: grid; gap: 6px; }

/* ---------- The story challenge ---------- */
.k-spread-challenge { grid-template-columns: 1fr; background: radial-gradient(120% 90% at 50% 0%, color-mix(in srgb, var(--sun) 26%, var(--paper)), var(--paper)); }
.k-challenge { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: clamp(20px, 3.4vw, 40px); text-align: center; }
.k-challenge .k-moment-kicker {
    display: inline-flex; align-items: center; gap: 8px; margin: 0; padding: 6px 16px; border-radius: 999px;
    background: var(--paper); box-shadow: var(--shadow-s); font-weight: 800; font-size: .95rem;
}
.k-challenge .k-moment-kicker .k-ico { width: 28px; height: 28px; }
.k-challenge-head { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.k-challenge-intro { margin: 0; color: var(--ink-soft); font-weight: 600; }
.k-challenge-steps { display: flex; gap: 8px; margin: 0; padding: 0; list-style: none; }
.k-challenge-steps li { width: 34px; height: 10px; border-radius: 999px; background: color-mix(in srgb, var(--ink) 14%, transparent); transition: background .3s, width .3s; }
.k-challenge-steps li.is-think { background: color-mix(in srgb, var(--grape) 30%, transparent); }
.k-challenge-steps li.is-done { background: var(--mint); }
.k-challenge-steps li.is-on { width: 52px; background: var(--sun-deep); }
.k-ch { display: flex; flex-direction: column; align-items: center; gap: 14px; width: 100%; }
.k-ch-count { margin: 0; font-weight: 800; color: var(--ink-faint); }
.k-ch-prompt { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 0; max-width: 820px; font-size: clamp(1.3rem, 2.6vw, 1.9rem); font-weight: 800; }
.k-ch-say { flex: none; width: 44px; height: 44px; border: 0; border-radius: 50%; cursor: pointer; background: var(--paper); box-shadow: var(--shadow-s); display: grid; place-items: center; }
.k-ch-say .k-ico { width: 26px; height: 26px; }
.k-ch-pics { display: grid; gap: 14px; width: min(100%, 900px); grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); }
.k-ch-pic {
    display: flex; flex-direction: column; padding: 0; overflow: hidden; border: 4px solid transparent; border-radius: 26px; cursor: pointer;
    background: var(--paper); color: var(--ink); box-shadow: 0 6px 0 color-mix(in srgb, var(--t) 35%, var(--paper)), var(--shadow);
    transition: transform .25s var(--ease-bounce), border-color .2s;
}
.k-ch-pic img { width: 100%; aspect-ratio: 3 / 2; object-fit: cover; display: block; }
.k-ch-pic span { padding: 10px 12px 12px; font-family: var(--font-display); font-weight: 800; font-size: 1.15rem; }
.k-ch-pic:hover:not([disabled]) { transform: translateY(-4px) rotate(-.6deg); }
.k-ch-choices { display: grid; gap: 12px; width: min(100%, 680px); }
.k-ch-choice {
    min-height: 60px; padding: 12px 22px; border-radius: 22px; border: 3px solid var(--line); cursor: pointer; text-align: start;
    background: var(--paper); color: var(--ink); font-family: var(--font-read); font-size: 1.1rem; font-weight: 700;
    box-shadow: 0 5px 0 color-mix(in srgb, var(--t) 30%, var(--paper)); transition: transform .15s, border-color .2s, background .2s;
}
.k-ch-choice:hover:not([disabled]) { transform: translateY(-2px); border-color: color-mix(in srgb, var(--t) 60%, var(--paper)); }
.k-ch-pic.is-right, .k-ch-choice.is-right { border-color: var(--leaf); background: var(--leaf-soft); }
.k-ch-choice.is-right::after, .k-ch-pic.is-right span::after { content: " \2713"; color: var(--leaf-deep); }
.k-ch-pic.is-wrong, .k-ch-choice.is-wrong { opacity: .55; animation: k-ch-wobble .4s ease; }
.k-ch-pic[disabled], .k-ch-choice[disabled] { cursor: default; }
@keyframes k-ch-wobble { 25% { transform: translateX(-6px); } 50% { transform: translateX(6px); } 75% { transform: translateX(-3px); } }
.k-ch-pic:focus-visible, .k-ch-choice:focus-visible { outline: 3px solid var(--t); outline-offset: 3px; }
.k-challenge .k-moment-feedback { margin: 0; max-width: 680px; padding: 12px 18px; border-radius: 18px; font-family: var(--font-read); font-size: 1.1rem; background: var(--paper); box-shadow: var(--shadow-s); }
.k-challenge .k-moment-feedback.is-good { background: var(--leaf-soft); }
.k-challenge .k-moment-feedback.is-try { background: var(--sun-soft); }
.k-ch-think { display: flex; flex-direction: column; align-items: center; gap: 12px; width: min(100%, 700px); }
.k-ch-think-hint { display: flex; align-items: center; gap: 8px; margin: 0; padding: 10px 16px; border-radius: 18px; background: color-mix(in srgb, var(--grape) 12%, var(--paper)); font-weight: 700; }
.k-ch-think-hint .k-ico { width: 28px; height: 28px; flex: none; }
.k-ch-ideas { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; width: 100%; text-align: start; }
.k-ch-ideas li { position: relative; padding-block: 10px; padding-inline: 40px 14px; border-radius: 16px; background: var(--paper); box-shadow: var(--shadow-s); font-family: var(--font-read); }
.k-ch-ideas li::before { content: ""; position: absolute; inset-inline-start: 14px; top: 16px; width: 12px; height: 12px; border-radius: 50%; background: var(--sun); }
.k-ch-result { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.k-ch-result h2 { margin: 0; font-size: clamp(1.8rem, 4vw, 2.6rem); }
.k-ch-result .k-end-stars i.is-off { background: color-mix(in srgb, var(--ink) 16%, transparent); }
.k-result-line { margin: 0; font-weight: 700; color: var(--ink-soft); }

/* ---------- The library: stats, the sixteen shelves, kind tags on covers ---------- */
.k-library-stats { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
/* A fixed line box: the chips keep their height when the web fonts arrive, so the shelf below does not jump. */
.k-library-stats span { padding: 6px 14px; border-radius: 999px; background: var(--glass); box-shadow: inset 0 0 0 1px var(--glass-edge); font-weight: 600; color: var(--ink-soft); line-height: 28px; }
.k-library-stats b { color: var(--ink); font-family: var(--font-display); font-size: 1.1rem; line-height: 1; }
.k-cats {
    display: flex; gap: 8px; margin: 4px -4px 18px; padding: 6px 4px 12px; overflow-x: auto; scroll-snap-type: x proximity;
    scrollbar-width: thin; overscroll-behavior-x: contain;
}
@media (min-width: 1100px) { .k-cats { flex-wrap: wrap; overflow: visible; } }
.k-cat {
    --c: var(--grape); flex: none; scroll-snap-align: start; display: inline-flex; align-items: center; gap: 6px; min-height: 46px; padding-block: 5px; padding-inline: 6px 12px;
    border: 0; border-radius: 999px; cursor: pointer; font-family: var(--font-display); font-weight: 700; font-size: .92rem; color: var(--ink);
    background: color-mix(in srgb, var(--c) 14%, var(--paper)); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--c) 35%, transparent);
    transition: transform .25s var(--ease-bounce), background .2s;
}
.k-cat:hover:not([disabled]) { transform: translateY(-2px); }
.k-cat[disabled] { opacity: .45; cursor: default; }
.k-cat-ico { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--paper); box-shadow: var(--shadow-s); }
.k-cat-ico .k-ico { width: 26px; height: 26px; }
.k-cat b { min-width: 24px; padding: 1px 7px; border-radius: 999px; background: color-mix(in srgb, var(--c) 30%, var(--paper)); font-size: .8rem; text-align: center; }
.k-cat[aria-pressed="true"] { background: color-mix(in srgb, var(--c) 72%, #000); color: #fff; box-shadow: 0 10px 18px -10px color-mix(in srgb, var(--c) 90%, #000), inset 0 -3px 0 rgba(0, 0, 0, .15); }
.k-cat[aria-pressed="true"] b { background: rgba(255, 255, 255, .3); }
.k-cat:focus-visible { outline: 3px solid var(--c); outline-offset: 2px; }
.k-cat--manners { --c: #8D72F0; }
.k-cat--honesty { --c: #1F80CC; }
.k-cat--kindness { --c: #E0503F; }
.k-cat--gratitude { --c: #C27F00; }
.k-cat--patience { --c: #1A8F70; }
.k-cat--parents { --c: #D9578A; }
.k-cat--friendship { --c: #E0662A; }
.k-cat--neighbours { --c: #2F8F49; }
.k-cat--charity { --c: #B2367A; }
.k-cat--salah { --c: #4F5BD5; }
.k-cat--ramadan { --c: #5B3FD0; }
.k-cat--eid { --c: #C23F8E; }
.k-cat--duas { --c: #12808F; }
.k-cat--history { --c: #A0602B; }
.k-cat--quran { --c: #0F7A5F; }
.k-cat--decisions { --c: #6B5A8E; }
.k-book-kind {
    position: absolute; inset-inline-start: 12px; bottom: 10px; padding: 3px 10px; border-radius: 999px;
    font-family: var(--font-display); font-weight: 700; font-size: .74rem; background: rgba(255, 249, 230, .95); color: #6B4A00;
}
.k-book-kind.k-kind--quran { background: rgba(225, 250, 240, .95); color: #0F5F49; }
.k-book-kind.k-kind--learn { background: rgba(226, 243, 255, .95); color: #134E7E; }
.k-book-cats { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.k-book-cats i { --c: var(--grape); font-style: normal; padding: 1px 8px; border-radius: 999px; font-size: .72rem; font-weight: 700; color: var(--ink); background: color-mix(in srgb, var(--c) 16%, var(--paper)); }
.k-kinds-key { display: grid; gap: 8px; margin-top: 14px; padding: 14px; border-radius: 24px; background: var(--glass); box-shadow: inset 0 0 0 1px var(--glass-edge); }
.k-kinds-key > strong { font-family: var(--font-display); }
.k-kinds-key p { margin: 0; font-size: .86rem; color: var(--ink-soft); line-height: 1.45; }
.k-kinds-key .k-kind { margin-inline-end: 4px; }
/* On a phone the stories come first (as with Noor's side tip): the key sat above the shelf there, and its wrapped lines
   re-flowed when the web fonts arrived, pushing the whole shelf down (CLS 0.15). Each book's badge still names its kind. */
@media (max-width: 760px) {
    .k-kinds-key { display: none; }
}
.k-grownups-kind .k-kind { margin-inline-end: 6px; }

@media (max-width: 860px) {
    .k-reader[data-age="9-12"] .k-spread[data-kind="page"] { grid-template-columns: 1fr; }
    .k-speed { height: 58px; padding: 4px; }
    .k-speed button { padding: 0 9px; }
    .k-speed button span { display: none; }
    .k-ctl-mark { min-width: 52px; padding: 0 10px; }
    .k-controls { gap: 8px; }
    .k-page-mark { inset-inline-end: 14px; }
}
@media (max-width: 520px) {
    .k-ctl { min-width: 50px; height: 54px; padding: 0 10px; }
    .k-speed { height: 54px; }
    .k-ch-pics { grid-template-columns: repeat(2, 1fr); }
    .k-ch-pic span { font-size: 1rem; }
    /* On a phone the word helper is a sheet along the bottom, above the reading toolbar. */
    .k-gloss-pop { position: fixed; inset-inline: 12px; top: auto !important; left: 12px !important; bottom: 12px; width: auto; z-index: 60; }
}
