/* ==========================================================================
   BEJO Studio. Builds on the tokens and buttons in styles.css.
   ========================================================================== */

.studio-page {
  background-color: var(--bg);
  background-image: radial-gradient(circle, var(--dot) 0 1px, transparent 1.5px);
  background-size: 8px 8px;
}

.studio {
  min-height: 100svh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: center;
  justify-items: center;
  gap: 1rem;
  padding: clamp(1rem, 4vw, 3rem) var(--gutter);
}

/* ---------- Window shell (also used by the reveal dialog) ---------- */
.window {
  width: min(100%, 1080px);
  background: var(--bg);
  border: 1px solid var(--line);
}

.window-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  height: 52px;
  padding-inline: 1rem;
  border-bottom: 1px solid var(--line);
  background: var(--bg-raised);
}
.window-logo img { height: 24px; width: auto; }
.window-title {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
}
.scope {
  flex: 1;
  min-width: 0;
  height: 32px;
  max-width: 320px;
  margin-left: auto;
}
.readout { display: flex; gap: 1.25rem; font-family: var(--font-mono); font-size: 0.75rem; }
.readout div { display: flex; gap: 0.4rem; }
.readout dt { color: var(--muted); }
.readout dd { font-weight: 700; }
.window-close {
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  margin-right: -0.5rem;
  font-size: 1.5rem;
  line-height: 1;
  text-decoration: none;
  color: var(--muted);
  transition: color 150ms ease;
}
@media (hover: hover) and (pointer: fine) {
  .window-close:hover { color: var(--text); }
}

/* ---------- Transport ---------- */
.transport {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  padding: 1.25rem;
  border-bottom: 1px solid var(--line);
}
.btn-play { min-width: 7rem; justify-content: center; }
.btn-play[aria-pressed="true"] { background: var(--text); border-color: var(--text); }
.btn:disabled { opacity: 0.4; pointer-events: none; }
.hint { margin-left: auto; color: var(--muted); font-size: 0.8125rem; }
kbd {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 0.15rem 0.4rem;
  border: 1px solid var(--line);
}

/* ---------- Bar picker ---------- */
.bars {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--line);
}
.bars-label {
  width: 8rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}
.bar-tabs {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.5rem;
  min-width: 0;
}
.bar-tab {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--line);
  background: var(--bg-raised);
  transition: transform 120ms var(--ease-out), border-color 150ms ease;
}
.bar-tab:active { transform: scale(0.97); }
.bar-tab[aria-pressed="true"] { border-color: var(--accent); }
.bar-num { font-family: var(--font-display); font-weight: 900; font-size: 1.375rem; line-height: 1; }
.bar-tab[aria-pressed="true"] .bar-num { color: var(--accent); }
/* Mini overview: one cell per step, filled when any lane has a hit there */
.bar-mini {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(16, minmax(0, 1fr));
  gap: 2px;
  min-width: 0;
}
.bar-mini i { height: 6px; background: var(--line); }
.bar-mini i.on { background: var(--muted); }
.bar-tab[aria-pressed="true"] .bar-mini i.on { background: var(--accent); }
/* The bar that is playing right now */
.bar-tab::after {
  content: "";
  position: absolute;
  left: -1px;
  right: -1px;
  bottom: -1px;
  height: 2px;
  background: var(--text);
  transform: scaleX(0);
}
.bar-tab.is-playing::after { transform: scaleX(1); }
.btn-small { padding: 0.6rem 1rem; font-size: 0.75rem; }
@media (hover: hover) and (pointer: fine) {
  .bar-tab:hover { border-color: var(--accent); }
}

