@font-face {
    font-family: "Book Fredoka";
    src: url("fonts/Fredoka-600.ttf") format("truetype");
    font-weight: 600;
    font-display: swap;
}

@font-face {
    font-family: "Book Nunito";
    src: url("fonts/Nunito-650.ttf") format("truetype");
    font-weight: 650;
    font-display: swap;
}

@font-face {
    font-family: "Book Baloo Bhaijaan";
    src: url("fonts/BalooBhaijaan2-VF.ttf") format("truetype");
    font-weight: 400 800;
    font-display: swap;
}

@font-face {
    font-family: "Book Tajawal";
    src: url("fonts/Tajawal-Bold.ttf") format("truetype");
    font-weight: 700;
    font-display: swap;
}

:root {
    --ink: #142d3f;
    --blue: #244d69;
    --paper: #fffdf8;
    --rule: #e7decd;
    color-scheme: light;
}

* { box-sizing: border-box; }

html { background: #f8f4e9; }

body {
    margin: 0;
    color: var(--ink);
    font: 1rem/1.6 "Segoe UI", sans-serif;
}

[lang="ar"] body { font-family: Tahoma, "Segoe UI", sans-serif; }

[hidden] { display: none !important; }
a { color: var(--blue); text-underline-offset: .22em; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 4px; }

.reader-frame { width: min(56rem, calc(100% - 2rem)); margin-inline: auto; }

.reader-header {
    background: var(--paper);
    border-block-end: 1px solid var(--rule);
}

.reader-header .reader-frame {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: .55rem 1rem;
    align-items: center;
    padding-block: .8rem;
}

.reader-brand {
    display: inline-flex;
    gap: .65rem;
    align-items: center;
    color: var(--ink);
    text-decoration: none;
    font: 1.2rem Georgia, serif;
}

.reader-brand img { border-radius: 50%; }
.reader-title { font-size: clamp(1.8rem, 5vw, 2.7rem); margin: 0; line-height: 1.25; }
[lang="en"] .reader-title { font-family: Georgia, serif; font-weight: 400; }

.reader-intro {
    display: flex;
    justify-content: space-between;
    gap: .75rem 1.25rem;
    align-items: center;
    flex-wrap: wrap;
    margin-block: 1.5rem 1rem;
}

.reader-tools { display: flex; flex-wrap: wrap; gap: .65rem; align-items: center; position: relative; }

.reader-control,
.reader-contents summary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.75rem;
    border: 1px solid var(--rule);
    border-radius: .5rem;
    padding: .35rem .8rem;
    text-decoration: none;
    font-size: .9rem;
    font-weight: 600;
    color: var(--blue);
    background: var(--paper);
}

