/*
 * TuneToy / Playful Utility design system — v1.0.0
 *
 * Tokens live on :root. Components use the .toy- prefix so this file can be
 * introduced to an existing project without taking over unrelated controls.
 */

@import url("https://fonts.googleapis.com/css2?family=Baloo+2:wght@500;600;700;800&family=Nunito:wght@400;600;700;800&display=swap");

:root {
  color-scheme: light;

  /* Brand palette */
  --toy-paper: #fff3e0;
  --toy-paper-soft: #fff9ef;
  --toy-panel: #ffffff;
  --toy-ink: #322b5f;
  --toy-text: #555080;
  --toy-muted: #6b6294;
  --toy-green: #1ca55d;
  --toy-green-fill: #2fbf71;
  --toy-cyan: #1e88d9;
  --toy-sky: #3fa9f5;
  --toy-yellow: #db8a00;
  --toy-yellow-fill: #ffc145;
  --toy-red: #f04e4e;
  --toy-coral: #ff6b6b;
  --toy-orange: #ff8a3d;
  --toy-grape: #9b6dff;

  /* Dark companions for accessible text and focus */
  --toy-green-text: #157a45;
  --toy-cyan-text: #126daa;
  --toy-coral-text: #bd3f48;
  --toy-yellow-text: #8c5600;
  --toy-red-text: #c83e3e;
  --toy-orange-text: #9b4c00;
  --toy-grape-text: #7650d3;
  --toy-focus: #126daa;

  /* Soft state fills */
  --toy-green-soft: #e9fbf0;
  --toy-blue-soft: #e3f4ff;
  --toy-grape-soft: #f3f0ff;
  --toy-yellow-soft: #fff4ce;
  --toy-red-soft: #ffe9e8;

  /* Typography */
  --toy-font-display: "Baloo 2", "Arial Rounded MT Bold", sans-serif;
  --toy-font-body: "Nunito", "Avenir Next", Avenir, "Helvetica Neue", sans-serif;
  --toy-text-xs: 0.6875rem;
  --toy-text-sm: 0.8125rem;
  --toy-text-base: 0.9375rem;
  --toy-text-md: 1.0625rem;
  --toy-text-lg: 1.3125rem;
  --toy-text-xl: clamp(2.375rem, 7vw, 4.5rem);
  --toy-leading-tight: 1.02;
  --toy-leading-body: 1.55;

  /* Spacing — 4px base rhythm */
  --toy-space-1: 0.25rem;
  --toy-space-2: 0.5rem;
  --toy-space-3: 0.75rem;
  --toy-space-4: 1rem;
  --toy-space-5: 1.25rem;
  --toy-space-6: 1.5rem;
  --toy-space-8: 2rem;
  --toy-space-10: 2.5rem;
  --toy-space-12: 3rem;
  --toy-space-16: 4rem;
  --toy-space-20: 5rem;

  /* Shape and depth */
  --toy-border-control: 2.5px;
  --toy-border-structure: 3px;
  --toy-radius-sm: 0.625rem;
  --toy-radius-md: 0.875rem;
  --toy-radius-lg: 1.125rem;
  --toy-radius-xl: 1.5rem;
  --toy-radius-shell: 1.75rem;
  --toy-radius-pill: 999px;
  --toy-shadow-pressed: 0 1px 0 var(--toy-ink);
  --toy-shadow-control: 0 3px 0 var(--toy-ink);
  --toy-shadow-card: 0 5px 0 var(--toy-ink);
  --toy-shadow-shell: 0 8px 0 var(--toy-ink);

  /* Motion */
  --toy-duration-fast: 100ms;
  --toy-duration-state: 120ms;
  --toy-ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);

  /* Layout */
  --toy-width-reading: 47.5rem;
  --toy-width-app: 68.75rem;
  --toy-gutter: 1.125rem;
}

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

