@tailwind base;
@tailwind components;
@tailwind utilities;

/*
 * Studio is a dark-only UI — pin the user-agent color scheme to dark so that
 * browser-native chrome (scrollbars, form controls, focus rings) picks the
 * matching palette instead of defaulting to light against our #0a0a0a body.
 */
:root {
  color-scheme: dark;
}

body {
  margin: 0;
  padding: 0;
  background: #0a0a0a;
  color: #e5e5e5;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
}

.hf-color-grading-number::-webkit-outer-spin-button,
.hf-color-grading-number::-webkit-inner-spin-button {
  margin: 0;
  appearance: none;
}

.hf-color-grading-number {
  -moz-appearance: textfield;
  appearance: textfield;
}

.hf-color-grading-range {
  height: 1.5rem;
  cursor: default;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
}

.hf-color-grading-range:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.hf-color-grading-range::-webkit-slider-runnable-track {
  height: 1.25rem;
  border: 0;
  background: transparent;
}

.hf-color-grading-range::-webkit-slider-thumb {
  width: 0.625rem;
  height: 1rem;
  margin-top: 0.125rem;
  border: 0;
  border-radius: 999px;
  -webkit-appearance: none;
  appearance: none;
  background: #ffffff;
  box-shadow:
    0 0 0 2px #0c0c0e,
    0 1px 4px rgba(0, 0, 0, 0.55);
  cursor: default;
}

.hf-color-grading-range::-moz-range-track {
  height: 1.25rem;
  border: 0;
  background: transparent;
}

.hf-color-grading-range::-moz-range-thumb {
  width: 0.625rem;
  height: 1rem;
  border: 0;
  border-radius: 999px;
  background: #ffffff;
  box-shadow:
    0 0 0 2px #0c0c0e,
    0 1px 4px rgba(0, 0, 0, 0.55);
  cursor: default;
}

.hf-color-grading-range:focus-visible {
  outline: none;
}

.hf-color-grading-range:focus-visible::-webkit-slider-thumb {
  box-shadow:
    0 0 0 2px #0c0c0e,
    0 0 0 4px rgba(60, 230, 172, 0.22),
    0 1px 4px rgba(0, 0, 0, 0.55);
}

.hf-color-grading-range:focus-visible::-moz-range-thumb {
  box-shadow:
    0 0 0 2px #0c0c0e,
    0 0 0 4px rgba(60, 230, 172, 0.22),
    0 1px 4px rgba(0, 0, 0, 0.55);
}

#root {
  width: 100vw;
  /*
   * 100vh on iOS Safari measures the LARGEST viewport (toolbars hidden) and
   * stays fixed at that value, so when the toolbar is visible the bottom of
   * the layout sits *under* it and anything at flex-end — the player
   * controls row, notably — becomes untappable. `100dvh` follows the
   * dynamic viewport, shrinking when the toolbar is shown so the bottom of
   * #root lines up with the bottom of the visible area. Fallback to 100vh
   * keeps older browsers (pre-Safari 15.4 / Firefox 101 / Chrome 108) on
   * the existing behaviour.
   */
  height: 100vh;
  height: 100dvh;
}

.timeline-clip {
  background-color: rgba(255, 255, 255, 0.055);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 8px;
}

.timeline-clip::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: rgba(60, 230, 172, 0.2);
  opacity: 0;
  pointer-events: none;
}

.timeline-clip[data-active] {
  border-color: rgba(60, 230, 172, 0.55);
}

.timeline-clip[data-active]::before {
  opacity: 1;
}

.timeline-clip.is-hovered {
  background-color: rgba(255, 255, 255, 0.09);
}

.timeline-clip[data-active].is-hovered {
  border-color: rgba(60, 230, 172, 0.75);
}

.timeline-clip.is-selected {
  box-shadow: 0 0 0 1.5px rgba(255, 255, 255, 0.85);
}

.timeline-clip[data-active].is-selected {
  box-shadow: 0 0 0 1.5px rgba(255, 255, 255, 0.85);
}

