/* The simulation's shared look — used by the student site (sim.tigc.nl) and by Kelly's pages.
   Taken from Kelly's house slide design (app/slides/template.py): warm paper ground, navy, Calibri;
   a short navy rule above every title; chapter pages navy with a big light-blue number; discussion
   slides orange with a faint question mark; quotes in a soft blue highlight; closing page navy.
   One orchestrated moment: each new step opens as a chapter page. Everything else moves only when
   someone acts. */

:root {
  --s-ink: #1D2330;
  --s-muted: #5B6270;
  --s-rule: #DAD5CB;
  --s-navy: #233A8B;
  --s-navy-2: #1B2E6F;
  --s-navy-3: #142253;
  --s-paper: #F7F5F0;
  --s-paper-2: #EFEBE3;
  --s-white: #FFFFFF;
  --s-light: #A9C6F0;
  --s-orange: #E9A650;
  --s-orange-soft: #FBEBD3;
  --s-hl: #DDE3F1;
  --s-teal: #0E7C86;
  --s-teal-soft: #D5ECEC;
  --s-red: #B83A2E;
  --s-red-soft: #F6E0DC;
  /* older names used below */
  --s-blue: var(--s-navy); --s-blue-2: var(--s-light); --s-mist: var(--s-paper-2); --s-mist-2: var(--s-rule);
  --s-ink-2: #3A4252; --s-green: var(--s-teal); --s-green-ink: #0A5F67; --s-green-soft: var(--s-teal-soft);
  --s-orange-ink: #8A5512;
  --s-font: Calibri, Carlito, "Segoe UI", -apple-system, BlinkMacSystemFont, Helvetica, Arial, sans-serif;
  --s-serif: var(--s-font);
  --s-sans: var(--s-font);
  --s-ease: cubic-bezier(.2, .7, .1, 1);
  --s-ease-in: cubic-bezier(.6, 0, .8, .3);
}

/* ── the title rule (the short navy bar above every slide title) ─────────── */
.trule { display: block; width: 40px; height: 3px; background: var(--s-navy); margin: 0 0 12px; transform-origin: left; }
.is-new .trule { animation: trule 700ms var(--s-ease) both; }
@keyframes trule { from { transform: scaleX(0); } }

