/* ============================================================
   Lull — Design System CSS
   Generated from Figma design tokens
   Dark mode implementation
   ============================================================ */

/* ── Primitive Tokens ──────────────────────────────────────── */
:root {

  /* Neutral scale — dark mode */
  --neutral-0:    #FFFFFF;
  --neutral-100:  #EAEBF2;
  --neutral-200:  #BEC2D3;
  --neutral-300:  #9CA2BE;
  --neutral-400:  #6E7496;
  --neutral-500:  #5D6382;
  --neutral-600:  #48526E;
  --neutral-700:  #30384B;
  --neutral-800:  #1E2634;
  --neutral-900:  #101827;
  --neutral-1000: #000000;

  /* Brand teal — dark mode */
  --brand-100: #9AE1D8;
  --brand-200: #86DCD1;
  --brand-300: #6FD7C9;
  --brand-400: #5AD3C3;
  --brand-500: #41CEBC;
  --brand-600: #2FC0AD;
  --brand-700: #27A494;
  --brand-800: #1E8577;
  --brand-900: #145D53;

  /* Negative */
  --negative-300: #CD2650;
  --negative-400: #A71D40;

  /* ── Semantic Tokens — Dark Mode ── */

  /* Surface */
  --Surface-L0:              #1E2634;

  /* Background */
  --bg-primary:              #121212;
  --bg-primary-hover:        #3D3D3D;
  --bg-primary-active:       #636363;
  --bg-primary-disabled:     #000000;
  --bg-brand-default:        #1C7573;
  --bg-brand-hover:          #269A96;
  --bg-brand-active:         #31BFBB;
  --bg-negative:             #F59EAD;

  /* Content / Text */
  --content-primary:         #FFFFFF;
  --content-secondary:       #CACACA;
  --content-tertiary:        #A6A6A6;
  --content-disabled:        #858585;
  --content-brand:           #31BFBB;
  --content-negative:        #F8C9D1;

  /* Border */
  --border-primary:          #858585;
  --border-primary-hover:    #CACACA;
  --border-primary-active:   #DAD9D7;
  --border-primary-disabled: #3D3D3D;
  --border-brand:            #31BFBB;
  --border-brand-hover:      #3FD5D1;
  --border-negative:         #F59EAD;
  --border-negative-subtle:  #C30D2C;

  /* Surface */
  --surface-l0: #3D3D3D;
  --surface-l1: #636363;
  --surface-l2: #858585;
  --surface-l3: #A6A6A6;
  --surface-l4: #CACACA;
  --surface-l5: #DAD9D7;
  --surface-l6: #EDECEA;

  /* Overlay */
  --overlay-50:         rgba(255, 255, 255, 0.5);
  --overlay-50-inverse: rgba(0, 0, 0, 0.5);

  /* Hex canvas */
  --Background-Inverse: #BEC2D3;
  --hex-fill:   #BEC2D3;
  --hex-border: #BEC2D3;

  /* Balls */
  --Content-BallLarge:  rgba(0, 0, 0, 0.25);
  --Content-BallMedium: rgba(0, 0, 0, 0.50);
  --Content-BallSmall:  rgba(0, 0, 0, 0.75);
  --ball-large:  #6E7496;
  --ball-medium: #5D6382;
  --ball-small:  #48526E;

  /* ── Drop Shadows ── */
  --shadow-l0: none;
  --shadow-l1: 0 2px 8px 0 rgba(0, 0, 0, 0.11);
  --shadow-l2: 0 4px 18px 0 rgba(0, 0, 0, 0.11);
  --shadow-l3: 0 6px 21px 0 rgba(0, 0, 0, 0.11);
  --shadow-l4: 0 8px 30px 0 rgba(0, 0, 0, 0.11);
  --shadow-l5: 0 10px 37px 0 rgba(0, 0, 0, 0.11);
  --shadow-l6: 0 12px 40px 0 rgba(0, 0, 0, 0.11);

  /* ── Typography ── */
  --font-logo: 'Unica One', sans-serif;
  --font-ui:   'Figtree', sans-serif;

  --text-2xs:   10px;
  --text-xs:    12px;
  --text-sm:    14px;
  --text-md:    16px;
  --text-lg:    18px;
  --text-logo:  30px;

  --weight-regular:  400;
  --weight-medium:   500;
  --weight-semibold: 600;
  --weight-bold:     700;

  --tracking-label: 1px;
  --tracking-logo:  -0.625px;

  /* ── Spacing ── */
  --space-2xs: 4px;
  --space-xs:  8px;
  --space-sm:  16px;
  --space-md:  24px;
  --space-lg:  32px;
  --space-xl:  48px;
  --space-2xl: 64px;
  --space-3xl: 80px;
  --space-4xl: 128px;

  /* ── Border Radius ── */
  --radius-sharp:  4px;
  --radius-md:     8px;
  --radius-soft:   24px;
  --radius-circle: 999px;

  /* ── Component Sizes ── */
  --toolbar-height:   80px;
  --toolbar-padding:  32px;
  --channel-width:    400px;
  --channel-gap:      12px;
  --hex-size:         277px;
  --dial-size:        48px;
  --button-size:      48px;
  --play-button-size: 56px;
  --dropdown-height:  40px;
  --dropdown-width:   135px;
}

