/* ============================================================
   TFM Audio Creator (Town Square)
   Built by js/tfm-audio.js inside the Elementor container ".tfm-audio".
   Reference: docs/mocks/audio-creator-mock.html
   Stage (beat curve, lanes, player) on full width, below it the channel
   strips and on the side length / my sounds / download. Below 900px the
   side column moves under the strips.
   Colours only from the area variables (body.tfm-area-square).
   The theme styles <button> and <label> globally, so colours, backgrounds
   and borders of the tool's buttons are secured with !important.
   ============================================================ */

.tfm-audio {
  --ac-accent: var(--area-accent, #40d9b0);
  --ac-soft: var(--area-accent-soft, #80e8cc);
  --ac-ink: var(--ink, #f6f1ea);
  --ac-text: var(--body-text, #e4ddf0);
  --ac-muted: var(--muted, #b6afc7);
  --ac-line: color-mix(in srgb, var(--ac-accent) 22%, transparent);
  --ac-card: rgba(30, 22, 52, 0.72);
  --ac-on-accent: #0b1a16;
  color: var(--ac-text);
  font-family: 'Jost', sans-serif;
  font-size: 15px;
  width: 100%;
}
.tfm-audio *,
.tfm-audio *::before,
.tfm-audio *::after {
  box-sizing: border-box;
}
/* The Elementor container is a flex column: without min-width 0 its items
   grow to the canvases' pixel width and the stage overflows on phones. */
.tfm-audio > *,
.tfm-audio > .e-con-inner > *,
.tfm-audio .ac-main > *,
.tfm-audio .ac-mixer > * {
  min-width: 0;
}
.tfm-audio canvas {
  max-width: 100%;
}
.tfm-audio button,
.tfm-audio input,
.tfm-audio label {
  font-family: inherit;
  font-size: inherit;
  letter-spacing: normal;
  text-transform: none;
  line-height: 1.3;
  box-shadow: none;
  min-height: 0;
}
.tfm-audio a {
  color: var(--ac-soft);
}
.tfm-audio :focus-visible {
  outline: 2px solid var(--ac-soft);
  outline-offset: 3px;
}

/* ---- stage: beat curve ---- */
.tfm-audio .ac-stage {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  background: radial-gradient(120% 140% at 50% 0%, #120d26, #07050f 70%);
  border: 1px solid var(--ac-line);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45), 0 0 40px color-mix(in srgb, var(--ac-accent) 8%, transparent);
}
.tfm-audio .ac-top {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: center;
  padding: 14px 16px 0;
}
.tfm-audio .ac-seg {
  display: inline-flex;
  border: 1px solid var(--ac-line);
  border-radius: 999px;
  padding: 3px;
  background: rgba(0, 0, 0, 0.25);
}
.tfm-audio .ac-seg button {
  background: none !important;
  border: 0 !important;
  border-radius: 999px !important;
  padding: 5px 14px !important;
  font-size: 0.82rem;
  letter-spacing: 0.06em;
  cursor: pointer;
  color: var(--ac-muted) !important;
}
.tfm-audio .ac-seg button[aria-pressed="true"] {
  background: color-mix(in srgb, var(--ac-accent) 20%, transparent) !important;
  color: var(--ac-ink) !important;
}
.tfm-audio .ac-now {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.5rem;
  color: var(--ac-ink);
}
.tfm-audio .ac-now small {
  font-family: 'Jost', sans-serif;
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ac-soft);
  margin-left: 6px;
}
.tfm-audio .ac-hp {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--ac-muted);
}
.tfm-audio .ac-curve {
  display: block;
  width: 100%;
  height: 250px;
  touch-action: none;
  cursor: crosshair;
}
.tfm-audio .ac-lanes canvas {
  display: block;
  width: 100%;
  height: 54px;
  touch-action: none;
  cursor: crosshair;
  border-top: 2px solid rgba(255, 255, 255, 0.05);
}
.tfm-audio .ac-lanes .ac-lane-words {
  height: 46px;
}
.tfm-audio .ac-lanes[hidden],
.tfm-audio .ac-lanes canvas[hidden] {
  display: none;
}
.tfm-audio .ac-hint.ac-curve-hint {
  margin: 4px 16px 0;
  min-height: 1.2em;
}
.tfm-audio .ac-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 16px 0;
}
.tfm-audio .ac-quick[hidden] {
  display: none;
}
.tfm-audio .ac-quick .ac-quick-label {
  margin: 0 4px 0 0;
  align-self: center;
}
.tfm-audio .ac-seek {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px 0;
  margin: 0;
  font-size: 0.78rem;
  color: var(--ac-muted);
}
.tfm-audio .ac-seek[hidden] {
  display: none;
}
.tfm-audio .ac-seek input {
  flex: 1;
}
.tfm-audio .ac-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  align-items: center;
  padding: 12px 16px 16px;
}
.tfm-audio .ac-play {
  width: 52px;
  height: 52px;
  flex: none;
  display: grid;
  place-items: center;
  padding: 0 !important;
  border-radius: 50% !important;
  border: 0 !important;
  background: var(--ac-accent) !important;
  color: var(--ac-on-accent) !important;
  font-size: 1.1rem;
  cursor: pointer;
  box-shadow: 0 0 24px color-mix(in srgb, var(--ac-accent) 35%, transparent);
}
.tfm-audio .ac-time {
  font-variant-numeric: tabular-nums;
  color: var(--ac-ink);
  min-width: 92px;
}
.tfm-audio .ac-vol {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 0.82rem;
  color: var(--ac-muted);
  min-width: 160px;
  flex: 1;
  max-width: 260px;
}
.tfm-audio .ac-scope {
  width: 150px;
  height: 40px;
  margin-left: auto;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.06);
}
.tfm-audio .ac-warn {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
  background: radial-gradient(circle, rgba(16, 12, 34, 0.9), rgba(5, 4, 12, 0.97));
}
.tfm-audio .ac-warn[hidden] {
  display: none;
}
.tfm-audio .ac-warn-title {
  font-family: 'Cormorant Garamond', serif;
  font-weight: 500;
  font-size: 1.8rem;
  color: var(--ac-ink);
  margin: 0 0 8px;
}
.tfm-audio .ac-warn p:not(.ac-warn-title) {
  max-width: 470px;
  margin: 0 auto 18px;
  line-height: 1.6;
}

