/* Cold case: leerlingenpagina (iPad Safari, staand en liggend). Huisstijl: creme, amber, slate; Alegreya + Inter.
   Dossier-thema: mappen, schrijfmachinelabels (American Typewriter), stempels. */
:root {
  --creme: #fffdf7; --creme-d: #f4ead8; --amber: #f59e0b; --amber-l: #fef3c7; --amber-d: #92400e;
  --slate: #0f172a; --slate-2: #334155;
  --rood: #b91c1c; --rood-l: #fee2e2; --groen: #15803d; --groen-l: #dcfce7; --blauw: #1d4ed8; --blauw-l: #dbeafe;
  --map: #ecdcb0; --map-d: #cdb06a; --map-rand: #a98a45; --papier: #fbf3e0; --sepia: #6b4a21;
  --kop: 'Alegreya', Georgia, 'Times New Roman', serif;
  --tekst: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --typ: 'American Typewriter', 'Courier New', Courier, monospace;
  --nav: 84px;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; background: var(--creme); color: var(--slate); font-family: var(--tekst);
  font-size: 1.25rem; line-height: 1.5; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
body.lade-open { overflow: hidden; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 4px solid var(--blauw); outline-offset: 3px; }
h1, h2, h3 { font-family: var(--kop); font-weight: 800; line-height: 1.1; margin: 0; color: var(--slate); }
h1 { font-size: 2.4rem; margin: 0.2rem 0 0.8rem; outline: none; }
h1:focus, h1:focus-visible { outline: none; }
h2 { font-size: 1.7rem; margin: 1.4rem 0 0.5rem; }
h3 { font-size: 1.4rem; margin: 0.8rem 0 0.3rem; }
p { margin: 0 0 0.9rem; }
.klein { font-size: 1.15rem; }
.grijs { color: var(--slate-2); }
.vet { font-weight: 700; }
.typ { font-family: var(--typ); }

/* ---------- bovenbalk ---------- */
.top { position: sticky; top: 0; z-index: 10; background: var(--slate); color: var(--creme-d); padding-top: env(safe-area-inset-top); }
.top-rij {
  display: flex; align-items: center; gap: 12px; min-height: 60px; flex-wrap: wrap;
  padding: 4px max(16px, env(safe-area-inset-right)) 4px max(16px, env(safe-area-inset-left)); max-width: 980px; margin: 0 auto;
}
.top-icoon { width: 34px; height: 34px; color: var(--amber); flex: none; }
.top-titel { font-family: var(--kop); font-weight: 800; font-size: 1.5rem; }
.top-zaak { font-family: var(--typ); font-size: 1.15rem; letter-spacing: 0.04em; color: var(--amber); flex: 1; min-width: 0; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-ruimte { flex: 0 0 0; }
.top-stap { font-weight: 700; font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.niveau-wissel { display: inline-flex; border: 2px solid rgba(244, 234, 216, 0.4); border-radius: 12px; overflow: hidden; }
.niveau-wissel button { min-height: 48px; padding: 0 14px; background: transparent; border: 0; font-weight: 700; font-size: 1.15rem; color: var(--creme-d); }
.niveau-wissel button[aria-pressed="true"] { background: var(--amber); color: var(--slate); }
.top-opnieuw { min-width: 48px; min-height: 48px; padding: 0 12px; border-radius: 12px; font-weight: 700; font-size: 1.15rem; background: transparent; border: 2px solid rgba(244, 234, 216, 0.4); color: var(--creme-d); }
.top-opnieuw span { display: none; }
@media (min-width: 700px) { .top-opnieuw span { display: inline; } }
@media (max-width: 899px) { .top-zaak { display: none; } .top-ruimte { flex: 1; } }
.voortgang { height: 8px; background: rgba(244, 234, 216, 0.18); }
.voortgang i { display: block; height: 100%; width: 0; background: var(--amber); transition: width 0.25s ease; }

/* ---------- inhoud ---------- */
main { max-width: 980px; margin: 0 auto; outline: none;
  padding: 20px max(18px, env(safe-area-inset-right)) calc(var(--nav) + 36px + env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left)); }
.scherm { animation: opkomen 0.25s ease; }
@keyframes opkomen { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.kicker { margin: 0 0 4px; font-family: var(--typ); font-size: 1.15rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--amber-d); }

.kaart { background: #fff; border: 3px solid var(--creme-d); border-radius: 16px; padding: 14px 20px; margin: 0 0 1rem; }
.kaart--amber { background: var(--amber-l); border-color: var(--amber); }
.kaart p:last-child, .kaart ul:last-child { margin-bottom: 0; }

/* stempel */
.stempel {
  display: inline-block; font-family: var(--typ); font-weight: 700; font-size: 1.3rem; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--rood); border: 4px solid var(--rood); border-radius: 6px; padding: 2px 14px 2px 18px; transform: rotate(-5deg);
  opacity: 0.88; background: rgba(254, 226, 226, 0.35); white-space: nowrap;
}
.stempel--groen { color: var(--groen); border-color: var(--groen); background: rgba(220, 252, 231, 0.5); }
.stempel--groot { font-size: 1.9rem; padding: 6px 22px 6px 28px; border-width: 5px; }
.titelrij { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.titelrij h1 { margin-bottom: 0.4rem; font-size: 3rem; }

/* verhaal (vertelstem) */
.verhaal {
  position: relative; margin: 0.6rem 0 1.2rem; padding: 18px 20px 6px 64px; border-radius: 0 16px 16px 0;
  background: linear-gradient(90deg, var(--creme-d), #f9f1e1); border-left: 8px solid var(--amber-d);
  font-family: var(--kop); font-style: italic; font-weight: 500; font-size: 1.45rem; line-height: 1.45;
}
.verhaal::before { content: '\201C'; position: absolute; left: 16px; top: -2px; font-size: 4rem; line-height: 1; color: var(--amber-d); opacity: 0.55; font-style: normal; }
.verhaal p { margin: 0 0 0.9rem; }

/* intro-stappen */
ol.nummers { list-style: none; counter-reset: n; margin: 0 0 1.2rem; padding: 0; display: flex; flex-direction: column; gap: 10px; }
ol.nummers li { counter-increment: n; position: relative; padding-left: 52px; min-height: 40px; }
ol.nummers li::before { content: counter(n); position: absolute; left: 0; top: 0.1em; width: 38px; height: 38px; border-radius: 50%; background: var(--slate); color: var(--creme); font-weight: 800; font-size: 1.15rem; display: flex; align-items: center; justify-content: center; }

/* ---------- dossiermappen ---------- */
.mappen { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; margin: 1.4rem 0 1rem; }
@media (max-width: 700px) { .mappen { grid-template-columns: 1fr; } }
.map {
  position: relative; text-align: left; border: 0; padding: 0; background: none; margin-top: 30px; min-height: 230px; display: block;
  transition: transform 0.18s ease;
}
.map-tab {
  position: absolute; top: -30px; left: 22px; height: 34px; min-width: 180px; padding: 4px 18px 0; border-radius: 12px 12px 0 0;
  background: var(--map-d); border: 3px solid var(--map-rand); border-bottom: 0; font-family: var(--typ); font-weight: 700; font-size: 1.15rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--sepia);
}
.map-lijf {
  display: flex; flex-direction: column; gap: 6px; min-height: 230px; padding: 20px 22px 18px;
  background: linear-gradient(180deg, var(--map), #e6d19b); border: 3px solid var(--map-rand); border-radius: 4px 16px 16px 16px;
  box-shadow: 0 3px 0 rgba(107, 74, 33, 0.25), 0 10px 18px rgba(15, 23, 42, 0.12);
}
.map-naam { font-family: var(--kop); font-weight: 800; font-size: 2.1rem; line-height: 1.05; color: var(--slate); }
.map-sub { font-family: var(--typ); font-size: 1.15rem; color: var(--sepia); letter-spacing: 0.04em; }
.map-korte { flex: 1; font-size: 1.2rem; color: var(--slate-2); }
.map-knop { align-self: flex-start; display: inline-flex; align-items: center; min-height: 48px; padding: 0 20px; border-radius: 12px; background: var(--slate); color: var(--creme); font-weight: 700; font-size: 1.2rem; }
.map-stempel { position: absolute; right: 18px; top: 16px; font-size: 1rem; padding: 0 8px 0 12px; border-width: 3px; transform: rotate(7deg); }
.map:active { transform: translateY(2px); }
@media (hover: hover) { .map:hover { transform: translateY(-4px); } .map:active { transform: translateY(1px); } }
.map:focus-visible { outline-offset: 6px; }
.map--havo { margin-top: 30px; grid-column: 1 / -1; min-height: 0; }
.map--havo .map-lijf { min-height: 0; flex-direction: row; align-items: center; gap: 18px; flex-wrap: wrap; background: linear-gradient(180deg, #f5e7bd, #eddba5); }
.map--havo .map-naam { font-size: 1.6rem; }
.map--havo .map-korte { flex: 1; min-width: 220px; }

/* niveaukeuze */
.niveaus { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 1rem 0; }
@media (max-width: 640px) { .niveaus { grid-template-columns: 1fr; } }
.niveau { text-align: left; min-height: 160px; padding: 18px 22px; border-radius: 18px; background: #fff; border: 4px solid var(--creme-d); display: flex; flex-direction: column; gap: 8px; }
.niveau-naam { font-family: var(--kop); font-weight: 800; font-size: 2.1rem; color: var(--slate); }
.niveau-zin { font-size: 1.25rem; color: var(--slate-2); }
.niveau[aria-pressed="true"] { background: var(--amber-l); border-color: var(--amber); box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.25); }
.niveau[aria-pressed="true"] .niveau-naam::after { content: ' \2713'; color: var(--groen); }

/* knoppen */
.knop {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 56px; padding: 0 26px; border-radius: 14px;
  background: var(--slate); color: var(--creme); border: 3px solid var(--slate); font-weight: 700; font-size: 1.25rem;
}
.knop--licht { background: #fff; color: var(--slate); border-color: var(--slate); }
.knop--amber { background: var(--amber); color: var(--slate); border-color: var(--amber-d); }
.knop:disabled { opacity: 0.4; cursor: default; }
.knop-rij { display: flex; flex-wrap: wrap; gap: 12px; margin: 1rem 0; }

/* papier-opdracht */
.papier { display: flex; gap: 14px; align-items: center; background: var(--amber-l); border: 3px dashed var(--amber-d); border-radius: 16px; padding: 12px 18px; margin: 0 0 1rem; }
.papier svg { width: 46px; height: 46px; flex: none; color: var(--amber-d); }
.papier p { margin: 0; }

/* ---------- bronnen ---------- */
.bronnen-rooster { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 18px; margin: 1rem 0; }
.bron-kaart {
  position: relative; display: flex; flex-direction: column; gap: 8px; text-align: left; padding: 14px 16px 12px; min-height: 140px;
  background: var(--papier); border: 2px dashed var(--map-rand); border-radius: 6px; box-shadow: 2px 3px 0 rgba(107, 74, 33, 0.22);
  font-family: var(--typ);
}
.bron-kaart:nth-child(odd) { transform: rotate(-0.5deg); }
.bron-kaart:nth-child(even) { transform: rotate(0.4deg); }
.bron-kaart:active { transform: translateY(2px); }
@media (hover: hover) { .bron-kaart:hover { background: #fff7e3; } }
.bron-label { font-family: var(--typ); font-weight: 700; font-size: 1.15rem; letter-spacing: 0.26em; text-transform: uppercase; color: var(--amber-d); }
.bron-titel { font-weight: 700; font-size: 1.2rem; line-height: 1.3; }
.bron-kaart img { width: 100%; height: 190px; object-fit: cover; border: 2px solid var(--map-rand); background: var(--creme-d); filter: sepia(0.35) contrast(1.02); display: block; }
.bron-uittreksel { font-size: 1.15rem; line-height: 1.4; color: var(--slate-2); display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; border-left: 5px solid var(--amber-d); padding-left: 10px; }
.vergroot { font-size: 1.15rem; font-weight: 700; color: var(--blauw); margin-top: auto; }
.vergroot::before { content: '\1F50D\FE0E '; }
.voetnoot { font-size: 1.15rem; color: var(--slate-2); font-family: var(--typ); margin-top: 1.2rem; border-top: 2px dashed var(--map-rand); padding-top: 10px; }

/* ---------- lade (bron vergroten) ---------- */
.lade { position: fixed; inset: 0; z-index: 50; background: rgba(15, 23, 42, 0.72); overflow-y: auto; -webkit-overflow-scrolling: touch; padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom)); }
.lade-kaart { max-width: 920px; margin: 0 auto; background: var(--papier); border: 4px solid var(--map-rand); border-radius: 12px; padding: 16px 20px 20px; animation: opkomen 0.2s ease; }
.lade-kop { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.lade-kaart h2 { margin: 0.2rem 0 0.8rem; font-size: 1.8rem; }
.lade-kaart figure { margin: 0 0 1rem; }
.lade-kaart img { display: block; width: 100%; max-height: 62vh; object-fit: contain; background: #1c1917; border: 3px solid var(--map-rand); }
.bron-tekst { font-family: var(--typ); font-size: 1.3rem; line-height: 1.5; }
.bron-tekst p { margin: 0 0 0.8rem; }
.bron-tekst blockquote { margin: 0 0 1rem; padding: 6px 0 6px 16px; border-left: 8px solid var(--amber-d); background: #fff7e3; }
.bron-tekst blockquote p { margin: 0 0 0.6rem; }
.bron-tekst blockquote p:last-child { margin: 0; }
.bron-verm { font-family: var(--typ); font-style: italic; font-size: 1.15rem; line-height: 1.45; color: #4a3b2d; border-top: 2px dashed var(--map-rand); padding-top: 10px; margin: 0 0 1rem; }
.lade-nav { display: flex; gap: 10px; flex-wrap: wrap; justify-content: space-between; }
.lade-nav .knop { flex: 1; min-width: 150px; padding: 0 12px; min-height: 56px; }
.lade-sluit { min-height: 52px; padding: 0 18px; border-radius: 12px; background: var(--slate); color: var(--creme); border: 0; font-weight: 700; font-size: 1.2rem; }
.lade-lijst h2 { margin-top: 0.4rem; }

/* ---------- stappen ---------- */
.vraag { background: #fff; border: 3px solid var(--creme-d); border-radius: 16px; padding: 14px 18px; margin: 0 0 14px; }
.vraag-kop { display: flex; gap: 14px; align-items: flex-start; }
.vraag-letter { flex: none; width: 44px; height: 44px; border-radius: 10px; background: var(--slate); color: var(--creme); font-family: var(--typ); font-weight: 700; font-size: 1.4rem; display: flex; align-items: center; justify-content: center; }
.vraag-tekst { flex: 1; min-width: 0; font-weight: 600; }
.kies { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 0; align-items: center; }
.kies-label { font-family: var(--typ); font-weight: 700; color: var(--amber-d); }
.chip { display: inline-block; padding: 4px 14px; border-radius: 99px; background: var(--creme-d); border: 2px solid var(--map-rand); font-size: 1.15rem; font-style: italic; }
.chip--abcd { font-style: normal; font-weight: 700; font-family: var(--typ); }
.onthoud { display: inline-block; margin-top: 8px; padding: 2px 12px; background: var(--amber); color: var(--slate); font-weight: 800; border-radius: 8px; }
.onthoud-kaart { background: var(--amber-l); border-left: 8px solid var(--amber); border-radius: 0 12px 12px 0; padding: 10px 16px; font-weight: 700; margin: 0 0 1rem; }

/* tijdlijn */
.tijdlijn { display: flex; align-items: center; gap: 6px; margin: 1rem 0 1.2rem; flex-wrap: wrap; font-family: var(--typ); font-weight: 700; }
.tijdlijn-vak { width: 62px; height: 62px; border: 3px solid var(--slate); border-radius: 10px; background: #fff; }
.tijdlijn-pijl { font-size: 1.5rem; color: var(--amber-d); }
.tijdlijn-eind { color: var(--amber-d); text-transform: uppercase; letter-spacing: 0.1em; font-size: 1.15rem; }

/* tips */
.tipregel { margin: 10px 0 0; }
body[data-tips="uit"] .tipregel { display: none; }
.tipknop { min-height: 48px; padding: 0 18px; border-radius: 12px; background: var(--blauw-l); border: 2px solid var(--blauw); color: var(--blauw); font-weight: 700; font-size: 1.15rem; }
.tipknop[aria-expanded="true"] { background: var(--blauw); color: #fff; }
.tipvak { margin-top: 8px; padding: 12px 16px; background: var(--blauw-l); border-left: 8px solid var(--blauw); border-radius: 0 12px 12px 0; }
.tipvak p { margin: 0 0 0.5rem; }
.tipvak p:last-child { margin: 0; }
.tipvak b { font-family: var(--typ); }

/* ---------- codeslot ---------- */
.slot-kaart { background: linear-gradient(180deg, #2a2f3d, var(--slate)); color: var(--creme); border-radius: 20px; padding: 20px 22px 22px; margin: 0 0 1.2rem; border: 4px solid #475569; max-width: 560px; margin-left: auto; margin-right: auto; text-align: center; }
.hangslot { width: 96px; height: 96px; color: var(--amber); }
.hangslot .beugel { transform-origin: 42px 28px; transition: transform 0.7s cubic-bezier(0.3, 1.4, 0.5, 1); }
.hangslot.open .beugel { transform: translate(0, -7px) rotate(-32deg); }
.code-uitleg { font-family: var(--typ); font-size: 1.2rem; color: var(--creme-d); margin: 0 0 12px; }
.code-uitleg b { color: var(--amber); }
.code-invoer {
  width: 100%; height: 76px; border-radius: 12px; border: 4px solid var(--amber); background: #111827; color: var(--amber);
  font-family: var(--typ); font-weight: 700; font-size: 2.6rem; letter-spacing: 0.5em; text-align: center; padding: 0 0 0 0.5em; caret-color: var(--amber);
}
.code-invoer::placeholder { color: rgba(245, 158, 11, 0.35); letter-spacing: 0.4em; }
.toetsen { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 14px 0; }
.toets { min-height: 66px; border-radius: 12px; border: 3px solid #64748b; background: #1e293b; color: var(--creme); font-family: var(--typ); font-weight: 700; font-size: 1.9rem; }
.toets:active { background: var(--amber); color: var(--slate); }
.toets--letter { border-color: var(--amber-d); color: var(--amber); }
.toets--wis { font-size: 1.15rem; font-family: var(--tekst); }
.toets--vol { background: var(--amber); color: var(--slate); border-color: var(--amber-d); min-height: 64px; width: 100%; font-size: 1.35rem; font-family: var(--tekst); }
.code-melding { margin: 0 auto 1rem; max-width: 560px; }
.melding { border-radius: 14px; padding: 12px 18px; margin: 0 0 10px; font-weight: 600; border-left: 8px solid; }
.melding--fout { background: var(--rood-l); border-color: var(--rood); color: #7f1d1d; }
.melding--info { background: var(--amber-l); border-color: var(--amber); }
.schud { animation: schud 0.4s ease; }
@keyframes schud { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-8px); } 40% { transform: translateX(8px); } 60% { transform: translateX(-5px); } 80% { transform: translateX(5px); } }

/* ---------- opgelost ---------- */
.opgelost-kop { display: flex; align-items: center; justify-content: center; gap: 24px; flex-wrap: wrap; margin: 0.4rem 0 1rem; }
.opgelost-kop .hangslot { color: var(--groen); width: 110px; height: 110px; }
.opgelost .stempel { animation: stempel 0.55s cubic-bezier(0.2, 1.2, 0.3, 1) both; animation-delay: 0.5s; }
@keyframes stempel { 0% { opacity: 0; transform: scale(2.6) rotate(-14deg); } 60% { opacity: 1; transform: scale(0.94) rotate(-4deg); } 100% { opacity: 0.92; transform: scale(1) rotate(-5deg); } }
.opgelost .verhaal, .opgelost .kaart, .opgelost .knop-rij { animation: opkomen 0.5s ease both; animation-delay: 0.9s; }
.wat-nu ol { margin: 0.4rem 0 0.6rem; padding-left: 1.4rem; }
.wat-nu li { margin-bottom: 6px; }

@media (prefers-reduced-motion: reduce) {
  .scherm, .lade-kaart, .opgelost .verhaal, .opgelost .kaart, .opgelost .knop-rij { animation: none; }
  .opgelost .stempel { animation: none; opacity: 0.92; }
  .voortgang i, .map, .hangslot .beugel { transition: none; }
  .schud { animation: none; }
}

/* ---------- onderbalk ---------- */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--creme); border-top: 4px solid var(--amber);
  padding: 10px max(16px, env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
.nav-rij { max-width: 980px; margin: 0 auto; display: flex; gap: 12px; align-items: center; }
.nav .knop { min-height: 60px; }
.nav-ruimte { flex: 1; }
@media (max-width: 560px) { .nav .knop { padding: 0 14px; font-size: 1.15rem; } }
