/* =====================================================================
 * SubRescue — css/styles.css
 * Critical shell styles + component styles that sit on top of the
 * Tailwind CDN utility classes.
 *
 * Everything here is layout-stable: fixed heights for ad slots, no
 * font-swap jank (font-display: swap), no CLS-inducing transitions.
 * ===================================================================== */

:root {
  --sr-bg: #06070b;
  --sr-bg-soft: #0a0c13;
  --sr-panel: #0e1119;
  --sr-panel-2: #121724;
  --sr-line: rgba(255, 255, 255, 0.09);
  --sr-line-strong: rgba(255, 255, 255, 0.16);
  --sr-text: #e6e9f0;
  --sr-muted: #8b93a7;
  --sr-teal: #2dd4bf;
  --sr-iris: #818cf8;
  --sr-amber: #fbbf24;
  --sr-rose: #fb7185;
  --sr-header-h: 64px;
}

* {
  -webkit-tap-highlight-color: transparent;
}

html {
  scroll-behavior: smooth;
  color-scheme: dark;
}

body {
  background-color: var(--sr-bg);
  color: var(--sr-text);
  font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto,
    'Helvetica Neue', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

/* Ambient studio glow ------------------------------------------------ */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(60rem 30rem at 12% -8%, rgba(45, 212, 191, 0.11), transparent 60%),
    radial-gradient(55rem 28rem at 92% 0%, rgba(129, 140, 248, 0.12), transparent 62%),
    radial-gradient(40rem 26rem at 50% 110%, rgba(45, 212, 191, 0.06), transparent 65%);
}

#page-root {
  position: relative;
  z-index: 1;
}

.font-mono,
code,
kbd,
pre {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* Skip link ---------------------------------------------------------- */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  background: var(--sr-teal);
  color: #04110f;
  padding: 0.6rem 1rem;
  border-radius: 0 0 0.75rem 0;
  font-weight: 600;
}
.skip-link:focus {
  left: 0;
}

/* Header ------------------------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--sr-header-h);
  backdrop-filter: blur(14px);
  background: rgba(6, 7, 11, 0.82);
  border-bottom: 1px solid var(--sr-line);
}

.brand-mark {
  background: linear-gradient(135deg, var(--sr-teal), var(--sr-iris));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.nav-link {
  position: relative;
  color: var(--sr-muted);
  transition: color 0.15s ease;
}
.nav-link:hover,
.nav-link[aria-current='page'] {
  color: #fff;
}
.nav-link[aria-current='page']::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -6px;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--sr-teal), var(--sr-iris));
}

/* Buttons ------------------------------------------------------------ */
.btn-primary {
  background: linear-gradient(135deg, var(--sr-teal), var(--sr-iris));
  color: #05070c;
  font-weight: 650;
  box-shadow: 0 8px 28px -12px rgba(45, 212, 191, 0.75);
  transition: transform 0.14s ease, box-shadow 0.14s ease, filter 0.14s ease;
}
.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  filter: brightness(1.06);
  box-shadow: 0 12px 34px -12px rgba(45, 212, 191, 0.9);
}
.btn-primary:disabled {
  opacity: 0.45;
  box-shadow: none;
  cursor: not-allowed;
}

.btn-ghost {
  border: 1px solid var(--sr-line-strong);
  background: rgba(255, 255, 255, 0.03);
  color: var(--sr-text);
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}
.btn-ghost:hover:not(:disabled) {
  border-color: rgba(45, 212, 191, 0.45);
  background: rgba(45, 212, 191, 0.07);
  color: #fff;
}
.btn-ghost:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary:focus-visible,
.btn-ghost:focus-visible,
.nav-link:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--sr-teal);
  outline-offset: 2px;
}

/* Cards -------------------------------------------------------------- */
.panel {
  background: linear-gradient(180deg, rgba(18, 23, 36, 0.92), rgba(10, 13, 20, 0.92));
  border: 1px solid var(--sr-line);
  border-radius: 1.25rem;
  box-shadow: 0 30px 80px -50px rgba(0, 0, 0, 0.95);
}

.panel-soft {
  background: rgba(255, 255, 255, 0.028);
  border: 1px solid var(--sr-line);
  border-radius: 1rem;
}

.eyebrow {
  color: var(--sr-teal);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.7rem;
  font-weight: 700;
}