/* ---------- Lanes ---------- */
.lane {
  display: grid;
  grid-template-columns: 8rem 1fr;
  align-items: start;
  gap: 1.25rem;
  padding: 1.25rem;
  border-bottom: 1px solid var(--line);
}
.lane-name {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 2rem;
  line-height: 1;
  text-transform: uppercase;
  padding-top: 0.35rem;
  transition: color 150ms ease;
}
.lane.is-off .lane-name { color: var(--muted); }
.lane-hint {
  margin-top: 0.5rem;
  font-size: 0.8125rem;
  line-height: 1.35;
  color: var(--muted);
}
.lane-body { display: grid; gap: 0.75rem; min-width: 0; }

.choices {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.5rem;
}
.choice {
  padding: 0.75rem 0.5rem;
  border: 1px solid var(--line);
  background: var(--bg-raised);
  font-weight: 500;
  font-size: 0.9375rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: transform 120ms var(--ease-out), border-color 150ms ease, background-color 150ms ease, color 150ms ease;
}
.choice:active { transform: scale(0.97); }
.choice[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--bg); font-weight: 700; }
@media (hover: hover) and (pointer: fine) {
  .choice:hover { border-color: var(--accent); }
}

/* Loop position (a playhead, not a progress meter) */
.loop-pos { height: 2px; }
.loop-pos span {
  display: block;
  height: 100%;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
}

/* Step grid. Beats alternate shade so the 4 groups read at a glance. */
.steps {
  display: grid;
  grid-template-columns: repeat(16, minmax(0, 1fr));
  gap: 4px;
}
.step {
  aspect-ratio: 1;
  max-height: 3rem;
  border: 1px solid var(--line);
  background: var(--bg-raised);
  transition: transform 100ms var(--ease-out);
}
.step-alt { background: var(--bg-alt); }
.step:active { transform: scale(0.92); }
.step[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); }
/* Bass: a held note reads as one block by filling the gap to the next step */
.step.joins-next { box-shadow: 5px 0 0 var(--accent); }
.step.is-now { border-color: var(--text); }
.step.is-now[aria-pressed="true"] { background: var(--text); border-color: var(--text); }
@media (hover: hover) and (pointer: fine) {
  .step:hover { border-color: var(--accent); }
}

/* Bass layers: the lane grid itself holds them, so the name sits in the same left
   column as the lane titles and the steps line up with the vox and FX steps */
.lane-bass { row-gap: 6px; }
.lane-bass .lane-hint { margin: 0 0 0.35rem; align-self: end; }
.layer-name {
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--line);
  background: var(--bg-raised);
  font-size: 0.875rem;
  font-weight: 500;
  text-align: left;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: transform 120ms var(--ease-out), border-color 150ms ease, color 150ms ease;
}
.layer-name:active { transform: scale(0.97); }
.layer-name.is-used { color: var(--text); border-color: var(--accent); }
.lane-bass .step { aspect-ratio: auto; height: 2.25rem; }
@media (hover: hover) and (pointer: fine) {
  .layer-name:hover { color: var(--text); border-color: var(--accent); }
}

/* ---------- Footer / drop ---------- */
.window-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem 2rem;
  padding: 1.25rem;
}
.window-foot p { color: var(--muted); max-width: 46ch; }
.btn-drop {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 1.75rem;
  letter-spacing: 0.04em;
  padding: 0.6rem 2.25rem;
}

.status, .placeholder-note {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted);
  text-align: center;
}
.status:empty { display: none; }

/* ---------- Commission ---------- */
.commission {
  width: min(100%, 1080px);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem 2rem;
  margin-top: 1rem;
  padding: 1.5rem 1.25rem;
  border: 1px solid var(--line);
  background: var(--bg);
}
.commission-text { display: grid; gap: 0.35rem; max-width: 60ch; }
.commission-title {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(1.5rem, 3vw, 2rem);
  line-height: 1;
  text-transform: uppercase;
}
.commission p { color: var(--muted); }

/* ---------- Rare-item glow (commission block + peek tab) ----------
   Like loot in a game: a soft purple aura that breathes, and a band of light
   running around the border. Asked for by the artist; motion stops under reduced motion. */
@property --loot-angle {
  syntax: "<angle>";
  inherits: false;
  initial-value: 0deg;
}
.commission,
.loot-peek { position: relative; isolation: isolate; }