.reader-control[href]:hover, .reader-contents summary:hover { background: #eee8d9; }
.reader-control[aria-disabled="true"] { color: #6e736f; background: #eeeae2; }
.reader-contents summary { cursor: pointer; gap: .45rem; }
.reader-contents summary::-webkit-details-marker { display: none; }
.reader-contents summary::after { content: "▾"; }

.reader-contents ol {
    margin: .4rem 0 0;
    padding: .75rem 1.2rem;
    padding-inline-start: 2rem;
    border: 1px solid var(--rule);
    border-radius: .65rem;
    background: var(--paper);
    position: absolute;
    inset-inline-start: 0;
    width: max-content;
    min-width: 13rem;
    max-width: min(20rem, calc(100vw - 2rem));
    max-height: 60vh;
    overflow: auto;
    z-index: 2;
    box-shadow: 0 .4rem 1.4rem #2820131c;
}

.reader-contents li a { display: block; padding: .35rem; }
.reader-contents a[aria-current] { border-radius: .3rem; background: #e6edf1; color: var(--ink); }

.reader-pages { border: 1px solid var(--rule); border-radius: .9rem; overflow: hidden; background: var(--paper); }
.reader-page { padding: clamp(1rem, 4vw, 2rem); }
.reader-page:focus { outline: none; }
.reader-page img { max-width: 100%; }
.reader-page h2 { font-size: clamp(1.55rem, 5vw, 2.35rem); line-height: 1.3; margin: 0 0 .65rem; }
[lang="en"] .reader-page h2 { font-family: Georgia, serif; font-weight: 400; }
.reader-page h3 { margin-block: .8rem .3rem; line-height: 1.35; }
.reader-page p { margin-block: .4rem .75rem; }

.reader-pagination {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: .35rem;
    margin: 1rem 0 2rem;
    font-size: .9rem;
}

.reader-pagination [data-previous] { justify-self: start; }
.reader-pagination [data-next] { justify-self: end; }

.reader-pages:has(.country-page:not([hidden])) {
    border: 0;
    border-radius: 0;
}

.country-page {
    --book-paper: #fbf6ec;
    --book-display: "Book Fredoka";
    --book-display-weight: 600;
    background: var(--book-paper);
    color: #3b3a4a;
    display: flex;
    flex-direction: column;
    padding: 0;
    font-family: "Book Nunito", "Segoe UI", sans-serif;
}

[lang="ar"] .country-page {
    --book-display: "Book Baloo Bhaijaan";
    --book-display-weight: 700;
    font-family: "Book Tajawal", Tahoma, sans-serif;
}

.country-artwork {
    position: relative;
    aspect-ratio: 8.5 / 5.25;
}

.country-artwork .reader-art {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center 40%;
    background: var(--book-paper);
}

.country-artwork .wave {
    position: absolute;
    inset-inline: 0;
    bottom: -1px;
    display: block;
    width: 100%;
    height: 8.6%;
    pointer-events: none;
}

[dir="rtl"] .country-artwork .wave { transform: scaleX(-1); }

.country-artwork .reader-region {
    position: absolute;
    inset-block-start: 8.6%;
    inset-inline-start: 7.1%;
    border-radius: 2rem;
    background: var(--country-badge);
    color: white;
    box-shadow: 0 .1rem .3rem #44233330;
    padding: .17em .8em;
    font: 600 1rem/1.4 var(--book-display), "Segoe UI", sans-serif;
}

.country-page .panel { padding: .9rem 7.1% 1.4rem; }

.reader-country-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: .85rem;
    margin: 0 0 .65rem;
}

html[lang] .reader-country-heading h2 {
    color: var(--country-heading);
    font: var(--book-display-weight) clamp(1.8rem, 6.1vw, 3.55rem)/1.05 var(--book-display), "Segoe UI", sans-serif;
    margin: 0;
    min-inline-size: 0;
    overflow-wrap: break-word;
}

html[lang="ar"] .reader-country-heading h2 {
    font-size: clamp(1.65rem, 5.35vw, 3.55rem);
    line-height: 1.27;
}

.reader-flag {
    flex: none;
    width: clamp(2.65rem, 11vw, 6.1rem);
    border-radius: .3rem;
    box-shadow: 0 0 0 1px #3b3a4a29, 0 .15rem .2rem #3b3a4a20;
}

.reader-facts {
    margin: 0;
    padding-inline-start: 1.24em;
    font-size: clamp(1.03rem, 2.5vw, 1.76rem);
    line-height: 1.42;
    font-weight: 650;
}

[lang="ar"] .reader-facts {
    font-size: clamp(1.14rem, 2.65vw, 1.81rem);
    line-height: 1.65;
    font-weight: 700;
}

.reader-facts li + li { margin-block-start: .1em; }
.reader-facts li::marker { color: var(--country-accent); }

.country-page .pn {
    margin-block-start: auto;
    padding-block: .2rem 1.5rem;
    text-align: center;
    font: 600 .85rem/1.3 var(--book-display), "Segoe UI", sans-serif;
    color: #746a5d;
}

.reader-page .t { font-size: clamp(1.8rem, 8vw, 3.65rem); line-height: 1.25; }
[lang="en"] .reader-page .t { font-family: Georgia, serif; }
.reader-page.cover, .reader-page.tp, .reader-page.back,
.reader-page .txt, .reader-page.recap, .reader-page .qhead { text-align: center; }
.reader-page.cover { background: #fbf3e2; }
.reader-page.cover .t span { color: #a7501f; }
.reader-page.cover .img, .reader-page .spot {
    display: block;
    margin: 1rem auto;
    width: min(100%, 34rem);
    border-radius: .65rem;
}
.reader-page .txt { margin: 1.25rem auto .25rem; font-size: 1.15rem; }
.reader-page .sub, .reader-page .s, .reader-page .foot { margin: .55rem 0; }
.reader-page .sub, .reader-page .foot { color: #5c6268; }
.reader-page .flagrow, .reader-page .grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(6.5rem, 1fr));
    justify-items: center;
    align-items: center;
    gap: 1rem;
    margin-block: 1.2rem;
}
.reader-page .flagrow img, .reader-page .fb img { width: 3.25rem; max-height: 2.2rem; object-fit: contain; }
.reader-page .cell { display: grid; justify-items: center; gap: .3rem; }
.reader-page .trow {
    display: flex;
    gap: .55rem;
    align-items: center;
    min-height: 2.6rem;
    padding: .3rem .15rem;
    border-block-end: 1px solid var(--rule);
    text-decoration: none;
}
.reader-page .trow:hover { background: #f8f4e9; }
.reader-page .trow > img, .reader-page .trow .ic svg { width: 1.65rem; max-height: 1.4rem; object-fit: contain; }
.reader-page .trow .n { margin-inline-start: auto; font-variant-numeric: tabular-nums; }
.reader-page.toc :is(.intro, .cols, .end) { margin-block: .8rem; }
.reader-page .qhead .ul { width: 6rem; height: 1rem; display: block; margin-inline: auto; }
.reader-page .qcards { display: grid; gap: .85rem; }
.reader-page .qcard, .reader-page .match, .reader-page .cert {
    position: relative;
    background: #f8f4e9;
    border: 1px solid var(--rule);
    border-radius: .65rem;
    padding: 1rem;
}
.reader-page .qcard + .qcard { margin: 0; }
.reader-page .qnum {
    display: inline-grid;
    place-items: center;
    border-radius: 50%;
    width: 1.65rem;
    height: 1.65rem;
    margin-inline-end: .4rem;
    background: var(--blue);
    color: white;
    font-size: .85rem;
}
.reader-page .qq { font-weight: 700; }
.reader-page .qthumb { float: inline-end; width: 3.7rem; margin-inline-start: .45rem; border-radius: .4rem; }
.reader-page .opts, .reader-page .popts { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .65rem; }
.reader-page .reader-choice {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .3rem;
    min-height: 2.55rem;
    padding: .25rem .5rem;
    border: 1px solid var(--rule);
    border-radius: .35rem;
    background: var(--paper);
    cursor: pointer;
}
.reader-page .reader-choice:has(input:checked) { border-color: var(--blue); background: #e4edf2; }
.reader-page .opts img { width: 1.5rem; max-height: 1.1rem; object-fit: contain; }
.reader-page .popts img { width: 3.8rem; border-radius: .3rem; }
.reader-page .match { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.reader-page .match > :is(.qnum, .qq) { grid-column: 1 / -1; }
.reader-page .mrow { display: flex; align-items: center; justify-content: space-between; gap: .4rem; margin-block: .35rem; }
.reader-page .mrow img { width: 2.8rem; max-height: 2rem; object-fit: contain; }
.reader-page .match-control {
    display: grid;
    place-items: center;
    width: 2.35rem;
    min-height: 2.35rem;
    border: 1px solid var(--rule);
    border-radius: 50%;
    background: var(--paper);
    font: inherit;
    color: var(--blue);
    cursor: pointer;
    flex-shrink: 0;
}
.reader-page .match-control[aria-pressed="true"] { border-color: var(--blue); background: #d6e8f1; }
.reader-page .fcard { margin-block-start: .85rem; }
.reader-page .gj, .reader-page .stars { display: flex; align-items: center; justify-content: center; gap: .4rem; margin-block: .8rem; }
.reader-page :is(.gj, .stars) svg { width: 1.25rem; height: 1.25rem; flex: none; }
.reader-page .agrid { display: grid; gap: .4rem .9rem; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); margin-block: .9rem; }
.reader-page .agrid div { display: flex; gap: .35rem; align-items: center; flex-wrap: wrap; }
.reader-page .agrid .w { grid-column: 1 / -1; }
.reader-page .agrid i { display: inline-flex; gap: .2rem; align-items: center; }
.reader-page .agrid img { width: 1.2rem; max-height: .85rem; }
.reader-page .cert { text-align: center; margin-block-start: 1rem; }
.reader-page .cert .ct { font-size: 1.4rem; font-weight: 700; }
.reader-page .cert .line { margin-block-start: .85rem; }
.reader-page .map { overflow-x: auto; }
.reader-page .map svg { display: block; width: 100%; min-width: 21rem; height: auto; }
.reader-page .lgg { display: grid; gap: .4rem .9rem; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); }
.reader-page .lgh { font-weight: 700; margin-block: .8rem .45rem; }
.reader-page .it, .reader-page .wl { display: flex; align-items: center; gap: .35rem; }
.reader-page .it img { width: 1.5rem; max-height: 1.1rem; object-fit: contain; }
.reader-page .map-answer, .reader-page .write-answer {
    padding: .3rem;
    min-height: 2rem;
    border: 1px solid var(--rule);
    border-radius: .35rem;
    background: white;
    color: var(--ink);
    font: inherit;
}
.reader-page .map-answer { width: 2.45rem; text-align: center; }
.reader-page .write-answer { width: min(16rem, 100%); }
.reader-page .wl { flex-wrap: wrap; margin-top: .95rem; }
.reader-page.back .ring { width: min(13rem, 60%); border-radius: 50%; }
.reader-page.back .blurb { margin: 0 auto .8rem; max-width: 36rem; }
.reader-page.back .pub { margin-top: 1rem; }
.reader-page:not(.country-page) .pn,
.reader-page :is(.qstar, .draw > .ic) { display: none; }

@media (max-width: 27rem) {
    .reader-header .reader-frame { column-gap: .55rem; }
    .reader-brand { font-size: 1.05rem; }
    .reader-header .reader-control { padding-inline: .6rem; }
}

@media (min-width: 43rem) {
    .reader-contents ol { inset-inline-start: auto; inset-inline-end: 0; }
    .reader-page.toc .cols, .reader-page.toc .end { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1.15rem; }
}

@media (min-width: 48rem) {
    .country-page { aspect-ratio: 1; }
    .country-page .panel { padding-top: 1.45rem; }
    .country-artwork .reader-region { font-size: 1.25rem; }
}