/* ── the decision map (an SVG drawn by simmap.js) ─────────────────────────── */
.smap { display: block; width: 100%; height: auto; overflow: visible; font-family: var(--s-sans); }
.smap .happy-band { fill: var(--s-green-soft); }
.smap .edge { fill: none; stroke: #C9D5E2; stroke-width: 1.2; }
.smap .edge.is-happy { stroke: var(--s-green); stroke-width: 2.2; stroke-opacity: .55; }
.smap .route { fill: none; stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
.smap .route.is-draw { stroke-dasharray: var(--len) var(--len); animation: route-draw 1.1s var(--s-ease) both; }
@keyframes route-draw { from { stroke-dashoffset: var(--len); } to { stroke-dashoffset: 0; } }
.smap .node { fill: #fff; stroke: #AFC0D3; stroke-width: 1.5; }
.smap .node.is-happy { stroke: var(--s-green); }
.smap .node.is-visited { stroke-width: 0; }
.smap .node.is-missed { fill: #fff; stroke: var(--s-red); stroke-width: 2; stroke-dasharray: 3 2; }
.smap .node.is-open { stroke-width: 3; fill: #fff; }
.smap .pulse { fill: none; stroke-width: 2; animation: pulse 1.8s ease-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes pulse { from { transform: scale(1); opacity: .8; } to { transform: scale(2.6); opacity: 0; } }
.smap .lbl { font-size: 10px; fill: var(--s-muted); }
.smap .lbl-lane { font-size: 10.5px; fill: var(--s-muted); }
.smap .lbl-lane.is-happy { fill: var(--s-green-ink); font-weight: 600; }
.smap .hit { fill: transparent; cursor: pointer; }
.smap .hit:hover + .node, .smap .node.is-sel { stroke: var(--s-ink); stroke-width: 2.5; }
.smap .miss-x { stroke: var(--s-red); stroke-width: 1.6; stroke-linecap: round; }
.smap .late-dot { fill: var(--s-orange); }

/* ── clips (animated scenes, scenes.js) ───────────────────────────────────── */
.clip {
  position: relative; aspect-ratio: 16 / 9; width: 100%; overflow: hidden; border-radius: 4px;
  background: var(--s-navy-3); color: #fff; font-family: var(--s-sans); isolation: isolate;
  container-type: inline-size;
}
.clip__stage { position: absolute; inset: 0; }
.clip__cap {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 5; display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; font-size: 12.5px; background: linear-gradient(transparent, rgba(8, 20, 36, .85));
}
.clip__cap span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; opacity: .9; }
.clip__replay {
  -webkit-appearance: none; appearance: none; border: 0; background: rgba(255, 255, 255, .14); color: #fff;
  width: 28px; height: 28px; border-radius: 50%; display: inline-grid; place-items: center; cursor: pointer; flex: none;
}
.clip__replay:hover { background: rgba(255, 255, 255, .26); }
.clip__replay svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.clip__tag {
  position: absolute; top: 10px; left: 10px; z-index: 5; font-size: 11px; font-weight: 600; letter-spacing: .02em;
  padding: 3px 8px; border-radius: 3px; background: rgba(255, 255, 255, .14);
}
.clip__tag.is-live { background: #D7372A; }
.clip [data-in] { opacity: 0; }
.clip.is-playing [data-in] { animation: clip-in 600ms var(--s-ease) both; animation-delay: calc(var(--d, 0) * 1ms); }
@keyframes clip-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.clip .w { display: inline; opacity: .14; }
.clip.is-playing .w { animation: word 380ms var(--s-ease) both; animation-delay: calc(var(--d, 0) * 1ms); }
@keyframes word { from { opacity: .14; } to { opacity: 1; } }

/* alert */
.sc-alert { position: absolute; inset: 0; background: radial-gradient(120% 90% at 70% 10%, #24507E, var(--s-navy-3)); }
.sc-alert__contours { position: absolute; inset: -10%; opacity: .35; }
.sc-alert__note {
  position: absolute; left: 7%; right: 7%; top: 12%; padding: 12px 14px; border-radius: 12px;
  background: rgba(255, 255, 255, .95); color: var(--s-ink); box-shadow: 0 12px 30px rgba(0, 0, 0, .35);
  display: grid; grid-template-columns: 34px 1fr; gap: 10px; align-items: start;
}
.clip.is-playing .sc-alert__note { animation: drop 700ms var(--s-ease) both; animation-delay: 250ms; }
@keyframes drop { from { opacity: 0; transform: translateY(-60px); } to { opacity: 1; transform: none; } }
.sc-alert__icon { width: 34px; height: 34px; border-radius: 8px; background: #D7372A; display: grid; place-items: center; color: #fff; font-weight: 700; }
.sc-alert__src { font-size: 11px; color: var(--s-muted); }
.sc-alert__txt { font-size: clamp(12px, 3.4cqi, 17px); font-weight: 600; line-height: 1.3; }
.sc-ticker { position: absolute; left: 0; right: 0; bottom: 38px; height: 30px; display: flex; overflow: hidden; background: #D7372A; font-size: 13px; font-weight: 600; }
.sc-ticker__lbl { flex: none; padding: 0 10px; display: flex; align-items: center; background: #fff; color: #D7372A; }
.sc-ticker__run { display: flex; align-items: center; white-space: nowrap; gap: 40px; padding-left: 100%; }
.clip.is-playing .sc-ticker__run { animation: ticker 18s linear infinite; animation-delay: 900ms; }
@keyframes ticker { to { transform: translateX(-100%); } }

/* call */
.sc-call { position: absolute; inset: 0; display: grid; grid-template-columns: 38% 1fr; background: linear-gradient(160deg, var(--s-navy-2), var(--s-navy-3)); }
.sc-call__who { display: grid; place-items: center; align-content: center; gap: 8px; text-align: center; padding: 10px; }
.sc-call__ava { position: relative; width: 56px; height: 56px; border-radius: 50%; background: var(--s-blue); display: grid; place-items: center; font-weight: 700; font-size: 20px; }
.sc-call__ava::before, .sc-call__ava::after { content: ""; position: absolute; inset: -6px; border-radius: 50%; border: 2px solid var(--s-green); opacity: 0; }
.clip.is-playing .sc-call__ava::before { animation: ring 1.8s ease-out infinite; }
.clip.is-playing .sc-call__ava::after { animation: ring 1.8s ease-out .6s infinite; }
@keyframes ring { from { transform: scale(.9); opacity: .9; } to { transform: scale(1.7); opacity: 0; } }
.sc-call__name { font-size: 13px; font-weight: 600; }
.sc-call__wave { display: flex; gap: 3px; align-items: center; height: 26px; }
.sc-call__wave i { width: 3px; height: 30%; background: var(--s-green); border-radius: 2px; }
.clip.is-playing .sc-call__wave i { animation: wave 900ms ease-in-out infinite alternate; animation-delay: calc(var(--d) * 1ms); }
@keyframes wave { to { height: 100%; } }
.sc-call__lines { padding: 14px 16px 44px 0; display: flex; flex-direction: column; justify-content: center; gap: 8px; font-family: var(--s-serif); font-size: clamp(12px, 3.2cqi, 17px); line-height: 1.35; }

/* chat */
.sc-chat { position: absolute; inset: 0; background: #E9EFF5; padding: 12px 12px 44px; display: flex; flex-direction: column; justify-content: flex-end; gap: 6px; color: var(--s-ink); }
.sc-chat__msg { max-width: 82%; padding: 6px 10px 7px; border-radius: 10px; background: #fff; font-size: clamp(11px, 2.9cqi, 14.5px); line-height: 1.3; box-shadow: 0 1px 1px rgba(0, 0, 0, .08); }
.sc-chat__msg b { display: block; font-size: 11px; color: var(--c, var(--s-blue)); }
.sc-chat__msg.is-me { align-self: flex-end; background: #D8F5DD; }
.sc-chat__typing { align-self: flex-start; display: flex; gap: 3px; padding: 8px 10px; border-radius: 10px; background: #fff; }
.sc-chat__typing i { width: 6px; height: 6px; border-radius: 50%; background: #9AA9BA; }
.clip.is-playing .sc-chat__typing i { animation: dot 1s ease-in-out infinite; animation-delay: calc(var(--d) * 1ms); }
@keyframes dot { 50% { transform: translateY(-3px); opacity: .5; } }

/* map */
.sc-map { position: absolute; inset: 0; background: #E8E1D3; }
.sc-map svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.sc-map .topo { fill: none; stroke: #B9AC93; stroke-width: 1; }
.sc-map .river { fill: none; stroke: #4E95D9; stroke-width: 5; stroke-linecap: round; }
.sc-map .slurry { fill: none; stroke: #7D7A73; stroke-width: 14; stroke-linecap: round; stroke-opacity: .85; stroke-dasharray: 900; stroke-dashoffset: 900; }
.clip.is-playing .sc-map .slurry { animation: slurry 4s var(--s-ease) .4s forwards; }
@keyframes slurry { to { stroke-dashoffset: 0; } }
.sc-map .dam { fill: #9C9586; stroke: #6F6A60; stroke-width: 1.5; }
.sc-map .town { fill: #C8372D; }
.sc-map__lbls { position: absolute; left: 10px; top: 36px; display: flex; flex-direction: column; gap: 5px; align-items: flex-start; }
.sc-map__lbls span { font-size: clamp(10.5px, 2.7cqi, 13.5px); padding: 4px 8px; border-radius: 3px; background: rgba(19, 36, 58, .82); }
.sc-map__scan { position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .25), transparent); width: 30%; }
.clip.is-playing .sc-map__scan { animation: scan 3.2s linear infinite; }
@keyframes scan { from { transform: translateX(-100%); } to { transform: translateX(400%); } }

/* data */
.sc-data { position: absolute; inset: 0; background: var(--s-paper); color: var(--s-ink); padding: 14px 18px 46px; display: flex; flex-direction: column; justify-content: center; gap: 9px; }
.sc-data__row { display: grid; grid-template-columns: minmax(0, 40%) 1fr; gap: 10px; align-items: center; font-size: clamp(11px, 2.8cqi, 14px); }
.sc-data__lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sc-data__bar { position: relative; height: 22px; background: var(--s-mist); border-radius: 2px; }
.sc-data__fill { position: absolute; left: 0; top: 0; bottom: 0; width: var(--w); background: var(--s-orange); transform-origin: left; border-radius: 2px; }
.sc-data__fill.is-ok { background: var(--s-blue); }
.clip.is-playing .sc-data__fill { animation: grow 1.4s var(--s-ease) both; animation-delay: calc(var(--d) * 1ms); }
@keyframes grow { from { transform: scaleX(0); } }
.sc-data__val { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); font-weight: 700; font-variant-numeric: tabular-nums; font-size: 12px; }
.sc-data__limit { position: absolute; top: -4px; bottom: -4px; left: var(--l); width: 2px; background: var(--s-ink); }
.sc-data__title { font-family: var(--s-serif); color: var(--s-blue); font-size: clamp(13px, 3.4cqi, 18px); }

/* document */
.sc-doc { position: absolute; inset: 0; background: #2A3B52; display: grid; place-items: center; padding-bottom: 30px; }
.sc-doc__page {
  width: 78%; height: 84%; background: #FBFAF6; color: var(--s-ink); padding: 6% 7%; box-shadow: 0 10px 30px rgba(0, 0, 0, .4);
  font-family: var(--s-serif); font-size: clamp(10.5px, 2.6cqi, 14px); line-height: 1.45; display: flex; flex-direction: column; gap: 8px; overflow: hidden;
}
.clip.is-playing .sc-doc__page { animation: page-in 900ms var(--s-ease) both; }
@keyframes page-in { from { opacity: 0; transform: translateY(24px) rotate(-1.5deg); } }
.sc-doc__head { font-family: var(--s-sans); font-size: 10px; color: var(--s-muted); display: flex; justify-content: space-between; border-bottom: 1px solid #DDD7C8; padding-bottom: 5px; }
.sc-doc__stamp { color: #C8372D; border: 2px solid currentColor; padding: 0 5px; font-weight: 700; transform: rotate(-4deg); }
.sc-doc mark { background: linear-gradient(90deg, #FFE38A 50%, transparent 50%) right / 200% 100% no-repeat; color: inherit; padding: 0 2px; }
.clip.is-playing .sc-doc mark { animation: hl 900ms var(--s-ease) both; animation-delay: calc(var(--d) * 1ms); }
@keyframes hl { to { background-position: left; } }

/* social */
.sc-social { position: absolute; inset: 0; background: #F4F6F9; color: var(--s-ink); padding: 10px 12px 44px; display: flex; flex-direction: column; gap: 7px; justify-content: flex-end; }
.sc-social__post { background: #fff; border: 1px solid #E1E7EE; border-radius: 8px; padding: 7px 10px; font-size: clamp(11px, 2.8cqi, 14px); line-height: 1.3; }
.sc-social__post b { font-size: 11.5px; color: var(--s-blue); margin-right: 6px; }
.sc-social__meta { display: flex; gap: 14px; margin-top: 4px; font-size: 10.5px; color: var(--s-muted); font-variant-numeric: tabular-nums; }

/* broadcast */
.sc-tv { position: absolute; inset: 0; background: radial-gradient(70% 80% at 50% 35%, #3B5C84, #0E2036); }
.sc-tv__podium { position: absolute; left: 50%; bottom: 30%; width: 26%; height: 30%; transform: translateX(-50%); background: #0B1B2E; border-top: 4px solid var(--s-blue-2); }
.sc-tv__head { position: absolute; left: 50%; bottom: 58%; width: 12%; aspect-ratio: 1; border-radius: 50%; transform: translateX(-50%); background: #0B1B2E; }
.sc-tv__flash { position: absolute; inset: 0; background: #fff; opacity: 0; }
.clip.is-playing .sc-tv__flash { animation: flash 3.4s steps(1) infinite; }
@keyframes flash { 0%, 100% { opacity: 0; } 12% { opacity: .5; } 13% { opacity: 0; } 47% { opacity: .35; } 48% { opacity: 0; } }
.sc-tv__l3 { position: absolute; left: 0; right: 12%; bottom: 40px; padding: 8px 14px; background: rgba(255, 255, 255, .96); color: var(--s-ink); border-left: 6px solid #D7372A; font-family: var(--s-serif); font-size: clamp(12px, 3.1cqi, 16.5px); line-height: 1.3; }
.clip.is-playing .sc-tv__l3 { animation: l3 700ms var(--s-ease) both; animation-delay: 500ms; }
@keyframes l3 { from { transform: translateX(-100%); } }

/* letter */
.sc-letter { position: absolute; inset: 0; background: linear-gradient(180deg, #DCE6F0, #C7D5E4); display: grid; place-items: center; padding-bottom: 30px; }
.sc-letter__sheet { width: 80%; height: 82%; background: #fff; color: var(--s-ink); padding: 5% 6%; box-shadow: 0 8px 24px rgba(19, 36, 58, .25); display: flex; flex-direction: column; gap: 7px; overflow: hidden; }
.sc-letter__bar { height: 6px; width: 34%; background: var(--s-blue); margin-bottom: 6px; }
.sc-letter__line { font-family: var(--s-serif); font-size: clamp(10.5px, 2.7cqi, 14px); line-height: 1.4; }

@media (prefers-reduced-motion: reduce) {
  .is-new .trule, .smap .route.is-draw, .smap .pulse { animation: none !important; }
  .clip *, .clip *::before, .clip *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; animation-delay: 0ms !important; }
  .clip .sc-map .slurry { stroke-dashoffset: 0; }
}