/* Aura: a blurred purple shadow on a pseudo-element, pulsed with opacity (cheap to animate) */
.commission::after,
.loot-peek::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  box-shadow: 0 0 32px 4px color-mix(in srgb, var(--accent) 55%, transparent),
              0 0 80px 10px color-mix(in srgb, var(--accent) 22%, transparent);
  opacity: 0.6;
}
/* Light sweep: a rotating conic gradient, masked down to a 1px border ring */
.commission::before,
.loot-peek::before {
  content: "";
  position: absolute;
  inset: -1px;
  padding: 1px;
  pointer-events: none;
  background: conic-gradient(from var(--loot-angle), transparent 0deg 250deg, var(--accent) 300deg, var(--text) 320deg, var(--accent) 340deg, transparent 360deg);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
          mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
}

.loot-peek {
  position: fixed;
  left: 50%;
  bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
  z-index: var(--z-header);
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  max-width: calc(100% - 2 * var(--gutter));
  padding: 0.7rem 1rem;
  border: 1px solid color-mix(in srgb, var(--accent) 50%, var(--line));
  background: var(--bg-raised);
  font-size: 0.9375rem;
  font-weight: 500;
  white-space: nowrap;
  transform: translateX(-50%);
  transition: opacity 250ms var(--ease-out), transform 250ms var(--ease-out), visibility 0s linear 0s;
}
.loot-peek.is-hidden {
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, 1rem);
  transition: opacity 200ms ease, transform 200ms ease, visibility 0s linear 200ms;
}
.loot-peek-tag {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
}
.loot-peek-text { overflow: hidden; text-overflow: ellipsis; }
.loot-peek-arrow { display: inline-block; color: var(--accent); }
.loot-peek:active { transform: translateX(-50%) scale(0.97); }
@media (hover: hover) and (pointer: fine) {
  .loot-peek:hover::after { opacity: 1; }
}

@media (prefers-reduced-motion: no-preference) {
  .commission::after,
  .loot-peek::after { animation: loot-breathe 2.6s ease-in-out infinite; }
  .commission::before,
  .loot-peek::before { animation: loot-sweep 3.2s linear infinite; }
  .loot-peek-arrow { animation: loot-bob 1.4s var(--ease-in-out) infinite; }
  .loot-peek.is-intro:not(.is-hidden) { animation: loot-rise 500ms var(--ease-out) 1.2s both; } /* first load only */
  /* First time the block scrolls into view: one bright "loot found" flash */
  .commission.is-found::after { animation: loot-found 900ms var(--ease-out), loot-breathe 2.6s ease-in-out 900ms infinite; }
}
@keyframes loot-breathe {
  0%, 100% { opacity: 0.45; }
  50%      { opacity: 0.95; }
}
@keyframes loot-sweep {
  to { --loot-angle: 360deg; }
}
@keyframes loot-bob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(3px); }
}
@keyframes loot-rise {
  from { opacity: 0; transform: translate(-50%, 1rem); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}
@keyframes loot-found {
  0%   { opacity: 0.4; transform: scale(1); }
  35%  { opacity: 1; transform: scale(1.03); }
  100% { opacity: 0.6; transform: scale(1); }
}

/* ---------- Mobile ---------- */
@media (max-width: 720px) {
  .readout { display: none; }
  .hint { display: none; }
  .lane { grid-template-columns: 1fr; gap: 0.75rem; }
  .lane-name { font-size: 1.5rem; padding-top: 0; }
  .lane-head { display: flex; align-items: baseline; gap: 0.75rem; flex-wrap: wrap; }
  .lane-hint { margin-top: 0; }
  .bars-label { width: auto; }
  .bar-tabs { flex-basis: 100%; order: 3; }
  .bar-tab { padding: 0.5rem; gap: 0.5rem; }
  .bar-mini { gap: 1px; }
  .step:nth-child(8n).joins-next { box-shadow: none; } /* row wraps after 8 steps */
  .choices { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .steps { grid-template-columns: repeat(8, minmax(0, 1fr)); }
  .btn-drop { width: 100%; justify-content: center; }
  .lane-bass { row-gap: 0.4rem; }
  .layer-name { justify-self: start; padding: 0.3rem 0.6rem; margin-top: 0.5rem; }
  .lane-bass .step { height: 1.75rem; }
  .loot-peek { font-size: 0.875rem; gap: 0.5rem; padding: 0.65rem 0.85rem; }
}

/* ==========================================================================
   Reveal dialog
   ========================================================================== */
.reveal {
  width: min(100% - 2 * var(--gutter), 760px);
  margin: auto; /* the global reset zeroes the margin dialogs use to center */
  max-width: none;
  max-height: calc(100svh - 2rem);
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  overflow: auto;
}
.reveal::backdrop {
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: blur(6px);
}
.reveal .window { width: 100%; }
.reveal .window-close { margin-left: auto; }

.reveal-body { display: grid; gap: 1.25rem; padding: clamp(1.25rem, 4vw, 2.5rem); }
.reveal-note {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--accent);
}
.reveal-title {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(3rem, 10vw, 5.5rem);
  line-height: 0.9;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}
.reveal-by { color: var(--muted); margin-top: -0.75rem; }

.wave {
  position: relative;
  height: 120px;
  border-block: 1px solid var(--line);
}
.wave canvas { width: 100%; height: 100%; }
.wave-head {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 2px;
  background: var(--text);
  opacity: 0;
}
.reveal.is-playing .wave-head { opacity: 1; }
.wave-loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted);
}
.reveal.is-ready .wave-loading { display: none; }

