@font-face {
  font-family: "Space Grotesk";
  src: url("./assets/fonts/space-grotesk-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Space Grotesk";
  src: url("./assets/fonts/space-grotesk-600.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Space Grotesk";
  src: url("./assets/fonts/space-grotesk-700.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --paper: #f2e9d4;
  --paper-panel: rgba(244, 237, 219, 0.945);
  --ink: #191a1d;
  --muted: rgba(25, 26, 29, 0.56);
  --line: rgba(25, 26, 29, 0.16);
  --accent: #1f31a6;
  --accent-soft: rgba(31, 49, 166, 0.18);
  --font: "Space Grotesk", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --mono: "SFMono-Regular", "Cascadia Mono", "Roboto Mono", Menlo, Consolas,
    monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

html {
  background: var(--paper);
}

body {
  margin: 0;
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior: none;
}

button,
input {
  font-family: inherit;
}

.stage {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background: var(--paper);
  pointer-events: none;
}

.stage canvas {
  display: block;
  animation: canvas-in 900ms ease both;
}

@keyframes canvas-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* ------------------------------------------------------------------ *
 * Floating control
 * ------------------------------------------------------------------ */

.panel-toggle {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 9px;
  height: 44px;
  padding: 0 17px;
  border: 1px solid var(--ink);
  border-radius: 0;
  background: var(--paper);
  color: var(--ink);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(46, 36, 18, 0.16);
  transition: background 180ms ease, color 180ms ease,
    border-color 180ms ease, opacity 240ms ease, transform 240ms ease;
}

.panel-toggle svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
}

.panel-toggle:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--paper);
}

body[data-panel="open"] .panel-toggle {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px);
}

/* ------------------------------------------------------------------ *
 * Panel
 * ------------------------------------------------------------------ */

.panel {
  position: fixed;
  top: 18px;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  width: 338px;
  background: var(--paper-panel);
  border: 1px solid rgba(25, 26, 29, 0.72);
  box-shadow: 0 2px 0 rgba(25, 26, 29, 0.06),
    0 26px 70px rgba(46, 36, 18, 0.18);
  -webkit-backdrop-filter: blur(18px) saturate(1.08);
  backdrop-filter: blur(18px) saturate(1.08);
  transition: transform 420ms cubic-bezier(0.22, 0.8, 0.24, 1),
    opacity 280ms ease;
}

.panel::before {
  content: "";
  position: absolute;
  top: -1px;
  left: -1px;
  width: 72px;
  height: 4px;
  background: var(--accent);
}

body[data-panel="closed"] .panel {
  opacity: 0;
  pointer-events: none;
  transform: translateX(calc(100% + 26px));
}

.panel-head {
  flex: 0 0 auto;
  padding: 20px 22px 16px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
}

.brand-mark {
  position: relative;
  width: 19px;
  height: 19px;
  flex: 0 0 auto;
  background: var(--accent);
}

.brand-mark i {
  position: absolute;
  right: 3px;
  bottom: 3px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--paper);
}

.brand-name {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.19em;
  text-transform: uppercase;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  margin-left: auto;
  padding: 0;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color 160ms ease, border-color 160ms ease,
    background 160ms ease;
}

.icon-button svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
}

.icon-button:hover {
  border-color: rgba(25, 26, 29, 0.32);
  color: var(--ink);
  background: rgba(25, 26, 29, 0.035);
}

.kicker {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 8.5px;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

h1 {
  margin: 8px 0 0;
  font-size: 29px;
  font-weight: 600;
  letter-spacing: -0.045em;
  line-height: 0.98;
}

.seed-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
  padding-top: 13px;
  border-top: 1px solid var(--line);
}

.seed-row > label {
  color: var(--muted);
  font-size: 8.5px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  white-space: nowrap;
}

.seed-field {
  display: flex;
  align-items: baseline;
  gap: 3px;
  flex: 1 1 auto;
  min-width: 0;
  border-bottom: 1px solid rgba(25, 26, 29, 0.42);
  transition: border-color 160ms ease;
}

.seed-field:focus-within {
  border-color: var(--accent);
}

.seed-field span {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
}

.seed-field input {
  width: 100%;
  min-width: 0;
  padding: 4px 0 3px;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.08em;
  -moz-appearance: textfield;
}

