/* Colors taken from the Teacher Cris logo */
:root {
  --navy: #26459a;
  --navy-deep: #172b63;
  --gold: #e6ac2f;
  --gold-deep: #b97a1c;
  --gold-light: #f7d27a;
  --orange: #d9731c;
  --cyan: #3fb6e8;
  --parchment: #f1e5cd;
  --parchment-2: #e5d2ae;
  --paper: #fbf5e8;
  --ink: #1f2b52;
  --muted: #6d6250;
  --radius: 22px;
  --shadow: 0 10px 0 rgba(151, 101, 26, .18), 0 18px 40px rgba(60, 40, 10, .18);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font: 600 16px/1.5 "Quicksand", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 10%, rgba(255, 255, 255, .65), transparent 40%),
    radial-gradient(circle at 85% 90%, rgba(230, 172, 47, .25), transparent 45%),
    repeating-radial-gradient(circle at 50% 50%, transparent 0 22px, rgba(185, 122, 28, .045) 22px 23px),
    var(--parchment);
  background-attachment: fixed;
}
h1, h2 { font-family: "Quicksand", sans-serif; margin: 0; letter-spacing: .2px; }
.muted { color: var(--muted); }
kbd { font: 700 12px "Quicksand", sans-serif; background: var(--paper); border: 1px solid var(--parchment-2); border-bottom-width: 3px; border-radius: 6px; padding: 0 6px; }

/* floating glowing squares, like the ones in the logo */
.sparkles { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 0; }
.sparkles i { position: absolute; width: 14px; height: 14px; border-radius: 3px; border: 3px solid var(--gold); background: var(--cyan); opacity: .55; box-shadow: 0 0 14px rgba(63, 182, 232, .8); animation: floaty 9s ease-in-out infinite; }
.sparkles i:nth-child(1) { left: 6%; top: 18%; }
.sparkles i:nth-child(2) { left: 92%; top: 12%; animation-delay: -2s; width: 10px; height: 10px; }
.sparkles i:nth-child(3) { left: 80%; top: 70%; animation-delay: -4s; background: var(--gold-light); }
.sparkles i:nth-child(4) { left: 12%; top: 82%; animation-delay: -1s; background: var(--gold-light); }
.sparkles i:nth-child(5) { left: 48%; top: 6%; animation-delay: -6s; width: 9px; height: 9px; }
.sparkles i:nth-child(6) { left: 64%; top: 90%; animation-delay: -3s; }
.sparkles i:nth-child(7) { left: 30%; top: 60%; animation-delay: -7s; width: 8px; height: 8px; opacity: .35; }
.sparkles i:nth-child(8) { left: 96%; top: 45%; animation-delay: -5s; background: var(--gold-light); }
.sparkles i:nth-child(9) { left: 3%; top: 50%; animation-delay: -8s; width: 10px; height: 10px; }
.sparkles i:nth-child(10) { left: 72%; top: 30%; animation-delay: -2.5s; width: 8px; height: 8px; opacity: .3; }
@keyframes floaty { 0%, 100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-22px) rotate(20deg); } }

.screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; overflow: auto; padding: 16px; z-index: 1; }
.screen[hidden] { display: none; }

