/* ============================================================
   Klok-engine — gedeelde stijl (huisstijl voorkant, juli '26)
   Werkt voor alle oefeningen; varianten via opgaven.js
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg:      #eef0ef;
    --kaart:   #ffffff;
    --border:  #e0e1de;
    --grafiet: #1d1d1b;
    --tekst:   #333333;
    --muted:   #8a857c;
    --goed:    #5f8a3f;
    --bijna:   #e0b341;
    --fout:    #b86a35;
    --accent:  #4a6fa5;
}

html, body {
    height: 100%;
}

body {
    font-family: 'Source Sans 3', Arial, sans-serif;
    background: var(--bg);
    color: var(--tekst);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ── Slanke topbalk met kruimelpad ── */
.mw-top {
    background: var(--grafiet);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 22px;
    flex: 0 0 auto;
}
.mw-brand {
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    font-size: 15px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #fff;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 9px;
    white-space: nowrap;
}
.mw-brand svg { height: 20px; }
.mw-divider { width: 1px; height: 18px; background: rgba(255,255,255,0.2); }
.mw-crumbs {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 13px;
    color: #9a958c;
    min-width: 0;
}
.mw-crumbs a { color: #9a958c; text-decoration: none; transition: color .12s; }
.mw-crumbs a:hover { color: #d8d4cc; }
.mw-crumbs .sep { opacity: 0.55; }
.mw-crumbs .current { color: #e8e4dc; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 600px) {
    .mw-top { padding: 9px 16px; gap: 10px; }
    .mw-brand { font-size: 14px; letter-spacing: 0.08em; }
    .mw-crumbs > a:first-child,
    .mw-crumbs > a:first-child + .sep { display: none; }
}

/* ── Werkgebied ── */
.werk {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px 16px 24px;
}

.kaart {
    position: relative;
    background: var(--kaart);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 4px 18px rgba(40,35,25,0.05);
    padding: clamp(16px, 3.2vh, 28px);
    width: 100%;
    max-width: 560px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(10px, 2vh, 18px);
}

/* Opgave */
.opgave {
    font-size: clamp(26px, 5.4vw, 34px);
    font-weight: 600;
    color: var(--grafiet);
    text-align: center;
    line-height: 1.1;
    min-height: 1.1em;
}
/* Digitale tijd: echt zeven-segment-schermpje (DSEG7), met zwakke
   'uit'-segmenten erachter voor een subtiele LCD-vibe */
.opgave.digitaal {
    font-family: 'DSEG7 Classic', 'Courier New', monospace;
    font-weight: 400;
    font-size: clamp(26px, 5.2vw, 32px);
    letter-spacing: 0.02em;
    color: var(--grafiet);
    position: relative;
}
.opgave.digitaal::before {
    content: "88:88";
    position: absolute;
    inset: 0;
    text-align: center;
    opacity: 0.08;
    pointer-events: none;
}

/* Langere verhaaltekst (klokverhalen): kleiner, leesbaar, meerdere regels */
.opgave.verhaal {
    font-size: clamp(16px, 3.3vw, 19px);
    font-weight: 400;
    line-height: 1.5;
    max-width: 32ch;
    min-height: 0;
}

/* ── Klokmodellen: kleurpalet + font per model ── */
:root {
    --klok-plaat:  #ffffff;
    --klok-rand:   #1d1d1b;
    --klok-streep: #1d1d1b;
    --klok-cijfer: #1d1d1b;
    --klok-wijzer: #1d1d1b;
    --klok-grip:   #1d1d1b;
    --klok-spil:   #1d1d1b;
    --klok-font:   'Source Sans 3', Arial, sans-serif;
    --klok-cijfer-gewicht: 500;
}
body.thema-zonnig {
    --klok-plaat:  #fff8ec;  --klok-rand:   #d98324;  --klok-streep: #b5701c;
    --klok-cijfer: #9c5b12;  --klok-wijzer: #c8641a;  --klok-grip:   #b5701c;
    --klok-spil:   #9c5b12;  --klok-font: 'Baloo 2', system-ui, sans-serif; --klok-cijfer-gewicht: 600;
}
body.thema-oceaan {
    --klok-plaat:  #eef6fb;  --klok-rand:   #2c7a9e;  --klok-streep: #3a86a8;
    --klok-cijfer: #1f5d78;  --klok-wijzer: #2c7a9e;  --klok-grip:   #2c7a9e;
    --klok-spil:   #1f5d78;  --klok-font: 'Nunito', system-ui, sans-serif; --klok-cijfer-gewicht: 700;
}
body.thema-framboos {
    --klok-plaat:  #fdeef4;  --klok-rand:   #c14b7f;  --klok-streep: #cd6592;
    --klok-cijfer: #9c3a63;  --klok-wijzer: #c14b7f;  --klok-grip:   #c14b7f;
    --klok-spil:   #9c3a63;  --klok-font: 'Fredoka', system-ui, sans-serif; --klok-cijfer-gewicht: 500;
}
body.thema-nacht {
    --klok-plaat:  #26314f;  --klok-rand:   #8ea6d6;  --klok-streep: #6f88bb;
    --klok-cijfer: #dbe4f7;  --klok-wijzer: #f0d98a;  --klok-grip:   #f0d98a;
    --klok-spil:   #f0d98a;  --klok-font: 'Space Mono', monospace; --klok-cijfer-gewicht: 400;
}
body.thema-antiek {
    --klok-plaat:  #f8f2e4;  --klok-rand:   #6b5138;  --klok-streep: #7c6146;
    --klok-cijfer: #5a4531;  --klok-wijzer: #6b5138;  --klok-grip:   #6b5138;
    --klok-spil:   #5a4531;  --klok-font: 'Playfair Display', Georgia, serif; --klok-cijfer-gewicht: 700;
}
body.thema-salie {
    --klok-plaat:  #eef2e8;  --klok-rand:   #4a6b4a;  --klok-streep: #567a56;
    --klok-cijfer: #3a5a3a;  --klok-wijzer: #4a6b4a;  --klok-grip:   #4a6b4a;
    --klok-spil:   #3a5a3a;  --klok-font: 'Playfair Display', Georgia, serif; --klok-cijfer-gewicht: 700;
}

/* ── Klokkiezer: klein knopje in de hoek dat een palet opent ── */
.thema-kiezer {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 5;
}
.thema-toggle {
    width: 24px; height: 24px;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px var(--border);
    background: var(--sw, #1d1d1b);
    cursor: pointer;
    padding: 0;
    transition: transform .12s;
}
.thema-toggle:hover { transform: scale(1.1); }
.thema-popover {
    position: absolute;
    top: 32px; right: 0;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 6px 20px rgba(40, 35, 25, 0.12);
    padding: 9px;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}
.thema-popover[hidden] { display: none; }
.thema-knop {
    width: 22px; height: 22px;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px var(--border);
    background: var(--sw);
    cursor: pointer;
    padding: 0;
    transition: transform .12s, box-shadow .12s;
}
.thema-knop:hover { transform: scale(1.14); }
.thema-knop.actief { box-shadow: 0 0 0 2px var(--grafiet); }

/* ── De klok ── */
#klok {
    display: block;
    width: min(78vw, 52vh);
    height: auto;
    aspect-ratio: 1 / 1;
    max-width: 420px;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;   /* geen scroll tijdens slepen */
}

.wijzerplaat { fill: var(--klok-plaat); stroke: var(--klok-rand); stroke-width: 4px; }
.uur-streep    { stroke: var(--klok-streep); stroke-width: 3px; }
.minuut-streep { stroke: var(--klok-streep); stroke-width: 1.5px; }
.minuut-streep.verborgen { display: none; }

.cijfer {
    font-family: var(--klok-font);
    font-size: 19px;
    font-weight: var(--klok-cijfer-gewicht, 500);
    fill: var(--klok-cijfer);
    user-select: none;
}

.hand-groep {
    transform-origin: 150px 150px;
    /* Geen CSS-transitie: de wijzer volgt de vinger frame-voor-frame.
       Een transitie zou de genormaliseerde hoek (bv. 1° -> 359° bij het
       voorbij-de-12 slepen) de lange kant om animeren = lelijke sweep. */
}
.wijzer { stroke: var(--klok-wijzer); stroke-linecap: round; pointer-events: none; }
.wijzer.uur    { stroke-width: 7px; }
.wijzer.minuut { stroke-width: 5.5px; }

.grip      { fill: var(--klok-grip); cursor: grab; }
.grip-ring { fill: var(--klok-plaat); pointer-events: none; }
.hand-groep.sleepbaar .grip:active { cursor: grabbing; }
.hand-groep:not(.sleepbaar) .grip,
.hand-groep:not(.sleepbaar) .grip-ring { display: none; }

.spil { fill: var(--klok-spil); }

#bewegingsvlak { fill: #7ba9d1; fill-opacity: 0.30; pointer-events: none; }   /* later = blauw */
#bewegingsvlak.vroeger { fill: #d47a76; }                                     /* vroeger = rood */

/* ── Knop (pill, huisstijl maatwerk) ── */
.controleer {
    appearance: none;
    border: none;
    background: var(--accent);
    color: #fff;
    font-family: 'Source Sans 3', Arial, sans-serif;
    font-size: 14px;
    font-weight: 600;
    padding: 8px 22px;
    border-radius: 999px;
    cursor: pointer;
    transition: background-color .18s;
}
.controleer:hover { background: #3d5d8a; }
.controleer.goed { background: var(--goed); color: #fff; }
.controleer.fout { background: var(--fout); color: #fff; }

/* ── Score ── */
.score {
    display: flex;
    gap: clamp(6px, 1.6vw, 10px);
    flex-wrap: wrap;
    justify-content: center;
}
.stip {
    width: 15px; height: 15px;
    border: 2px solid #d8d2c4;
    border-radius: 50%;
    box-sizing: border-box;
}
.stip.goed  { background: var(--goed);  border-color: var(--goed); }
.stip.bijna { background: var(--bijna); border-color: var(--bijna); }
.stip.fout  { background: var(--fout);  border-color: var(--fout); }

/* ── Uitslag-popup ── */
.overlay {
    position: fixed; inset: 0;
    background: rgba(29,29,27,0.42);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 20;
}
.overlay.zichtbaar { display: flex; }
.popup {
    background: #fff;
    border-radius: 14px;
    padding: 28px 30px;
    text-align: center;
    max-width: 340px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}
.popup h2 {
    font-family: 'Playfair Display', serif;
    font-size: 24px; font-weight: 700; color: var(--grafiet);
    margin-bottom: 8px;
}
.popup p { color: var(--muted); font-size: 15px; margin-bottom: 18px; }
.popup .cijfer-groot { font-size: 40px; font-weight: 700; color: var(--goed); display: block; margin-bottom: 4px; }
.popup button {
    appearance: none; border: none;
    background: var(--accent); color: #fff;
    font-family: 'Source Sans 3', Arial, sans-serif;
    font-size: 15px; font-weight: 600;
    padding: 11px 24px; border-radius: 10px; cursor: pointer;
    transition: background-color .2s;
}
.popup button:hover { background: #3d5d8a; }

/* korte, brede schermen: klok wat kleiner zodat alles past */
@media (max-height: 620px) {
    #klok { width: min(60vw, 46vh); }
    .opgave { font-size: clamp(22px, 4.4vw, 28px); }
}
