/* Mossa Labs Simulators: shared "playful lab" theme.
   Light-first candy palette; dark mode follows the OS unless the viewer
   picks a theme with the toggle (data-theme on <html>). */

:root {
  color-scheme: light;
  --plane: #fff7ec;
  --surface: #ffffff;
  --surface-2: #fff1dc;
  --surface-3: #f7f2ff;
  --ink: #1d1a2f;
  --ink-2: #4a4560;
  --muted: #706b88;
  --line: #1d1a2f;
  --hair: #ece4d6;
  --grid: #ece7df;
  --axis: #cfc8bb;

  --pink: #ff5fa2;
  --mint: #2fd3a7;
  --sun: #ffc93c;
  --grape: #7c5cff;
  --sky: #4cc9f0;

  /* Chart series: validated with the dataviz palette checker on --surface. */
  --series-a: #2a78d6;
  --series-b: #eb6834;
  --series-ai: #6250d6;
  --series-base: #8a8698;
  --series-low: #1baf7a;
  --series-high: #eda100;
  --b-building: #008300;
  --b-ceremonies: #6250d6;
  --b-rework: #e34948;
  --b-collab: #1baf7a;
  --b-switch: #eda100;
  --b-lost: #e87ba4;

  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;

  --radius: 22px;
  --radius-sm: 14px;
  --shadow: 4px 4px 0 var(--line);
  --shadow-sm: 2px 2px 0 var(--line);
  --font-display: "Fredoka", "Nunito", system-ui, sans-serif;
  --font-body: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --plane: #14121f;
    --surface: #1f1d33;
    --surface-2: #29263f;
    --surface-3: #2b2547;
    --ink: #f3f0ff;
    --ink-2: #c9c4e0;
    --muted: #9a94b5;
    --line: #07060d;
    --hair: #34304d;
    --grid: #2f2b45;
    --axis: #4a4566;
    --series-a: #3987e5;
    --series-b: #d95926;
    --series-ai: #9085e9;
    --series-base: #8f89a8;
    --series-low: #199e70;
    --series-high: #c98500;
    --b-building: #008300;
    --b-ceremonies: #9085e9;
    --b-rework: #e66767;
    --b-collab: #199e70;
    --b-switch: #c98500;
    --b-lost: #d55181;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --plane: #14121f;
  --surface: #1f1d33;
  --surface-2: #29263f;
  --surface-3: #2b2547;
  --ink: #f3f0ff;
  --ink-2: #c9c4e0;
  --muted: #9a94b5;
  --line: #07060d;
  --hair: #34304d;
  --grid: #2f2b45;
  --axis: #4a4566;
  --series-a: #3987e5;
  --series-b: #d95926;
  --series-ai: #9085e9;
  --series-base: #8f89a8;
  --series-low: #199e70;
  --series-high: #c98500;
  --b-building: #008300;
  --b-ceremonies: #9085e9;
  --b-rework: #e66767;
  --b-collab: #199e70;
  --b-switch: #c98500;
  --b-lost: #d55181;
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--plane);
  background-image:
    radial-gradient(circle at 8% 4%, color-mix(in srgb, var(--pink) 18%, transparent) 0, transparent 28rem),
    radial-gradient(circle at 96% 12%, color-mix(in srgb, var(--sky) 20%, transparent) 0, transparent 26rem),
    radial-gradient(circle at 50% 100%, color-mix(in srgb, var(--sun) 14%, transparent) 0, transparent 30rem);
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  overflow-x: hidden;
}

/* ------------------------------------------------------------- scrollbars */

/* Candy-gradient thumbs on a track that matches whatever the scroller sits
   on. Containers override --scroll-track (and --scroll-ring) for their own
   surface. WebKit/Blink get the gradient; Firefox only takes solid colours.
   Chrome ignores ::-webkit-scrollbar once scrollbar-color/width is set, so
   the standard properties are kept to browsers without the pseudo-elements. */
:root {
  --scroll-track: var(--plane);
  --scroll-ring: var(--line);
  --scroll-thumb: linear-gradient(180deg, var(--pink), var(--grape));
  --scroll-thumb-hover: linear-gradient(180deg, var(--sun), var(--pink));
}