/* ---- buttons, chips, fields ---- */
.tfm-audio .ac-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 18px !important;
  border-radius: 999px !important;
  border: 1px solid var(--ac-accent) !important;
  background: var(--ac-accent) !important;
  color: var(--ac-on-accent) !important;
  font-weight: 500;
  letter-spacing: 0.04em;
  cursor: pointer;
}
.tfm-audio .ac-btn.is-ghost {
  background: transparent !important;
  color: var(--ac-soft) !important;
}
.tfm-audio .ac-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.tfm-audio .ac-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 2px;
}
.tfm-audio .ac-chip {
  padding: 4px 12px !important;
  border-radius: 999px !important;
  border: 1px solid var(--ac-line) !important;
  background: rgba(255, 255, 255, 0.03) !important;
  color: var(--ac-text) !important;
  font-size: 0.84rem;
  cursor: pointer;
}
.tfm-audio .ac-chip[aria-pressed="true"] {
  background: color-mix(in srgb, var(--ac-accent) 18%, transparent) !important;
  border-color: var(--ac-accent) !important;
  color: var(--ac-ink) !important;
}
.tfm-audio .ac-chip:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.tfm-audio input[type="range"] {
  width: 100%;
  accent-color: var(--ac-accent);
}
.tfm-audio .ac-field {
  display: grid;
  grid-template-columns: 84px 1fr 56px;
  gap: 8px;
  align-items: center;
  margin: 8px 0;
  font-size: 0.88rem;
  color: var(--ac-text);
}
.tfm-audio .ac-field output {
  font-size: 0.78rem;
  color: var(--ac-muted);
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.tfm-audio .ac-hint {
  margin: 8px 0 0;
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--ac-muted);
}
.tfm-audio .ac-hint:empty {
  display: none;
}
.tfm-audio .ac-hint.ac-curve-hint:empty {
  display: block;
}
.tfm-audio .ac-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.tfm-audio .ac-input {
  flex: 1;
  min-width: 0;
  padding: 8px 12px;
  border: 1px solid var(--ac-line);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.25);
  color: var(--ac-ink);
}
.tfm-audio .ac-login {
  border: 1px dashed var(--ac-line);
  border-radius: 10px;
  padding: 12px;
  color: var(--ac-muted);
  font-size: 0.86rem;
  line-height: 1.5;
}
.tfm-audio .ac-chiprow {
  margin: 8px 0 2px;
}
.tfm-audio .ac-chiprow > span {
  display: block;
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ac-muted);
  margin-bottom: 4px;
}
.tfm-audio .ac-chiprow[hidden] {
  display: none;
}
.tfm-audio .ac-chiprow .ac-chips {
  margin: 0;
}
.tfm-audio .ac-chiprow .ac-chip {
  padding: 3px 10px !important;
  font-size: 0.8rem;
}

