/* ==========================================================================
   Roblox Game Dev — 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 */

  /* The three axes. Roblox colours them the same way. */
  --axis-x: #FF5A5A;
  --axis-y: #5FE07A;
  --axis-z: #5AA9FF;

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

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

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

.hl { color: #C9B8FF !important; }

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

/* Dark box used for the Explorer and the Properties panel */
.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;
}

/* Small dark label in the corner of a scene */
.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;
}

/* ---- Scenes and 3D boxes ------------------------------------------------- */

/* A patch of sky to build the game world in. --u is how many px one stud is. */
.scene {
  --u: 56px;
  position: relative;
  overflow: hidden;
  border-radius: 22px;
  perspective: 2400px;
  background:
    radial-gradient(circle at 88% 16%, #FFF6C2 0 44px, rgba(255, 246, 194, 0.35) 46px 70px, transparent 72px),
    linear-gradient(#7CC8FF, #D6F1FF);
}

/* The camera: everything inside is seen from a little above and to one side.
   Its top-left corner is the middle of the ground. */
.world {
  position: absolute;
  left: 50%;
  top: 68%;
  width: 0;
  height: 0;
  transform-style: preserve-3d;
  transform: rotateX(-20deg) rotateY(-32deg);
}

/* One block. --w, --h, --d are its size and --x, --y, --z are where its middle
   is, all in studs. script.js adds the six sides. */
.box,
.decal {
  position: absolute;
  left: calc((var(--x, 0) - var(--w) / 2) * var(--u));
  top: calc((0 - var(--y, 0) - var(--h) / 2) * var(--u));
  width: calc(var(--w) * var(--u));
  height: calc(var(--h) * var(--u));
  transform: translateZ(calc(var(--z, 0) * var(--u)));
  transform-style: preserve-3d;
}

/* --tone makes each side a little lighter or darker, as if the sun is above.
   --skin is the pattern of the material, drawn over the colour. */
.side {
  position: absolute;
  backface-visibility: hidden;
  background:
    linear-gradient(var(--tone, transparent), var(--tone, transparent)),
    var(--skin, none),
    var(--color, #A3A2A5);
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.14);
  transition: opacity 0.3s, box-shadow 0.3s;
}

.side--front,
.side--back { inset: 0; }

.side--left,
.side--right {
  top: 0;
  bottom: 0;
  left: calc((var(--w) - var(--d)) / 2 * var(--u));
  width: calc(var(--d) * var(--u));
}

.side--top,
.side--bottom {
  left: 0;
  right: 0;
  top: calc((var(--h) - var(--d)) / 2 * var(--u));
  height: calc(var(--d) * var(--u));
}

.side--front  { --tone: rgba(0, 0, 0, 0.07);        transform: translateZ(calc(var(--d) / 2 * var(--u))); }
.side--back   { --tone: rgba(0, 0, 0, 0.3);         transform: rotateY(180deg) translateZ(calc(var(--d) / 2 * var(--u))); }
.side--right  { --tone: rgba(0, 0, 0, 0.24);        transform: rotateY(90deg) translateZ(calc(var(--w) / 2 * var(--u))); }
.side--left   { --tone: rgba(0, 0, 0, 0.24);        transform: rotateY(-90deg) translateZ(calc(var(--w) / 2 * var(--u))); }
.side--top    { --tone: rgba(255, 255, 255, 0.18);  transform: rotateX(90deg) translateZ(calc(var(--h) / 2 * var(--u))); }
.side--bottom { --tone: rgba(0, 0, 0, 0.4);         transform: rotateX(-90deg) translateZ(calc(var(--h) / 2 * var(--u))); }

/* A grid on top, one square per stud, like a Roblox baseplate */
.box--studs > .side--top {
  --skin:
    linear-gradient(rgba(0, 0, 0, 0.13) 2px, transparent 2px) 0 0 / var(--u) var(--u),
    linear-gradient(90deg, rgba(0, 0, 0, 0.13) 2px, transparent 2px) 0 0 / var(--u) var(--u);
}

/* A flat picture stuck on the front of a box */
.decal { backface-visibility: hidden; transition: opacity 0.3s, box-shadow 0.3s; }

.face {
  background:
    radial-gradient(circle calc(var(--u) * 0.1) at 30% 38%, var(--ink) 96%, transparent),
    radial-gradient(circle calc(var(--u) * 0.1) at 70% 38%, var(--ink) 96%, transparent);
}

.face::after {
  content: '';
  position: absolute;
  left: 24%;
  right: 24%;
  top: 48%;
  height: 26%;
  border-bottom: calc(var(--u) * 0.1) solid var(--ink);
  border-radius: 0 0 50% 50% / 0 0 100% 100%;
}

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

/* ---- Object Orientation (slide 2) ---------------------------------------- */
/* The Explorer on the left lists every object in the game world on the right. */

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

.explorer { min-height: 560px; }

.tree,
.tree ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

/* The objects inside an object: hidden until it is opened, and set in from it */
.tree ul {
  display: none;
  margin-left: 19px;
  padding-left: 20px;
  border-left: 2px solid rgba(255, 255, 255, 0.12);
}

.tree li.is-open > ul { display: block; }

/* One row:  ▸ 🧱 Head            Part */
.node {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 46px;
  padding-right: 12px;
  font-size: 28px;
  border-radius: 12px;
  transition: background 0.25s, box-shadow 0.25s;
}

.twist {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  padding: 0;
  font: inherit;
  font-size: 24px;
  color: var(--muted);
  background: none;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.2s, background 0.2s;
}

/* The arrow itself: a little triangle pointing right */
.twist::before {
  content: '';
  display: inline-block;
  border: solid transparent;
  border-width: 8px 0 8px 12px;
  border-left-color: currentColor;
}

.twist:hover { background: rgba(140, 109, 245, 0.22); }
.twist:disabled { visibility: hidden; }
.tree li.is-open > .node .twist { transform: rotate(90deg); }

.node-name {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 100%;
  padding: 0;
  font: inherit;
  font-weight: 500;
  text-align: left;
  white-space: nowrap;
  color: var(--text);
  background: none;
  border: 0;
  cursor: pointer;
}

.node-icon {
  width: 34px;
  font-size: 26px;
  text-align: center;
}

.node small {
  font-family: var(--mono);
  font-size: 20px;
  color: var(--muted);
}

.twist:focus-visible,
.node-name:focus-visible { outline: 3px solid var(--primary-light); outline-offset: 2px; }

.tree li.is-picked > .node {
  background: rgba(255, 200, 87, 0.12);
  box-shadow: inset 0 0 0 2px var(--warn);
}

/* The rows that have just been uncovered */
.tree li.is-new > .node { animation: slide-in 0.45s cubic-bezier(0.2, 0.7, 0.2, 1) both; }

@keyframes slide-in {
  from { opacity: 0; transform: translateX(-18px); }
}

/* "parent" beside an object, and "child" beside each object inside it */
.tree li.is-parent > .node::after,
.tree li.is-parent > ul > li > .node::after {
  margin-left: 10px;
  padding: 2px 14px;
  font-size: 20px;
  font-weight: 600;
  border-radius: 999px;
}

.tree li.is-parent > .node::after {
  content: 'parent';
  color: var(--ink);
  background: var(--warn);
}

.tree li.is-parent > ul > li > .node::after {
  content: 'child';
  color: var(--text);
  background: var(--primary);
}

.world-scene { --u: 60px; }
.world-scene [data-object] { cursor: pointer; }

/* The objects that are picked get an outline; everything else fades back */
.is-picked > .side,
.decal.is-picked { box-shadow: inset 0 0 0 5px var(--warn); }

.is-dim > .side,
.decal.is-dim { opacity: 0.2; }

/* The outline round the whole world, for when the Workspace is picked */
.world-scene.is-all::after {
  content: '';
  position: absolute;
  inset: 0;
  border: 8px dashed var(--warn);
  border-radius: inherit;
  pointer-events: none;
}

/* ---- Properties (slide 3) ------------------------------------------------ */
/* The Properties panel on the left changes the part 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: 62px;
  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,
.materials,
.views { grid-column: 2 / -1; }

.swatches,
.materials,
.views {
  display: flex;
  justify-content: flex-end;
}

.swatches { gap: 14px; }
.materials,
.views { gap: 8px; }

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

.material,
.view {
  height: 46px;
  padding: 0 12px;
  font: inherit;
  font-size: 24px;
  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: 14px;
  cursor: pointer;
  transition: background 0.2s;
}

.material:hover,
.material.is-on,
.view:hover,
.view.is-on { background: var(--primary); }

.material.is-on,
.view.is-on { border-color: var(--text); }

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

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

.prop-stage .world { top: 72%; }

/* The part stands on the scales, so its middle is half its height off the ground.
   --w, --h, --d and --color are set by script.js. */
.part { --y: calc(var(--h) / 2); }

.part,
.part > .side,
.mover,
.mover > .side {
  transition:
    left 0.6s cubic-bezier(0.2, 0.7, 0.2, 1),
    top 0.6s cubic-bezier(0.2, 0.7, 0.2, 1),
    width 0.6s cubic-bezier(0.2, 0.7, 0.2, 1),
    height 0.6s cubic-bezier(0.2, 0.7, 0.2, 1),
    transform 0.6s cubic-bezier(0.2, 0.7, 0.2, 1),
    background-color 0.4s;
}

.props-demo.is-live .part,
.props-demo.is-live .part > .side { transition: none; }

/* Materials: each one is a see-through pattern, so the colour still shows.
   Plastic is plain. To add a material, add its button in index.html, its
   weight in script.js and its pattern here. */
.part[data-material="Wood"] {
  --skin: repeating-linear-gradient(0deg,
    transparent 0 14px, rgba(0, 0, 0, 0.16) 14px 17px,
    transparent 17px 27px, rgba(0, 0, 0, 0.09) 27px 29px,
    transparent 29px 44px, rgba(255, 255, 255, 0.12) 44px 46px);
}

.part[data-material="Brick"] {
  --skin: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='50' height='50'%3E%3Cpath d='M0 1.5h50M0 26.5h50M12 1.5v25M37 26.5v25' stroke='%23fff' stroke-opacity='.5' stroke-width='3' fill='none'/%3E%3C/svg%3E") 0 0 / var(--u) var(--u);
}

.part[data-material="Metal"] {
  --skin:
    linear-gradient(120deg, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0) 28%, rgba(0, 0, 0, 0.2) 55%, rgba(255, 255, 255, 0.32) 82%, rgba(255, 255, 255, 0) 100%),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.08) 0 2px, transparent 2px 5px);
}