.timeline-clip.is-dragging {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.timeline-clip[data-active].is-selected.is-dragging {
  box-shadow:
    0 0 0 1.5px rgba(255, 255, 255, 0.85),
    0 8px 24px rgba(0, 0, 0, 0.4);
}

.timeline-clip__label {
  position: absolute;
  top: 6px;
  left: 12px;
  right: 10px;
  z-index: 6;
  overflow: hidden;
  color: rgba(255, 255, 255, 0.5);
  font-size: 10px;
  font-weight: 500;
  line-height: 1;
  pointer-events: none;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.85);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.timeline-clip[data-active] .timeline-clip__label {
  color: rgba(232, 255, 247, 0.95);
}

.timeline-clip__timecode {
  position: absolute;
  bottom: 6px;
  left: 12px;
  overflow: hidden;
  color: rgba(255, 255, 255, 0.34);
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 9px;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (prefers-reduced-motion: no-preference) {
  .timeline-clip {
    transition:
      background-color 200ms cubic-bezier(0.22, 1, 0.36, 1),
      border-color 200ms cubic-bezier(0.22, 1, 0.36, 1),
      box-shadow 200ms cubic-bezier(0.22, 1, 0.36, 1),
      color 200ms cubic-bezier(0.22, 1, 0.36, 1),
      opacity 200ms cubic-bezier(0.22, 1, 0.36, 1);
  }

  .timeline-clip::before {
    transition: opacity 200ms cubic-bezier(0.22, 1, 0.36, 1);
  }

  .timeline-clip__label {
    transition: color 200ms cubic-bezier(0.22, 1, 0.36, 1);
  }

  .timeline-clip__handle-bar {
    transition: opacity 120ms ease-out;
  }
}

/* CodeMirror overrides */
.cm-editor {
  height: 100%;
  font-size: 13px;
}

.cm-editor .cm-scroller {
  font-family: "JetBrains Mono", "Fira Code", "SF Mono", monospace;
}

.cm-editor.cm-focused {
  outline: none;
}

/*
 * HyperFrames brand loader. Shared by preview overlays that need a calm,
 * branded loading state instead of a generic spinner.
 */
.hf-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  width: min(34rem, 100%);
  padding: 1.5rem;
  box-sizing: border-box;
  text-align: center;
  cursor: default;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
}

.hf-frame {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  min-height: 12rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.52);
}

.hf-loader-mark-frame {
  display: grid;
  place-items: center;
  overflow: visible;
  transform-origin: 50% 50%;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
}

.hf-loader-mark {
  display: block;
  overflow: visible;
  filter: drop-shadow(0 0 7px rgba(79, 219, 94, 0.2));
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
}

.hf-loader-title {
  font-family:
    Inter,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0;
  color: var(--hf-heading, #f4f4f5);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hf-loader-detail {
  max-width: 32rem;
  min-height: 2.5rem;
  overflow: hidden;
  color: var(--hf-text-secondary, rgba(244, 244, 245, 0.68));
  font-family:
    Inter,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  font-size: 0.82rem;
  line-height: 1.6;
}

.hf-loader-mono {
  width: min(36rem, 100%);
  min-height: 1.5rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--hf-text-tertiary, rgba(244, 244, 245, 0.46));
  font-family: "IBM Plex Mono", "SF Mono", "Fira Code", monospace;
  font-size: 0.75rem;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
}

.hf-loader-progress {
  width: min(18rem, 72vw);
  height: 0.375rem;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
}

@keyframes hf-thumb-fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.hf-loader-progress__fill {
  width: 100%;
  height: 100%;
  transform: scaleX(0);
  transform-origin: left center;
  border-radius: inherit;
  background: linear-gradient(90deg, #06e3fa, #4fdb5e);
  transition: transform 160ms ease;
}

/* Toast enter/exit (StudioToast) */
@keyframes hf-toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes hf-toast-out {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(8px);
  }
}

.hf-toast-enter {
  animation: hf-toast-in 160ms ease-out;
}

.hf-toast-exit {
  animation: hf-toast-out 160ms ease-in forwards;
}

@media (prefers-reduced-motion: reduce) {
  .hf-toast-enter,
  .hf-toast-exit {
    animation: none;
  }
  .hf-toast-exit {
    opacity: 0;
  }
}

/* Overlay/backdrop entrance — the heaviest visual changes shouldn't pop in */
@keyframes hf-backdrop-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.hf-backdrop-in {
  animation: hf-backdrop-in 150ms ease-out;
}

@media (prefers-reduced-motion: reduce) {
  .hf-backdrop-in {
    animation: none;
  }
}