/* ── Base Reset ──────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  background: var(--Surface-L0, #1E2634);
  color: var(--content-primary);
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  font-weight: var(--weight-regular);
  overflow: hidden;
  user-select: none;
  -webkit-font-smoothing: antialiased;
}

/* ── Top Bar ─────────────────────────────────────────────────── */
#topbar {
  display: flex;
  align-items: center;
  padding: var(--toolbar-padding);
  padding-bottom: 0;
  width: 100%;
  backdrop-filter: blur(5px);
  position: relative;
  z-index: 10;
}

/* Logo — flex:1 so it takes half the flanking space */
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
}

.logo-text {
  font-family: var(--font-logo);
  font-size: var(--text-logo);
  letter-spacing: var(--tracking-logo);
  color: var(--content-primary);
}

/* Toolbar center group — in normal flow, flanked by two flex:1 items */
.bar-center {
  display: flex;
  align-items: center;
}

.bar-controls {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
  /* The vol label (28px) + gap (4px) = 32px left overhang shifts the play button
     16px right of the group's geometric centre. A negative margin also shrinks
     bar-center's flex size, re-offsetting bar-center's start position — so the
     full correction is 2× the visual offset: −32px. */
  margin-left: -32px;
}

/* Toolbar right side — flex:1 + justify-content:flex-end pushes content right */
.bar-sides {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

/* Record button + timer group — row: timer left, button right */
.record-group {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 12px;
}

/* ── Buttons ─────────────────────────────────────────────────── */
.icon-btn {
  width: var(--button-size);
  height: var(--button-size);
  border-radius: var(--radius-circle);
  border: 1px solid var(--neutral-600);   /* #48526e */
  background: var(--neutral-900);         /* #101827 */
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--content-primary);          /* #ffffff */
  transition: border-color 0.2s, background 0.2s;
  flex-shrink: 0;
}

.icon-btn:hover {
  border-color: var(--neutral-400);       /* #6e7496 */
  background: var(--neutral-800);         /* #1e2634 */
}

.icon-btn:active {
  background: var(--neutral-700);         /* #30384b */
  border-color: var(--neutral-300);       /* #9ca2be */
}

.icon-btn:disabled {
  background: var(--neutral-1000);        /* #000000 */
  border-color: var(--neutral-800);       /* #1e2634 */
  color: var(--content-disabled);
  cursor: default;
}

.icon-btn svg {
  width: 24px;
  height: 24px;
}


/* Record button — recording active state */
#recordBtn.recording {
  border-color: var(--negative-300);
  color: var(--negative-300);
}

#recTimer {
  font-size: var(--text-2xs);
  font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--content-tertiary);
  height: 14px;
  text-align: center;
}

#recTimer.active {
  color: var(--negative-300);
}

/* ── AUTO Hex Button ─────────────────────────────────────────── */
#modeToggle {
  display: flex;
  justify-content: center;
  padding: 32px 0;
  width: 100%;
}

.toggle-track {
  position: relative;
  width: 46px;
  height: 50px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
}