/* Neon glows, and is the same brightness on every side */
.part[data-material="Neon"] > .side {
  --tone: rgba(255, 255, 255, 0.22);
  box-shadow: 0 0 60px var(--color), inset 0 0 0 2px rgba(255, 255, 255, 0.3);
}

/* ---- From 2D to 3D (slide 4) --------------------------------------------- */
/* The Position panel on the left moves the part along the axes on the right. */

.axes-demo {
  display: grid;
  grid-template-columns: 600px 1fr;
  gap: 24px 48px;
  align-items: stretch;

  /* The camera. It starts close up and straight in front, so the world looks flat. */
  --tilt: 0deg;
  --turn: 0deg;
  --zoom: 1.3;

  /* Where the part is, in grid squares. Set by script.js. */
  --px: 0;
  --py: 0;
  --pz: 0;
}

/* Turned to look from above and to one side, like the other scenes */
.axes-demo[data-camera="3d"] {
  --tilt: -20deg;
  --turn: -32deg;
  --zoom: 1;
}

/* Anything with data-axis takes that axis's colour */
[data-axis="x"] { --axis: var(--axis-x); }
[data-axis="y"] { --axis: var(--axis-y); }
[data-axis="z"] { --axis: var(--axis-z); }

.axes-demo .prop {
  grid-template-columns: 230px 1fr 48px;
  min-height: 78px;
  transition: background 0.25s, box-shadow 0.25s, opacity 0.4s;
}

