/* ═══════════════════════════════════════════════════════════
   TuvaLLM — Tuvaluan Speech Recognition Demo
   Ocean-depth palette with coral accents
   ═══════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Instrument+Serif:ital@0;1&family=DM+Sans:ital,opsz,wght@0,9..40,300..700;1,9..40,300..700&display=swap');

:root {
  --abyss: #060d1a;
  --deep: #0a1628;
  --ocean: #0f1f3a;
  --shelf: #162a4a;
  --reef: #1e3a5f;
  --teal: #0d9488;
  --teal-bright: #14b8a6;
  --lagoon: #4dc4ff;
  --coral: #f97316;
  --coral-soft: #fb923c;
  --sand: #f5e6d3;
  --foam: #e8f4f8;
  --text: #c8d6e5;
  --text-dim: #7a8fa6;
  --text-bright: #e2ecf5;

  --font-display: 'Instrument Serif', Georgia, serif;
  --font-body: 'DM Sans', system-ui, -apple-system, sans-serif;

  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font-body);
  background: var(--abyss);
  color: var(--text);
  line-height: 1.65;
  overflow-x: hidden;
}

a { color: var(--lagoon); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--teal-bright); }

/* ── Utility ───────────────────────────────────────────── */
.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 2rem;
}

/* ── Animated ocean background ─────────────────────────── */
.ocean-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse 120% 60% at 20% 100%, rgba(13,148,136,0.08) 0%, transparent 70%),
    radial-gradient(ellipse 80% 50% at 80% 0%, rgba(77,196,255,0.05) 0%, transparent 60%),
    var(--abyss);
}

.ocean-bg::before {
  content: '';
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 30 Q15 25 30 30 T60 30' fill='none' stroke='%23ffffff' stroke-opacity='0.015' stroke-width='1'/%3E%3C/svg%3E");
  background-size: 60px 60px;
  animation: drift 40s linear infinite;
}

@keyframes drift {
  to { background-position: 60px 30px; }
}

/* ── Hero ──────────────────────────────────────────────── */
.hero {
  min-height: 70vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 6rem 0 4rem;
  position: relative;
}

.hero-flag {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--teal-bright);
  margin-bottom: 1.5rem;
  opacity: 0;
  animation: fadeUp 0.8s var(--ease-out-expo) 0.1s forwards;
}

.hero-flag::before {
  content: '';
  display: block;
  width: 24px;
  height: 14px;
  background: linear-gradient(135deg, var(--lagoon) 30%, var(--teal) 70%);
  border-radius: 2px;
  box-shadow: 0 0 8px rgba(77,196,255,0.3);
}

.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(3.5rem, 10vw, 7rem);
  font-weight: 400;
  line-height: 0.95;
  color: var(--foam);
  letter-spacing: -0.02em;
  opacity: 0;
  animation: fadeUp 0.8s var(--ease-out-expo) 0.2s forwards;
}

.hero h1 em {
  font-style: italic;
  color: var(--teal-bright);
}

.hero-subtitle {
  font-family: var(--font-display);
  font-size: clamp(1.2rem, 3vw, 1.6rem);
  font-style: italic;
  color: var(--text-dim);
  margin-top: 0.75rem;
  opacity: 0;
  animation: fadeUp 0.8s var(--ease-out-expo) 0.35s forwards;
}

.hero-desc {
  max-width: 540px;
  font-size: 1.05rem;
  color: var(--text);
  margin-top: 1.75rem;
  opacity: 0;
  animation: fadeUp 0.8s var(--ease-out-expo) 0.5s forwards;
}

.hero-wave {
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 100%;
  height: 80px;
  overflow: hidden;
}

.hero-wave svg {
  position: absolute;
  bottom: 0;
  width: 200%;
  height: 100%;
  animation: waveScroll 12s linear infinite;
}

@keyframes waveScroll {
  to { transform: translateX(-50%); }
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Demo Section ──────────────────────────────────────── */
.demo-section {
  padding: 5rem 0;
  position: relative;
}

.section-label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--coral);
  margin-bottom: 0.75rem;
}

