@property --motion-x {
  syntax: "<length>";
  inherits: false;
  initial-value: 0px;
}

@property --motion-y {
  syntax: "<length>";
  inherits: false;
  initial-value: 0px;
}

@property --shape-x {
  syntax: "<number>";
  inherits: false;
  initial-value: 1;
}

@property --shape-y {
  syntax: "<number>";
  inherits: false;
  initial-value: 1;
}

:root {
  --paper: #f3efe6;
  --surface: #fffdf8;
  --surface-strong: #ffffff;
  --ink: #17201d;
  --muted: #68716d;
  --line: rgb(23 32 29 / 14%);
  --green: #0e9f76;
  --green-dark: #087357;
  --green-soft: #dff5ec;
  --blue: #3978f2;
  --blue-dark: #2457b8;
  --blue-soft: #e5edff;
  --coral: #f06f52;
  --coral-dark: #a9402d;
  --coral-soft: #ffe3da;
  --yellow: #f1c64d;
  --shadow: 0 26px 72px rgb(43 39 31 / 12%);
  color-scheme: light;
  font-family: "Avenir Next", "Hiragino Sans", "Yu Gothic", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 3% 3%, rgb(57 120 242 / 14%), transparent 31rem),
    radial-gradient(circle at 97% 4%, rgb(240 111 82 / 18%), transparent 34rem),
    linear-gradient(135deg, #eef3ee, var(--paper) 54%, #ece2d7);
}

button,
input {
  color: inherit;
  font: inherit;
}

button {
  cursor: pointer;
}

code,
pre {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

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

.page {
  width: min(1480px, calc(100% - 48px));
  margin: 0 auto;
  padding: 32px 0 48px;
}

.hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
  margin-bottom: 22px;
}

.hero-copy {
  min-width: 0;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 11px;
  color: var(--green-dark);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.14em;
}

.eyebrow::before {
  width: 18px;
  height: 9px;
  border: solid var(--green);
  border-width: 3px 0;
  border-radius: 50%;
  content: "";
  transform: rotate(-18deg);
}

h1 {
  font-size: clamp(42px, 5.3vw, 76px);
  line-height: 1;
}

.lead {
  margin-top: 12px;
  color: var(--muted);
  font-size: clamp(15px, 1.4vw, 19px);
  font-weight: 800;
  line-height: 1.65;
}

.lead code {
  color: var(--green-dark);
}

.hero-actions,
.preview-actions,
.preview-head,
.preview-head > div:first-child,
.panel-head > div,
.code-head,
.code-head > div:first-child {
  display: flex;
  align-items: center;
}

.hero-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 9px;
}

.support-chip {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 0 13px;
  border: 1px solid rgb(14 159 118 / 28%);
  border-radius: 12px;
  color: var(--green-dark);
  background: var(--green-soft);
  font-size: 10px;
  font-weight: 900;
}

.support-chip.is-unsupported {
  color: var(--coral-dark);
  border-color: rgb(240 111 82 / 30%);
  background: var(--coral-soft);
}

.button,
.replay-button {
  min-height: 44px;
  padding: 0 15px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  font-size: 10px;
  font-weight: 900;
}

.button {
  transition:
    border-color 160ms ease,
    transform 160ms ease;
}

.button:hover {
  border-color: rgb(23 32 29 / 34%);
  transform: translateY(-2px);
}

.button--dark {
  color: white;
  border-color: var(--ink);
  background: var(--ink);
}

.button--copy {
  color: white;
  border-color: var(--coral);
  background: var(--coral);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(360px, 0.72fr) minmax(0, 1.28fr);
  gap: 16px;
  align-items: start;
}

.control-panel,
.preview-panel,
.code-panel {
  border: 1px solid var(--line);
  border-radius: 26px;
  background: rgb(255 253 248 / 92%);
  box-shadow: var(--shadow);
}

.control-panel {
  position: sticky;
  top: 14px;
  overflow: hidden;
}

.panel-head,
.preview-head,
.code-head {
  justify-content: space-between;
  gap: 18px;
  padding: 19px 20px;
  border-bottom: 1px solid var(--line);
}

