/* ---------------------------------------------------------------
   Shared chrome for the generative pages.
   Ported from the landing page so the sub-pages read as one site:
   full-bleed visual, minimal controls bottom right, settings and
   explanation below the fold.
   --------------------------------------------------------------- */

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  overflow-x: hidden;
  overflow-y: auto;
  background: #ffffff;
  color: #111;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

/* --- The visual itself: fixed, filling the viewport --- */
#stage {
  position: fixed;
  inset: 0;
  z-index: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #ffffff;
}

/* Scoped to the canvas we create ourselves. A blanket `#stage canvas` rule
   collapses Plotly's gl canvases, whose containing block has no width. */
#sketch canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
}

/* Plotly measures its container, so the host needs real dimensions. */
#stage .plot-host {
  display: block;
  width: 100%;
  height: 100%;
}

/* --- Scroll region: space to breathe, then the written material --- */
#scroll-content {
  position: relative;
  z-index: 2;
  pointer-events: none;
}

.scroll-spacer {
  min-height: 100vh;
}

.sheet {
  pointer-events: auto;
  background: #ffffff;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  padding: 64px 32px 96px;
}

.sheet-inner {
  width: min(880px, 100%);
  margin: 0 auto;
}

.sheet h2 {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.3px;
  color: #4a4a4a;
}

.sheet h3 {
  margin: 34px 0 10px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.55px;
  text-transform: uppercase;
  color: #8a8a8a;
}

.sheet p {
  margin: 0 0 12px;
  font-size: 13.5px;
  line-height: 1.6;
  color: #5c5c5c;
  max-width: 62ch;
}

.sheet p.lede {
  font-size: 14.5px;
  color: #4a4a4a;
}

.sheet code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px;
  color: #4a4a4a;
  background: rgba(0, 0, 0, 0.045);
  border-radius: 5px;
  padding: 1px 5px;
}

.sheet .formula {
  display: block;
  background: rgba(0, 0, 0, 0.035);
  border-radius: 10px;
  padding: 14px 16px;
  margin: 0 0 16px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px;
  line-height: 1.75;
  color: #555;
  overflow-x: auto;
}

.sheet ul {
  margin: 0 0 12px;
  padding-left: 18px;
  max-width: 62ch;
}

.sheet li {
  font-size: 13.5px;
  line-height: 1.6;
  color: #5c5c5c;
  margin-bottom: 6px;
}

/* --- Full settings grid, below the fold --- */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px 28px;
  margin-top: 4px;
}

.setting {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.setting-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.45px;
  color: #8a8a8a;
}

.setting-head output {
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0;
  color: #919191;
}

.setting-note {
  font-size: 10.5px;
  font-weight: 500;
  color: #a3a3a3;
  letter-spacing: 0.2px;
  line-height: 1.45;
}

.setting-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 6px;
}

/* --- Overlay UI (menu + minimal controls) --- */
#site-ui {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10000;
}

#menuButton {
  pointer-events: auto;
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 3;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  font-size: 20px;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}

.menu-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1;
  background: rgba(0, 0, 0, 0.35);
  opacity: 0;
  transition: opacity 220ms ease;
  pointer-events: none;
}

.menu-panel {
  pointer-events: auto;
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 2;
  width: min(360px, calc(100vw - 28px));
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.22);
  transform: translateY(-8px);
  opacity: 0;
  transition: opacity 220ms ease, transform 220ms ease;
  display: none;
  overflow: hidden;
}

.menu-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 14px 10px;
}

.menu-title {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.menu-close {
  border: 0;
  background: transparent;
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
  padding: 6px 8px;
  border-radius: 10px;
}

.menu-close:hover {
  background: rgba(0, 0, 0, 0.06);
}

.menu-links {
  display: flex;
  flex-direction: column;
  padding: 6px 14px 14px;
  gap: 10px;
}

.menu-links a {
  color: #111;
  text-decoration: none;
  font-size: 14px;
  padding: 10px 10px;
  border-radius: 10px;
  transition: background 160ms ease;
}

.menu-links a:hover {
  background: rgba(0, 0, 0, 0.06);
}

.menu-divider {
  height: 1px;
  background: rgba(0, 0, 0, 0.12);
  margin: 6px 0;
}

.menu-hint {
  font-size: 12px;
  color: rgba(0, 0, 0, 0.65);
  padding: 0 14px 14px;
  line-height: 1.35;
}

body.menu-open .menu-panel {
  display: block;
  opacity: 1;
  transform: translateY(0);
}

body.menu-open .menu-backdrop {
  opacity: 1;
  pointer-events: auto;
}

/* --- Minimal controls, bottom right --- */
.generation-controls {
  pointer-events: auto;
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 3;
  width: min(300px, calc(100vw - 28px));
  background: transparent;
  border: 0;
  box-shadow: none;
  padding: 0;
  opacity: 0.72;
  transition: opacity 160ms ease;
}

.generation-controls:hover,
.generation-controls:focus-within {
  opacity: 0.9;
}

.new-pattern-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  margin-bottom: 6px;
}