.section-title {
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 2.8rem);
  color: var(--foam);
  margin-bottom: 0.5rem;
}

.section-desc {
  color: var(--text-dim);
  max-width: 560px;
  margin-bottom: 2.5rem;
}

/* ── Mic Button ────────────────────────────────────────── */
.mic-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 2.5rem;
}

.mic-btn {
  position: relative;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  border: 2px solid var(--reef);
  background: linear-gradient(145deg, var(--ocean), var(--deep));
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s var(--ease-out-expo);
  box-shadow:
    0 4px 24px rgba(0,0,0,0.3),
    inset 0 1px 0 rgba(255,255,255,0.05);
}

.mic-btn:hover {
  border-color: var(--teal);
  transform: scale(1.05);
  box-shadow:
    0 8px 40px rgba(13,148,136,0.2),
    inset 0 1px 0 rgba(255,255,255,0.08);
}

.mic-btn svg {
  width: 32px;
  height: 32px;
  fill: var(--text);
  transition: fill 0.2s;
}

.mic-btn:hover svg { fill: var(--foam); }

/* Pulsing ring when recording */
.mic-btn.recording {
  border-color: var(--coral);
  background: linear-gradient(145deg, #1a0800, #2a1000);
}

.mic-btn.recording svg { fill: var(--coral); }

.mic-btn.recording::before,
.mic-btn.recording::after {
  content: '';
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 1.5px solid var(--coral);
  animation: ripple 2s ease-out infinite;
}

.mic-btn.recording::after {
  animation-delay: 1s;
}

@keyframes ripple {
  0% { transform: scale(1); opacity: 0.6; }
  100% { transform: scale(1.6); opacity: 0; }
}

.mic-status {
  font-size: 0.85rem;
  color: var(--text-dim);
  height: 1.2em;
  transition: color 0.3s;
}

.mic-status.active {
  color: var(--coral-soft);
}

/* ── Transcript Display ────────────────────────────────── */
.transcript-box {
  position: relative;
  min-height: 140px;
  padding: 1.75rem 2rem;
  background: var(--deep);
  border: 1px solid var(--shelf);
  border-radius: 12px;
  font-size: 1.15rem;
  line-height: 1.75;
  color: var(--text-bright);
  transition: border-color 0.3s;
  overflow: hidden;
}

.transcript-box.active {
  border-color: var(--teal);
  box-shadow: 0 0 0 1px var(--teal), 0 8px 32px rgba(13,148,136,0.08);
}

.transcript-box.error {
  border-color: #ef4444;
}

.transcript-placeholder {
  color: var(--text-dim);
  font-style: italic;
  font-family: var(--font-display);
  font-size: 1rem;
}

.transcript-text {
  white-space: pre-wrap;
  word-break: break-word;
}

.transcript-cursor {
  display: inline-block;
  width: 2px;
  height: 1.1em;
  background: var(--teal-bright);
  vertical-align: text-bottom;
  margin-left: 2px;
  animation: blink 1s step-end infinite;
}

@keyframes blink {
  50% { opacity: 0; }
}

/* Processing bar */
.transcript-box .processing-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--teal), var(--lagoon), var(--teal));
  background-size: 200% 100%;
  animation: shimmer 1.5s ease infinite;
  transition: width 0.3s;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── File Upload ───────────────────────────────────────── */
.upload-area {
  margin-top: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.upload-divider {
  font-size: 0.75rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.upload-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.2rem;
  background: var(--shelf);
  border: 1px solid var(--reef);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}

.upload-btn:hover {
  background: var(--reef);
  border-color: var(--teal);
  color: var(--foam);
}

.upload-btn svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.upload-btn.uploading {
  pointer-events: none;
  opacity: 0.6;
}

#file-input { display: none; }

.upload-info {
  font-size: 0.8rem;
  color: var(--text-dim);
}

/* ── About Section ─────────────────────────────────────── */
.about-section {
  padding: 5rem 0;
}

.about-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  margin-top: 2rem;
}

