/* ==========================================================================
   FormBharDo.Ai — Brand: Purple / Black / White
   "Phone-to-PC Instant AI Tunnel"
   ========================================================================== */

:root {
  /* Color tokens */
  --black:        #0A0912;
  --black-soft:   #15121F;
  --black-card:   #1B1729;
  --purple-deep:  #4C1D95;
  --purple:       #7C3AED;
  --purple-bright:#A78BFA;
  --purple-glow:  #C4B5FD;
  --white:        #F7F5FF;
  --white-pure:   #FFFFFF;
  --gray-muted:   #948FAE;
  --gray-line:    rgba(167, 139, 250, 0.16);
  --danger:       #F43F5E;

  /* Type */
  --font-display: 'Outfit', sans-serif;
  --font-body:    'Manrope', sans-serif;
  --font-mono:    'JetBrains Mono', monospace;

  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-sm: 12px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--black);
  color: var(--white);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(60% 50% at 50% 0%, rgba(124, 58, 237, 0.22) 0%, rgba(124, 58, 237, 0) 60%),
    radial-gradient(80% 60% at 50% 100%, rgba(76, 29, 149, 0.18) 0%, rgba(76, 29, 149, 0) 60%),
    var(--black);
}

.container {
  max-width: 460px;
  margin: 0 auto;
  padding: 28px 20px 48px;
}

::selection {
  background: var(--purple);
  color: var(--white-pure);
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* ==========================================================================
   Header
   ========================================================================== */

.header {
  text-align: center;
  margin-bottom: 24px;
}

.brand-footer {
  color: var(--gray-muted) !important;
  font-family: var(--font-mono);
  font-size: 0.72rem !important;
  letter-spacing: 0.04em;
  opacity: 0.8;
}

.brand-footer strong {
  color: var(--purple-bright);
  font-weight: 600;
}

.breathes-heart {
  display: inline-block;
  animation: breathe 2.4s ease-in-out infinite;
}

@keyframes breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

.header h1 {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.7rem;
  letter-spacing: -0.01em;
  color: var(--white-pure);
  background: linear-gradient(120deg, var(--white-pure) 35%, var(--purple-bright) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.header p {
  margin: 6px 0 0;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--gray-muted);
}

/* ==========================================================================
   Card
   ========================================================================== */

.card {
  background: linear-gradient(180deg, var(--black-card) 0%, var(--black-soft) 100%);
  border: 1px solid var(--gray-line);
  border-radius: var(--radius-lg);
  padding: 28px 22px 24px;
  box-shadow:
    0 30px 60px -30px rgba(0, 0, 0, 0.7),
    0 0 0 1px rgba(124, 58, 237, 0.04) inset;
  position: relative;
  overflow: hidden;
}

.card::before {
  content: "";
  position: absolute;
  top: -60%;
  left: -20%;
  width: 140%;
  height: 140%;
  background: radial-gradient(closest-side, rgba(124, 58, 237, 0.12), transparent 70%);
  pointer-events: none;
}

/* ==========================================================================
   Status badge
   ========================================================================== */

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 auto 22px;
  padding: 7px 14px 7px 10px;
  border-radius: 999px;
  background: rgba(244, 63, 94, 0.08);
  border: 1px solid rgba(244, 63, 94, 0.25);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: #FCA5B1;
  width: fit-content;
  position: relative;
  z-index: 1;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 0 0 rgba(244, 63, 94, 0.5);
  animation: pulse-dot 2s ease-out infinite;
}

.status-badge.streaming {
  background: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.35);
  color: #10B981;
}

.status-badge.streaming .status-dot {
  background: #10B981;
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.5);
}