.panel-head > div,
.preview-head > div:first-child,
.code-head > div:first-child {
  gap: 11px;
}

.panel-head p,
.preview-head p,
.code-head p {
  color: var(--green-dark);
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 0.13em;
}

.preview-head p {
  color: var(--blue-dark);
}

.code-head p {
  color: var(--coral-dark);
}

.panel-head h2,
.preview-head h2,
.code-head h2 {
  margin-top: 2px;
  font-size: 20px;
  line-height: 1.2;
}

.section-number {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 39px;
  height: 39px;
  border-radius: 12px;
  color: white;
  background: var(--green);
  font-size: 10px;
  font-weight: 900;
}

.section-number--blue {
  background: var(--blue);
}

.section-number--coral {
  background: var(--coral);
}

.control-section {
  padding: 17px 20px;
  border-bottom: 1px solid var(--line);
}

.control-section:last-child {
  border-bottom: 0;
}

.control-title {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.control-title span {
  color: var(--green-dark);
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.control-title h3 {
  margin-top: 3px;
  font-size: 15px;
}

.control-title output {
  color: var(--green-dark);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 9px;
  font-weight: 900;
}

.segmented {
  position: relative;
  display: flex;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgb(23 32 29 / 4%);
}

.segmented button {
  position: relative;
  z-index: 1;
  min-height: 37px;
  padding: 0 12px;
  border: 0;
  border-radius: 9px;
  color: var(--muted);
  background: transparent;
  font-size: 9px;
  font-weight: 900;
}

.segmented button[aria-pressed="true"] {
  color: var(--ink);
  background: white;
  box-shadow: 0 4px 14px rgb(23 32 29 / 10%);
}

.pattern-switch button {
  flex: 1;
}

@supports (anchor-name: --selected-option) {
  .segmented::before {
    position: absolute;
    z-index: 0;
    top: anchor(top);
    left: anchor(left);
    width: anchor-size(width);
    height: anchor-size(height);
    border-radius: 9px;
    background: white;
    box-shadow: 0 4px 14px rgb(23 32 29 / 10%);
    content: "";
    pointer-events: none;
    transition:
      top 250ms cubic-bezier(0.22, 1, 0.36, 1),
      left 250ms cubic-bezier(0.22, 1, 0.36, 1),
      width 250ms cubic-bezier(0.22, 1, 0.36, 1),
      height 250ms cubic-bezier(0.22, 1, 0.36, 1);
  }

  .pattern-switch button[aria-pressed="true"] {
    anchor-name: --pattern-selected;
  }

  .pattern-switch::before {
    position-anchor: --pattern-selected;
  }

  .speed-switch button[aria-pressed="true"] {
    anchor-name: --speed-selected;
  }

  .speed-switch::before {
    position-anchor: --speed-selected;
  }

  .code-switch button[aria-pressed="true"] {
    anchor-name: --code-selected;
  }

  .code-switch::before {
    position-anchor: --code-selected;
  }

  .segmented button[aria-pressed="true"] {
    background: transparent;
    box-shadow: none;
  }
}

.preset-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
}

.preset-grid button {
  display: grid;
  place-items: center;
  gap: 6px;
  min-width: 0;
  min-height: 72px;
  padding: 8px 4px;
  border: 1px solid var(--line);
  border-radius: 13px;
  color: var(--muted);
  background: white;
  font-size: 8px;
  font-weight: 900;
}

.preset-grid button[aria-pressed="true"] {
  color: var(--green-dark);
  border-color: var(--green);
  background: var(--green-soft);
  box-shadow: 0 0 0 2px rgb(14 159 118 / 10%);
}

.preset-shape {
  display: block;
  width: 32px;
  height: 32px;
  border: 2px solid currentColor;
  border-radius: 50%;
  background: rgb(14 159 118 / 10%);
}

.preset-shape--soft {
  scale: 1.08 0.92;
}

.preset-shape--mochi {
  border-radius: 58% 22% 22% 58% / 50% 28% 28% 50%;
  scale: 0.84 1.16;
}

.preset-shape--rubber {
  scale: 1.25 0.75;
}

.preset-shape--snappy {
  border-radius: 38%;
  scale: 1.08 0.92;
}

.range-stack {
  display: grid;
  gap: 15px;
}

.range-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 13px;
}

