/* Läseboken – bokvyn för en lektions lästext (js/bok.js).
   Boken är RTL: första grid-barnet i .bok-nav hamnar till höger (Tillbaka),
   sista till vänster (Nästa framåt). Inga emoji – bara ART-illustrationer. */

/* ---------- ramen ---------- */
.bok{direction:rtl;width:min(1040px,100%);margin:0 auto 28px;background:var(--card);border:1px solid var(--border);border-radius:18px;display:flex;flex-direction:column;overflow:hidden;min-height:clamp(500px,calc(100dvh - 224px),760px);box-shadow:none}
.bok-top{min-height:64px;display:grid;grid-template-columns:minmax(92px,1fr) minmax(0,1.4fr) minmax(92px,1fr);align-items:center;gap:12px;padding-block:0;padding-inline:14px;border-bottom:1px solid var(--border)}
.bok-tt{min-width:0;overflow:hidden;text-align:center;line-height:1.2}
.bok-tt b{display:block;overflow:hidden;font:700 22px/1.55 var(--font-ar-read);color:var(--fg);text-overflow:ellipsis;white-space:nowrap}
.bok-tt b[lang="sv"]{font-family:var(--ui)}
.bok-tt small{display:block;overflow:hidden;color:var(--muted);font-size:12px;line-height:1.45;margin-top:1px;text-overflow:ellipsis;unicode-bidi:isolate;white-space:nowrap}
.bok-quit{display:grid;place-items:center;width:44px;height:44px;min-width:44px;min-height:44px;border-radius:10px;border:0;background:transparent;color:var(--muted);cursor:pointer;text-decoration:none}
.bok-quit:hover{background:var(--hover);color:var(--fg)}
.bok-tools{display:flex;align-items:center;gap:4px;flex-wrap:nowrap;justify-self:end}
.bok .bok-tools .btn{min-width:44px;min-height:44px;white-space:nowrap;border-color:transparent;background:transparent;color:var(--muted);border-radius:10px;padding:0 10px;font-size:13px;font-weight:650;box-shadow:none}
.bok .bok-tools .btn:hover{background:var(--hover);color:var(--fg);transform:none}
.bok .bok-tools .btn[aria-pressed="true"]{color:var(--brand);background:var(--brand-soft)}
.bok-tools .text-audio{margin:0;display:flex;align-items:center}.bok-tools .text-audio>button{margin:0}
.bok-tools [hidden]{display:none!important}
.bok-src{margin:8px 18px 0;color:var(--muted);font-size:13px;unicode-bidi:isolate}

/* visningsmeny */
.bok-menu{position:relative;display:inline-flex}
.bok-viewbtn .ic:last-child{transform:rotate(90deg);margin-inline-start:-2px}
.bok-menu-pop{position:fixed;z-index:1200;min-width:min(250px,calc(100vw - 40px));padding:6px;background:var(--card-solid);border:1px solid var(--border-strong);border-radius:12px;box-shadow:var(--pop-sh);text-align:start}
.bok-menu-item{display:flex;align-items:center;gap:10px;width:100%;min-height:44px;padding:0 12px;border:0;border-radius:8px;background:transparent;color:var(--fg);font:600 14px/1.2 var(--ui);text-align:start;cursor:pointer}
.bok-menu-item:hover{background:var(--hover)}
.bok-menu-item .ic{color:var(--muted);flex:none}
.bok-menu-item span{unicode-bidi:isolate}

