/*
 * RAMA L visual system
 * --------------------
 * These values come from Pat's website and app design system. Changing a
 * value here updates the same colour or measurement throughout the page.
 */
:root {
  --bg: #ffffff;
  --bg-tint: #f2f2f2;
  --fg: #0d0d0d;
  --fg-muted: #888076;
  --border: rgba(13, 13, 13, 0.12);
  --border-strong: rgba(13, 13, 13, 0.24);
  --accent: #2f6fed;
  --accent-strong: #174fc6;
  --accent-soft: rgba(47, 111, 237, 0.12);
  --danger: #7d2929;
  --font: "IBM Plex Mono", "Courier New", monospace;
  --topbar-height: 54px;
}

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

html {
  min-width: 320px;
  min-height: 100%;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background-color: var(--bg);
  background-image:
    linear-gradient(rgba(13, 13, 13, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(13, 13, 13, 0.025) 1px, transparent 1px);
  background-size: 32px 32px;
  color: var(--fg);
  font-family: var(--font);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  line-height: 1.7;
}

button,
input,
output {
  color: inherit;
  font: inherit;
}

button,
input[type="range"],
.drop-zone {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
.drop-zone:focus-visible {
  outline: 1px dashed var(--accent);
  outline-offset: 4px;
}

[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* The fixed bar makes the page feel like part of the same family as the
   website and desktop tools without adding another navigation system. */
.topbar {
  position: fixed;
  inset: 0 0 auto;
  z-index: 20;
  height: var(--topbar-height);
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
}

.topbar__inner {
  display: flex;
  width: min(1040px, calc(100% - 40px));
  height: 100%;
  margin: 0 auto;
  align-items: center;
  justify-content: space-between;
}

.wordmark {
  font-size: 11px;
  letter-spacing: 0.04em;
}

/* The wordmark doubles as a quiet route back to Pat's main website. */
.wordmark__home:hover {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.eyebrow,
.panel-head,
.sample-library__head,
.loop-head,
.loop-values,
.waveform-axis,
.file-meta,
.file-error,
.copy-state,
.site-footer {
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.eyebrow,
.panel-head,
.sample-library__head,
.loop-head,
.loop-values,
.file-meta,
.copy-state,
.site-footer {
  color: var(--fg-muted);
}

.machine-shell {
  width: min(1040px, calc(100% - 40px));
  margin: 0 auto;
  padding: calc(var(--topbar-height) + 54px) 0 34px;
}

.page-head {
  padding: 0 0 30px;
  border-bottom: 1px solid var(--border);
  animation: workspace-enter 350ms ease-out both;
}

.eyebrow {
  margin: 0 0 14px;
}

.title-row {
  display: flex;
  gap: 36px;
  align-items: end;
  justify-content: space-between;
}

h1,
h2,
p {
  margin-top: 0;
}

h1,
h2 {
  margin-bottom: 0;
}

h1 {
  color: var(--accent);
  font-size: clamp(42px, 8vw, 76px);
  font-weight: 500;
  letter-spacing: -0.075em;
  line-height: 0.86;
}

h1 sup {
  margin-left: 0.16em;
  color: var(--accent);
  font-size: 0.34em;
  letter-spacing: 0;
  line-height: 0;
  vertical-align: super;
}

.title-row p {
  max-width: 330px;
  margin-bottom: 0;
  color: var(--fg-muted);
  font-size: 11px;
  line-height: 1.7;
}

/* Panels use thin rules and a small calibration notch. This is one of the
   repeated signatures across Music Analyser, Album Builder and Journal. */
.panel {
  position: relative;
  min-width: 0;
  margin-top: 18px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.92);
  animation: workspace-enter 350ms 60ms ease-out both;
}

.panel-head {
  position: relative;
  display: flex;
  min-height: 48px;
  padding: 0 18px;
  border-bottom: 1px solid var(--border);
  align-items: center;
  justify-content: space-between;
}

.panel-head::before {
  position: absolute;
  top: -1px;
  left: 50%;
  width: 18px;
  border-top: 1px solid color-mix(in srgb, var(--accent) 38%, var(--border));
  content: "";
  transform: translateX(-50%);
}

.panel-head::after {
  position: absolute;
  top: 4px;
  left: 50%;
  height: 4px;
  border-left: 1px solid color-mix(in srgb, var(--accent) 30%, var(--border));
  content: "";
}

.panel-head h2 {
  color: var(--fg);
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.panel-body {
  padding: 18px;
}

.input-body {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(250px, 0.7fr);
  min-height: 360px;
}

.input-empty {
  /* The drop button is the entire left input field, not a content-sized box. */
  display: flex;
  min-height: 322px;
  border: 1px solid var(--border);
  grid-column: 1;
  grid-row: 1;
}

.drop-zone {
  position: relative;
  display: grid;
  width: 100%;
  min-height: 100%;
  min-width: 0;
  box-sizing: border-box;
  padding: 34px;
  border: 0;
  background:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px),
    var(--bg);
  background-size: 64px 64px;
  align-content: center;
  justify-items: center;
  font: inherit;
  text-align: center;
  transition: background-color 160ms ease, border-color 160ms ease;
}

.drop-zone::before,
.drop-zone::after {
  position: absolute;
  width: 20px;
  height: 20px;
  border-color: var(--border-strong);
  content: "";
}

.drop-zone::before {
  top: 14px;
  left: 14px;
  border-top: 1px solid;
  border-left: 1px solid;
}

.drop-zone::after {
  right: 14px;
  bottom: 14px;
  border-right: 1px solid;
  border-bottom: 1px solid;
}

.drop-zone:hover,
.drop-zone.is-dragging,
.drop-zone:focus-within {
  border-color: var(--accent);
  background-color: var(--accent-soft);
}

.drop-index {
  position: absolute;
  top: 18px;
  right: 20px;
  color: var(--fg-muted);
  font-size: 8px;
  letter-spacing: 0.08em;
}

.drop-label {
  color: var(--fg);
  font-size: clamp(17px, 2.4vw, 24px);
  letter-spacing: -0.03em;
}

.drop-or {
  margin: 7px 0 9px;
  color: var(--fg-muted);
  font-size: 8px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.picker-button,
.button {
  display: inline-grid;
  min-height: 38px;
  padding: 0 13px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg);
  align-items: center;
  font-size: 10px;
  letter-spacing: 0.04em;
  transition: border-color 140ms ease, background 140ms ease, color 140ms ease;
}

.picker-button {
  border-color: var(--accent);
  color: var(--accent);
}

.drop-zone:hover .picker-button,
.drop-zone:focus-within .picker-button {
  background: var(--accent);
  color: #ffffff;
}

.file-meta {
  max-width: 100%;
  margin-top: 16px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sample-library {
  display: grid;
  grid-template-rows: 48px minmax(0, 1fr);
  min-width: 0;
  min-height: 322px;
  border: 1px solid var(--border);
  border-left: 0;
  background: var(--bg-tint);
  grid-column: 2;
  grid-row: 1;
}

.sample-library__head {
  display: flex;
  gap: 10px;
  padding: 0 14px;
  border-bottom: 1px solid var(--border);
  align-items: center;
  justify-content: space-between;
}

.sample-library__head span:last-child {
  font-size: 7px;
  text-align: right;
}

.sample-list {
  display: grid;
  align-content: start;
  padding: 12px;
}

.sample-button {
  display: grid;
  width: 100%;
  min-height: 58px;
  padding: 10px 11px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg);
  gap: 3px;
  text-align: left;
  transition: border-color 140ms ease, transform 140ms ease;
}

.sample-button::before {
  width: 7px;
  height: 7px;
  margin-bottom: 4px;
  background: var(--accent);
  content: "";
}

.sample-button span {
  font-size: 10px;
}

.sample-button small {
  color: var(--fg-muted);
  font-size: 8px;
}

.sample-button:hover,
.sample-button:focus-visible {
  border-color: var(--accent);
  outline: 0;
  transform: translateY(-2px);
}

/* Once a source is available, the panel becomes a compact editing field. */
.source-workspace {
  /* The loop editor uses these same insets so its handles map exactly onto
     the visible waveform canvas rather than the wider surrounding panel. */
  --waveform-inset-left: 48px;
  --waveform-inset-right: 20px;
  min-width: 0;
  padding-right: 18px;
  animation: source-enter 220ms ease-out both;
  grid-column: 1;
  grid-row: 1;
}

.source-tools {
  display: flex;
  min-height: 30px;
  margin-bottom: 12px;
  align-items: center;
  justify-content: space-between;
}

.source-name {
  max-width: calc(100% - 120px);
  overflow: hidden;
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quiet-action {
  padding: 3px 0;
  border: 0;
  background: transparent;
  color: var(--fg-muted);
  font-size: 9px;
  text-decoration: none;
}

.quiet-action:hover,
.quiet-action:focus-visible {
  color: var(--accent);
  outline: 0;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.waveform-frame {
  position: relative;
  padding: 22px var(--waveform-inset-right) 18px var(--waveform-inset-left);
  border: 1px solid var(--border);
  background: var(--bg-tint);
}

.waveform-frame::before {
  position: absolute;
  top: 50%;
  right: var(--waveform-inset-right);
  left: var(--waveform-inset-left);
  border-top: 1px solid var(--border);
  content: "";
  pointer-events: none;
}

.waveform {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 210px;
}

.waveform-axis {
  position: absolute;
  left: 12px;
  color: var(--fg-muted);
  font-size: 7px;
  writing-mode: vertical-rl;
}

.waveform-axis--top {
  top: 20px;
}

.waveform-axis--bottom {
  bottom: 18px;
  writing-mode: horizontal-tb;
}

.loop-block {
  display: grid;
  gap: 10px;
  margin-top: 17px;
  padding-right: calc(var(--waveform-inset-right) + 1px);
  padding-left: calc(var(--waveform-inset-left) + 1px);
}

.loop-head {
  display: flex;
  gap: 16px;
  justify-content: space-between;
}

.loop-shell {
  position: relative;
  height: 22px;
  cursor: crosshair;
}

.loop-shell.is-disabled {
  opacity: 0.28;
}

.loop-track,
.loop-selection {
  position: absolute;
  top: 10px;
  height: 1px;
  pointer-events: none;
}

.loop-track {
  right: 0;
  left: 0;
  background: var(--border-strong);
}

.loop-selection {
  background: var(--accent);
  box-shadow: 0 -4px 0 var(--accent-soft), 0 4px 0 var(--accent-soft);
}

.loop-shell input[type="range"] {
  position: absolute;
  inset: 0;
  width: 100%;
  pointer-events: none;
}

.loop-values {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
}

.loop-values span:nth-child(2) {
  color: var(--accent);
  text-align: center;
}

.error-block {
  display: flex;
  gap: 12px;
  margin-top: 12px;
  padding: 10px 12px;
  border-left: 1px solid var(--danger);
  background: color-mix(in srgb, var(--danger) 6%, var(--bg));
  align-items: center;
  flex-wrap: wrap;
}

.file-error {
  margin-right: auto;
  color: var(--danger);
}

.error-copy {
  color: var(--danger);
}

.copy-state {
  min-width: 44px;
}

.play-panel {
  animation-delay: 110ms;
}

.playback-body {
  display: grid;
  gap: 24px;
}

.control {
  display: grid;
  grid-template-columns: 100px minmax(0, 1fr) 62px;
  gap: 18px;
  align-items: center;
}

.control > span {
  color: var(--fg-muted);
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.control output {
  color: var(--accent);
  font-size: 10px;
  text-align: right;
}

input[type="range"] {
  appearance: none;
  width: 100%;
  height: 12px;
  margin: 0;
  background: transparent;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 1px;
  background: var(--border-strong);
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 7px;
  height: 7px;
  margin-top: -3px;
  border: 0;
  border-radius: 0;
  background: var(--accent);
}

input[type="range"]::-moz-range-track {
  height: 1px;
  background: var(--border-strong);
}

input[type="range"]::-moz-range-thumb {
  width: 7px;
  height: 7px;
  border: 0;
  border-radius: 0;
  background: var(--accent);
}

.transport-row {
  display: flex;
  gap: 22px;
  align-items: center;
  justify-content: space-between;
}

.button-row {
  display: flex;
  flex: 0 0 auto;
  gap: 9px;
}

.button:hover,
.button:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
  outline: 0;
}

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

.button-primary:hover,
.button-primary:focus-visible {
  background: var(--bg);
  color: var(--accent);
}

.button:disabled {
  cursor: default;
  opacity: 0.28;
}

.status {
  min-height: 1.5em;
  margin: 0;
  color: var(--fg-muted);
  font-size: 10px;
  text-align: right;
}

.site-footer {
  display: flex;
  gap: 24px;
  margin-top: 20px;
  justify-content: space-between;
}

.site-footer p {
  margin: 0;
}

.site-footer a {
  color: var(--accent);
}

.site-footer a:hover,
.site-footer a:focus-visible {
  text-decoration: underline;
  text-underline-offset: 3px;
}

@keyframes workspace-enter {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes source-enter {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 720px) {
  .topbar__inner,
  .machine-shell {
    width: min(100% - 24px, 1040px);
  }

  .machine-shell {
    padding-top: calc(var(--topbar-height) + 32px);
  }

  .title-row {
    display: grid;
    gap: 18px;
  }

  .input-body {
    grid-template-columns: 1fr;
  }

  .drop-zone {
    min-height: 250px;
  }

  .sample-library {
    min-height: 150px;
    border-top: 0;
    border-left: 1px solid var(--border);
    grid-column: 1;
    grid-row: 2;
  }

  .source-workspace {
    padding-right: 0;
    grid-column: 1;
    grid-row: 1;
  }

  .waveform {
    height: 160px;
  }

  .control {
    grid-template-columns: 1fr auto;
  }

  .control input {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .transport-row,
  .site-footer {
    align-items: start;
    flex-direction: column;
  }

  .status {
    text-align: left;
  }
}

@media (max-width: 460px) {
  .panel-body {
    padding: 12px;
  }

  .panel-head {
    padding: 0 12px;
  }

  .drop-zone {
    padding: 24px 16px;
  }

  .source-workspace {
    --waveform-inset-left: 34px;
    --waveform-inset-right: 10px;
  }

  .button-row {
    width: 100%;
  }

  .button {
    flex: 1;
    justify-content: center;
  }
}

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