.range-field {
  display: grid;
  gap: 7px;
}

.range-field[hidden] {
  display: none;
}

.range-field > span {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.range-field b {
  font-size: 11px;
}

.range-field output {
  color: var(--green-dark);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 9px;
  font-weight: 900;
}

.range-field small {
  color: var(--muted);
  font-size: 8px;
  font-weight: 700;
  line-height: 1.4;
}

input[type="range"] {
  width: 100%;
  height: 5px;
  margin: 4px 0;
  border-radius: 999px;
  outline: none;
  background:
    linear-gradient(var(--green), var(--green)) 0 / var(--range-progress, 50%) 100% no-repeat,
    rgb(23 32 29 / 11%);
  appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
  width: 17px;
  height: 17px;
  border: 3px solid white;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 2px 8px rgb(23 32 29 / 24%);
  appearance: none;
}

input[type="range"]::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border: 3px solid white;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 2px 8px rgb(23 32 29 / 24%);
}

.switches {
  display: grid;
  gap: 9px;
}

.switch-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 13px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: white;
  cursor: pointer;
}

.switch-field span {
  display: grid;
  gap: 3px;
}

.switch-field b {
  font-size: 10px;
}

.switch-field small {
  color: var(--muted);
  font-size: 8px;
  font-weight: 700;
}

.switch-field input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch-field > i {
  position: relative;
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background: rgb(23 32 29 / 14%);
  transition: background-color 180ms ease;
}

.switch-field > i::after {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 2px 7px rgb(23 32 29 / 22%);
  content: "";
  transition: translate 220ms cubic-bezier(0.22, 1, 0.36, 1);
}

.switch-field input:checked + i {
  background: var(--green);
}

.switch-field input:checked + i::after {
  translate: 18px 0;
}

.result-column {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.preview-panel,
.code-panel {
  min-width: 0;
  overflow: hidden;
}

.preview-actions {
  gap: 8px;
}

.speed-switch button {
  min-width: 44px;
}

.replay-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: white;
  border-color: var(--ink);
  background: var(--ink);
}

.replay-button span {
  font-size: 16px;
}

.motion-stage {
  position: relative;
  height: 330px;
  margin: 16px 18px 12px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background:
    linear-gradient(rgb(23 32 29 / 5%) 1px, transparent 1px),
    linear-gradient(90deg, rgb(23 32 29 / 5%) 1px, transparent 1px),
    rgb(255 255 255 / 72%);
  background-size: 24px 24px;
  overflow: hidden;
}

.motion-stage--drop,
.motion-stage--combined {
  height: 516px;
}

.stage-grid {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 50% 50%, rgb(57 120 242 / 8%), transparent 45%),
    linear-gradient(135deg, transparent 48%, rgb(57 120 242 / 4%) 48% 52%, transparent 52%);
  pointer-events: none;
}

.target-surface,
.travel-line {
  position: absolute;
  z-index: 0;
  display: block;
}

.motion-stage--horizontal .target-surface {
  top: 38px;
  right: 48px;
  bottom: 38px;
  width: 5px;
  border-radius: 999px;
  background: var(--ink);
  box-shadow: 9px 0 0 rgb(23 32 29 / 8%);
}

.motion-stage--horizontal .travel-line {
  top: 50%;
  right: 48px;
  left: 34px;
  height: 2px;
  background: linear-gradient(90deg, rgb(23 32 29 / 10%), rgb(23 32 29 / 20%));
}

.motion-stage--drop .target-surface {
  right: 48px;
  bottom: 38px;
  left: 48px;
  height: 5px;
  border-radius: 999px;
  background: var(--ink);
  box-shadow: 0 9px 0 rgb(23 32 29 / 8%);
}

.motion-stage--drop .travel-line {
  top: 36px;
  bottom: 38px;
  left: 50%;
  width: 2px;
  background: linear-gradient(rgb(23 32 29 / 10%), rgb(23 32 29 / 20%));
}