.about-card {
  padding: 2rem;
  background: var(--deep);
  border: 1px solid var(--shelf);
  border-radius: 12px;
  transition: border-color 0.3s;
}

.about-card:hover {
  border-color: var(--reef);
}

.about-card h3 {
  font-family: var(--font-display);
  font-size: 1.3rem;
  color: var(--foam);
  margin-bottom: 0.75rem;
}

.about-card p {
  font-size: 0.95rem;
  color: var(--text);
  line-height: 1.7;
}

.about-card .card-accent {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--teal-bright);
  margin-bottom: 0.5rem;
}

/* ── Stats / Technical ─────────────────────────────────── */
.stats-section {
  padding: 5rem 0;
  border-top: 1px solid var(--shelf);
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.5rem;
  margin-top: 2.5rem;
  margin-bottom: 3rem;
}

.stat-item {
  text-align: center;
  padding: 1.5rem 1rem;
  background: var(--deep);
  border: 1px solid var(--shelf);
  border-radius: 10px;
}

.stat-value {
  font-family: var(--font-display);
  font-size: 2.2rem;
  color: var(--foam);
  line-height: 1.1;
}

.stat-value .accent { color: var(--teal-bright); }

.stat-label {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.tech-detail {
  font-size: 0.95rem;
  color: var(--text);
  max-width: 640px;
  line-height: 1.75;
}

.tech-detail code {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.85em;
  background: var(--shelf);
  padding: 0.15em 0.45em;
  border-radius: 4px;
  color: var(--lagoon);
}

/* ── Pipeline graphic ──────────────────────────────────── */
.pipeline {
  display: flex;
  align-items: center;
  gap: 0;
  margin: 2.5rem 0;
  overflow-x: auto;
  padding-bottom: 0.5rem;
}

.pipeline-step {
  flex-shrink: 0;
  padding: 0.75rem 1.2rem;
  background: var(--deep);
  border: 1px solid var(--shelf);
  border-radius: 8px;
  font-size: 0.8rem;
  color: var(--text);
  text-align: center;
  white-space: nowrap;
}

.pipeline-step strong {
  display: block;
  font-size: 0.7rem;
  color: var(--teal-bright);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.25rem;
}

.pipeline-arrow {
  flex-shrink: 0;
  width: 32px;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.9rem;
}

/* ── Footer ────────────────────────────────────────────── */
.site-footer {
  padding: 3rem 0;
  border-top: 1px solid var(--shelf);
  text-align: center;
}

.footer-inner {
  font-size: 0.85rem;
  color: var(--text-dim);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.footer-dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--reef);
}

/* ── Connection status toast ───────────────────────────── */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(calc(100% + 2rem));
  padding: 0.75rem 1.5rem;
  background: var(--shelf);
  border: 1px solid var(--reef);
  border-radius: 10px;
  font-size: 0.85rem;
  color: var(--text);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  transition: transform 0.4s var(--ease-spring);
  z-index: 100;
  pointer-events: none;
}

.toast.visible {
  transform: translateX(-50%) translateY(0);
}

.toast.error {
  border-color: #ef4444;
  color: #fca5a5;
}

.toast.success {
  border-color: var(--teal);
  color: var(--teal-bright);
}

/* ── Responsive ────────────────────────────────────────── */
@media (max-width: 768px) {
  .container { padding: 0 1.25rem; }
  .hero { min-height: 55vh; padding: 4rem 0 3rem; }
  .about-grid { grid-template-columns: 1fr; }
  .stats-row { grid-template-columns: 1fr 1fr; }
  .pipeline { gap: 0; }
  .pipeline-arrow { width: 24px; font-size: 0.8rem; }
  .transcript-box { padding: 1.25rem 1.5rem; }
}

@media (max-width: 480px) {
  .stats-row { grid-template-columns: 1fr; }
  .hero h1 { font-size: 3rem; }
  .upload-area { flex-direction: column; align-items: flex-start; }
}