/* An axis that hasn't been drawn yet */
.prop.is-locked { opacity: 0.35; }

.prop[data-axis] output,
.prop-position span,
.tag span { color: var(--axis); }

.prop[data-axis] input::-webkit-slider-thumb { background: var(--axis); }
.prop[data-axis] input::-moz-range-thumb { background: var(--axis); }

.view { min-width: 84px; }

/* The name of a row:  (X) left · right */
.axis-name {
  display: flex;
  align-items: center;
  gap: 14px;
}

.axis-name small {
  font-size: 20px;
  white-space: nowrap;
  color: var(--muted);
}

.dot,
.chip {
  display: grid;
  place-items: center;
  font-weight: 700;
  color: var(--ink);
  background: var(--axis);
  border-radius: 50%;
}

.dot {
  flex-shrink: 0;
  width: 46px;
  height: 46px;
  font-size: 26px;
}

/* Graph paper instead of sky */
.axes-scene {
  --u: 50px;
  min-height: 540px;
  background:
    radial-gradient(720px 440px at 50% 62%, rgba(92, 72, 231, 0.24), transparent 70%),
    #070C18;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.axes-scene .badge {
  padding: 4px 22px;
  font-size: 30px;
  background: var(--primary);
}

/* The corner where the axes meet. It moves over when the camera turns, to keep
   everything in the picture. */