.gradient-text {
  background: linear-gradient(120deg, #ffffff 12%, var(--sr-teal) 52%, var(--sr-iris) 92%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* Drop zone ---------------------------------------------------------- */
.dropzone {
  position: relative;
  border: 1.5px dashed rgba(255, 255, 255, 0.16);
  border-radius: 1rem;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.012));
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease;
  cursor: pointer;
}
.dropzone:hover {
  border-color: rgba(45, 212, 191, 0.5);
  background: linear-gradient(180deg, rgba(45, 212, 191, 0.06), rgba(255, 255, 255, 0.015));
}
.dropzone.is-dragging {
  border-color: var(--sr-teal);
  background: linear-gradient(180deg, rgba(45, 212, 191, 0.12), rgba(45, 212, 191, 0.03));
  transform: scale(1.005);
}

/* Options ------------------------------------------------------------ */
.option-field {
  border: 1px solid var(--sr-line);
  border-radius: 0.75rem;
  background: rgba(255, 255, 255, 0.025);
  transition: border-color 0.15s ease, background 0.15s ease;
}
.option-field:focus-within {
  border-color: rgba(45, 212, 191, 0.55);
  background: rgba(45, 212, 191, 0.04);
}

.select-input,
.text-input {
  width: 100%;
  background: transparent;
  color: var(--sr-text);
  border: 0;
  outline: none;
  font-size: 0.875rem;
}
.select-input option {
  background: #0e1119;
  color: #e6e9f0;
}

/* Locked / unlocked Pro affordances ---------------------------------- */
[data-pro-only].is-locked {
  opacity: 0.92;
}
[data-pro-only].is-locked::after {
  content: '';
}

.pro-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  border-radius: 9999px;
  border: 1px solid rgba(251, 191, 36, 0.35);
  background: rgba(251, 191, 36, 0.12);
  color: var(--sr-amber);
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 0.1rem 0.45rem;
  text-transform: uppercase;
}
.pro-pill.is-active {
  border-color: rgba(52, 211, 153, 0.35);
  background: rgba(52, 211, 153, 0.12);
  color: #34d399;
}

/* Result preview ------------------------------------------------------ */
.preview-area {
  background: #05070c;
  border: 1px solid var(--sr-line);
  border-radius: 0.75rem;
  min-height: 220px;
  max-height: 460px;
  overflow: auto;
}
.preview-area textarea {
  background: transparent;
  width: 100%;
  min-height: 220px;
  resize: vertical;
  color: #cbd5e1;
  font-size: 0.8125rem;
  line-height: 1.6;
  padding: 0.9rem 1rem;
  outline: none;
}

/* Hidden state -------------------------------------------------------- */
.is-empty {
  display: none !important;
}

/* Ad slots — reserved height guarantees CLS = 0 ---------------------- */
.ad-slot {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  overflow: hidden;
  border-radius: 0.75rem;
  border: 1px solid var(--sr-line);
  background:
    repeating-linear-gradient(
      45deg,
      rgba(255, 255, 255, 0.014),
      rgba(255, 255, 255, 0.014) 10px,
      transparent 10px,
      transparent 20px
    ),
    rgba(255, 255, 255, 0.012);
}
.ad-slot--banner {
  min-height: 90px;
}
.ad-slot--card {
  min-height: 250px;
  max-width: 320px;
  margin-inline: auto;
}
@media (max-width: 767px) {
  .ad-slot--banner {
    min-height: 50px;
  }
  .ad-slot--card {
    min-height: 250px;
  }
}
.ad-placeholder {
  font-size: 0.6875rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(148, 163, 184, 0.72);
}