/* ---------- sidorna ---------- */
.bok-stage{flex:1;min-height:0;padding:28px 44px 22px;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:16px}
.bok-stage>.reading-translation,.bok-stage>.bok-svbox,.bok-stage>audio,.bok-stage>.bok-glossnote{width:min(820px,100%);align-self:center}
.bok-stage>.reading-translation{margin:0;background:var(--surface);border:1px solid var(--border);border-inline-start:3px solid var(--brand);border-radius:10px;padding:12px 16px;color:var(--fg);font-size:15px;line-height:1.65;text-align:start;unicode-bidi:isolate}
.bok-stage>audio{display:block;margin:0}
.bok-stage>.bok-svbox{margin:0;background:var(--surface);border:1px solid var(--border);border-radius:10px;color:var(--fg)}
.bok-stage>.bok-svbox>summary{display:flex;align-items:center;min-height:44px;padding:0 14px;font-weight:700;cursor:pointer}
.bok-stage>.bok-svbox>p{margin:0;padding:0 14px 12px;text-align:start}
.bok-stage>.bok-glossnote{display:block;margin:0;color:var(--muted);font-size:14px}
.bok-stage>.bok-glossnote:empty{display:none}
.bok-pg{display:none}
.bok-pg.on{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:14px;width:min(820px,100%);margin-block:auto;animation:bok-in .25s ease}
@keyframes bok-in{from{opacity:0}to{opacity:1}}
@media (prefers-reduced-motion:reduce){.bok-pg.on{animation:none}}
.bok-h{margin:0;font:700 20px/1.55 var(--font-ar-read);color:var(--fg)}

/* ord sidan före sida 1 */
.bok-wl{list-style:none;margin:0;padding:0;display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:10px;width:100%}
.bok-wl li{display:flex;align-items:center;gap:10px;border:1px solid var(--border);border-radius:12px;padding:10px 12px;background:transparent;min-height:64px}
.bok-wl b{font:500 21px/1.6 var(--font-ar-read);flex:none;color:var(--read-fg)}
.bok-wa{display:inline-grid;place-items:center;width:40px;height:40px;flex:none}
.bok-wa svg{width:100%;height:100%;display:block}
.bok-wm{flex:1;min-width:0;display:flex;flex-direction:column;line-height:1.45}
.bok-wm span[lang]{color:var(--muted);font-size:14px;unicode-bidi:isolate}
.bok-wm span[lang="ar"]{font:500 15px/1.6 var(--font-ar-read);color:var(--muted)}
.bok-wl .speak{width:44px;height:44px;min-width:44px;min-height:44px;border:0;background:transparent;border-radius:10px;color:var(--muted)}
.bok-wl .speak:hover{background:var(--hover);color:var(--fg)}

/* lässidan */
.bok-page{gap:clamp(18px,3vh,32px)}
.bok-pic{margin:0;display:grid;place-items:center;width:132px;height:132px}
.bok-pic[hidden]{display:none}
.bok-pic .bok-art,.bok-pic svg{width:100%;height:100%;display:block}
.bok .bok-lines{width:100%;font-family:var(--font-ar-read);font-weight:400;font-size:clamp(26px,3vw,34px);line-height:2.1;color:var(--read-fg);text-align:start;letter-spacing:0;background:transparent;border:0;padding:0;box-shadow:none}
.bok-lines p{margin:0 0 .35em}
.bok-lines p:last-child{margin-bottom:0}
.bok-lines .tw{border-radius:4px;padding-inline:1px}
.bok-lines .tw:hover{background:var(--brand-soft)}

/* frågesidan */
.bok-q{align-items:stretch;gap:18px}
.bok-qs{margin:0;font:500 clamp(22px,2.5vw,27px)/1.7 var(--font-ar-read);color:var(--read-fg)}
.bok-opts{display:grid;gap:8px}
.bok-opt{font:500 20px/1.6 var(--font-ar-read);text-align:start;min-height:48px;padding:10px 14px;border:1px solid var(--border);border-radius:10px;background:transparent;color:var(--read-fg);cursor:pointer}
.bok-opt:hover:not(:disabled){border-color:var(--brand);background:var(--brand-soft)}
.bok-opt:disabled{cursor:default}
.bok-opt.ok{border-color:var(--o);background:var(--o-soft)}
.bok-opt.bad{border-color:var(--v);background:var(--v-soft)}
.bok-opt.sel{box-shadow:0 0 0 2px color-mix(in srgb,var(--brand) 45%,transparent)}
.bok-why{border-inline-start:3px solid var(--brand);background:var(--brand-soft);border-radius:8px;padding:10px 14px;font-size:14px;line-height:1.5}
.bok-why[hidden]{display:none}
.bok-why p{margin:0 0 4px}.bok-why p:last-child{margin:0}
.bok-why b{font-family:var(--font-ar-read)}
.bok-why-ok{color:var(--o);font-weight:700}
.bok-qnxt{align-self:center;min-height:44px}