/* ---- main: mixer + side ---- */
.tfm-audio .ac-main {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 18px;
  margin-top: 18px;
  align-items: start;
}
.tfm-audio .ac-mixer {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
  align-items: start;
}
.tfm-audio .ac-strip,
.tfm-audio .ac-box {
  position: relative;
  background: var(--ac-card);
  border: 1px solid var(--ac-line);
  border-radius: 14px;
  padding: 14px 16px;
}
.tfm-audio .ac-strip.is-on {
  border-color: color-mix(in srgb, var(--ac-accent) 45%, transparent);
  box-shadow: 0 0 24px color-mix(in srgb, var(--ac-accent) 7%, transparent);
}
.tfm-audio .ac-strip header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.tfm-audio .ac-open {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 0 !important;
  border: 0 !important;
  background: none !important;
  color: var(--ac-text) !important;
  text-align: left;
  cursor: pointer;
}
.tfm-audio .ac-open::before {
  content: '▸';
  align-self: center;
  color: var(--ac-soft);
  font-size: 0.8rem;
  transition: transform 0.2s ease;
}
.tfm-audio .ac-open[aria-expanded="true"]::before {
  transform: rotate(90deg);
}
.tfm-audio .ac-strip-title {
  font-family: 'Cormorant Garamond', serif;
  font-weight: 500;
  font-size: 1.35rem;
  color: var(--ac-ink);
  white-space: nowrap;
}
.tfm-audio .ac-sum {
  font-size: 0.74rem;
  color: var(--ac-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tfm-audio .ac-body[hidden] {
  display: none;
}
.tfm-audio .ac-desc {
  margin: 6px 0;
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--ac-muted);
}
.tfm-audio .ac-strip:not(.is-on) .ac-ctl {
  opacity: 0.55;
}
.tfm-audio .ac-lock {
  position: absolute;
  right: 12px;
  top: -9px;
  z-index: 1;
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-decoration: none;
  background: var(--ac-accent);
  color: var(--ac-on-accent) !important;
  border-radius: 999px;
  padding: 2px 9px;
}
.tfm-audio .is-locked .ac-ctl,
.tfm-audio .is-locked .ac-switch {
  opacity: 0.4;
  pointer-events: none;
}
.tfm-audio .ac-staff {
  display: inline-block;
  margin-left: 6px;
  font-family: 'Jost', sans-serif;
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  vertical-align: middle;
  border: 1px solid var(--ac-soft);
  color: var(--ac-soft);
  border-radius: 999px;
  padding: 1px 7px;
}
.tfm-audio .ac-switch {
  position: relative;
  flex: none;
  width: 42px;
  height: 24px;
  padding: 0 !important;
  border-radius: 12px !important;
  border: 1px solid var(--ac-line) !important;
  background: rgba(255, 255, 255, 0.06) !important;
  cursor: pointer;
}
.tfm-audio .ac-switch::after {
  content: '';
  position: absolute;
  left: 3px;
  top: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--ac-muted);
  transition: left 0.2s ease, background 0.2s ease;
}
.tfm-audio .ac-switch[aria-checked="true"] {
  background: color-mix(in srgb, var(--ac-accent) 30%, transparent) !important;
  border-color: var(--ac-accent) !important;
}
.tfm-audio .ac-switch[aria-checked="true"]::after {
  left: 21px;
  background: var(--ac-accent);
}
.tfm-audio .ac-deep {
  margin-top: 10px;
  font-size: 0.8rem;
}
.tfm-audio .ac-deep::before {
  content: '↓ ';
  color: var(--ac-soft);
}
.tfm-audio.is-steady .ac-deep {
  opacity: 0.45;
}