.toy-surface {
  background-color: var(--toy-paper);
  background-image: radial-gradient(rgb(50 43 95 / 5.5%) 2.5px, transparent 2.5px);
  background-size: 28px 28px;
  color: var(--toy-text);
  font: var(--toy-text-base) / var(--toy-leading-body) var(--toy-font-body);
  -webkit-font-smoothing: antialiased;
}

.toy-surface button,
.toy-surface input,
.toy-surface select,
.toy-surface textarea {
  font: inherit;
}

.toy-surface button {
  touch-action: manipulation;
}

.toy-surface a {
  color: var(--toy-cyan-text);
  text-decoration: none;
}

.toy-surface a:hover {
  text-decoration: underline;
}

.toy-surface :is(button, input, select, textarea, a):focus-visible {
  outline: 3px solid var(--toy-focus);
  outline-offset: 3px;
}

.toy-display {
  color: var(--toy-ink);
  font-family: var(--toy-font-display);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: var(--toy-leading-tight);
}

.toy-eyebrow {
  color: var(--toy-green-text);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.toy-lede {
  color: var(--toy-text);
  font-size: clamp(1.0625rem, 2.2vw, 1.3125rem);
  font-weight: 600;
  line-height: 1.5;
}

.toy-brand {
  color: var(--toy-ink) !important;
  font-family: var(--toy-font-display);
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  line-height: 1;
  text-decoration: none !important;
}

.toy-brand__accent {
  color: var(--toy-coral-text);
}

.toy-sr-only {
  border: 0 !important;
  clip: rect(0 0 0 0) !important;
  clip-path: inset(50%) !important;
  height: 1px !important;
  margin: -1px !important;
  overflow: hidden !important;
  padding: 0 !important;
  position: absolute !important;
  white-space: nowrap !important;
  width: 1px !important;
}

.toy-button {
  align-items: center;
  appearance: none;
  background: var(--toy-panel);
  border: var(--toy-border-control) solid var(--toy-ink);
  border-radius: var(--toy-radius-md);
  box-shadow: var(--toy-shadow-control);
  color: var(--toy-ink);
  cursor: pointer;
  display: inline-flex;
  font-family: var(--toy-font-display);
  font-weight: 800;
  gap: var(--toy-space-2);
  justify-content: center;
  min-height: 2.625rem;
  padding: 0.55rem 1rem;
  text-decoration: none !important;
  transition:
    background var(--toy-duration-state),
    box-shadow var(--toy-duration-fast),
    transform var(--toy-duration-fast);
}

.toy-button:hover {
  background: var(--toy-paper-soft);
  box-shadow: 0 4px 0 var(--toy-ink);
  transform: translateY(-1px);
}

.toy-button:active,
.toy-button[aria-pressed="true"] {
  box-shadow: var(--toy-shadow-pressed);
  transform: translateY(2px);
}

.toy-button--primary {
  background: var(--toy-coral);
}

.toy-button--primary:hover {
  background: #ff7f7f;
}

.toy-button--yellow {
  background: var(--toy-yellow-fill);
}

.toy-button--green {
  background: var(--toy-green-fill);
  color: var(--toy-ink);
}

.toy-button--pill {
  border-radius: var(--toy-radius-pill);
  min-height: 2.25rem;
  padding: 0.35rem 0.85rem;
}

.toy-button--hero {
  border-width: var(--toy-border-structure);
  border-radius: var(--toy-radius-xl);
  box-shadow: 0 6px 0 var(--toy-ink);
  font-size: 1.35rem;
  min-height: 4rem;
  padding-inline: 2rem;
}

.toy-button--hero:hover {
  box-shadow: 0 8px 0 var(--toy-ink);
  transform: translateY(-2px);
}

.toy-button--hero:active {
  box-shadow: 0 2px 0 var(--toy-ink);
  transform: translateY(4px);
}

.toy-button:disabled,
.toy-button[aria-disabled="true"] {
  cursor: not-allowed;
  filter: grayscale(0.4);
  opacity: 0.55;
  transform: none;
}

.toy-card {
  background: var(--toy-panel);
  border: var(--toy-border-structure) solid var(--toy-ink);
  border-radius: var(--toy-radius-lg);
  box-shadow: var(--toy-shadow-card);
  padding: var(--toy-space-5);
}

.toy-card--tint {
  background: var(--toy-paper-soft);
}

.toy-machine {
  background: var(--toy-panel);
  border: var(--toy-border-structure) solid var(--toy-ink);
  border-radius: var(--toy-radius-shell);
  box-shadow: var(--toy-shadow-shell);
  padding: var(--toy-space-6);
  position: relative;
}

.toy-machine::before,
.toy-machine::after {
  border: var(--toy-border-control) solid var(--toy-ink);
  border-radius: 50%;
  content: "";
  height: 0.75rem;
  position: absolute;
  top: 0.875rem;
  width: 0.75rem;
}

.toy-machine::before {
  background: var(--toy-grape);
  left: 0.875rem;
}

.toy-machine::after {
  background: var(--toy-yellow-fill);
  right: 0.875rem;
}

.toy-display-panel {
  background: var(--toy-green-soft);
  border: var(--toy-border-structure) solid var(--toy-ink);
  border-radius: var(--toy-radius-lg);
  box-shadow: inset 0 3px 0 rgb(50 43 95 / 12%);
  color: var(--toy-green-text);
  padding: var(--toy-space-4) var(--toy-space-5);
}

.toy-control {
  color: var(--toy-muted);
  display: grid;
  font-size: 0.6875rem;
  font-weight: 800;
  gap: 0.3125rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.toy-input,
.toy-select {
  appearance: none;
  background-color: var(--toy-panel);
  border: var(--toy-border-control) solid var(--toy-ink);
  border-radius: var(--toy-radius-md);
  box-shadow: 0 2px 0 var(--toy-ink);
  color: var(--toy-ink);
  font-weight: 700;
  min-height: 2.625rem;
  padding: 0.4rem 0.75rem;
  width: 100%;
}

.toy-select {
  background-image:
    linear-gradient(45deg, transparent 50%, var(--toy-ink) 50%),
    linear-gradient(135deg, var(--toy-ink) 50%, transparent 50%);
  background-position:
    calc(100% - 1rem) 52%,
    calc(100% - 0.7rem) 52%;
  background-repeat: no-repeat;
  background-size: 0.35rem 0.35rem;
  padding-right: 2.4rem;
}

.toy-range {
  appearance: none;
  background: transparent;
  cursor: pointer;
  min-height: 1.5rem;
  width: 100%;
}

.toy-range::-webkit-slider-runnable-track {
  background: var(--toy-paper);
  border: 2px solid var(--toy-ink);
  border-radius: var(--toy-radius-pill);
  height: 0.625rem;
}

.toy-range::-webkit-slider-thumb {
  appearance: none;
  background: var(--toy-yellow-fill);
  border: 2.5px solid var(--toy-ink);
  border-radius: 50%;
  height: 1.35rem;
  margin-top: -0.47rem;
  width: 1.35rem;
}

.toy-range::-moz-range-track {
  background: var(--toy-paper);
  border: 2px solid var(--toy-ink);
  border-radius: var(--toy-radius-pill);
  height: 0.625rem;
}

.toy-range::-moz-range-thumb {
  background: var(--toy-yellow-fill);
  border: 2.5px solid var(--toy-ink);
  border-radius: 50%;
  height: 1.1rem;
  width: 1.1rem;
}

.toy-status {
  align-items: center;
  color: var(--toy-muted);
  display: inline-flex;
  font-size: 0.75rem;
  font-weight: 800;
  gap: var(--toy-space-2);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.toy-status::before {
  background: #b9d9c6;
  border: 2px solid var(--toy-ink);
  border-radius: 50%;
  content: "";
  height: 0.7rem;
  width: 0.7rem;
}

.toy-status--active {
  color: var(--toy-green-text);
}

.toy-status--active::before {
  animation: toy-breathe 1s ease-in-out infinite;
  background: var(--toy-green-fill);
  box-shadow: 0 0 10px rgb(47 191 113 / 80%);
}

.toy-chip {
  align-items: center;
  background: var(--toy-panel);
  border: var(--toy-border-control) solid var(--toy-ink);
  border-radius: var(--toy-radius-pill);
  box-shadow: 0 3px 0 var(--toy-ink);
  color: var(--toy-ink);
  display: inline-flex;
  font-size: 0.75rem;
  font-weight: 800;
  min-height: 2rem;
  padding: 0.25rem 0.75rem;
}

.toy-chip--yellow { background: var(--toy-yellow-fill); }
.toy-chip--blue { background: var(--toy-blue-soft); }
.toy-chip--grape { background: var(--toy-grape-soft); }

.toy-note-key {
  appearance: none;
  background: var(--toy-panel);
  border: var(--toy-border-structure) solid var(--toy-ink);
  border-radius: var(--toy-radius-md);
  box-shadow: 0 4px 0 var(--toy-ink);
  color: var(--toy-ink);
  cursor: pointer;
  font-family: var(--toy-font-display);
  font-size: 1.0625rem;
  font-weight: 800;
  min-height: 3.75rem;
  padding: 0.5rem 0.75rem;
  position: relative;
  transition: background var(--toy-duration-state), box-shadow var(--toy-duration-fast), transform var(--toy-duration-fast);
}

.toy-note-key small {
  color: var(--toy-muted);
  display: block;
  font-family: var(--toy-font-body);
  font-size: 0.625rem;
  margin-top: 0.1rem;
}

.toy-note-key:hover {
  box-shadow: 0 5px 0 var(--toy-ink);
  transform: translateY(-1px);
}

.toy-note-key:active {
  box-shadow: 0 2px 0 var(--toy-ink);
  transform: translateY(2px);
}

.toy-note-key[aria-pressed="true"] {
  background: var(--toy-yellow-fill);
}

.toy-note-key[data-complete="true"]::after {
  align-items: center;
  background: var(--toy-green-fill);
  border: var(--toy-border-control) solid var(--toy-ink);
  border-radius: 50%;
  color: var(--toy-ink);
  content: "✓";
  display: flex;
  font-family: var(--toy-font-body);
  font-size: 0.7rem;
  font-weight: 800;
  height: 1.45rem;
  justify-content: center;
  position: absolute;
  right: -0.6rem;
  top: -0.6rem;
  width: 1.45rem;
}

.toy-callout {
  background: var(--toy-grape-soft);
  border: var(--toy-border-structure) solid var(--toy-ink);
  border-radius: var(--toy-radius-md);
  box-shadow: 0 4px 0 var(--toy-ink);
  color: var(--toy-text);
  padding: var(--toy-space-4);
}

.toy-callout--yellow { background: var(--toy-yellow-soft); }
.toy-callout--green { background: var(--toy-green-soft); }

.toy-callout strong {
  color: var(--toy-ink);
}

.toy-divider {
  border: 0;
  border-top: 3px dashed rgb(50 43 95 / 25%);
  margin: var(--toy-space-8) 0;
}

.toy-local-badge {
  background: var(--toy-panel);
  border: var(--toy-border-structure) solid var(--toy-ink);
  border-radius: var(--toy-radius-lg);
  box-shadow: 0 4px 0 var(--toy-ink);
  color: var(--toy-muted);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.45;
  max-width: 15rem;
  padding: var(--toy-space-3) var(--toy-space-4);
  transform: rotate(1.5deg);
}

.toy-local-badge strong {
  color: var(--toy-ink);
  display: block;
  font-weight: 800;
}

@keyframes toy-breathe {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}

@media (max-width: 42.5rem) {
  :root { --toy-gutter: 0.75rem; }
  .toy-machine { border-radius: 1.375rem; padding: var(--toy-space-4) var(--toy-space-3); }
  .toy-local-badge { max-width: none; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .toy-surface *,
  .toy-surface *::before,
  .toy-surface *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
  }
}
