/* 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;
}

/* Crop stage. The video sits in normal flow; the shade and box are absolutely
   positioned over it, so the box coordinates map 1:1 onto the rendered frame. */
/* overflow:hidden is LOAD-BEARING. The crop box shades everything outside
   itself with a 9999px outline; without clipping here that outline paints over
   the whole PAGE, so the entire screen greys out and the tool reads as a modal
   you cannot interact with. Reported from real use. */
.vc-stage { position: relative; display: inline-block; max-width: 100%; line-height: 0; overflow: hidden; }
/* The element must be EXACTLY the shape of the picture.
   .bae-preview inherits `aspect-ratio: 4/3` from the audio tool, where a fixed
   preview footprint stopped the card jumping height. Here it letterboxes the
   video inside the element — a 16:9 clip rendered 492x277 inside a 492x369 box,
   46px of black above and below. The crop box is positioned against the
   ELEMENT, so every coordinate was off by that inset: the box sat above the
   picture and "drag down" ran out of room 46px early. Reported from real use as
   "I can drag up but not down". */
.vc-video {
  display: block;
  max-width: 100%;
  width: 100%;
  height: auto;
  aspect-ratio: auto;
  border-radius: 0;
  background: #0e0d1f;
}
.vc-shade { position: absolute; inset: 0; background: rgba(10, 8, 40, 0.55); pointer-events: none; }
/* The box is a hole punched in the shade: a huge outline covers everything
   outside it, which is cheaper and sharper than four separate shade panels. */
.vc-box {
  position: absolute; cursor: move; touch-action: none;
  outline: 9999px solid rgba(10, 8, 40, 0.55);
  box-shadow: 0 0 0 2px #5d59ff inset;
}
.vc-h {
  position: absolute; width: 18px; height: 18px; background: #fff;
  border: 2px solid #5d59ff; border-radius: 3px; touch-action: none;
}
.vc-nw { left: -9px; top: -9px; cursor: nwse-resize; }
.vc-ne { right: -9px; top: -9px; cursor: nesw-resize; }
.vc-sw { left: -9px; bottom: -9px; cursor: nesw-resize; }
.vc-se { right: -9px; bottom: -9px; cursor: nwse-resize; }
.vc-dims {
  position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%);
  background: rgba(10, 8, 40, 0.82); color: #fff; font: 500 13px/1.4 system-ui, sans-serif;
  padding: 3px 8px; border-radius: 4px; white-space: nowrap; pointer-events: none;
}
/* Handles are 18px on a phone too — a 44px touch target would cover the crop
   region on a small preview, so they stay visually small but sit on top. */
.vc-h, .vc-box { z-index: 2; }
/* The box needs to look grabbable. Without this it is an outline on a video and
   nothing suggests you can move it. */
.vc-box::after {
  content: ''; position: absolute; inset: 0;
  background:
    linear-gradient(#fff, #fff) center/22px 2px no-repeat,
    linear-gradient(#fff, #fff) center/2px 22px no-repeat;
  opacity: .55; pointer-events: none;
}
.vc-box:hover::after { opacity: .85; }