/* ---- side ---- */
.tfm-audio .ac-box + .ac-box {
  margin-top: 14px;
}
.tfm-audio .ac-box-title {
  margin: 0 0 10px;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ac-soft);
}
.tfm-audio .ac-presets {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  border: 1px solid var(--ac-line);
  border-radius: 10px;
}
.tfm-audio .ac-presets:empty {
  display: none;
}
.tfm-audio .ac-presets li {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 7px 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}
.tfm-audio .ac-presets li:first-child {
  border-top: 0;
}
.tfm-audio .ac-preset-load {
  flex: 1;
  min-width: 0;
  padding: 0 !important;
  border: 0 !important;
  background: none !important;
  color: var(--ac-ink) !important;
  font-family: 'Cormorant Garamond', serif !important;
  font-size: 1.08rem !important;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}
.tfm-audio .ac-ic {
  padding: 2px 4px !important;
  border: 0 !important;
  background: none !important;
  color: var(--ac-muted) !important;
  font-size: 1rem;
  cursor: pointer;
}
.tfm-audio .ac-ic.ac-fav[aria-pressed="true"] {
  color: #ff6b8a !important;
}
.tfm-audio .ac-dl {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.tfm-audio .ac-foot {
  margin: 22px 0 0;
  max-width: 760px;
  font-size: 0.82rem;
  line-height: 1.6;
  color: var(--ac-muted);
}

/* ---- download dialog ---- */
.tfm-audio .ac-dialog {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(5, 4, 12, 0.78);
}
.tfm-audio .ac-dialog[hidden] {
  display: none;
}
.tfm-audio .ac-dialog > div {
  width: 100%;
  max-width: 400px;
  padding: 20px;
  border-radius: 16px;
  border: 1px solid var(--ac-line);
  background: #1a1430;
}
.tfm-audio .ac-dialog-title {
  margin: 0 0 6px;
  font-family: 'Cormorant Garamond', serif;
  font-weight: 500;
  font-size: 1.6rem;
  color: var(--ac-ink);
}
.tfm-audio .ac-progress {
  height: 6px;
  margin: 14px 0;
  border-radius: 3px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.08);
}
.tfm-audio .ac-progress i {
  display: block;
  width: 0;
  height: 100%;
  background: var(--ac-accent);
  transition: width 0.2s ease;
}
.tfm-audio .ac-dialog-foot {
  margin-top: 14px;
}

@media (max-width: 900px) {
  .tfm-audio .ac-main {
    grid-template-columns: minmax(0, 1fr);
  }
}
@media (max-width: 600px) {
  .tfm-audio .ac-curve {
    height: 200px;
  }
  .tfm-audio .ac-hp {
    margin-left: 0;
    width: 100%;
  }
  .tfm-audio .ac-scope {
    width: 100%;
    margin-left: 0;
  }
  .tfm-audio .ac-mixer {
    grid-template-columns: minmax(0, 1fr);
  }
}