/* berätta-sidan */
.bok-tell{align-items:stretch}
.bok-tell .bok-qs{margin-bottom:4px}
.bok-th{color:var(--muted);margin:0;line-height:1.5;unicode-bidi:isolate}
.bok-model{font:500 20px/1.9 var(--font-ar-read);color:var(--read-fg);background:var(--surface);border:1px solid var(--border);border-radius:10px;padding:14px 18px;margin:0}
.bok-model[hidden]{display:none}

/* slutsidan */
.bok-end{text-align:center;gap:18px}
.bok-end-art{display:block;width:86px;height:86px}
.bok-end-art svg{width:100%;height:100%;display:block}
.bok-score{font-size:15px;color:var(--muted);margin:0}
.bok-endrow{display:flex;gap:10px;flex-wrap:wrap;justify-content:center}
.bok-nextwrap{margin:4px 0 0;color:var(--muted)}
.bok-nextwrap:empty{display:none}
.bok-nextwrap b{font-weight:700;color:var(--fg)}

/* ---------- bläddra ---------- */
.bok-nav{min-height:62px;display:grid;grid-template-columns:auto minmax(0,1fr) auto;align-items:center;gap:12px;padding:0 16px;border-top:1px solid var(--border)}
.bok-navbtn{display:inline-flex;align-items:center;justify-content:center;gap:6px;min-width:48px;min-height:48px;border:0;background:transparent;border-radius:10px;padding:0 12px;font:700 14px var(--ui);color:var(--fg);cursor:pointer;white-space:nowrap}
.bok-navbtn:hover:not(:disabled){background:var(--hover);color:var(--brand)}
.bok-navbtn:disabled{opacity:.28;cursor:default}
.bok-mid{display:flex;justify-content:center;align-items:center;gap:10px;min-width:0}
.bok-dots{display:flex;gap:0;flex-wrap:nowrap;justify-content:center;overflow-x:auto;max-width:100%;min-height:44px;align-items:center;padding-block:2px;padding-inline:12px;scrollbar-width:none}
.bok-dots::-webkit-scrollbar{display:none}
.bok-dot{position:relative;flex:none;width:44px;height:44px;min-width:44px;min-height:44px;margin-inline:-10px;border:0;background:transparent;padding:0;cursor:pointer}
.bok-dot::after{content:"";position:absolute;inset:0;margin:auto;width:7px;height:7px;border-radius:50%;border:0;background:var(--chip)}
.bok-dot:hover::after{background:var(--muted)}
.bok-dot.on::after{background:var(--brand)}
.bok-step,.bok-pageno,.bok-pageno-alt{color:var(--muted);font-size:12px;font-weight:600;white-space:nowrap;unicode-bidi:isolate}
.bok-pageno,.bok-pageno-alt{direction:ltr}

.bok-ui{max-width:1040px;margin-inline:auto}
.bok-crumbsep{color:var(--muted)}

/* ---------- lärarens bokhylla ---------- */
.bok-crumbs{display:flex;align-items:center;gap:4px;color:var(--muted);font-size:13px;margin-bottom:14px;flex-wrap:wrap;max-width:1040px;margin-inline:auto}
.bok-crumbs a{color:var(--muted)}
.bok-crumbs a:hover{color:var(--brand)}
.bok-shelf{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:14px;max-width:1040px;margin:18px auto 0}
.bok-cover{display:grid;grid-template-columns:72px minmax(0,1fr) auto;align-items:center;gap:14px;text-align:start;background:var(--card);border:1px solid var(--border);border-radius:16px;padding:18px;color:var(--fg);box-shadow:none;text-decoration:none}
.bok-cover:hover{border-color:var(--brand);background:var(--hover)}
.bok-cv-art{width:72px;height:72px;display:grid;place-items:center}
.bok-cv-art svg{width:100%;height:100%;display:block}
.bok-cover b{font-size:17px;display:block}
.bok-cover small{color:var(--muted);font-size:13px;display:block;margin-top:3px}
.bok-count{justify-self:end;font-size:12px;font-weight:700;color:var(--brand);background:var(--brand-soft);border-radius:999px;padding:3px 10px;white-space:nowrap}
.bok-cv-tt{display:block;min-width:0}
.bok-cv-tt .ar{display:block;margin-top:2px;color:var(--read-fg);font:400 22px/1.6 var(--font-ar-read)}
.bok-levels{display:inline-flex;width:fit-content;max-width:100%;flex-wrap:wrap;margin:-4px 0 14px}
.bok-levels[dir="rtl"]{direction:rtl}
.bok-levels .rs-seg-btn{flex:none}
.bok-levels a{text-decoration:none;unicode-bidi:isolate}
.bok-pagehead{align-items:center;max-width:1040px;margin-inline:auto}
.bok-pagehead .pagehead-actions{display:flex;align-items:center;margin-inline-start:auto}
.bok-pagehead .pagehead-actions:empty{display:none}

