/* ==========================================================================
   Game Development — 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;
  --good: #C3E88D;
  --ink: #14102E; /* dark text on the light game scenes */

  --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").
   [data-from] — the same, for the parts of a demo that appear on a certain step. */
.fragment,
[data-from] {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.fragment.visible,
[data-from].is-shown {
  opacity: 1;
  transform: none;
}

/* ---- 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;
}

h3 {
  font-size: 44px;
  line-height: 1.2;
  font-weight: 700;
}

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;
}

.hl { color: #C9B8FF !important; }

kbd {
  display: inline-block;
  min-width: 1.5em;
  padding: 0 0.35em;
  font-family: var(--mono);
  font-size: 0.85em;
  text-align: center;
  color: var(--text);
  background: rgba(140, 109, 245, 0.22);
  border: 1.5px solid rgba(140, 109, 245, 0.55);
  border-bottom-width: 4px;
  border-radius: 8px;
}

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

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

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

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

/* Dark box used for the properties panel and the filmstrip */
.panel {
  padding: 26px 28px;
  background: #050A14;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 22px;
}

.panel-title {
  margin-bottom: 14px;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Caption under each demo: what just happened, and "2 / 6" on the right */
.caption {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
  min-height: 60px;
  font-size: 32px;
  line-height: 1.35;
  color: var(--text);
}

.caption b { color: #C9B8FF; }

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

/* ---- Sprites and scenes -------------------------------------------------- */

.sprite {
  display: inline-block;
  flex-shrink: 0;
  background-repeat: no-repeat;
  image-rendering: pixelated;
}

/* The character: one frame of Walk.png, which is 8 frames in a row, 128×128 each.
   --frame picks the frame. Only the 64×88 part of a frame that the character
   stands in is shown, so give this a width OR a height and it keeps its shape. */
.sprite--hero {
  aspect-ratio: 64 / 88;
  background-image: url(Walk.png);
  background-size: calc(1024 / 64 * 100%) calc(128 / 88 * 100%);
  background-position: calc((var(--frame, 0) * 128 + 26) / (1024 - 64) * 100%) 100%;
}

/* The enemy picture is drawn by script.js */
.sprite--enemy {
  aspect-ratio: 48 / 40;
  background-image: var(--enemy);
  background-size: 100% 100%;
}

/* A light box to stand sprites in, so they show up on the dark slide */
.scene {
  --ground: 56px;
  position: relative;
  overflow: hidden;
  border-radius: 22px;
  background:
    linear-gradient(rgba(20, 16, 46, 0.06) 2px, transparent 2px) 0 0 / 48px 48px,
    linear-gradient(90deg, rgba(20, 16, 46, 0.06) 2px, transparent 2px) 0 0 / 48px 48px,
    #EEF3FB;
}

/* The background image: sky, sun, hills and ground */
.backdrop {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 84% 20%, #FFF6C2 0 44px, rgba(255, 246, 194, 0.35) 46px 70px, transparent 72px),
    radial-gradient(52% 44% at 24% 100%, #86D694 99%, transparent 100%),
    radial-gradient(46% 34% at 82% 100%, #6CCB7D 99%, transparent 100%),
    linear-gradient(#7CC8FF, #D6F1FF);
}

.backdrop::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--ground);
  background: linear-gradient(#4CBB5A 0 14px, #9A6A47 14px);
}

.backdrop[data-from] { transform: none; }

/* Sprite picture on a light tile, for use inside cards */
.thumb {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 104px;
  height: 104px;
  border-radius: 24px;
  background: linear-gradient(#8FD0FF, #D6F1FF);
}

.thumb .sprite { height: 88px; }

/* Small name label */
.tag {
  padding: 4px 18px;
  font-size: 24px;
  font-weight: 600;
  white-space: nowrap;
  color: var(--text);
  background: var(--ink);
  border-radius: 999px;
}

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

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

.title-logo { width: 760px; }

/* Add "slide--demo" to a slide with an interactive demo, to leave it more room. */
.slide--demo h2 {
  font-size: 64px;
  margin-bottom: 28px;
}

.slide--demo .lead {
  font-size: 38px;
  margin-bottom: 28px;
}

/* ---- What are frames? (slide 2) ------------------------------------------ */
/* Big preview on the left; the filmstrip of frames and the controls on the right. */

.animator {
  display: grid;
  grid-template-columns: 400px 1fr;
  gap: 24px 48px;
  align-items: center;
}

.anim-preview { height: 420px; }

.anim-sprite {
  position: absolute;
  left: 50%;
  bottom: var(--ground);
  width: 200px;
  margin-left: -100px;
}

.anim-badge {
  position: absolute;
  top: 18px;
  left: 18px;
  z-index: 1;
  padding: 4px 18px;
  font-family: var(--mono);
  font-size: 24px;
  color: var(--text);
  background: var(--ink);
  border-radius: 999px;
}

.anim-side {
  display: flex;
  flex-direction: column;
  gap: 28px;
  min-width: 0;
}

.filmstrip {
  display: flex;
  gap: 12px;
  padding: 20px;
  background: #050A14;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 22px;
}

.frame-tile {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 4px 8px;
  font: inherit;
  font-size: 20px;
  font-weight: 600;
  color: var(--ink);
  background: linear-gradient(#8FD0FF, #D6F1FF);
  border: 0;
  border-radius: 14px;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.frame-tile .sprite { width: 76%; }

.frame-tile.is-on {
  transform: translateY(-10px);
  box-shadow: 0 0 0 5px var(--warn), 0 16px 30px rgba(0, 0, 0, 0.5);
}

.frame-tile:focus-visible { outline: 3px solid var(--primary-light); outline-offset: 3px; }

.anim-controls {
  display: flex;
  align-items: center;
  gap: 36px;
  font-size: 28px;
  color: var(--text);
}

.anim-play {
  min-width: 180px;
  padding: 12px 28px;
  font: inherit;
  font-weight: 600;
  color: var(--text);
  background: var(--primary);
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s;
}

.anim-play:hover { background: var(--primary-light); }
.anim-play:focus-visible { outline: 3px solid var(--primary-light); outline-offset: 3px; }

.anim-speed {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 18px;
}

.anim-speed output {
  min-width: 1.4em;
  font-family: var(--mono);
  text-align: right;
  color: var(--good);
}

.anim-speed small {
  font-size: 22px;
  white-space: nowrap;
  color: var(--muted);
}

/* ---- Objects (slide 3) --------------------------------------------------- */
/* The three kinds of object on the left; the same things in a game on the right. */

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

.objects .stack { gap: 22px; }
.objects .card { padding: 26px 34px; }
.objects .card p { font-size: 28px; }
.objects .emoji { width: 104px; font-size: 76px; text-align: center; }

.object-scene {
  height: 500px;
  --ground: 64px;
}

/* A sprite standing on the ground with its name above it */
.actor {
  position: absolute;
  bottom: var(--ground);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.actor .sprite { width: 150px; }

.tag--sky {
  position: absolute;
  top: 110px;
  left: 50%;
  margin-left: -130px;
}

/* The outline and label that point out the whole layout */
.layout-mark {
  position: absolute;
  inset: 0;
  border: 8px dashed var(--warn);
  border-radius: inherit;
  transform: none;
}

.layout-mark .tag {
  position: absolute;
  top: 18px;
  left: 18px;
  color: var(--ink);
  background: var(--warn);
}

/* ---- Properties (slide 4) ------------------------------------------------ */
/* The Properties panel on the left changes the sprite on the right. */

.props-demo {
  display: grid;
  grid-template-columns: 1fr 760px;
  gap: 24px 48px;
  align-items: stretch;
}

.prop {
  display: grid;
  grid-template-columns: 150px 1fr 76px;
  align-items: center;
  gap: 20px;
  min-height: 68px;
  padding: 0 16px;
  font-size: 30px;
  color: var(--text);
  border-radius: 12px;
  transition: background 0.25s, box-shadow 0.25s;
}

.prop.is-active {
  background: rgba(255, 200, 87, 0.12);
  box-shadow: inset 0 0 0 2px var(--warn);
}

.prop output,
.prop b {
  font-family: var(--mono);
  font-weight: 500;
  text-align: right;
  color: var(--good);
}

.prop b,
.swatches { grid-column: 2 / -1; }

.swatches {
  display: flex;
  justify-content: flex-end;
  gap: 14px;
}

.swatch {
  width: 46px;
  height: 46px;
  padding: 0;
  border: 3px solid rgba(255, 255, 255, 0.25);
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}

.swatch.is-on {
  transform: scale(1.12);
  box-shadow: 0 0 0 4px var(--bg), 0 0 0 7px var(--primary-light);
}

.swatch:focus-visible { outline: 3px solid var(--primary-light); outline-offset: 4px; }

.prop-stage { min-height: 420px; }

/* A box exactly the size of the sprite. --w, --h and --angle are set by script.js.
   The sprite turns inside it, so the size labels stay the right way up. */
.prop-box {
  position: absolute;
  left: 50%;
  top: 46%;
  width: calc(var(--w) * 1.5px);
  height: calc(var(--h) * 1.5px);
  transform: translate(-50%, -50%);
  transition: width 0.6s cubic-bezier(0.2, 0.7, 0.2, 1), height 0.6s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.prop-box .sprite {
  position: absolute;
  inset: 0;
  transform: rotate(calc(var(--angle) * 1deg));
  transition: transform 0.6s cubic-bezier(0.2, 0.7, 0.2, 1);
}

/* The width and height of the sprite, written along its edges */
.dim {
  position: absolute;
  font-family: var(--mono);
  font-size: 22px;
  line-height: 1;
  text-align: center;
  color: var(--primary);
}

.dim--w {
  left: 0;
  right: 0;
  top: calc(100% + 14px);
  padding-top: 10px;
  border-top: 3px solid var(--primary);
}

.dim--h {
  top: 0;
  bottom: 0;
  right: calc(100% + 14px);
  display: grid;
  place-items: center;
  padding-right: 10px;
  border-right: 3px solid var(--primary);
}

.props-demo.is-live .prop-box,
.props-demo.is-live .prop-box .sprite { transition: none; }

/* ---- Event (slide 5) ----------------------------------------------------- */
/* The events on the left, and a tiny game that obeys them on the right. */

.events-demo {
  display: grid;
  grid-template-columns: 1fr 640px;
  gap: 24px 48px;
  align-items: center;
}

.rules {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* One event:  [ WHEN … ]  ▶  [ DO … ] */
.rule {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: stretch;
  gap: 20px;
  border-radius: 22px;
}

.rule-when,
.rule-do {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 18px 28px 20px;
  font-size: 34px;
  line-height: 1.3;
  font-weight: 600;
  color: var(--text);
  border-radius: 22px;
  transition: box-shadow 0.3s;
}

.rule-when {
  background: rgba(140, 109, 245, 0.22);
  border: 1.5px solid rgba(140, 109, 245, 0.55);
}

.rule-do {
  background: rgba(195, 232, 141, 0.1);
  border: 1.5px solid rgba(195, 232, 141, 0.45);
}

.rule small {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.rule-arrow {
  align-self: center;
  font-size: 36px;
  line-height: 1;
  color: var(--primary-light);
}

/* The event that was just added */
.rule.is-new .rule-when,
.rule.is-new .rule-do { box-shadow: 0 0 0 4px var(--warn); }

/* "When something happens… do something": the pattern every event follows */
.rule--pattern .rule-when,
.rule--pattern .rule-do {
  font-style: italic;
  background: transparent;
  border: 2.5px dashed rgba(163, 170, 200, 0.6);
}

.game {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.game-view {
  height: 330px;
  --ground: 48px;
}

.game-view .sprite {
  position: absolute;
  bottom: var(--ground);
}

/* left is set by script.js; the negative margin puts the middle of the sprite there */
.game-hero { width: 80px; margin-left: -40px; }
.game-enemy { width: 90px; margin-left: -45px; }

.game-lives {
  position: absolute;
  top: 14px;
  left: 18px;
  font-size: 34px;
  letter-spacing: 4px;
}

.game-over {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 64px;
  font-weight: 800;
  color: var(--text);
  background: rgba(8, 15, 26, 0.65);
}

.game-keys {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 24px;
  color: var(--muted);
}

.game-keys span { margin-left: 10px; }

.key {
  width: 64px;
  height: 64px;
  font: inherit;
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  background: rgba(140, 109, 245, 0.2);
  border: 1.5px solid rgba(140, 109, 245, 0.55);
  border-bottom-width: 6px;
  border-radius: 14px;
  cursor: pointer;
  touch-action: none;
  transition: background 0.1s, transform 0.1s;
}

.key.is-down {
  background: var(--primary);
  transform: translateY(4px);
  border-bottom-width: 2px;
}

.key:focus-visible { outline: 3px solid var(--primary-light); outline-offset: 3px; }

/* ---- Sliders ------------------------------------------------------------- */

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 12px;
  margin: 0;
  background: rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 32px;
  height: 32px;
  background: var(--primary-light);
  border: 4px solid var(--text);
  border-radius: 50%;
}

input[type="range"]::-moz-range-thumb {
  width: 24px;
  height: 24px;
  background: var(--primary-light);
  border: 4px solid var(--text);
  border-radius: 50%;
}

input[type="range"]:focus-visible { outline: 3px solid var(--primary-light); outline-offset: 6px; }

/* ---- 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, [data-from] { transform: none; transition: opacity 0.2s; }
  .prop-box, .prop-box .sprite { transition: none; }
}
