/* =========================================================
   SAUTI — Language ID Demo
   Same FUI theme as main portfolio
   ========================================================= */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-0: #04060f;
  --bg-1: #070b18;
  --bg-2: #0b1122;
  --panel: rgba(12, 20, 40, 0.55);
  --border: rgba(90, 170, 255, 0.18);
  --border-strong: rgba(120, 200, 255, 0.45);
  --neon: #4fc3ff;
  --neon-2: #7ee0ff;
  --neon-deep: #1e6fe0;
  --glow: rgba(79, 195, 255, 0.55);
  --fire: #ff4d2e;
  --text: #e8f1ff;
  --text-dim: #8ba3c7;
  --text-mute: #5a6f91;
  --font-sans: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
  --font-display: 'Orbitron', 'Inter', sans-serif;
}

html, body {
  min-height: 100%;
  background: var(--bg-0);
  color: var(--text);
  font-family: var(--font-sans);
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
.mono { font-family: var(--font-mono); }
a { color: inherit; text-decoration: none; }

/* ---------- DRIFTING GRID BACKGROUND ---------- */
.bg-grid {
  position: fixed;
  inset: -25%;
  z-index: 0;
  background:
    radial-gradient(ellipse 60% 40% at 50% 0%, rgba(30, 111, 224, 0.14), transparent 60%),
    repeating-linear-gradient(0deg, rgba(79, 195, 255, 0.06) 0 1px, transparent 1px 42px),
    repeating-linear-gradient(90deg, rgba(79, 195, 255, 0.06) 0 1px, transparent 1px 42px);
  animation: gridDrift 28s linear infinite;
  pointer-events: none;
  will-change: transform;
  backface-visibility: hidden;
}
@keyframes gridDrift {
  from { transform: translate(0, 0); }
  to   { transform: translate(42px, 42px); }
}

/* ---------- HUD ---------- */
.hud {
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.18em;
  color: var(--text-dim);
}
.hud-corner {
  position: absolute;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 1rem 1.25rem;
}
.hud-tl { top: 0; left: 0; flex-direction: row; align-items: center; gap: 0.5rem; }
.hud-tr { top: 0; right: 0; text-align: right; }
.hud-bl { bottom: 0; left: 0; }
.hud-br { bottom: 0; right: 0; text-align: right; }
.hud-link { pointer-events: auto; transition: color 0.25s ease; }
.hud-link:hover { color: var(--neon); }

.hud-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--neon);
  box-shadow: 0 0 8px var(--glow);
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.8); }
}
.hud-sub { font-size: 0.6rem; color: var(--text-mute); }

@media (max-width: 640px) {
  .hud-tr, .hud-br { display: none; }
}

/* ---------- STAGE ---------- */
.stage {
  position: relative;
  z-index: 5;
  max-width: 900px;
  margin: 0 auto;
  padding: clamp(5rem, 10vh, 7rem) clamp(1.25rem, 4vw, 3rem) 6rem;
  display: flex;
  flex-direction: column;
  gap: clamp(2rem, 5vh, 3.5rem);
}

/* ---------- HEADLINE ---------- */
.headline-block { text-align: left; }
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 100px;
  background: rgba(79, 195, 255, 0.04);
  font-size: 0.62rem;
  letter-spacing: 0.25em;
  color: var(--text-dim);
  margin-bottom: 1.5rem;
}
.pulse-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--neon);
  box-shadow: 0 0 8px var(--glow);
  animation: pulse 2s ease-in-out infinite;
}

.title {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(2rem, 6.5vw, 4.2rem);
  line-height: 0.96;
  letter-spacing: -0.01em;
  margin-bottom: 1.5rem;
}
.title .line { display: block; }
.title .line-accent {
  color: transparent;
  -webkit-text-stroke: 1.4px var(--neon);
  text-shadow: 0 0 30px rgba(79, 195, 255, 0.35);
}