::-webkit-scrollbar {
  width: 16px;
  height: 16px;
}

::-webkit-scrollbar-track,
::-webkit-scrollbar-corner {
  background: var(--scroll-track);
}

::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb);
  background-clip: padding-box;
  border: 3px solid transparent;
  border-radius: 999px;
  box-shadow: inset 0 0 0 2px var(--scroll-ring);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--scroll-thumb-hover);
  background-clip: padding-box;
}

@supports not selector(::-webkit-scrollbar) {
  * {
    scrollbar-color: var(--grape) var(--scroll-track);
  }
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.15;
  margin: 0 0 0.5em;
}

a {
  color: inherit;
}

img {
  max-width: 100%;
}

:focus-visible {
  outline: 3px solid var(--grape);
  outline-offset: 2px;
}

.wrap {
  width: 100%;
  max-width: 1360px;
  margin: 0 auto;
  padding: 0 16px;
}

/* ---------------------------------------------------------------- header */

.lab-header {
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(10px);
  background: color-mix(in srgb, var(--plane) 82%, transparent);
  border-bottom: 2px solid var(--hair);
}

.lab-header__inner {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 64px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.1rem;
}

.brand img {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 2px solid var(--line);
  box-shadow: var(--shadow-sm);
  object-fit: cover;
  background: #fff;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.brand:hover img {
  transform: rotate(-8deg) scale(1.06);
}

.crumbs {
  display: flex;
  gap: 6px;
  align-items: center;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.92rem;
  min-width: 0;
}

.crumbs a {
  text-decoration: none;
  color: var(--ink-2);
}

.crumbs a:hover {
  color: var(--grape);
}

.crumbs span:last-child {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lab-header__spacer {
  flex: 1;
}

/* ---------------------------------------------------------------- cards */

.card {
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  min-width: 0;
}

.card h2 {
  font-size: 1.3rem;
}

.card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.card__head h2 {
  margin: 0;
}

.card__sub {
  color: var(--muted);
  font-size: 0.92rem;
  margin: 4px 0 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 999px;
  border: 2px solid var(--line);
  background: var(--sun);
  color: #1d1a2f;
  font-weight: 800;
  font-size: 0.82rem;
  box-shadow: var(--shadow-sm);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 0.8rem;
  border: 2px solid currentColor;
}

/* ---------------------------------------------------------------- buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: 999px;
  border: 2px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font: 800 0.95rem var(--font-body);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.btn:hover {
  transform: translate(-1px, -1px);
  box-shadow: 3px 3px 0 var(--line);
}

.btn:active {
  transform: translate(2px, 2px);
  box-shadow: 0 0 0 var(--line);
}

.btn--primary {
  background: var(--grape);
  color: #fff;
}

.btn--pink {
  background: var(--pink);
  color: #1d1a2f;
}

.btn--mint {
  background: var(--mint);
  color: #1d1a2f;
}

.btn--sm {
  padding: 5px 12px;
  font-size: 0.85rem;
}

.btn[aria-pressed="true"] {
  background: var(--sun);
  color: #1d1a2f;
}

.icon-btn {
  width: 42px;
  height: 42px;
  padding: 0;
  font-size: 1.2rem;
}

/* ---------------------------------------------------------------- chips */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1.6;
  text-decoration: none;
  background: var(--surface-2);
  color: var(--ink-2);
  border: 1px solid var(--hair);
  white-space: nowrap;
  transition: background 0.2s ease, transform 0.15s ease;
}

a.chip:hover {
  transform: translateY(-1px);
  background: var(--surface-3);
}

.chip__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  flex: none;
}

.chip--measured .chip__dot { background: var(--good); }
.chip--experiment .chip__dot { background: var(--sky); }
.chip--survey .chip__dot { background: var(--grape); }
.chip--framework .chip__dot { background: var(--sun); }
.chip--classic .chip__dot { background: var(--pink); }
.chip--reporting .chip__dot { background: var(--mint); }
.chip--assumption .chip__dot { background: var(--muted); }

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