.axes-scene .world {
  left: 29%;
  top: 83%;
  transform: scale(var(--zoom)) rotateX(var(--tilt)) rotateY(var(--turn));
  transition: left 1.2s ease-in-out, top 1.2s ease-in-out, transform 1.2s ease-in-out;
}

.axes-demo[data-camera="3d"] .world {
  left: 46%;
  top: 60%;
}

/* With negative numbers on, the corner moves to the middle and the camera backs
   away, to fit in the minus half of every axis. */
.axes-demo.is-negative { --zoom: 0.95; }
.axes-demo.is-negative[data-camera="3d"] { --zoom: 0.72; }

.axes-demo.is-negative .world {
  left: 50%;
  top: 55%;
}

.axes-demo.is-negative[data-camera="3d"] .world { top: 50%; }

/* One grid square per stud. The wall stands up behind the X and Y axes, and the
   floor lies down between the X and Z axes. Both sit a hair behind the axes.
   Each grid reaches just as far on the minus side of the axes too, but that
   part is cut off (clip-path) until negative numbers are switched on. */
.grid {
  --line: rgba(190, 199, 236, 0.2);
  position: absolute;
  left: calc(var(--w) * var(--u) * -1);
  width: calc(var(--w) * var(--u) * 2);
  background:
    linear-gradient(var(--line) 2px, transparent 2px) 0 0 / var(--u) var(--u),
    linear-gradient(90deg, var(--line) 2px, transparent 2px) 0 0 / var(--u) var(--u),
    rgba(140, 109, 245, 0.07);
  border: solid var(--line);
  border-width: 0 2px 2px 0;
  transition: opacity 0.6s, clip-path 0.8s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.grid--wall {
  top: calc(var(--h) * var(--u) * -1);
  height: calc(var(--h) * var(--u) * 2);
  transform: translateZ(calc(var(--u) * -0.07));
  clip-path: inset(0 0 calc(50% - 2px) 50%);
}

.grid--floor {
  top: calc(var(--u) * 0.07);
  height: calc(var(--d) * var(--u) * 2);
  transform-origin: top;
  transform: translateZ(calc(var(--d) * var(--u) * -1)) rotateX(90deg);
  clip-path: inset(50% 0 0 50%);
}

.axes-demo.is-negative .grid { clip-path: inset(0); }

/* A flat world has no floor */
.axes-demo.is-flat .grid--floor,
.axes-demo.is-flat .shadow { opacity: 0; }

/* An axis is a long thin box: index.html says how long it is and where its
   middle is. It grows out of the corner when it is drawn. */
.axis {
  --w: 0.12;
  --h: 0.12;
  --d: 0.12;
  --color: var(--axis);
  transition: scale 0.8s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.axis > .side { box-shadow: none; }

.axis[data-axis="x"] { transform-origin: left; }
.axis[data-axis="y"] { transform-origin: bottom; }

/* The minus half of an axis grows out of the corner the other way */
.axis--minus[data-axis="x"] { transform-origin: right; }
.axis--minus[data-axis="y"] { transform-origin: top; }

.axis[data-axis="x"]:not(.is-on) { scale: 0 1 1; }
.axis[data-axis="y"]:not(.is-on) { scale: 1 0 1; }
.axis[data-axis="z"]:not(.is-on) { scale: 1 1 0; }

/* The letter at the end of an axis. It rides out on the tip as the axis grows,
   and turns against the camera so that it always faces you. */
.chip {
  position: absolute;
  left: 0;
  top: 0;
  width: 50px;
  height: 50px;
  margin: -25px;
  font-size: 28px;
  transform:
    translate3d(calc(var(--x, 0) * var(--u)), calc(var(--y, 0) * -1 * var(--u)), calc(var(--z, 0) * var(--u)))
    rotateY(calc(var(--turn) * -1)) rotateX(calc(var(--tilt) * -1));
  scale: 0;
  transition:
    transform 1.2s ease-in-out,
    scale 0.8s cubic-bezier(0.2, 0.7, 0.2, 1),
    box-shadow 0.3s;
}

.chip.is-on { scale: 1; }
.chip.is-active { box-shadow: 0 0 0 6px rgba(255, 255, 255, 0.35); }

/* The part: one grid square big, and --px, --py, --pz squares away from the corner */
.mover {
  --w: 1;
  --h: 1;
  --d: 1;
  --x: calc(var(--px) + 0.5);
  --y: calc(var(--py) + 0.5);
  --z: calc(var(--pz) + var(--d) / 2);
  --color: #FFD23F;
}

.axes-demo.is-flat .mover { --d: 0; }

/* Where the part is, floating above it. It always faces you too. */
.tag {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 22px);
  display: flex;
  gap: 12px;
  padding: 3px 14px;
  font-family: var(--mono);
  font-size: 24px;
  white-space: nowrap;
  background: var(--ink);
  border: 2px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  transform:
    translateX(-50%) translateZ(calc(var(--u) * 0.6))
    rotateY(calc(var(--turn) * -1)) rotateX(calc(var(--tilt) * -1));
  transition: transform 1.2s ease-in-out;
}

/* The part's shadow on the floor, to show how far forward and how high it is */
.shadow {
  position: absolute;
  left: calc(var(--px) * var(--u));
  top: calc(var(--u) * 0.03);
  width: var(--u);
  height: var(--u);
  background: rgba(0, 0, 0, 0.5);
  border-radius: 6px;
  transform-origin: top;
  transform: translateZ(calc(var(--pz) * var(--u))) rotateX(90deg);
  transition:
    left 0.6s cubic-bezier(0.2, 0.7, 0.2, 1),
    transform 0.6s cubic-bezier(0.2, 0.7, 0.2, 1),
    opacity 0.6s;
}

/* When an axis has just been drawn, the part wiggles along it to show which way it goes */
.axes-demo[data-wiggle="x"] :is(.mover, .shadow) { animation: wiggle-x 1.5s 0.7s ease-in-out; }
.axes-demo[data-wiggle="y"] .mover { animation: wiggle-y 1.5s 0.7s ease-in-out; }
.axes-demo[data-wiggle="z"] :is(.mover, .shadow) { animation: wiggle-z 1.5s 0.7s ease-in-out; }

@keyframes wiggle-x {
  30% { translate: calc(var(--u) * 2) 0; }
  60% { translate: 0 0; }
  80% { translate: var(--u) 0; }
}

@keyframes wiggle-y {
  30% { translate: 0 calc(var(--u) * -2); }
  60% { translate: 0 0; }
  80% { translate: 0 calc(var(--u) * -1); }
}

@keyframes wiggle-z {
  30% { translate: 0 0 calc(var(--u) * 2); }
  60% { translate: 0 0 0; }
  80% { translate: 0 0 var(--u); }
}

/* Dragging a slider, or pressing Back: nothing is animated */
.axes-demo.is-live .scene * { transition: none; }

/* ---- 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 { transform: none; transition: opacity 0.2s; }
  .tree li.is-new > .node { animation: none; }
  .part, .part > .side { transition: none; }
  .axes-scene * { transition: none; animation: none; }
}