@keyframes pulse-dot-green {
  0%   { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.45); }
  70%  { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.status-badge.streaming .status-dot {
  animation: pulse-dot-green 2s ease-out infinite;
}

@keyframes pulse-dot {
  0%   { box-shadow: 0 0 0 0 rgba(244, 63, 94, 0.45); }
  70%  { box-shadow: 0 0 0 8px rgba(244, 63, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(244, 63, 94, 0); }
}

/* ==========================================================================
   Recorder — signature element
   ========================================================================== */

.recorder-demo-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  z-index: 1;
  padding: 6px 0 8px;
}

.recorder {
  position: relative;
  width: 176px;
  height: 176px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 18px;
}

/* Ambient rotating tunnel ring — always present, slow */
.recorder::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  padding: 2px;
  background: conic-gradient(
    from 0deg,
    var(--purple) 0deg,
    transparent 90deg,
    var(--purple-bright) 180deg,
    transparent 270deg,
    var(--purple) 360deg
  );
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  animation: tunnel-spin 6s linear infinite;
  opacity: 0.55;
}

@keyframes tunnel-spin {
  to { transform: rotate(360deg); }
}

/* Halo pulse rings — active only while recording */
.halo {
  position: absolute;
  inset: 10px;
  border-radius: 50%;
  pointer-events: none;
}

.recorder.recording .halo::before,
.recorder.recording .halo::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1.5px solid var(--purple-bright);
  animation: halo-pulse 1.8s ease-out infinite;
}

.recorder.recording .halo::after {
  animation-delay: 0.9s;
}

@keyframes halo-pulse {
  0%   { transform: scale(0.75); opacity: 0.8; }
  100% { transform: scale(1.55); opacity: 0; }
}

/* Audio level bars (20 radial equalizer bars behind the core) */
.bars {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.bar {
  position: absolute;
  inset: 0;
}

.bar-fill {
  position: absolute;
  left: 50%;
  bottom: 50%;
  width: 4px;
  height: 46px; /* starting height, matches inner_radius in app.js */
  transform: translateX(-50%);
  transform-origin: bottom center;
  border-radius: 2px;
  background: linear-gradient(to top, var(--purple), #C026D3);
  opacity: 0.35;
  will-change: height, opacity;
  transition: height 0.05s linear, opacity 0.05s linear;
}

/* Core button */
.core {
  position: relative;
  z-index: 2;
  width: 118px;
  height: 118px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--purple), #5B21B6);
  color: var(--white-pure);
  box-shadow: 0 14px 30px -10px rgba(124, 58, 237, 0.55), inset 0 1px 0 rgba(255,255,255,0.25);
  transition: background .4s ease, box-shadow .3s ease, transform .15s ease;
}

.core:hover {
  box-shadow: 0 16px 34px -8px rgba(124,58,237,0.6), inset 0 1px 0 rgba(255,255,255,0.3);
}

.core:active {
  transform: scale(0.94);
}

.core svg {
  width: 36px;
  height: 36px;
}

.core svg[hidden] {
    display: none;
}

.core.recording {
  background: linear-gradient(135deg, #C026D3, var(--purple));
  box-shadow: 0 16px 36px -10px rgba(232,121,249,0.55), inset 0 1px 0 rgba(255,255,255,0.3);
}

.core.paused {
  background: linear-gradient(135deg, var(--purple), var(--black-card));
  box-shadow: 0 8px 24px -6px rgba(124,58,237,0.3), inset 0 1px 0 rgba(255,255,255,0.15);
}

/* Pause/finish button — small satellite button */
.finish-btn {
  position: absolute;
  bottom: -6px;
  right: 6px;
  z-index: 3;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: var(--black-card);
  color: var(--white-pure);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
  opacity: 0;
  transform: scale(0.7);
  pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
}

.finish-btn:hover { background: #2E1657; }

.finish-btn.show { opacity: 1; transform: scale(1); pointer-events: auto; }

.finish-btn svg {
  width: 16px;
  height: 16px;
}

.finish-btn svg[hidden] {
  display: none;
}

/* Meta row: rec dot + timer */
.meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-family: var(--font-mono);
}

.meta .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gray-muted);
  opacity: 0.4;
}