.square-button {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  padding: 0;
  border: 1px solid rgba(25, 26, 29, 0.4);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease,
    color 160ms ease, transform 300ms ease;
}

.square-button svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.square-button:hover {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--paper);
  transform: rotate(24deg);
}

.square-button:active {
  transform: rotate(24deg) scale(0.94);
}

/* ------------------------------------------------------------------ *
 * Body / controls
 * ------------------------------------------------------------------ */

.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  flex: 0 0 auto;
  border-bottom: 1px solid var(--line);
}

.tab-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 38px;
  padding: 0 3px;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-size: 8.5px;
  font-weight: 600;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 150ms ease, border-color 150ms ease,
    background 150ms ease;
}

.tab-button span {
  color: var(--accent);
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 400;
  letter-spacing: 0;
}

.tab-button:hover {
  background: rgba(25, 26, 29, 0.035);
  color: var(--ink);
}

.tab-button.is-active {
  border-bottom-color: var(--accent);
  color: var(--ink);
}

.tab-button:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: -3px;
}

.panel-body {
  flex: 1 1 auto;
  min-height: 0;
  padding: 0 22px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(25, 26, 29, 0.25) transparent;
}

.panel-body::-webkit-scrollbar {
  width: 6px;
}

.panel-body::-webkit-scrollbar-thumb {
  background: rgba(25, 26, 29, 0.22);
}

.panel-body::-webkit-scrollbar-track {
  background: transparent;
}

.group {
  padding: 6px 0 10px;
}

.tab-panel {
  display: none;
}

.tab-panel.is-active {
  display: block;
}

.control {
  padding: 7px 0 8px;
}

.control-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.control label,
.control .label {
  color: var(--ink);
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.002em;
  cursor: pointer;
}

.control .label {
  cursor: default;
}

.control output {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

/* Range inputs */

input[type="range"] {
  --fill: 50%;
  display: block;
  width: 100%;
  height: 18px;
  margin: 5px 0 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

input[type="range"]:focus {
  outline: none;
}

input[type="range"]:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 5px;
}

input[type="range"]::-webkit-slider-runnable-track {
  width: 100%;
  height: 2px;
  background: linear-gradient(
    to right,
    var(--accent) 0,
    var(--accent) var(--fill),
    rgba(25, 26, 29, 0.17) var(--fill),
    rgba(25, 26, 29, 0.17) 100%
  );
}

input[type="range"]::-webkit-slider-thumb {
  width: 11px;
  height: 11px;
  margin-top: -4.5px;
  border: 1px solid rgba(25, 26, 29, 0.28);
  border-radius: 0;
  background: var(--accent);
  box-shadow: 0 0 0 2px var(--paper-panel);
  -webkit-appearance: none;
  appearance: none;
  transition: transform 120ms ease;
}

input[type="range"]:active::-webkit-slider-thumb {
  transform: scale(1.18);
}

input[type="range"]::-moz-range-track {
  width: 100%;
  height: 2px;
  background: rgba(25, 26, 29, 0.17);
}

input[type="range"]::-moz-range-progress {
  height: 2px;
  background: var(--accent);
}

input[type="range"]::-moz-range-thumb {
  width: 10px;
  height: 10px;
  border: 1px solid rgba(25, 26, 29, 0.28);
  border-radius: 0;
  background: var(--accent);
}

/* Distribution bar */

.distribution-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 1px 0 5px;
}

.distribution {
  display: flex;
  flex: 1 1 auto;
  height: 6px;
  overflow: hidden;
  border: 1px solid rgba(25, 26, 29, 0.25);
  background: rgba(25, 26, 29, 0.04);
}

.distribution span {
  display: block;
  width: 0;
  height: 100%;
  transition: width 260ms ease;
}

.distribution [data-seg="solid"] {
  background: var(--accent);
}

.distribution [data-seg="hatch"] {
  background: repeating-linear-gradient(
      90deg,
      var(--accent) 0,
      var(--accent) 1px,
      transparent 1px,
      transparent 3px
    ),
    var(--accent-soft);
}

.distribution [data-seg="figure"] {
  background: color-mix(in srgb, var(--accent) 56%, var(--paper));
}

.distribution [data-seg="blank"] {
  background: transparent;
}