/* Modal --------------------------------------------------------------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.18s ease, visibility 0.18s ease;
}
.modal.is-open {
  opacity: 1;
  visibility: visible;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 4, 8, 0.78);
  backdrop-filter: blur(6px);
}
.modal-card {
  position: relative;
  width: 100%;
  max-width: 30rem;
  max-height: 90vh;
  overflow: auto;
  transform: translateY(12px) scale(0.985);
  transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1);
}
.modal.is-open .modal-card {
  transform: translateY(0) scale(1);
}

/* Toast --------------------------------------------------------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translate(-50%, 140%);
  z-index: 70;
  max-width: min(92vw, 30rem);
  padding: 0.7rem 1rem;
  border-radius: 0.75rem;
  border: 1px solid var(--sr-line-strong);
  background: rgba(14, 17, 25, 0.97);
  color: var(--sr-text);
  font-size: 0.8125rem;
  box-shadow: 0 20px 50px -20px rgba(0, 0, 0, 0.9);
  transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.2s ease;
  opacity: 0;
}
.toast.is-visible {
  transform: translate(-50%, 0);
  opacity: 1;
}
.toast[data-tone='success'] {
  border-color: rgba(52, 211, 153, 0.4);
  color: #a7f3d0;
}
.toast[data-tone='warn'] {
  border-color: rgba(251, 191, 36, 0.4);
  color: #fde68a;
}
.toast[data-tone='error'] {
  border-color: rgba(251, 113, 133, 0.45);
  color: #fecdd3;
}

/* FAQ ----------------------------------------------------------------- */
.faq-item {
  border: 1px solid var(--sr-line);
  border-radius: 0.9rem;
  background: rgba(255, 255, 255, 0.025);
  overflow: hidden;
}
.faq-item + .faq-item {
  margin-top: 0.65rem;
}
.faq-item > summary {
  cursor: pointer;
  list-style: none;
  padding: 1rem 1.15rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  font-weight: 600;
  color: var(--sr-text);
}
.faq-item > summary::-webkit-details-marker {
  display: none;
}
.faq-item > summary::after {
  content: '+';
  color: var(--sr-teal);
  font-weight: 700;
  font-size: 1.2rem;
  line-height: 1.1;
}
.faq-item[open] > summary::after {
  content: '\2212';
}
.faq-answer {
  padding: 0 1.15rem 1.1rem;
  color: var(--sr-muted);
  font-size: 0.9rem;
  line-height: 1.7;
}
.faq-answer a {
  color: var(--sr-teal);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Tables -------------------------------------------------------------- */
.compare-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}
.compare-table th,
.compare-table td {
  padding: 0.8rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--sr-line);
  font-size: 0.875rem;
}
.compare-table thead th {
  color: var(--sr-muted);
  font-weight: 600;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Misc ---------------------------------------------------------------- */
.prose-sr p {
  color: var(--sr-muted);
  line-height: 1.75;
}
.prose-sr p + p {
  margin-top: 0.9rem;
}
.prose-sr h2 {
  color: #fff;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.prose-sr h3 {
  color: #fff;
  font-weight: 650;
}
.prose-sr strong {
  color: #dfe4ee;
  font-weight: 600;
}
.prose-sr code {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--sr-line);
  border-radius: 0.35rem;
  padding: 0.1rem 0.35rem;
  font-size: 0.8em;
  color: #a5f3fc;
}
.prose-sr ul {
  margin: 0.9rem 0;
  padding-left: 1.15rem;
  list-style: disc;
}
.prose-sr li {
  color: var(--sr-muted);
  line-height: 1.7;
  margin-top: 0.35rem;
}
.prose-sr li::marker {
  color: var(--sr-teal);
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 9999px;
  background: var(--sr-teal);
  box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.16);
}

.divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--sr-line-strong), transparent);
}

/* Language switcher ---------------------------------------------------- */
.lang-select {
  appearance: none;
  -webkit-appearance: none;
  background-color: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--sr-line-strong);
  border-radius: 0.5rem;
  color: var(--sr-text);
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.45rem 0.6rem;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
  max-width: 9.5rem;
}
.lang-select:hover {
  border-color: rgba(45, 212, 191, 0.45);
  background: rgba(45, 212, 191, 0.07);
}
.lang-select option {
  background: #0e1119;
  color: #e6e9f0;
}

/* Right-to-left -------------------------------------------------------- */
[dir='rtl'] body {
  font-family: 'Inter', 'Noto Sans Arabic', 'Segoe UI', Tahoma, ui-sans-serif, system-ui,
    sans-serif;
}

[dir='rtl'] .font-mono,
[dir='rtl'] code,
[dir='rtl'] kbd,
[dir='rtl'] pre {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  direction: ltr;
  text-align: start;
}

/* Directional arrow icons travel with the text flow. */
[dir='rtl'] .group:hover .group-hover\:translate-x-0\.5 {
  transform: translateX(-0.125rem);
}

/* The lock and arrow glyphs in the drop zone stay mirrored. */
[dir='rtl'] .dropzone svg,
[dir='rtl'] .panel-soft svg {
  transform: scaleX(-1);
}
[dir='rtl'] .dropzone svg path[d='M12 16V4m0 0L8 8m4-4 4 4'] {
  transform: none;
}

/* Numbers, timecodes and file sizes stay left-to-right. */
[dir='rtl'] .font-mono,
[dir='rtl'] [data-i18n='stats.cues'],
[dir='rtl'] [data-i18n='stats.source'] {
  unicode-bidi: plaintext;
}

/* The modal close button hugs the logical end of the card. */
[dir='rtl'] .modal-card {
  text-align: start;
}
[dir='rtl'] .modal-card ul,
[dir='rtl'] .modal-card ol {
  padding-inline-start: 1.1rem;
}

[dir='rtl'] .compare-table th,
[dir='rtl'] .compare-table td {
  text-align: start;
}

/* Notices read better with the icon on the reading-order side. */
[dir='rtl'] .flex.items-start.gap-2\.5 > svg {
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