/* ---------------------------------------------------------------- forms */

.field {
  display: grid;
  gap: 4px;
  margin: 0 0 14px;
}

.field__top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.field label,
.field__label {
  font-weight: 800;
  font-size: 0.9rem;
}

.field__value {
  font-family: var(--font-display);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  background: var(--surface-2);
  border-radius: 999px;
  padding: 0 10px;
  min-width: 3.5em;
  text-align: center;
  white-space: nowrap;
}

.field__help {
  color: var(--muted);
  font-size: 0.8rem;
  margin: 0;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 26px;
  background: transparent;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--pink), var(--grape) var(--fill, 50%), var(--hair) var(--fill, 50%));
  border: 2px solid var(--line);
}

input[type="range"]::-moz-range-track {
  height: 6px;
  border-radius: 999px;
  background: var(--hair);
  border: 2px solid var(--line);
}

input[type="range"]::-moz-range-progress {
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--pink), var(--grape));
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  margin-top: -8px;
  border-radius: 50%;
  background: var(--sun);
  border: 2px solid var(--line);
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
}

input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--sun);
  border: 2px solid var(--line);
}

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

select,
input[type="text"],
input[type="number"] {
  font: 700 0.92rem var(--font-body);
  color: var(--ink);
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: 12px;
  padding: 6px 10px;
  min-width: 0;
  max-width: 100%;
}

select:focus,
input:focus {
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--grape) 40%, transparent);
}

.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  border: 2px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.segmented button {
  border: 0;
  background: transparent;
  color: var(--ink);
  font: 800 0.85rem var(--font-body);
  padding: 6px 12px;
  cursor: pointer;
  transition: background 0.2s ease;
}

.segmented button + button {
  border-left: 2px solid var(--line);
}

.segmented button[aria-pressed="true"] {
  background: var(--sun);
  color: #1d1a2f;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 0.88rem;
  cursor: pointer;
  user-select: none;
}

.switch input {
  appearance: none;
  -webkit-appearance: none;
  width: 40px;
  height: 24px;
  border-radius: 999px;
  border: 2px solid var(--line);
  background: var(--hair);
  position: relative;
  cursor: pointer;
  margin: 0;
  transition: background 0.2s ease;
}

.switch input::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--line);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.switch input:checked {
  background: var(--mint);
}

.switch input:checked::after {
  transform: translateX(16px);
}

/* ---------------------------------------------------------------- toasts */

.toasts {
  position: fixed;
  z-index: 60;
  right: 16px;
  bottom: 16px;
  display: grid;
  gap: 8px;
  max-width: min(360px, calc(100vw - 32px));
  pointer-events: none;
}

.toast {
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  padding: 10px 14px;
  font-weight: 700;
  animation: toast-in 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.toast--out {
  animation: toast-out 0.3s ease forwards;
}

@keyframes toast-in {
  from { transform: translateY(20px) scale(0.9); opacity: 0; }
}

@keyframes toast-out {
  to { transform: translateX(30px); opacity: 0; }
}

/* ---------------------------------------------------------------- confetti */

.confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 70;
  overflow: hidden;
}

.confetti i {
  position: absolute;
  top: -12px;
  width: 9px;
  height: 14px;
  border-radius: 3px;
  animation: confetti-fall var(--dur, 1.6s) cubic-bezier(0.2, 0.6, 0.4, 1) forwards;
}

@keyframes confetti-fall {
  to {
    transform: translate(var(--dx, 0), 105vh) rotate(var(--rot, 540deg));
    opacity: 0.2;
  }
}

/* ---------------------------------------------------------------- footer */

.lab-footer {
  margin: 48px 0 0;
  padding: 28px 0 40px;
  border-top: 2px solid var(--hair);
  color: var(--muted);
  font-size: 0.9rem;
}

.lab-footer__inner {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 24px;
  align-items: center;
  justify-content: space-between;
}

.lab-footer a {
  color: var(--ink-2);
  font-weight: 800;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

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