/* ═══════════════════════════════════════════════════════════════
   LinguaFlow · Aurora
   Dark glassmorphism · aurora gradient · neon glow on active
   ═══════════════════════════════════════════════════════════════ */

:root {
  --bg-base:     #07070f;
  --ink:         #fafafa;
  --ink-muted:   rgba(255, 255, 255, 0.6);
  --ink-faint:   rgba(255, 255, 255, 0.35);
  --ink-mono:    rgba(255, 255, 255, 0.5);
  --glass-bg:    rgba(255, 255, 255, 0.06);
  --glass-bg-2:  rgba(255, 255, 255, 0.08);
  --glass-line:  rgba(255, 255, 255, 0.10);
  --glass-line-2: rgba(255, 255, 255, 0.15);

  --accent-1:    #a78bfa;   /* violet */
  --accent-2:    #22d3ee;   /* cyan   */
  --accent-3:    #f472b6;   /* pink   */

  --sans:    'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --serif:   'Instrument Serif', Georgia, serif;
  --mono:    'JetBrains Mono', ui-monospace, SFMono-Regular, monospace;

  --r-lg: 24px;
  --r-md: 18px;
  --r-sm: 12px;
  --r-pill: 999px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg-base);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior: none;
}

body {
  /* Aurora gradient layers */
  background:
    radial-gradient(ellipse 80% 60% at 20% 10%,  rgba(167, 139, 250, 0.45), transparent 60%),
    radial-gradient(ellipse 70% 50% at 80% 30%,  rgba(34, 211, 238, 0.35),  transparent 60%),
    radial-gradient(ellipse 90% 70% at 50% 100%, rgba(244, 114, 182, 0.30), transparent 60%),
    var(--bg-base);
  background-attachment: fixed;

  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;

  padding-top:    max(env(safe-area-inset-top),    20px);
  padding-bottom: max(env(safe-area-inset-bottom), 20px);
  padding-left:   20px;
  padding-right:  20px;

  position: relative;
}

/* Subtle noise grain overlay */
body::before {
  content: '';
  position: fixed; inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px);
  background-size: 3px 3px;
  pointer-events: none;
  z-index: 0;
}

body > * { position: relative; z-index: 1; }

button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }

/* ─────────────────────────────────────────────────────────────
   HEADER · brand + language selector
   ───────────────────────────────────────────────────────────── */
header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
  padding: 8px 4px;
}

.brand {
  display: flex; align-items: center; gap: 10px;
}
.brand img {
  width: 32px; height: 32px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  box-shadow: 0 4px 16px -4px rgba(167, 139, 250, 0.6);
  object-fit: cover;
}
/* If the user has no icon yet, fallback gradient + glow looks good even on broken img */
.brand img[alt=""] { color: transparent; }

.brand span {
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
  color: var(--ink);
}

#langOther {
  font: inherit;
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  appearance: none;
  -webkit-appearance: none;
  background-color: var(--glass-bg);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  border: 1px solid var(--glass-line);
  border-radius: var(--r-sm);
  padding: 8px 30px 8px 12px;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6' fill='none'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23fafafa' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 10px;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}
#langOther:hover { background-color: var(--glass-bg-2); border-color: var(--glass-line-2); }
#langOther:focus { outline: none; border-color: var(--accent-1); box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.25); }
#langOther option { background: #1a1a2a; color: var(--ink); }

/* ─────────────────────────────────────────────────────────────
   MAIN · spoken + translated text
   ───────────────────────────────────────────────────────────── */
main {
  flex: 1;
  display: flex; flex-direction: column;
  justify-content: center;
  gap: 24px;
  min-height: 0;
  padding: 24px 0;
}

#display {
  display: flex; flex-direction: column;
  gap: 18px;
  align-items: stretch;
  text-align: center;
}

.said, .translated {
  margin: 0;
  line-height: 1.2;
  letter-spacing: -0.015em;
  overflow-wrap: break-word;
  word-break: break-word;
}

.said {
  font-family: var(--serif);
  font-weight: 400;
  font-style: italic;
  font-size: clamp(22px, 7vw, 30px);
  color: var(--ink-muted);
  min-height: 1.2em;
}
.said:empty::before {
  content: 'Habla…';
  opacity: 0.4;
}