/* ---- cards & buttons ---- */
.card {
  width: min(560px, 100%);
  background: var(--paper);
  border: 4px solid var(--gold);
  border-radius: 30px;
  padding: 28px 28px 24px;
  box-shadow: var(--shadow), inset 0 0 0 4px var(--paper), inset 0 0 0 6px var(--parchment-2);
  position: relative;
}
.card.center { text-align: center; }
.card h2 { color: var(--navy); font-size: 1.7rem; margin: 10px 0 8px; overflow-wrap: anywhere; }
.pop { animation: pop .45s cubic-bezier(.2, 1.4, .4, 1) both; }
@keyframes pop { from { transform: scale(.85); opacity: 0; } }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: 600 1.05rem "Quicksand", sans-serif; text-decoration: none; cursor: pointer;
  padding: 12px 22px; border-radius: 999px; border: 0;
  transition: transform .15s, box-shadow .15s, filter .15s;
}
.btn svg { width: 20px; height: 20px; fill: currentColor; }
.btn:hover { transform: translateY(-2px); filter: brightness(1.05); }
.btn:active { transform: translateY(2px); }
.btn:disabled { opacity: .6; cursor: default; }
.btn-play { background: linear-gradient(180deg, #f08a2c, var(--orange)); color: #fff; box-shadow: 0 5px 0 #a4520f; text-shadow: 0 1px 0 rgba(0, 0, 0, .2); }
.btn-play:active { box-shadow: 0 2px 0 #a4520f; }
.btn-soft { background: var(--navy); color: #fff; box-shadow: 0 5px 0 var(--navy-deep); }
.btn-soft:active { box-shadow: 0 2px 0 var(--navy-deep); }
.buttons { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin: 20px 0 14px; }
.back-link { display: inline-block; margin-top: 6px; color: var(--navy); font-weight: 800; text-decoration: none; }
.back-link:hover { text-decoration: underline; }
.chip { display: inline-block; margin: 0; padding: 3px 12px; border-radius: 999px; background: var(--parchment); color: var(--gold-deep); font-weight: 800; font-size: .9rem; }
.hint { font-size: .82rem; color: var(--muted); margin: 0 0 4px; }

/* ---- library ---- */
#library { align-items: flex-start; }
.library { width: min(1100px, 100%); margin: 0 auto; padding: 10px 0 40px; }
.brand { display: flex; align-items: center; gap: 22px; margin: 6px 0 22px; }
.brand-logo { width: 130px; height: 130px; object-fit: contain; filter: drop-shadow(0 8px 14px rgba(120, 80, 20, .3)); animation: bob 4s ease-in-out infinite; flex: none; }
@keyframes bob { 0%, 100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-8px) rotate(2deg); } }
.eyebrow { margin: 0 0 8px; font: 700 .95rem "Quicksand", sans-serif; letter-spacing: 3px; text-transform: uppercase; color: var(--orange); }
.brand h1 {
  font-family: "Luckiest Guy", "Quicksand", sans-serif; font-weight: 400;
  font-size: clamp(2.6rem, 7vw, 4.2rem); line-height: 1; letter-spacing: 2px;
  color: #a4540c;
  -webkit-text-stroke: 8px #fff; paint-order: stroke fill;   /* white outline */
  text-shadow: 0 5px 0 rgba(120, 62, 8, .35), 0 8px 16px rgba(94, 52, 6, .25);
  transform: rotate(-2deg); transform-origin: left center; padding-top: 4px;
}
.tagline { margin: 6px 0 0; font-weight: 800; color: var(--navy); font-size: 1.1rem; }

.toolbar { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 22px; }
.search { flex: 1 1 260px; display: flex; align-items: center; gap: 8px; background: var(--paper); border: 3px solid var(--parchment-2); border-radius: 999px; padding: 0 16px; transition: border-color .15s; }
.search:focus-within { border-color: var(--gold); }
.search svg, .open-local svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.search svg { color: var(--gold-deep); }
.search input { flex: 1; border: 0; outline: 0; background: transparent; font: 700 1rem "Quicksand", sans-serif; color: var(--ink); padding: 12px 0; min-width: 0; }
.open-local { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; padding: 12px 20px; border-radius: 999px; border: 3px dashed var(--navy); color: var(--navy); font-weight: 800; background: rgba(255, 255, 255, .5); transition: background .15s, transform .15s; }
.open-local:hover, .open-local.over { background: #fff; transform: translateY(-2px); }
.open-local input { display: none; }

.deck-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 22px; }
.deck {
  --accent: var(--navy);
  display: flex; flex-direction: column; text-decoration: none; color: var(--ink);
  background: var(--paper); border-radius: var(--radius); overflow: hidden;
  border: 4px solid var(--accent); box-shadow: 0 7px 0 var(--accent), 0 14px 26px rgba(60, 40, 10, .16);
  transition: transform .18s cubic-bezier(.2, 1.4, .4, 1), box-shadow .18s;
  animation: pop .45s cubic-bezier(.2, 1.4, .4, 1) both;
}
.deck:nth-child(4n+2) { --accent: var(--gold-deep); }
.deck:nth-child(4n+3) { --accent: var(--orange); }
.deck:nth-child(4n+4) { --accent: #2a8fc0; }
.deck:hover { transform: translateY(-6px) rotate(-1deg); box-shadow: 0 12px 0 var(--accent), 0 22px 34px rgba(60, 40, 10, .22); }
.deck:active { transform: translateY(2px); }
.thumb { position: relative; aspect-ratio: 16 / 9; background: linear-gradient(135deg, var(--parchment-2), var(--parchment)); display: grid; place-items: center; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; animation: fadein .4s both; }
.thumb .ph { width: 56px; height: 56px; object-fit: contain; opacity: .7; }
.thumb .play { position: absolute; right: 10px; bottom: 10px; width: 44px; height: 44px; border-radius: 50%; background: var(--orange); box-shadow: 0 4px 0 #a4520f; display: grid; place-items: center; transform: scale(.85); transition: transform .18s; }
.thumb .play svg { width: 20px; height: 20px; fill: #fff; margin-left: 3px; }
.deck:hover .play { transform: scale(1.05); }
.deck .title { padding: 12px 14px 14px; font: 600 1.08rem/1.25 "Quicksand", sans-serif; color: var(--navy-deep); }
@keyframes fadein { from { opacity: 0; } }
.empty { grid-column: 1 / -1; text-align: center; padding: 30px; background: rgba(255, 255, 255, .5); border: 3px dashed var(--parchment-2); border-radius: var(--radius); color: var(--muted); font-weight: 700; }
code { background: var(--parchment); padding: 1px 6px; border-radius: 6px; }

/* ---- loading / ready ---- */
.logo-bob { width: 120px; height: 120px; object-fit: contain; animation: bob 2.4s ease-in-out infinite; filter: drop-shadow(0 8px 12px rgba(120, 80, 20, .3)); }
.logo-small { width: 90px; height: 90px; object-fit: contain; }
.progress { height: 16px; background: var(--parchment); border-radius: 999px; overflow: hidden; margin: 18px 0 10px; border: 3px solid var(--parchment-2); }
#progress-bar {
  height: 100%; width: 8%; border-radius: 999px; transition: width .25s;
  background: repeating-linear-gradient(45deg, var(--gold) 0 12px, var(--gold-light) 12px 24px);
  background-size: 34px 34px; animation: stripes .8s linear infinite;
}
@keyframes stripes { to { background-position: 34px 0; } }
.ready-card { width: min(620px, 100%); }
.ready-thumb { position: relative; aspect-ratio: 16 / 9; border-radius: 16px; overflow: hidden; background: linear-gradient(135deg, var(--parchment-2), var(--parchment)); border: 4px solid var(--navy); box-shadow: 0 6px 0 var(--navy-deep); display: grid; place-items: center; }
.ready-thumb #ready-thumb { width: 100%; height: 100%; object-fit: cover; }
.ready-thumb .ready-logo { width: 110px; height: 110px; object-fit: contain; }
.ready-thumb #ready-thumb:not([hidden]) + .ready-logo { position: absolute; width: 64px; height: 64px; right: 8px; bottom: 8px; filter: drop-shadow(0 3px 6px rgba(0, 0, 0, .35)); }

/* ---- show ---- */
#show { background: var(--navy-deep); padding: 0; overflow: hidden; z-index: 2; }
#viewport { position: absolute; inset: 0; overflow: hidden; background: radial-gradient(circle at 50% 40%, #22397a, var(--navy-deep) 70%); touch-action: manipulation; user-select: none; -webkit-user-select: none; }
#stage { position: absolute; left: 0; top: 0; transform-origin: 0 0; overflow: hidden; background: #000; contain: layout paint; }
/* compact button bar, bottom-left corner, stacked so it covers as little of the slide as possible */
#controls {
  position: fixed; left: 10px; bottom: 10px; z-index: 20;
  display: flex; flex-direction: column-reverse; align-items: center; gap: 3px; padding: 4px;
  border-radius: 18px; background: rgba(23, 43, 99, .85); border: 2px solid var(--gold);
  box-shadow: 0 4px 14px rgba(0, 0, 0, .3);
  opacity: .75; transition: opacity .2s, background .2s, border-color .2s, box-shadow .2s;
}
#controls:hover { opacity: 1; }
#controls button { display: grid; place-items: center; width: 30px; height: 30px; padding: 0; background: transparent; border: 0; color: var(--gold-light); cursor: pointer; border-radius: 50%; }
#controls button svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.8; stroke-linecap: round; stroke-linejoin: round; }
#controls button:hover { background: rgba(247, 210, 122, .2); color: #fff; }
.ctl-group { display: flex; flex-direction: column; align-items: center; gap: 1px; overflow: hidden; max-height: 320px; transition: max-height .3s ease, opacity .2s; }
#controls .ctl-toggle { position: relative; width: 30px; height: 30px; }
#controls .ctl-toggle img { width: 28px; height: 28px; border-radius: 50%; display: block; }
#controls .ctl-toggle .chev { position: absolute; right: -3px; top: -3px; width: 13px; height: 13px; padding: 1px; border-radius: 50%; background: var(--gold); color: var(--navy-deep); stroke-width: 4; transform: rotate(-90deg); transition: transform .3s; }
#controls .ctl-home { background: var(--gold); color: var(--navy-deep); }
#controls .ctl-home:hover { background: var(--gold-light); color: var(--navy-deep); }
#controls .ctl-home span { display: none; }
.ctl-sep { width: 18px; height: 2px; background: rgba(247, 210, 122, .3); margin: 3px 0; flex: none; }
/* hidden state: only the small logo stays, faded */
body.ctl-collapsed #controls { background: transparent; border-color: transparent; box-shadow: none; opacity: .4; }
body.ctl-collapsed #controls:hover { opacity: 1; }
body.ctl-collapsed .ctl-group { max-height: 0; opacity: 0; pointer-events: none; }
body.ctl-collapsed #controls .ctl-toggle .chev { transform: rotate(90deg); }
#counter { font: 700 11px "Quicksand", sans-serif; font-variant-numeric: tabular-nums; color: #fff; padding: 2px 0; text-align: center; line-height: 1.1; white-space: pre-line; width: 30px; }
body.embed #controls .ctl-home, body.embed #controls .ctl-home + .ctl-sep { display: none; }
#controls button span { white-space: nowrap; }
#end { position: fixed; inset: 0; z-index: 15; display: flex; align-items: center; justify-content: center; padding: 16px; background: radial-gradient(circle, rgba(241, 229, 205, .96), rgba(229, 210, 174, .98)); }
#end[hidden], #curtain[hidden] { display: none; }
#curtain { position: fixed; inset: 0; z-index: 16; }

@media (max-width: 560px) {
  .brand { gap: 14px; }
  .brand-logo { width: 88px; height: 88px; }
  .deck-grid { grid-template-columns: 1fr 1fr; gap: 14px; }
  .deck .title { font-size: .95rem; padding: 9px 10px 11px; }
  .thumb .play { width: 34px; height: 34px; }
  .card { padding: 22px 18px 18px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---- slide content (keep as is) ---- */
.slide { position: absolute; left: 0; top: 0; overflow: hidden; background: #fff; }
.slide .bg, .slide .deco, .slide .content { position: absolute; inset: 0; }
.slide .bg { pointer-events: none; }
.pe { position: absolute; pointer-events: none; transform-origin: 50% 50%; }
.pi { position: absolute; inset: 0; transform-origin: 50% 50%; }
.pic { position: absolute; inset: 0; overflow: hidden; pointer-events: auto; }
.pic img { position: absolute; max-width: none; pointer-events: none; }
svg.geo { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }
svg.geo .hit { pointer-events: visiblePainted; }
svg.geo .hit-stroke { pointer-events: visibleStroke; }
.tx { position: absolute; inset: 0; display: flex; flex-direction: column; pointer-events: none; overflow: visible; }
.tx.cell { position: static; }
.tx.nowrap .pp { white-space: pre; }
.pp { position: relative; margin: 0; white-space: pre-wrap; overflow-wrap: break-word; tab-size: 4; }
.pp .r, .pp .bu { pointer-events: auto; }
.hl { cursor: pointer; }
.link > .pi, .pe.link .pic, .pe.link .hit { cursor: pointer; }
.pe.audio .pic, .pe.video .pic { cursor: pointer; }
.media-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; visibility: hidden; pointer-events: auto; background: #000; }
table.tbl { position: absolute; inset: 0; border-collapse: collapse; table-layout: fixed; width: 100%; pointer-events: auto; }
table.tbl td { overflow: hidden; }
.unsupported { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; border: 1px dashed #999; color: #999; font: 14px system-ui; }