/* SVG hex shape — absolutely fills the button */
.hex-shape {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.hex-path {
  fill: var(--neutral-900);
  stroke: var(--neutral-600);
  transition: fill 0.2s, stroke 0.2s;
}

.toggle-track:hover .hex-path {
  fill: var(--neutral-800);
  stroke: var(--neutral-500);
}

.toggle-track:active .hex-path {
  fill: var(--neutral-900);
  stroke: var(--neutral-600);
}

.toggle-track.on .hex-path {
  fill: var(--Background-PrimaryActive, #30384B);
  stroke: var(--Border-PrimaryActive, #9CA2BE);
  stroke-width: 1px;
}

/* Indicator dot — teal when on, dim when off */
.toggle-knob {
  display: block;
  position: relative;
  z-index: 1;
  width: 6px;
  height: 6px;
  border-radius: var(--radius-circle);
  background: var(--neutral-500);
  flex-shrink: 0;
  transition: background 0.25s;
}

.toggle-track.on .toggle-knob {
  background: var(--brand-500);
}

#modeToggle span {
  position: relative;
  z-index: 1;
  font-size: 10px;
  font-weight: var(--weight-medium);
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--content-primary);
  line-height: 1;
}

/* ── Dials ───────────────────────────────────────────────────── */
.dial-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2xs);
  cursor: ns-resize;
}

.dial-label {
  font-size: var(--text-2xs);
  font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--neutral-400);    /* #6e7496 — matches Figma --content/secondary */
  height: 14px;
  line-height: 14px;
  white-space: nowrap;
}

.dial-label.dragging {
  color: var(--neutral-0);
}

/* Master Vol in topbar: row layout, knob left · label right */
.master-dial {
  flex-direction: row;
  align-items: center;
  gap: 4px;
  height: 67px;
}

.master-dial .dial-label {
  height: auto;
  line-height: normal;
  width: 28px;         /* fixed: wide enough for "10.0" at 10px Figtree Medium + 1px tracking */
  flex-shrink: 0;
  text-align: right;   /* right-align so knob never shifts regardless of text length */
}

.dial-svg {
  width: 48px;
  height: 48px;
  overflow: visible;
  flex-shrink: 0;
}

/* ── Dial Knob States ──────────────────────────────────────────── */

/* Idle outer ring */
.dial-svg circle:first-child {
  fill: var(--neutral-900);
  stroke: var(--neutral-600);
  stroke-width: 1;
}

/* Hover */
.dial-wrap:hover .dial-svg circle:first-child {
  fill: var(--neutral-800);
  stroke: var(--neutral-400);
  stroke-width: 1;
}

/* ── Channel Canvas Area ─────────────────────────────────────── */
#canvas {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: var(--space-sm);
  padding: 5vh var(--space-lg) 0;
}

.channel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
  width: var(--channel-width);
  max-width: var(--channel-width);
  transition: transform 400ms ease-in-out;
}

.channel.auto-centered {
  transform: translateY(80px);
}

.hex-canvas {
  width: var(--hex-size);
  height: var(--hex-size);
  flex-shrink: 0;
}

/* ── Channel Controls ────────────────────────────────────────── */
.channel-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
  width: 100%;
  opacity: 1;
  transform: translateY(0);
  transition: opacity 300ms ease-out, transform 300ms ease-out;
}

.channel-controls.auto-mode {
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 200ms ease-in, transform 200ms ease-in;
}


/* ── Source Dropdown ─────────────────────────────────────────── */
.sound-source {
  width: 100%;
  max-width: 176px;
  display: flex;
  align-items: center;
}

/* Upload button is hidden — "Add sound +" lives as the first dropdown option instead */
.sound-source button {
  display: none;
}

.sound-source select {
  flex: 1;
  height: auto;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--content-primary);
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 500;
  padding: 8px 36px 8px 16px;
  cursor: pointer;
  outline: none;
  appearance: none;
  box-shadow: 0px 1px 1px rgba(0, 0, 0, 0.05);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23FFFFFF' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}

.sound-source select:hover {
  border-color: transparent;
  border-bottom-color: var(--neutral-400);
  border-radius: 0;
  box-shadow: 0px 1px 2px rgba(0, 0, 0, 0.05);
}

.sound-source select:focus {
  background-color: var(--neutral-700);
  border-color: transparent;
  border-radius: 8px;
  box-shadow: 0px 1px 1px rgba(0, 0, 0, 0.05);
}

.sound-source select:disabled {
  color: var(--neutral-600);
  cursor: not-allowed;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%2348526E' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
}