.recorder.recording ~ .meta .dot,
.meta .dot.live {
  background: var(--danger);
  opacity: 1;
  animation: pulse-dot 1.4s ease-out infinite;
}

.timer {
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--white);
  font-variant-numeric: tabular-nums;
}

.label {
  margin: 2px 0 0;
  font-size: 0.86rem;
  color: var(--gray-muted);
  text-align: center;
}

.toast {
  margin-top: 10px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--purple-glow);
  min-height: 1em;
  text-align: center;
}

/* ==========================================================================
   Actions section
   ========================================================================== */

.actions-section {
  margin-top: 26px;
  position: relative;
  z-index: 1;
}

.action-group {
  margin-bottom: 6px;
}

.section-title {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--gray-muted);
  margin: 0 0 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--gray-line);
}

.dual-buttons {
  display: flex;
  gap: 14px;
}

.btn-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.action-btn-outer {
  width: 100%;
  aspect-ratio: 1 / 1;
  max-height: 84px;
  border-radius: var(--radius-md);
  padding: 3px;
  cursor: pointer;
  background: linear-gradient(150deg, var(--purple) 0%, transparent 60%);
  transition: transform 0.15s ease;
}

.action-btn-outer:active {
  transform: scale(0.96);
}

.action-btn-inner {
  width: 100%;
  height: 100%;
  border-radius: calc(var(--radius-md) - 3px);
  background: linear-gradient(160deg, var(--black-card), var(--black-soft));
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--gray-line);
}

.action-icon {
  width: 26px;
  height: 26px;
  fill: var(--purple-bright);
}

.camera-btn .action-icon {
  fill: none;
  stroke: #ec4899;
}

.btn-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--gray-muted);
  letter-spacing: 0.03em;
}

.file-list {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.file-list:empty {
  display: none;
}

.file-list .file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--black-soft);
  border: 1px solid var(--gray-line);
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--white);
}

/* ==========================================================================
   Submit actions
   ========================================================================== */

.submit-actions {
  margin-top: 26px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
  z-index: 1;
}

.primary-btn,
.secondary-btn {
  width: 100%;
  padding: 15px 20px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform 0.12s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.primary-btn {
  background: linear-gradient(135deg, var(--purple-bright) 0%, var(--purple) 55%, var(--purple-deep) 100%);
  color: var(--white-pure);
  box-shadow: 0 14px 28px -12px rgba(124, 58, 237, 0.6);
}

.primary-btn:hover { transform: translateY(-1px); }
.primary-btn:active { transform: translateY(0); }

.primary-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.secondary-btn {
  background: transparent;
  color: var(--white);
  border-color: var(--gray-line);
}

.secondary-btn:hover {
  border-color: var(--purple);
  color: var(--purple-bright);
}

/* Progress bar */
.progress-bar-container {
  margin-top: 16px;
  height: 5px;
  width: 100%;
  border-radius: 999px;
  background: var(--black-soft);
  overflow: hidden;
  border: 1px solid var(--gray-line);
}

.progress-bar {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--purple), var(--purple-bright));
  transition: width 0.2s ease;
}

/* ==========================================================================
   Crop modal
   ========================================================================== */

#cropModal {
  background: rgba(10, 9, 18, 0.92) !important;
  backdrop-filter: blur(6px);
}

#cropImage {
  border-radius: var(--radius-sm);
}

#cropModal .secondary-btn,
#cropModal .primary-btn {
  margin: 0;
}

/* ==========================================================================
   Focus visibility (a11y)
   ========================================================================== */

button:focus-visible,
.action-btn-outer:focus-visible {
  outline: 2px solid var(--purple-bright);
  outline-offset: 3px;
}

/* ==========================================================================
   Small screens
   ========================================================================== */

@media (max-width: 380px) {
  .recorder { width: 156px; height: 156px; }
  .core { width: 102px; height: 102px; }
  .header h1 { font-size: 1.45rem; }
}
