html {
  scroll-behavior: smooth;
}
html,
body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #eee;
}
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

/* --- Recipe A: full-page fixed background (also the playground target) --- */
#bg {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: -1;
}

main {
  position: relative;
  z-index: 1;
  padding: 6vh 8vw;
  max-width: 640px;
}

h1 {
  font-size: 2.2rem;
  margin-top: 0;
}
p {
  line-height: 1.6;
  opacity: 0.9;
}

/* Each demo recipe lives in a full-viewport-tall .section; #section-nav + .scroll-cue mark "there's more below". */
.section {
  position: relative;
  min-height: 100vh;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
#hero-section {
  justify-content: space-between;
}

/* Full-width translucent band, not a boxed card, so it never competes with #playground-panel for a corner. */
.hero-band {
  width: 100%;
  max-width: none;
  box-sizing: border-box;
  margin: 0;
  padding: 4vh 8vw;
  background: rgba(10, 10, 15, 0.55);
  backdrop-filter: blur(6px);
  border-radius: 0 0 24px 24px;
}
.hero-band p {
  margin-bottom: 0;
}
/* Full-width band, but text itself stays at a readable line length. */
.hero-band h1,
.hero-band > p {
  max-width: 720px;
}

.feature-chips {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 14px 0 0;
  padding: 0;
}
.feature-chips li {
  font-size: 0.74rem;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  opacity: 0.9;
  white-space: nowrap;
}
.feature-chip-extra.is-hidden {
  display: none;
}
.features-toggle {
  margin-top: 7px;
  font-size: 0.74rem;
  padding: 5px 10px;
  border-radius: 999px;
  background: none;
  border: 1px dashed rgba(255, 255, 255, 0.3);
  color: inherit;
  opacity: 0.75;
  cursor: pointer;
}
.features-toggle:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.08);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}
.hero-actions button {
  font-size: 0.85rem;
  padding: 8px 16px;
}

.scroll-cue {
  align-self: center;
  margin-bottom: 5vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: inherit;
  text-decoration: none;
  font-size: 0.78rem;
  opacity: 0.75;
  transition: opacity 0.15s ease;
}
.scroll-cue:hover {
  opacity: 1;
}
.scroll-cue-arrow {
  font-size: 1.2rem;
  animation: scroll-cue-bounce 1.6s ease-in-out infinite;
}
@keyframes scroll-cue-bounce {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(6px);
  }
}
@media (prefers-reduced-motion: reduce) {
  .scroll-cue-arrow {
    animation: none;
  }
}

.section-intro {
  max-width: 640px;
  margin: 0 auto;
  padding: 6vh 8vw 0;
  text-align: center;
}

/* Deliberately empty: where the full-page background is meant to be seen with nothing on top. */
.spacer {
  height: 60vh;
}
.spacer-end {
  height: 20vh;
}

/* Fixed section nav: jump between the two demos. */
#section-nav {
  position: fixed;
  left: 20px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 15;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.section-nav-dot {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
}
.section-nav-dot::before {
  content: "";
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.5);
  background: rgba(255, 255, 255, 0.15);
  transition:
    background 0.15s ease,
    transform 0.15s ease;
}
.section-nav-dot.active::before {
  background: #eee;
  transform: scale(1.15);
}
.section-nav-label {
  font-size: 0.74rem;
  white-space: nowrap;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(10, 10, 15, 0.75);
  opacity: 0;
  transform: translateX(-6px);
  transition:
    opacity 0.15s ease,
    transform 0.15s ease;
}
.section-nav-dot:hover .section-nav-label,
.section-nav-dot:focus-visible .section-nav-label,
.section-nav-dot.active .section-nav-label {
  opacity: 0.9;
  transform: translateX(0);
}
@media (max-width: 700px) {
  /* Not enough width for a left-edge nav without overlapping the box demo's own toolbar. */
  #section-nav {
    display: none;
  }
}

/* --- "Made with love" credit --- */
#site-credit {
  position: fixed;
  left: 16px;
  bottom: 16px;
  z-index: 15;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(10, 10, 15, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 0.74rem;
  opacity: 0.85;
  backdrop-filter: blur(6px);
}
#site-credit a {
  color: inherit;
  font-weight: 600;
  text-decoration: none;
}
#site-credit a:hover {
  text-decoration: underline;
}
.pixel-heart {
  width: 12px;
  height: 12px;
  fill: #ff5c8a;
  shape-rendering: crispEdges;
}

/* --- Recipe B: contained box --- */
#box-demo {
  position: relative;
  width: min(90vw, 900px);
  height: 420px;
  margin: 4vh auto 0;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}
#box-demo .toolbar {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 2;
  display: flex;
  /* Stacked, not side-by-side: avoids competing with box-demo's width. */
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}
#box-demo .label {
  background: rgba(0, 0, 0, 0.4);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.85rem;
  white-space: nowrap;
}
.randomize-btn {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #eee;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
}
.randomize-btn:hover {
  background: rgba(0, 0, 0, 0.6);
}

