/* Extract audio from video — tool widget styles.
   Everything is namespaced under .bae so it can't leak into the page's own
   prose/hero rules, and so Astro's scoped selectors have nothing to fight. */

.bae {
  --bae-ink: #1d1b48;
  --bae-muted: #5c608a;
  --bae-line: #dcdcec;
  --bae-accent: #5b4ff0;
  --bae-danger: #b3261e;
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  padding: 28px;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 18px 48px rgba(29, 27, 72, 0.12);
  color: var(--bae-ink);
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

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

/* Must come before the component rules below. `[hidden]`'s UA `display:none`
   is a plain attribute selector, so ANY later `display:` in this file wins and
   the element stays visible — which showed the drop pane, the preview, the
   progress bar and the finished panel all at once. */
.bae [hidden] {
  display: none !important;
}

/* Two columns like the live widget: media on the left, controls on the right.
   Collapses to one column before the panes get too narrow to use. */
.bae-cols {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 40px;
  align-items: start;
}

.bae-left,
.bae-right {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

@media (max-width: 860px) {
  .bae-cols {
    grid-template-columns: minmax(0, 1fr);
    gap: 26px;
  }
}

/* ------------------------------------------------------------ right column */

.bae-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.bae-h {
  margin: 0;
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.bae-sub {
  margin: 0 0 8px;
  font-size: 15px;
  line-height: 1.5;
  color: var(--bae-muted);
}

/* Underline-only control, matching the live widget's field treatment. */
.bae-select {
  font: inherit;
  font-size: 16px;
  color: var(--bae-ink);
  width: 100%;
  padding: 8px 2px;
  border: 0;
  border-bottom: 1px solid var(--bae-line);
  border-radius: 0;
  background: transparent;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 6l4 4 4-4' fill='none' stroke='%231d1b48' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 2px center;
  background-size: 16px;
  cursor: pointer;
}

.bae-select:focus-visible {
  outline: none;
  border-bottom-color: var(--bae-accent);
}

.bae-trim {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 28px;
  margin-top: 4px;
}

.bae-trim-item {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 15px;
  min-width: 0;
}

.bae-trim-item input {
  font: inherit;
  font-size: 16px;
  color: var(--bae-ink);
  width: 84px;
  min-width: 0;
  padding: 6px 2px;
  border: 0;
  border-bottom: 1px solid var(--bae-line);
  border-radius: 0;
  background: transparent;
  text-align: right;
}

.bae-trim-item input:focus-visible {
  outline: none;
  border-bottom-color: var(--bae-accent);
}

.bae-trim-item i {
  font-style: normal;
  color: var(--bae-muted);
  font-size: 14px;
}

.bae-trim-note {
  margin: 10px 0 0;
  font-size: 13.5px;
  color: var(--bae-muted);
  min-height: 1em;
}

.bae-trim-note.is-bad {
  color: var(--bae-danger);
}

/* ------------------------------------------------------------- left column */

.bae-preview {
  width: 100%;
  max-width: 100%;
  /* Match the drop pane's footprint so swapping one for the other doesn't
     make the card jump height. */
  aspect-ratio: 4 / 3;
  border-radius: 12px;
  background: #0e0d1f;
  display: block;
}

/* ---------------------------------------------------------------- dropzone */

.bae-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 30px 20px;
  aspect-ratio: 4 / 3;
  border-radius: 12px;
  background: #eef2fd;
  cursor: pointer;
  transition: background 0.15s ease, box-shadow 0.15s ease;
  text-align: center;
}

.bae-drop:hover,
.bae-drop:focus-visible,
.bae-drop.is-over {
  background: #e6ecfc;
  box-shadow: inset 0 0 0 2px var(--bae-accent);
  outline: none;
}

.bae-ico {
  width: 46px;
  height: 46px;
  color: #8f8bd8;
}

.bae-drop-title {
  margin: 0;
  font-size: 17px;
  color: #8f93bd;
}

/* Styled as the live widget's pill, but it's a span inside the label-as-button
   dropzone — a nested <button> would swallow the click that opens the picker. */
.bae-upload {
  display: inline-block;
  padding: 12px 26px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 500;
  color: #fff;
  background: linear-gradient(90deg, #5b4ff0 0%, #8b6ff2 100%);
}

.bae-drop-sub {
  margin: 6px 0 0;
  font-size: 13px;
  color: #9296bf;
}

/* ------------------------------------------------------------ chosen file */

.bae-file {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.bae-file-name {
  font-size: 15px;
  font-weight: 500;
  /* Long filenames must not push the card wider than its column. */
  min-width: 0;
  overflow-wrap: anywhere;
}

.bae-clear {
  flex: none;
  border: 0;
  background: none;
  padding: 4px;
  color: var(--bae-muted);
  font-size: 14px;
  text-decoration: underline;
  cursor: pointer;
}

.bae-clear:hover {
  color: var(--bae-ink);
}

.bae-warn {
  margin: 10px 0 0;
  font-size: 13.5px;
  line-height: 1.5;
  color: #8a5a00;
}

/* --------------------------------------------------------------- formats */

.bae-formats {
  margin: 0;
  padding: 0;
  border: 0;
}

.bae-formats legend {
  padding: 0;
  margin-bottom: 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--bae-muted);
}

.bae-format-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.bae-format {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 16px;
  border: 1px solid var(--bae-line);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.bae-format:hover {
  border-color: var(--bae-accent);
}

.bae-format:has(input:checked) {
  border-color: var(--bae-accent);
  background: #f4f2ff;
}

.bae-format input {
  margin: 2px 0 0;
  accent-color: var(--bae-accent);
  flex: none;
}

.bae-format-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.bae-format-hint {
  font-size: 13px;
  color: var(--bae-muted);
}

/* ---------------------------------------------------------------- actions */

.bae-go,
.bae-download,
.bae-again {
  font: inherit;
  cursor: pointer;
  border: 0;
  border-radius: 999px;
  text-align: center;
}

.bae-go {
  align-self: flex-start;
  padding: 16px 40px;
  font-size: 16px;
  font-weight: 500;
  color: #fff;
  background: linear-gradient(90deg, #5b4ff0 0%, #b39ff0 100%);
  transition: opacity 0.15s ease;
}

.bae-go:hover:not(:disabled) {
  opacity: 0.9;
}

.bae-go:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* --------------------------------------------------------------- progress */

.bae-progress {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bae-bar {
  height: 8px;
  border-radius: 999px;
  background: #eceaf8;
  overflow: hidden;
}

.bae-bar-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, #5b4ff0 0%, #b39ff0 100%);
  transition: width 0.25s ease;
}

.bae-progress-label,
.bae-status {
  margin: 0;
  font-size: 14px;
  color: var(--bae-muted);
}

.bae-status:empty {
  display: none;
}

.bae-error {
  margin: 0;
  padding: 14px 16px;
  border-radius: 10px;
  border: 1px solid #f0c7c4;
  background: #fdf3f2;
  color: var(--bae-danger);
  font-size: 14.5px;
  line-height: 1.55;
}

/* ------------------------------------------------------------------- done */

.bae-done {
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: flex-start;
}

.bae-done-title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.bae-audio {
  width: 100%;
  max-width: 100%;
}

.bae-download {
  display: inline-block;
  padding: 16px 36px;
  font-size: 16px;
  font-weight: 500;
  color: #fff;
  background: linear-gradient(90deg, #5b4ff0 0%, #b39ff0 100%);
  text-decoration: none;
}

.bae-download:hover {
  opacity: 0.9;
}

.bae-again {
  padding: 0;
  background: none;
  color: var(--bae-muted);
  font-size: 14px;
  text-decoration: underline;
}

.bae-again:hover {
  color: var(--bae-ink);
}

@media (max-width: 640px) {
  .bae {
    padding: 20px;
    gap: 16px;
  }
  .bae-drop {
    padding: 30px 14px;
  }
  .bae-go,
  .bae-download {
    align-self: stretch;
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .bae-bar-fill,
  .bae-drop,
  .bae-format,
  .bae-go {
    transition: none;
  }
}

/* The before → after line. This is the tool's actual answer, so it reads at the
   size of a result rather than as a caption under the download button. */
.bae-saved {
  margin: 4px 0 14px;
  font-size: 18px;
  font-weight: 500;
  color: var(--color-ink, #16143a);
  text-align: center;
}