.micro {
  margin: 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 8.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

/* Segmented control */

.segmented {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin-top: 7px;
  border: 1px solid rgba(25, 26, 29, 0.3);
}

.segmented button {
  height: 28px;
  padding: 0;
  border: 0;
  border-left: 1px solid rgba(25, 26, 29, 0.17);
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease;
}

.segmented button:first-child {
  border-left: 0;
}

.segmented button:hover:not(.is-active) {
  background: rgba(25, 26, 29, 0.05);
  color: var(--ink);
}

.segmented button.is-active {
  background: var(--accent);
  color: var(--paper);
}

/* Palettes */

.palette-control .control-head {
  margin-bottom: 2px;
}

.palettes {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 7px;
  margin-top: 8px;
}

.palette {
  position: relative;
  height: 27px;
  padding: 0;
  border: 1px solid rgba(25, 26, 29, 0.26);
  border-radius: 0;
  background: transparent;
  cursor: pointer;
  transition: outline-color 150ms ease, transform 150ms ease;
  outline: 1px solid transparent;
  outline-offset: 2px;
}

.palette:hover {
  transform: translateY(-1px);
}

.palette.is-active {
  outline: 2px solid var(--accent);
}

.palette::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    135deg,
    var(--palette-ink) 0,
    var(--palette-ink) 49.5%,
    var(--palette-paper) 50%,
    var(--palette-paper) 100%
  );
}

.palette:focus-visible {
  outline: 2px solid var(--accent);
}

/* ------------------------------------------------------------------ *
 * Footer
 * ------------------------------------------------------------------ */

.panel-actions {
  flex: 0 0 auto;
  padding: 14px 22px 16px;
  border-top: 1px solid var(--line);
  background: linear-gradient(
    to top,
    var(--paper-panel) 72%,
    rgba(244, 237, 219, 0)
  );
}

.button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 41px;
  padding: 0 10px;
  border: 1px solid rgba(25, 26, 29, 0.52);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.13em;
  line-height: 1;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 170ms ease, color 170ms ease,
    border-color 170ms ease, transform 120ms ease;
}

.button svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.button-primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--paper);
}

.button-primary:hover {
  border-color: var(--ink);
  background: var(--ink);
}

.button:not(.button-primary):hover {
  background: rgba(25, 26, 29, 0.055);
}

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

.button:focus-visible,
.panel-toggle:focus-visible,
.square-button:focus-visible,
.icon-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}

.shortcuts {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  margin: 9px 0 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.shortcuts i {
  font-style: normal;
  opacity: 0.55;
}

.shortcuts kbd {
  display: inline-grid;
  place-items: center;
  min-width: 14px;
  height: 14px;
  padding: 0 3px;
  border: 1px solid rgba(25, 26, 29, 0.26);
  border-radius: 0;
  font-family: inherit;
  font-size: 8px;
}

/* ------------------------------------------------------------------ *
 * Toast
 * ------------------------------------------------------------------ */

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  z-index: 40;
  padding: 10px 16px;
  background: var(--ink);
  color: var(--paper);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 10px);
  transition: opacity 220ms ease, transform 220ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ------------------------------------------------------------------ *
 * Responsive
 * ------------------------------------------------------------------ */

@media (max-width: 760px) {
  .panel {
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    width: auto;
    max-height: 76dvh;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    box-shadow: 0 -18px 60px rgba(46, 36, 18, 0.2);
  }

  body[data-panel="closed"] .panel {
    transform: translateY(calc(100% + 20px));
  }

  .panel-toggle {
    top: auto;
    right: 16px;
    bottom: 16px;
  }

  .panel-head {
    padding-top: 18px;
  }

  h1 {
    font-size: 26px;
  }

  .toast {
    bottom: 82px;
  }
}

@media (max-height: 760px) and (min-width: 761px) {
  .panel {
    top: 12px;
    bottom: 12px;
  }

  .panel-head {
    padding-top: 16px;
    padding-bottom: 12px;
  }

  h1 {
    font-size: 25px;
  }

  .seed-row {
    margin-top: 12px;
    padding-top: 10px;
  }

  .group {
    padding-top: 13px;
  }

  .control {
    padding-top: 5px;
    padding-bottom: 6px;
  }
}

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