/* ==========================================================================
   Introduction To AI — DotCode
   All sizes are in px on a 1920×1080 stage; script.js scales it to fit.
   ========================================================================== */

:root {
  /* DotCode brand */
  --primary: #5C48E7;
  --primary-light: #8C6DF5;
  --lavender: #BEC7EC;

  --bg: #080F1A;
  --bg-soft: #0E1628;
  --panel: rgba(255, 255, 255, 0.045);
  --panel-border: rgba(140, 109, 245, 0.24);
  --text: #F1F2FA;
  --muted: #A3AAC8;
  --warn: #FFC857;

  --radius: 28px;
  --font: 'Poppins', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --mono: 'JetBrains Mono', Consolas, 'Courier New', monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ---- Stage --------------------------------------------------------------- */

#viewport {
  position: fixed;
  inset: 0;
}

#stage {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 1920px;
  height: 1080px;
  transform-origin: center;
  overflow: hidden;
  background:
    radial-gradient(900px 620px at 88% 8%, rgba(92, 72, 231, 0.34), transparent 70%),
    radial-gradient(760px 520px at 4% 100%, rgba(140, 109, 245, 0.16), transparent 70%),
    radial-gradient(circle, rgba(190, 199, 236, 0.07) 1.5px, transparent 1.8px) 0 0 / 48px 48px,
    var(--bg);
}

.stage-footer {
  position: absolute;
  left: 140px;
  bottom: 40px;
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 22px;
  color: var(--muted);
  transition: opacity 0.4s;
}

/* The logo SVG has lots of empty space around it, so it's drawn large and pulled in */
.stage-footer img { height: 130px; margin: -40px -24px -40px -44px; }
#stage.hide-footer .stage-footer { opacity: 0; }

/* ---- Slides -------------------------------------------------------------- */

.slide {
  position: absolute;
  inset: 0;
  padding: 90px 140px 150px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transform: translateX(80px);
  transition: opacity 0.5s ease, transform 0.6s cubic-bezier(0.2, 0.7, 0.2, 1), visibility 0s 0.6s;
}

.slide.past { transform: translateX(-80px); }

.slide.active {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition: opacity 0.5s ease, transform 0.6s cubic-bezier(0.2, 0.7, 0.2, 1), visibility 0s;
}

/* .reveal — rises in automatically when its slide opens. --i sets the order. */
.slide.active .reveal {
  animation: rise 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) both;
  animation-delay: calc(150ms + var(--i, 0) * 110ms);
}

@keyframes rise {
  from { opacity: 0; transform: translateY(36px); }
  to   { opacity: 1; transform: none; }
}