.pill-button {
  appearance: none;
  border: 1px solid #c2c2c2;
  border-radius: 999px;
  background: linear-gradient(180deg, #fbfbfb 0%, #e7e7e7 100%);
  color: #727272;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.5px;
  line-height: 1;
  padding: 5px 9px;
  box-shadow: inset 0 1px 0 #ffffff, 0 1px 2px rgba(0, 0, 0, 0.14);
  cursor: pointer;
}

.pill-button:hover {
  filter: brightness(1.02);
}

.pill-button:active {
  transform: translateY(1px);
}

.new-pattern-note {
  font-size: 10px;
  font-weight: 500;
  color: #8f8f8f;
  letter-spacing: 0.2px;
  user-select: none;
}

.performance-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 10.5px;
  letter-spacing: 0.45px;
  font-weight: 600;
  color: #8a8a8a;
  margin-bottom: 6px;
}

.performance-row output {
  font-size: 10.5px;
  letter-spacing: 0;
  font-weight: 500;
  color: #919191;
}

.performance-meta {
  margin-top: 4px;
  font-size: 10px;
  font-weight: 500;
  color: #999999;
  letter-spacing: 0.2px;
}

/* Sliders: the landing-page treatment, applied to every range input */
input[type="range"].minimal-slider {
  width: 100%;
  height: 9px;
  appearance: none;
  border-radius: 999px;
  background: linear-gradient(180deg, #a2a2a2 0%, #8f8f8f 100%);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.22), inset 0 -1px 0 rgba(255, 255, 255, 0.22);
  outline: none;
  margin: 2px 0 10px;
}

input[type="range"].minimal-slider::-webkit-slider-thumb {
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid #b8b8b8;
  background: linear-gradient(180deg, #fbfbfb 0%, #e2e2e2 100%);
  box-shadow: inset 0 1px 0 #ffffff, 0 1px 3px rgba(0, 0, 0, 0.2);
  cursor: pointer;
}

input[type="range"].minimal-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid #b8b8b8;
  background: linear-gradient(180deg, #fbfbfb 0%, #e2e2e2 100%);
  box-shadow: inset 0 1px 0 #ffffff, 0 1px 3px rgba(0, 0, 0, 0.2);
  cursor: pointer;
}

.minimal-number {
  appearance: none;
  width: 100%;
  border: 1px solid #d6d6d6;
  border-radius: 8px;
  background: #fcfcfc;
  color: #6f6f6f;
  font-family: inherit;
  font-size: 11.5px;
  padding: 6px 8px;
  outline: none;
}

.minimal-number:focus {
  border-color: #b5b5b5;
}

.minimal-select {
  appearance: none;
  width: 100%;
  border: 1px solid #d6d6d6;
  border-radius: 8px;
  background: #fcfcfc;
  color: #6f6f6f;
  font-family: inherit;
  font-size: 11.5px;
  padding: 6px 8px;
  outline: none;
  cursor: pointer;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.45px;
  color: #8a8a8a;
}

.toggle-caption {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 10.5px;
  color: #8a8a8a;
  letter-spacing: 0.45px;
  font-weight: 600;
}

.toggle-mode {
  font-size: 10px;
  color: #9a9a9a;
  font-weight: 500;
  letter-spacing: 0;
}

.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  user-select: none;
}

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

.switch-track {
  position: relative;
  width: 40px;
  height: 22px;
  border-radius: 999px;
  background: linear-gradient(180deg, #d2d2d2 0%, #bebebe 100%);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.18), inset 0 -1px 0 rgba(255, 255, 255, 0.5);
  transition: background 180ms ease;
  display: inline-block;
}

.switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: linear-gradient(180deg, #fefefe 0%, #e5e5e5 100%);
  border: 1px solid #bbbbbb;
  box-shadow: inset 0 1px 0 #ffffff, 0 1px 3px rgba(0, 0, 0, 0.18);
  transition: transform 180ms ease;
}

.switch input:checked + .switch-track {
  background: linear-gradient(180deg, #a9a9a9 0%, #989898 100%);
}

.switch input:checked + .switch-track .switch-thumb {
  transform: translateX(16px);
}

/* --- Scroll cue --- */
.scroll-cue {
  pointer-events: none;
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 3;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.6px;
  color: #a8a8a8;
  transition: opacity 200ms ease;
}

body.scrolled .scroll-cue {
  opacity: 0;
}

@media (max-width: 480px) {
  #menuButton {
    top: 10px;
    right: 10px;
  }

  .menu-panel {
    top: 10px;
    right: 10px;
    width: calc(100vw - 20px);
  }

  .generation-controls {
    right: 10px;
    bottom: 10px;
    width: calc(100vw - 20px);
  }

  .sheet {
    padding: 48px 20px 72px;
  }

  .scroll-spacer {
    min-height: 92vh;
  }
}