/* innehållsförteckning */
.bok-toc{list-style:none;margin:12px auto 0;padding:0;display:grid;gap:8px;max-width:1040px}
@media (min-width:900px){.bok-toc-shelf{grid-template-columns:repeat(2,minmax(0,1fr));gap:8px 14px}}
.bok-row{display:flex;align-items:center;gap:12px;background:var(--card);border:1px solid var(--border);border-radius:12px;padding:11px 14px;color:var(--fg);text-decoration:none}
button.bok-row{width:100%;font:inherit;text-align:start;cursor:pointer}
.bok-row:hover{border-color:var(--brand);background:var(--hover)}
.bok-rn{flex:none;width:34px;height:34px;border-radius:9px;display:grid;place-items:center;background:color-mix(in srgb,var(--lc,var(--brand)) 14%,var(--tint-base));color:var(--brand);font:700 14px var(--ui)}
.bok-rt{flex:1;min-width:0;text-align:start}
.bok-rt b{display:block;font:500 19px/1.55 var(--font-ar-read);color:var(--read-fg)}
.bok-rt small{display:block;color:var(--muted);font-size:13px;margin-top:1px;unicode-bidi:isolate}
.bok-read{flex:none;display:inline-flex;align-items:center;gap:4px;font-size:12px;font-weight:700;color:var(--o)}
.bok-note{max-width:1040px;margin:14px auto 0;color:var(--muted);font-size:13.5px}
.bok-load p{text-align:center;color:var(--muted)}

/* ---------- bokstavsboken (nivå 1) ---------- */
.bok-letter{align-items:stretch;gap:18px}
.bok-ltop{display:flex;align-items:center;gap:20px}
.bok-big{flex:none;width:150px;height:150px;border-radius:16px;background:var(--brand);color:var(--on-primary);display:grid;place-items:center;font:700 96px/1 var(--font-ar-read);padding-bottom:26px}
.bok-lmeta{flex:1;min-width:0}
.bok-lname{margin:0;display:flex;align-items:center;gap:10px;flex-wrap:wrap}
.bok-lname b{font:700 30px/1.55 var(--font-ar-read);color:var(--read-fg)}
.bok-lname .speak{width:44px;height:44px;min-width:44px;min-height:44px;border:0;background:transparent;border-radius:10px;color:var(--muted)}
.bok-lsv{margin:6px 0 0;color:var(--muted);font-size:15px;line-height:1.5;unicode-bidi:isolate}
.bok-forms{display:flex;gap:8px;flex-wrap:wrap;direction:rtl}
.bok-forms>div{background:var(--surface);border:1px solid var(--border);border-radius:10px;padding:8px 16px;text-align:center;min-width:64px}
.bok-forms b{display:block;font:500 40px/1.45 var(--font-ar-read);color:var(--read-fg)}
.bok-forms small{color:var(--muted);font-size:12px}
.bok-lpic{list-style:none;margin:0;padding:0;display:grid;grid-template-columns:repeat(auto-fit,minmax(215px,1fr));gap:10px;width:100%}
.bok-lpic li{display:flex;align-items:center;gap:10px;border:1px solid var(--border);border-radius:12px;padding:8px 12px;background:transparent;min-height:64px}
.bok-lpic li.is-draft{border-style:dashed}
.bok-lart{display:inline-grid;place-items:center;width:44px;height:44px;flex:none}
.bok-lart svg{width:100%;height:100%;display:block}
.bok-lpic li>b{font:500 21px/1.55 var(--font-ar-read);flex:none;color:var(--read-fg)}
.bok-lwm{flex:1;min-width:0;display:flex;flex-direction:column;line-height:1.45}
.bok-lwm span[lang]{color:var(--muted);font-size:14px;unicode-bidi:isolate}
.bok-utk{align-self:flex-start;font-style:normal;font-size:11.5px;font-weight:700;color:var(--amber-ink);background:var(--accent-soft);border:1px solid var(--amber);border-radius:999px;padding:1px 8px}
.bok-lpic .speak{width:44px;height:44px;min-width:44px;min-height:44px;flex:none;border:0;background:transparent;border-radius:10px;color:var(--muted)}