/* ── Dial Grid ───────────────────────────────────────────────── */
/* ── Dial Grid (3×3) ─────────────────────────────────────────────
   JS creates 5 dial-wraps in order: GRAV, ROT, BALLS, ROUND, GRAIN.
   Grid layout per Figma (node 232:928):
     col 2 row 1  → GRAV  (nth-child 1)
     col 1 row 2  → ROT   (nth-child 2)
     col 2 row 2  → BALLS (nth-child 3)
     col 3 row 2  → ROUND (nth-child 4)
     col 2 row 3  → GRAIN (nth-child 5)
   ─────────────────────────────────────────────────────────────── */
.dials-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, auto);
  column-gap: 8px;
  row-gap: 16px;
  width: 267px;
  padding: 16px;
  box-sizing: border-box;
}

.dials-row .dial-wrap:nth-child(1) { grid-column: 2; grid-row: 1; }
.dials-row .dial-wrap:nth-child(2) { grid-column: 1; grid-row: 2; }
.dials-row .dial-wrap:nth-child(3) { grid-column: 2; grid-row: 2; }
.dials-row .dial-wrap:nth-child(4) { grid-column: 3; grid-row: 2; }
.dials-row .dial-wrap:nth-child(5) { grid-column: 2; grid-row: 3; }

/* ── Save Dialog ─────────────────────────────────────────────── */
#saveDialog {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
}

.save-card {
  background: var(--neutral-900);
  border-radius: 24px;
  padding: 32px 48px;
  width: 340px;
  display: flex;
  flex-direction: column;
  gap: 32px;
  box-sizing: border-box;
}

.save-top {
  display: flex;
  flex-direction: column;
  gap: 24px;
  width: 100%;
}

.save-label {
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 500;
  color: var(--content-primary);
  line-height: 1.4;
}

#saveFilename {
  background: var(--neutral-900);
  border: 1px solid var(--neutral-600);
  border-radius: 4px;
  color: var(--content-primary);
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 500;
  height: 32px;
  padding: 0 13px;
  outline: none;
  width: 100%;
  box-sizing: border-box;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05);
}

#saveFilename:focus {
  border-color: var(--neutral-400);
}

.save-buttons {
  display: flex;
  gap: 8px;
  width: 100%;
}

#saveCancelBtn,
#saveConfirmBtn {
  display: flex;
  height: 48px;
  padding: 16px 24px;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 0;
  border-radius: 999px;
  font-family: var(--font-ui);
  font-size: 16px;
  font-weight: 400;
  color: var(--content-primary);
  cursor: pointer;
  box-sizing: border-box;
}

#saveCancelBtn {
  background: var(--neutral-900);
  border: 1px solid var(--neutral-600);
  flex: 1;
  transition: border-color 0.2s;
}

#saveCancelBtn:hover {
  border-color: var(--neutral-400);
}

#saveConfirmBtn {
  background: var(--brand-700);
  border: none;
  flex: 1;
  transition: background 0.2s;
}

#saveConfirmBtn:hover {
  background: var(--brand-600);
}

/* ── Sound Tuning Panel ──────────────────────────────────────── */
#tuningPanel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-primary);
  border-top: 1px solid var(--border-primary-disabled);
  z-index: 50;
}

#tuningToggle {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-xs);
  cursor: pointer;
  color: var(--content-tertiary);
  font-size: var(--text-2xs);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  gap: var(--space-xs);
}

#tuningBody {
  display: none;
  padding: var(--space-sm) var(--space-lg) var(--space-md);
}

#tuningBody input[type="range"] {
  width: 100%;
  accent-color: var(--content-brand);
}

#tuningBody label {
  font-size: var(--text-2xs);
  color: var(--content-tertiary);
  text-transform: uppercase;
  letter-spacing: var(--tracking-label);
}

#tuningBody span {
  font-size: var(--text-2xs);
  color: var(--content-secondary);
  text-align: center;
}

#saveTuning,
#resetTuning {
  background: transparent;
  border: 1px solid var(--border-primary-disabled);
  color: var(--content-secondary);
  font-family: var(--font-ui);
  font-size: var(--text-2xs);
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}

#saveTuning:hover,
#resetTuning:hover {
  border-color: var(--border-primary-hover);
  color: var(--content-primary);
}