.reveal-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; }

.reveal-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
}
.field { display: grid; gap: 0.4rem; }
.field label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}
.field input {
  font: inherit;
  color: var(--text);
  background: var(--bg-raised);
  border: 1px solid var(--line);
  padding: 0.7rem 0.85rem;
  border-radius: 0;
}
.field input:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
@media (max-width: 560px) {
  .reveal-fields { grid-template-columns: 1fr; }
}

/* ---------- Video for socials ---------- */
.video-share {
  display: grid;
  gap: 1rem;
  justify-items: start;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
}
.video-share-head { display: grid; gap: 0.35rem; }
.video-share-title {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 1.75rem;
  line-height: 1;
  text-transform: uppercase;
}
.video-share-head p { color: var(--muted); max-width: 52ch; }
.video-panel {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 200px) minmax(0, 1fr);
  align-items: center;
  gap: 1.25rem;
}
.video-stage {
  aspect-ratio: 9 / 16;
  background: var(--bg-raised);
  border: 1px solid var(--line);
}
.video-stage canvas,
.video-stage video { display: block; width: 100%; height: 100%; object-fit: contain; }
.video-side { display: grid; gap: 1rem; align-content: center; }
.video-status { color: var(--muted); }
.video-progress { height: 2px; }
.video-progress span {
  display: block;
  height: 100%;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
}
.video-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; }
@media (max-width: 560px) {
  .video-panel { grid-template-columns: 1fr; }
  .video-stage { width: min(100%, 240px); }
}

/* ---------- Motion ---------- */
@media (prefers-reduced-motion: no-preference) {
  .reveal[open] {
    transition: opacity 220ms var(--ease-out), transform 220ms var(--ease-out);
    @starting-style { opacity: 0; transform: scale(0.96); }
  }
  /* The unveil: waveform wipes in once the mix is ready */
  .reveal.is-ready .wave canvas { animation: wipe 900ms var(--ease-in-out) both; }
  .reveal.is-ready .reveal-title { animation: glitch-in 520ms steps(1, end) both; }
}
@keyframes wipe {
  from { clip-path: inset(0 100% 0 0); }
  to   { clip-path: inset(0 0 0 0); }
}