/* .fragment — hidden until Next is pressed (PowerPoint "on click"). */
.fragment {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.fragment.visible {
  opacity: 1;
  transform: none;
}

/* Inline fragments (e.g. lines inside a code block) keep their place in the text */
span.fragment { display: inline-block; }

/* ---- Typography ---------------------------------------------------------- */

h1, h2, h3, p { margin: 0; }

h1 {
  font-size: 150px;
  line-height: 1;
  font-weight: 800;
  letter-spacing: -0.03em;
}

h2 {
  font-size: 72px;
  line-height: 1.1;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 56px;
}

p {
  font-size: 34px;
  line-height: 1.5;
  color: var(--muted);
}

p strong { color: var(--text); font-weight: 600; }

.lead {
  font-size: 42px;
  line-height: 1.45;
  color: var(--text);
}

.grad {
  background: linear-gradient(90deg, var(--primary-light), #C9B8FF 55%, #7FD6FF);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.emoji {
  font-size: 68px;
  line-height: 1;
  flex-shrink: 0;
}

.byline {
  font-size: 44px;
  margin-top: 48px;
}

/* ---- Building blocks ----------------------------------------------------- */

.card {
  background: var(--panel);
  border: 1.5px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 44px;
}

.card--row {
  display: flex;
  align-items: center;
  gap: 36px;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 56px;
  align-items: center;
}

.quote {
  margin: 0;
  padding: 44px 52px;
  font-size: 38px;
  line-height: 1.55;
  font-style: italic;
  color: var(--text);
  background: var(--panel);
  border-left: 8px solid var(--primary-light);
  border-radius: 0 var(--radius) var(--radius) 0;
}

.quote--small { font-size: 31px; }

/* The generated sentence */
.quote--output {
  background: linear-gradient(160deg, rgba(92, 72, 231, 0.4), rgba(140, 109, 245, 0.1));
  border-left-color: #7FD6FF;
}

.callout {
  display: flex;
  align-items: center;
  gap: 24px;
  margin-top: 40px;
  padding: 28px 40px;
  font-size: 34px;
  color: var(--text);
  background: rgba(255, 200, 87, 0.08);
  border-left: 6px solid var(--warn);
  border-radius: 0 20px 20px 0;
}

.stack .callout { margin-top: 0; }

.text-block {
  font-size: 36px;
  color: var(--text);
}

.example {
  font-size: 40px;
  color: var(--muted);
}

.word {
  display: inline-block;
  padding: 4px 22px;
  margin: 0 8px;
  font-weight: 600;
  color: var(--text);
  background: rgba(140, 109, 245, 0.22);
  border: 1.5px solid rgba(140, 109, 245, 0.55);
  border-radius: 999px;
}

/* Word dictionary code block */
.dict {
  margin: 0;
  padding: 40px 48px;
  font-family: var(--mono);
  font-size: 32px;
  line-height: 1.7;
  color: #D6DBF5;
  background: #050A14;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 22px;
  white-space: pre;
}

.dict .k { color: #C792EA; }
.dict .s { color: #C3E88D; }
.dict .c { color: var(--muted); }

/* ---- Markov chain demos (slides 5 and 6) --------------------------------- */
/* Purple = the word we're looking at (the key), green = the word that comes next,
   yellow = the dice rolling across a list. */

.bigram {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 40px 48px;
  align-items: center;
}

.generator {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 40px 48px;
  align-items: center;
}

/* Words in the slide 5 passage */
.tok {
  border-radius: 6px;
  transition: background 0.25s, box-shadow 0.25s;
}

.tok.is-key {
  background: rgba(199, 146, 234, 0.35);
  box-shadow: 0 0 0 6px rgba(199, 146, 234, 0.35);
}

.tok.is-next {
  background: rgba(195, 232, 141, 0.3);
  box-shadow: 0 0 0 6px rgba(195, 232, 141, 0.3);
}

/* The dictionary */
.bigram-dict,
.gen-dict {
  font-size: 26px;
  padding: 36px 40px;
  white-space: normal;
}

.dict-row {
  display: grid;
  grid-template-columns: auto 1fr; /* long lists wrap under their first word */
}

.dict-key { white-space: pre; }

.dict-row .k {
  padding: 0 0.15em;
  margin: 0 -0.15em;
  border-radius: 6px;
  transition: background 0.25s, box-shadow 0.25s;
}

.dict-row .k.is-active {
  background: rgba(199, 146, 234, 0.25);
  box-shadow: 0 0 0 2px #C792EA;
}

.dict-more { color: var(--muted); }

/* A word from "... and so on", shown while the generator needs it */
.dict-extra {
  margin: 4px -12px;
  padding: 2px 12px;
  border: 1.5px dashed rgba(163, 170, 200, 0.45);
  border-radius: 10px;
}

.chip {
  display: inline-block;
  padding: 0 0.15em;
  margin: 0 -0.15em;
  border-radius: 6px;
  transition: background 0.1s, box-shadow 0.1s;
}

.chip.is-spin {
  background: rgba(255, 200, 87, 0.25);
  box-shadow: 0 0 0 2px var(--warn);
}

.chip.is-new {
  background: rgba(195, 232, 141, 0.2);
  box-shadow: 0 0 0 2px #C3E88D;
}

.chip.is-waiting { visibility: hidden; }

.chip.pop,
.gen-word.pop { animation: pop 0.35s cubic-bezier(0.3, 1.6, 0.5, 1); }

@keyframes pop {
  from { transform: scale(1.4); }
  to   { transform: none; }
}

/* The copy of a word that flies across the slide */
.chip-ghost {
  position: absolute;
  z-index: 5;
  padding: 0 0.2em;
  font-family: var(--mono);
  font-size: 26px;
  line-height: 1.5;
  white-space: nowrap;
  color: #C3E88D;
  background: #16230F;
  border-radius: 6px;
  box-shadow: 0 0 0 2px #C3E88D, 0 14px 30px rgba(0, 0, 0, 0.5);
  pointer-events: none;
  transform: translate(-50%, -50%);
}

/* Slide 6: the generated text */
.gen-output {
  align-self: stretch;
  display: flex;
  flex-direction: column;
  padding: 36px 44px;
  background: linear-gradient(160deg, rgba(92, 72, 231, 0.4), rgba(140, 109, 245, 0.1));
  border-left: 8px solid #7FD6FF;
  border-radius: 0 var(--radius) var(--radius) 0;
}

.gen-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.gen-label {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #7FD6FF;
}

.gen-new {
  padding: 10px 22px;
  font: inherit;
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  background: rgba(140, 109, 245, 0.2);
  border: 1.5px solid rgba(140, 109, 245, 0.55);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s;
}

.gen-new:hover { background: rgba(140, 109, 245, 0.4); }
.gen-new:focus-visible { outline: 3px solid var(--primary-light); outline-offset: 3px; }

.gen-text {
  font-size: 38px;
  line-height: 1.6;
  color: var(--text);
}

.gen-word {
  display: inline-block;
  padding: 0 0.12em;
  margin: 0 -0.12em;
  border-radius: 6px;
}

.gen-word.is-new {
  color: #C3E88D;
  background: rgba(22, 35, 15, 0.85);
  box-shadow: 0 0 0 2px #C3E88D;
}

.gen-word.is-waiting { visibility: hidden; }

/* Caption under both demos */
.bigram-caption {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
  min-height: 60px;
  font-size: 32px;
  color: var(--text);
}

.bigram-caption .ck { color: #C792EA; }
.bigram-caption .cn { color: #C3E88D; }

.bigram-caption .count {
  flex-shrink: 0;
  font-size: 24px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* Image with a light backing so it reads on the dark stage */
.figure {
  margin: 0;
  padding: 24px;
  background: #FFFFFF;
  border-radius: var(--radius);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
}

.figure img {
  display: block;
  max-height: 760px;
  max-width: 100%;
}

/* Cropped chat screenshot (already has rounded, transparent corners) */
.chat-shot {
  display: block;
  max-height: 780px;
  border-radius: 30px;
  box-shadow: 0 0 0 1.5px var(--panel-border), 0 30px 80px rgba(0, 0, 0, 0.55);
}

.hl { color: #C9B8FF !important; }

.note {
  margin-top: 18px;
  font-size: 22px;
  color: var(--muted);
}

/* ---- Slide layouts ------------------------------------------------------- */

/* Title */
.slide--title {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 90px;
}

.title-logo { width: 760px; }

/* Title on the left, big image on the right */
.slide--split {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 80px;
  padding-bottom: 110px;
}

.slide--split h2 {
  margin: 0;
  font-size: 96px;
}

/* By the end of this course… */
.goal {
  display: flex;
  align-items: center;
  gap: 44px;
  padding: 64px;
  background: linear-gradient(160deg, rgba(92, 72, 231, 0.4), rgba(140, 109, 245, 0.08));
  border-color: rgba(140, 109, 245, 0.7);
}

.goal .emoji { font-size: 110px; }
.goal .lead { font-size: 50px; }

/* AI companies */
.companies {
  display: grid;
  grid-template-columns: 440px 1fr;
  gap: 72px;
  align-items: center;
}

.logo-wall {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
}

.logo-tile {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  padding: 36px;
  background: var(--bg-soft);
  border: 1.5px solid var(--panel-border);
  border-radius: var(--radius);
}

.logo-tile--light { background: #FFFFFF; }
.logo-tile:first-child { grid-column: 1 / -1; width: 50%; justify-self: center; }
.logo-tile img { width: 100%; }

.model-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.model-list li {
  display: flex;
  align-items: baseline;
  gap: 28px;
  padding: 14px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.model-list strong {
  flex: 0 0 250px;
  font-size: 32px;
  font-weight: 700;
}

.model-list span {
  font-size: 29px;
  color: var(--muted);
}

/* ---- Controls ------------------------------------------------------------ */

#progress {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 10;
  width: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
  transition: width 0.4s ease;
}

#controls {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px;
  background: rgba(14, 22, 40, 0.85);
  border: 1px solid rgba(140, 109, 245, 0.3);
  border-radius: 999px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  transition: opacity 0.3s;
}

.ctrl {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s;
}

.ctrl:hover { background: rgba(140, 109, 245, 0.22); }
.ctrl.primary { background: var(--primary); }
.ctrl.primary:hover { background: var(--primary-light); }
.ctrl:disabled { opacity: 0.3; cursor: default; background: transparent; }
.ctrl:focus-visible { outline: 3px solid var(--primary-light); outline-offset: 2px; }
.ctrl svg { width: 22px; height: 22px; }

#counter {
  min-width: 70px;
  text-align: center;
  font-size: 15px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.divider {
  width: 1px;
  height: 28px;
  margin: 0 4px;
  background: rgba(255, 255, 255, 0.14);
}

.icon-compress { display: none; }
.is-fullscreen .icon-expand { display: none; }
.is-fullscreen .icon-compress { display: block; }

/* In fullscreen, hide the controls and cursor when the mouse is still */
.is-fullscreen.idle #controls:not(:hover) { opacity: 0; }
.is-fullscreen.idle { cursor: none; }

/* ---- Reduced motion ------------------------------------------------------ */

@media (prefers-reduced-motion: reduce) {
  .slide, .slide.past { transform: none; }
  .slide.active .reveal { animation: none; }
  .fragment { transform: none; transition: opacity 0.2s; }
}