.typed-line {
  font-size: clamp(0.85rem, 2vw, 1.05rem);
  color: var(--neon-2);
  min-height: 2.2em;
  letter-spacing: 0.02em;
}
.typed-line .caret { color: var(--neon); margin-right: 0.5rem; }
.cursor { color: var(--neon); animation: blink 1s step-end infinite; }
@keyframes blink { 50% { opacity: 0; } }
.lang-tag {
  color: var(--text-mute);
  font-size: 0.85em;
  letter-spacing: 0.15em;
  margin-left: 0.35rem;
}

/* ---------- MIC ---------- */
.mic-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  padding: 1rem 0;
}

.mic-btn {
  position: relative;
  width: clamp(140px, 34vw, 180px);
  height: clamp(140px, 34vw, 180px);
  border-radius: 50%;
  border: none;
  background: transparent;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform 0.25s ease;
  -webkit-tap-highlight-color: transparent;
}
.mic-btn:hover { transform: scale(1.03); }
.mic-btn:active { transform: scale(0.97); }

.mic-ring {
  position: absolute;
  border-radius: 50%;
  border: 1px solid rgba(79, 195, 255, 0.4);
  pointer-events: none;
}
.mic-ring-1 { inset: 0; animation: ringPulse 3s ease-in-out infinite; }
.mic-ring-2 { inset: 12%; animation: ringPulse 3s ease-in-out 0.5s infinite; opacity: 0.7; }
.mic-ring-3 { inset: 24%; border-style: dashed; animation: spin 22s linear infinite; opacity: 0.55; }
@keyframes ringPulse {
  0%, 100% { transform: scale(1); opacity: 0.35; }
  50% { transform: scale(1.06); opacity: 0.75; }
}
@keyframes spin { to { transform: rotate(360deg); } }

.mic-core {
  position: relative;
  z-index: 2;
  width: 55%;
  height: 55%;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #16264a 0%, #070f22 70%);
  border: 1px solid var(--border-strong);
  display: grid;
  place-items: center;
  box-shadow: 0 0 40px rgba(79, 195, 255, 0.25), inset 0 0 20px rgba(79, 195, 255, 0.1);
  transition: all 0.3s ease;
}
.mic-icon { width: 42%; height: 42%; color: var(--neon); transition: color 0.3s ease; }