.arrow {
  font-family: var(--mono);
  text-align: center;
  font-size: 14px;
  color: var(--accent-2);
  opacity: 0.7;
  user-select: none;
  animation: arrowDrift 2.6s ease-in-out infinite;
}
@keyframes arrowDrift {
  0%, 100% { transform: translateY(0);   opacity: 0.5; }
  50%      { transform: translateY(4px); opacity: 0.85; }
}

.translated {
  font-family: var(--sans);
  font-weight: 600;
  font-size: clamp(26px, 8.5vw, 34px);
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #fafafa 0%, var(--accent-1) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  min-height: 1.2em;
}
.translated:empty { min-height: 0; }

.status {
  text-align: center;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-mono);
  margin-top: 4px;
}

/* ─────────────────────────────────────────────────────────────
   FOOTER · the two language buttons
   ───────────────────────────────────────────────────────────── */
footer {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  flex-shrink: 0;
}

.lang-btn {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 6px;
  padding: 18px 12px;

  background: var(--glass-bg);
  backdrop-filter: blur(24px) saturate(140%);
  -webkit-backdrop-filter: blur(24px) saturate(140%);
  border: 1px solid var(--glass-line);
  border-radius: var(--r-lg);
  color: var(--ink);

  position: relative;
  overflow: hidden;
  transition:
    transform 0.18s cubic-bezier(0.2, 0.7, 0.3, 1),
    box-shadow 0.25s ease,
    background 0.25s ease,
    border-color 0.25s ease;

  -webkit-tap-highlight-color: transparent;
}

.lang-btn:hover { background: var(--glass-bg-2); border-color: var(--glass-line-2); }
.lang-btn:active { transform: scale(0.97); }

.lang-btn .btn-flag {
  font-size: 30px;
  line-height: 1;
  display: block;
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.lang-btn .btn-name {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

/* ── ACTIVE STATE · neon glow + flag bounce ──────────────── */
.lang-btn.active {
  background: linear-gradient(135deg,
    rgba(167, 139, 250, 0.25),
    rgba(34, 211, 238, 0.18));
  border-color: rgba(167, 139, 250, 0.6);
  color: var(--ink);
  animation: btnGlow 2s ease-in-out infinite;
}
.lang-btn.active .btn-name { color: var(--ink); }
.lang-btn.active .btn-flag {
  animation: flagBounce 0.9s cubic-bezier(0.34, 1.56, 0.64, 1) infinite;
  filter: drop-shadow(0 4px 12px rgba(167, 139, 250, 0.6));
}

@keyframes btnGlow {
  0%, 100% {
    box-shadow:
      0 0 0 1px rgba(167, 139, 250, 0.40),
      0 0 40px  rgba(167, 139, 250, 0.45),
      0 0 80px  rgba(34, 211, 238, 0.25),
      inset 0 1px 0 rgba(255, 255, 255, 0.15);
  }
  50% {
    box-shadow:
      0 0 0 1px rgba(167, 139, 250, 0.60),
      0 0 60px  rgba(167, 139, 250, 0.70),
      0 0 110px rgba(34, 211, 238, 0.40),
      inset 0 1px 0 rgba(255, 255, 255, 0.20);
  }
}

@keyframes flagBounce {
  0%, 100% { transform: translateY(0)    scale(1); }
  30%      { transform: translateY(-10px) scale(1.18); }
  55%      { transform: translateY(0)     scale(0.92); }
  75%      { transform: translateY(-4px)  scale(1.05); }
}

/* ─────────────────────────────────────────────────────────────
   NO-SPEECH WARNING
   ───────────────────────────────────────────────────────────── */
#noSpeech {
  position: fixed;
  left: 50%; bottom: 24px;
  transform: translateX(-50%);
  z-index: 100;

  background: var(--glass-bg-2);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(244, 114, 182, 0.4);
  color: var(--ink);
  padding: 12px 18px;
  border-radius: var(--r-pill);
  font-size: 13px;
  box-shadow: 0 12px 40px -8px rgba(244, 114, 182, 0.35);
  max-width: calc(100vw - 40px);
  text-align: center;
}
#noSpeech strong { color: var(--accent-3); font-weight: 600; }

/* ─────────────────────────────────────────────────────────────
   REDUCED MOTION
   ───────────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* ─────────────────────────────────────────────────────────────
   LARGER VIEWPORTS · keep the app comfortably centered
   ───────────────────────────────────────────────────────────── */
@media (min-width: 520px) {
  body {
    max-width: 480px;
    margin-left: auto;
    margin-right: auto;
    padding-left: 24px;
    padding-right: 24px;
  }
}