.motion-stage--combined .target-surface {
  right: 48px;
  bottom: 38px;
  left: 34px;
  height: 5px;
  border-radius: 999px;
  background: var(--ink);
  box-shadow: 0 9px 0 rgb(23 32 29 / 8%);
}

.motion-stage--combined .target-surface::after {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 5px;
  height: 48px;
  border-radius: 999px;
  background: var(--ink);
  content: "";
}

.motion-stage--combined .travel-line {
  top: 36px;
  bottom: 38px;
  left: 34px;
  width: 36%;
  border-bottom: 2px dashed rgb(23 32 29 / 16%);
  border-radius: 0 0 72% 0;
  transform: skewX(-8deg);
  transform-origin: left bottom;
}

.stage-label {
  position: absolute;
  z-index: 2;
  color: var(--muted);
  font-size: 7px;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.motion-stage--horizontal .stage-label--start {
  bottom: 18px;
  left: 34px;
}

.motion-stage--horizontal .stage-label--target {
  right: 48px;
  bottom: 18px;
}

.motion-stage--drop .stage-label--start {
  top: 18px;
  left: calc(50% + 50px);
}

.motion-stage--drop .stage-label--target {
  right: 20px;
  bottom: 38px;
}

.motion-stage--combined .stage-label--start {
  top: 18px;
  left: 34px;
}

.motion-stage--combined .stage-label--target {
  right: 48px;
  bottom: 18px;
}

.motion-object {
  --motion-x: 0px;
  --motion-y: 0px;
  position: absolute;
  z-index: 3;
  width: 82px;
  height: 82px;
  will-change: translate;
}

.motion-stage--horizontal .motion-object {
  top: 50%;
  left: 34px;
  translate: var(--motion-x) -50%;
}

.motion-stage--drop .motion-object {
  top: 36px;
  left: 50%;
  translate: -50% var(--motion-y);
}

.motion-stage--combined .motion-object {
  top: 36px;
  left: 34px;
  translate: var(--motion-x) var(--motion-y);
}

.motion-shape {
  --shape-x: 1;
  --shape-y: 1;
  display: grid;
  place-items: center;
  width: 82px;
  height: 82px;
  border: 4px solid var(--ink);
  border-radius: 50%;
  color: white;
  background: var(--coral);
  box-shadow: 9px 11px 0 rgb(23 32 29 / 13%);
  scale: var(--shape-x) var(--shape-y);
  will-change: scale, border-radius;
}

.motion-stage--horizontal .motion-shape {
  transform-origin: right center;
}

.motion-stage--drop .motion-shape,
.motion-stage--combined .motion-shape {
  transform-origin: center bottom;
}

.motion-shape span {
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 0.09em;
}

.motion-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 9px;
  padding: 0 18px 14px;
}

.motion-summary article {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 3px 10px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: white;
}

.motion-summary span {
  color: var(--blue-dark);
  font-size: 7px;
  font-weight: 900;
  letter-spacing: 0.1em;
}

.motion-summary strong {
  grid-row: 1 / 3;
  grid-column: 2;
  align-self: center;
  font-size: 17px;
}

.motion-summary small {
  color: var(--muted);
  font-size: 8px;
  font-weight: 700;
}

.curve-panel {
  margin: 0 18px 18px;
  padding: 13px 14px 10px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #121a17;
}

.curve-panel header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 8px;
}

.curve-panel header span {
  color: #7cb8ff;
  font-size: 7px;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.curve-panel h3 {
  margin-top: 2px;
  color: white;
  font-size: 13px;
}

.curve-legend {
  display: flex;
  align-items: center;
  gap: 6px;
  color: rgb(255 255 255 / 60%);
  font-size: 8px;
  font-weight: 800;
}

.curve-legend i,
.curve-legend b {
  display: block;
  width: 18px;
  height: 3px;
  border-radius: 999px;
  background: var(--coral);
}

.curve-legend b {
  margin-left: 5px;
  background: var(--blue);
}

#curveCanvas {
  display: block;
  width: 100%;
  height: 118px;
}

.code-panel {
  background: #111814;
}

.code-head {
  border-bottom-color: rgb(255 255 255 / 12%);
}

.code-head h2 {
  color: white;
}