/* ---------- elevens helskärmslager ---------- */
.bok-ol{position:fixed;inset:0;z-index:55;background:var(--bg);overflow-y:auto;padding:18px 24px 30px}
.bok-ol[hidden]{display:none}
.bok-ol-in{width:min(1040px,100%);margin:0 auto}
.bok-ol .bok{width:100%;margin:0;min-height:calc(100dvh - 48px)}
/* Skärmlåset är rent CSS: när överlagret försvinner ur DOM (omrendering,
   flikbyte) släpper det automatiskt – ingen body-klass att hålla i sync. */
body:has(.bok-ol:not([hidden])){overflow:hidden}
.bok-openbtn{gap:8px}

@media (max-width:760px){
  .bok .bok-tools .btn>span{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0 0 0 0);clip-path:inset(50%);white-space:nowrap;border:0}
  .bok .bok-tools .btn{min-width:44px;padding:0 10px;position:relative}
  .bok-dots{display:none}
}

/* ---------- liten skärm ---------- */
@media (max-width:640px){
  .bok{margin-bottom:20px;min-height:clamp(440px,calc(100dvh - 190px),700px)}
  .bok-levels{border-radius:var(--rad-md)}
  .bok-top{min-height:60px;padding:0 10px;gap:6px}
  .bok-tt b{font-size:18px}
  .bok-tt small{font-size:11px}
  .bok-stage{padding:24px 18px 18px}
  .bok .bok-lines{font-size:clamp(22px,6.2vw,24px);line-height:2.02}
  .bok-pic{width:100px;height:100px}
  .bok-nav{min-height:62px;padding:0 10px;gap:4px}
  .bok-navbtn{padding:0 8px}
  .bok-big{width:110px;height:110px;font-size:66px;padding-bottom:18px}
  .bok-ltop{gap:14px}
  .bok-shelf{grid-template-columns:1fr}
  .bok-pagehead .pagehead-actions{margin-inline-start:0}
  .bok-pagehead .pagehead-actions .rs-btn{width:100%}
  .bok-ol{padding:10px 12px 24px}
  .bok-ol .bok{min-height:calc(100dvh - 34px)}
}
@media (min-width:641px) and (max-width:1023px){
  .bok .bok-lines{font-size:clamp(24px,3vw,30px);line-height:2.05}
  .bok-shelf{grid-template-columns:repeat(2,minmax(0,1fr))}
  .bok-stage{padding-inline:28px}
}

/* ---------- utskrift av själva sidan (dokumentet är huvudvägen) ---------- */
#bok-print{display:none}
@media print{
  @page bok-chapter{size:A4;margin:13mm 12mm}
  .bok-nav,.bok-tools,.bok-quit,.bok-qnxt,.bok-ol,.bok-stage>.reading-translation,.bok-stage>.bok-svbox,.bok-stage>audio,.bok-stage>.bok-glossnote{display:none!important}
  .bok{border:0;box-shadow:none}
  .bok-pg{display:block!important;break-inside:avoid}
  /* Saknas dokumentvägen skrivs kapitlet ur det tillfälliga lagret #bok-print;
     klassen bok-printing håller resten av appen borta bara i utskrift. */
  body.bok-printing>*:not(#bok-print){display:none!important}
  .bok-big{background:var(--soft);color:var(--ink)}
  #bok-print{display:block;page:bok-chapter}
  #bok-print .bok-pp{break-inside:avoid}
}