select,
input,
button {
  font: inherit;
  color: inherit;
}
#playground-panel select,
#playground-panel input[type="number"] {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 5px;
  padding: 2px 6px;
  color-scheme: dark;
}

/* Playground control panel: a plain div + toggle button, not <details>/<summary> - Chromium never lets a <details>'s
   content shrink below its natural height in a flex/scroll container, so overflow-y: auto below wouldn't engage. */
#playground-panel {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 20;
  /* Collapsed: shrinks to fit the toggle button (see :not(.open) below), clear of the hero's scroll cue. */
  width: min(94vw, 760px);
  max-height: calc(100vh - 32px);
  background: rgba(10, 10, 15, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#playground-panel:not(.open) {
  width: fit-content;
}
#playground-panel .panel-summary {
  all: unset;
  box-sizing: border-box;
  cursor: pointer;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  white-space: nowrap;
  user-select: none;
  font-weight: 600;
  font-size: 0.95rem;
  font-family: inherit;
  color: inherit;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex: 0 0 auto;
}
#playground-panel:not(.open) .panel-summary {
  border-bottom: none;
}
#playground-panel .panel-summary .chev {
  transition: transform 0.15s ease;
  opacity: 0.7;
}
#playground-panel.open .panel-summary .chev {
  transform: rotate(180deg);
}
#playground-panel:not(.open) .panel-body {
  display: none;
}

.panel-body {
  /* flex: 1 1 auto + min-height: 0 lets overflow-y: auto actually engage - without it a flex child never
     shrinks below its content height, so it grows past max-height and gets clipped instead of scrolling. */
  flex: 1 1 auto;
  min-height: 0;
  padding: 14px 16px 16px;
  overflow-y: auto;
}
/* Single stacked column (controls, then code/JSON) so the editor gets the panel's full width. */
.panel-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  align-items: start;
}

fieldset {
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  padding: 8px 12px 10px;
  margin: 0 0 12px;
}
fieldset:last-child {
  margin-bottom: 0;
}
legend {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.65;
  padding: 0 4px;
}
.field {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 7px 0;
  font-size: 0.8rem;
}
.field label {
  flex: 1 1 auto;
  opacity: 0.9;
}
.field input[type="range"] {
  flex: 1.4 1 0;
  width: 0;
}
.field .val {
  width: 3.6em;
  text-align: right;
  opacity: 0.7;
  font-variant-numeric: tabular-nums;
  font-size: 0.76rem;
}
.field input[type="number"] {
  width: 5.5em;
}
.field input[type="color"] {
  width: 2.1em;
  height: 1.5em;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: none;
}
.field select {
  flex: 1.4 1 0;
}

.axis-group {
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 4px 8px 6px;
  margin: 7px 0;
}
.axis-group-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.55;
  margin: 3px 0 2px;
}
.subgroup {
  display: none;
  padding-left: 2px;
  border-left: 2px solid rgba(255, 255, 255, 0.1);
  margin-left: 2px;
}
.subgroup.active {
  display: block;
}
.palette-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.palette-row input[type="color"] {
  flex: none;
}
.palette-row input.weight {
  width: 4.2em;
}
.palette-row .remove-color-btn {
  flex: none;
  width: 1.6em;
  height: 1.6em;
  line-height: 1;
  padding: 0;
  border-radius: 5px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
  color: #eee;
  cursor: pointer;
  font-size: 0.85rem;
}
.palette-row .remove-color-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.18);
}
.palette-row .remove-color-btn:disabled {
  opacity: 0.35;
  cursor: default;
}
.add-color-btn {
  margin-top: 6px;
}

.code-panel {
  display: flex;
  flex-direction: column;
  min-height: 260px;
}
.code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 0.78rem;
  opacity: 0.85;
}
.code-header button,
.reset-btn {
  font-size: 0.76rem;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
  color: #eee;
  cursor: pointer;
}
.code-header button:hover,
.reset-btn:hover {
  background: rgba(255, 255, 255, 0.18);
}
pre#code-output {
  flex: none;
  max-height: 260px;
  margin: 0;
  padding: 12px;
  background: #0c0c12;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.74rem;
  line-height: 1.5;
  overflow: auto;
  white-space: pre;
}
.code-header-actions {
  display: flex;
  gap: 6px;
}
.json-section {
  display: flex;
  flex-direction: column;
  margin-top: 16px;
}
#config-json {
  min-height: 140px;
  margin: 0;
  padding: 12px;
  background: #0c0c12;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #eee;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.74rem;
  line-height: 1.5;
  resize: vertical;
}
#config-json:focus {
  outline: 1px solid rgba(255, 255, 255, 0.35);
}
.json-status {
  min-height: 1.2em;
  margin-top: 5px;
  font-size: 0.76rem;
  opacity: 0.9;
  color: #8fffc8;
}
.json-status.error {
  color: #ff9d9d;
}
.panel-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
}
.panel-footer-hint {
  font-size: 0.72rem;
  opacity: 0.6;
}
.panel-footer-hint kbd {
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.08);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.7rem;
}