.code-switch {
  margin: 14px 18px 0;
  border-color: rgb(255 255 255 / 12%);
  background: rgb(255 255 255 / 7%);
}

.code-switch button {
  flex: 1;
  color: rgb(255 255 255 / 56%);
}

.code-switch button[aria-pressed="true"] {
  color: var(--ink);
}

.code-panel pre {
  max-height: 420px;
  margin: 12px 18px 0;
  padding: 16px;
  border: 1px solid rgb(255 255 255 / 10%);
  border-radius: 15px;
  overflow: auto;
  color: #eaf3ee;
  background: #080d0b;
  font-size: 10px;
  line-height: 1.65;
  tab-size: 2;
}

.code-panel footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 48px;
  padding: 9px 18px 14px;
}

.code-panel footer p {
  color: rgb(255 255 255 / 54%);
  font-size: 8px;
  font-weight: 700;
  line-height: 1.5;
}

.copy-status {
  color: #80dfbe !important;
  font-weight: 900 !important;
  text-align: right;
}

.page-note {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 16px;
  padding: 15px 18px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: rgb(255 253 248 / 76%);
}

.page-note strong {
  color: var(--green-dark);
  font-size: 8px;
  letter-spacing: 0.12em;
}

.page-note p {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.page-note span {
  margin-left: auto;
  color: var(--green-dark);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 8px;
  font-weight: 900;
}

@media (max-width: 1100px) {
  .page {
    width: min(100% - 32px, 880px);
  }

  .hero {
    align-items: flex-start;
    flex-direction: column;
  }

  .hero-actions {
    justify-content: flex-start;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .control-panel {
    position: static;
  }
}

@media (max-width: 680px) {
  .page {
    width: min(100% - 22px, 520px);
    padding: 18px 0 32px;
  }

  h1 {
    font-size: clamp(38px, 11vw, 56px);
  }

  .hero-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }

  .support-chip {
    grid-column: 1 / -1;
  }

  .control-panel,
  .preview-panel,
  .code-panel {
    border-radius: 20px;
  }

  .panel-head,
  .preview-head,
  .code-head {
    align-items: flex-start;
    flex-direction: column;
    padding: 15px;
  }

  .preview-actions {
    width: 100%;
  }

  .speed-switch {
    flex: 1;
  }

  .speed-switch button,
  .replay-button {
    flex: 1;
  }

  .control-section {
    padding: 15px;
  }

  .preset-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .range-grid {
    grid-template-columns: 1fr;
  }

  .motion-stage {
    height: 280px;
    margin: 13px;
  }

  .motion-stage--drop,
  .motion-stage--combined {
    height: 460px;
  }

  .motion-object,
  .motion-shape {
    width: 68px;
    height: 68px;
  }

  .motion-stage--horizontal .target-surface {
    right: 32px;
  }

  .motion-stage--horizontal .travel-line {
    right: 32px;
    left: 24px;
  }

  .motion-stage--horizontal .motion-object {
    left: 24px;
  }

  .motion-stage--horizontal .stage-label--start {
    left: 24px;
  }

  .motion-stage--horizontal .stage-label--target {
    right: 32px;
  }

  .motion-stage--combined .target-surface {
    right: 32px;
    left: 24px;
  }

  .motion-stage--combined .travel-line,
  .motion-stage--combined .motion-object,
  .motion-stage--combined .stage-label--start {
    left: 24px;
  }

  .motion-stage--combined .stage-label--target {
    right: 32px;
  }

  .motion-summary {
    grid-template-columns: repeat(2, 1fr);
    padding: 0 13px 13px;
  }

  .curve-panel {
    margin: 0 13px 13px;
  }

  .curve-panel header {
    align-items: flex-start;
    flex-direction: column;
  }

  .code-switch {
    margin-inline: 13px;
  }

  .code-panel pre {
    margin-inline: 13px;
    font-size: 9px;
  }

  .code-panel footer {
    align-items: flex-start;
    flex-direction: column;
    padding-inline: 13px;
  }

  .page-note {
    align-items: flex-start;
    flex-direction: column;
  }

  .page-note span {
    margin-left: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }

  .motion-object,
  .motion-shape {
    animation-duration: 0.01ms !important;
  }
}