/* recording state */
.mic-btn.recording .mic-ring-1 { border-color: var(--fire); animation-duration: 1.1s; }
.mic-btn.recording .mic-ring-2 { border-color: var(--fire); animation-duration: 1.1s; }
.mic-btn.recording .mic-core {
  background: radial-gradient(circle at 35% 30%, #3a1410 0%, #170604 70%);
  border-color: rgba(255, 77, 46, 0.7);
  box-shadow: 0 0 60px rgba(255, 77, 46, 0.45), inset 0 0 22px rgba(255, 77, 46, 0.25);
}
.mic-btn.recording .mic-icon { color: var(--fire); }

/* processing state */
.mic-btn.processing .mic-ring-3 { animation-duration: 3s; border-color: var(--neon-2); }
.mic-btn.processing .mic-core { box-shadow: 0 0 70px rgba(79, 195, 255, 0.6); }

.mic-hint {
  font-size: 0.65rem;
  letter-spacing: 0.25em;
  color: var(--text-mute);
  text-align: center;
  min-height: 1.4em;
  transition: color 0.3s ease;
}
.mic-hint.recording { color: var(--fire); text-shadow: 0 0 12px rgba(255, 77, 46, 0.5); }

.waveform {
  width: min(100%, 480px);
  height: 60px;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.waveform.active { opacity: 1; }

/* ---------- RESULT PANEL ---------- */
.result-panel {
  position: relative;
  padding: 1.75rem 1.75rem 1.5rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  transition: all 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}
.result-panel.is-active {
  border-color: var(--border-strong);
  box-shadow: 0 24px 80px -30px rgba(79, 195, 255, 0.5);
}
.panel-corner {
  position: absolute;
  width: 12px; height: 12px;
  border: 1px solid var(--neon);
  opacity: 0.7;
}
.panel-corner.tl { top: 8px; left: 8px; border-right: 0; border-bottom: 0; }
.panel-corner.tr { top: 8px; right: 8px; border-left: 0; border-bottom: 0; }
.panel-corner.bl { bottom: 8px; left: 8px; border-right: 0; border-top: 0; }
.panel-corner.br { bottom: 8px; right: 8px; border-left: 0; border-top: 0; }

.result-head {
  display: flex;
  justify-content: space-between;
  font-size: 0.6rem;
  letter-spacing: 0.28em;
  color: var(--text-mute);
  margin-bottom: 1.25rem;
}
.result-tag { color: var(--neon); }
.result-tag.processing { color: var(--neon-2); }
.result-tag.error { color: var(--fire); }

.result-label {
  display: block;
  font-size: 0.6rem;
  letter-spacing: 0.3em;
  color: var(--text-mute);
  margin-bottom: 0.5rem;
}
.result-lang {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.6rem, 5vw, 2.6rem);
  letter-spacing: 0.02em;
  color: var(--text);
  margin-bottom: 1rem;
  transition: color 0.4s ease;
}
.result-lang.success { color: var(--neon); text-shadow: 0 0 24px var(--glow); }
.result-lang.low { color: #ffb347; text-shadow: 0 0 18px rgba(255, 179, 71, 0.5); }
.result-lang.error { color: var(--fire); }

.confidence-wrap {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin-bottom: 1rem;
}
.confidence-bar {
  flex: 1;
  height: 6px;
  background: rgba(79, 195, 255, 0.1);
  border: 1px solid var(--border);
  border-radius: 100px;
  overflow: hidden;
  position: relative;
}
.confidence-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--neon-deep), var(--neon-2));
  box-shadow: 0 0 14px var(--glow);
  transition: width 0.9s cubic-bezier(0.22, 1, 0.36, 1);
}
.confidence-pct {
  font-size: 0.75rem;
  color: var(--neon);
  letter-spacing: 0.15em;
  min-width: 3.5em;
  text-align: right;
}

.result-alts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  min-height: 1px;
}
.alt-chip {
  padding: 0.35rem 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  background: rgba(79, 195, 255, 0.06);
  border: 1px solid var(--border);
  border-radius: 100px;
  color: var(--text-dim);
}
.alt-chip strong { color: var(--text); font-weight: 500; }
.alt-chip .pct { color: var(--neon); margin-left: 0.4rem; }

.result-note {
  margin-top: 1rem;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  color: var(--text-mute);
  min-height: 1.2em;
  line-height: 1.5;
}

/* ---------- MANIFESTO ---------- */
.manifesto {
  padding-top: 2rem;
  border-top: 1px solid var(--border);
  text-align: center;
}
.manifesto-line {
  max-width: 620px;
  margin: 0 auto 1.5rem;
  font-size: clamp(0.9rem, 1.8vw, 1rem);
  color: var(--text-dim);
  line-height: 1.7;
}
.manifesto-line .glow {
  color: var(--neon);
  text-shadow: 0 0 14px var(--glow);
}
.credits {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.6rem;
  font-size: 0.62rem;
  letter-spacing: 0.2em;
  color: var(--text-mute);
}
.credits a { color: var(--text-dim); border-bottom: 1px solid transparent; transition: all 0.25s ease; }
.credits a:hover { color: var(--neon); border-bottom-color: var(--neon); }
.credits .divider { color: var(--text-mute); opacity: 0.5; }

/* ---------- MOBILE ---------- */
@media (max-width: 640px) {
  .stage { padding-top: 5rem; gap: 2rem; }
  .mic-block { gap: 1rem; }
  .mic-hint { font-size: 0.6rem; }
  .result-panel { padding: 1.25rem; }
  .result-head { font-size: 0.55rem; }
}

/* ---------- REDUCED MOTION ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .bg-grid { animation: none; }
}