/* =================================================================
   MultiLingMeet — styles
   Modern, responsive, Indian-flavoured colour palette.
   Designed to scale fluidly from 320px phones to 4K displays.
   ================================================================= */

/* ---------- Tokens ---------- */
:root {
  /* Indian-flag-inspired but muted for sustained reading */
  --ink:            #0f1b2d;
  --ink-soft:       #2c3e50;
  --paper:          #fbfaf6;
  --paper-soft:     #f1ede2;
  --line:           rgba(15, 27, 45, 0.10);
  --accent:         #ff8a1f;   /* warm saffron */
  --accent-deep:    #d96f10;
  --teal:           #0e7c7b;   /* Ashoka blue cousin */
  --teal-soft:      #d4ecec;
  --danger:         #d23434;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;
  --shadow-1:  0 1px 2px rgba(15, 27, 45, .06), 0 1px 4px rgba(15, 27, 45, .04);
  --shadow-2:  0 6px 22px rgba(15, 27, 45, .08), 0 2px 6px rgba(15, 27, 45, .05);

  /* Fluid type — scales with viewport, clamped at extremes */
  --fs-xs:  clamp(0.75rem, 0.7rem + 0.2vw, 0.85rem);
  --fs-sm:  clamp(0.85rem, 0.8rem + 0.3vw, 1rem);
  --fs-md:  clamp(1rem,   0.95rem + 0.3vw, 1.15rem);
  --fs-lg:  clamp(1.25rem, 1.1rem + 0.6vw, 1.6rem);
  --fs-xl:  clamp(1.75rem, 1.4rem + 1.6vw, 3rem);
  --fs-xxl: clamp(2.5rem,  1.8rem + 3vw,   4.5rem);

  /* Fluid spacing */
  --gap-xs:  clamp(0.35rem, 0.3rem + 0.2vw, 0.5rem);
  --gap-sm:  clamp(0.6rem,  0.5rem + 0.3vw, 0.9rem);
  --gap-md:  clamp(1rem,    0.85rem + 0.6vw, 1.6rem);
  --gap-lg:  clamp(1.5rem,  1.2rem + 1vw,    2.5rem);
  --gap-xl:  clamp(2rem,    1.5rem + 2vw,    4rem);

  /* Content max-width keeps things readable on giant screens */
  --content-max: 1480px;
}

/* Dark mode tokens */
@media (prefers-color-scheme: dark) {
  :root {
    --ink:        #f0eee6;
    --ink-soft:   #b8c1cf;
    --paper:      #0c121d;
    --paper-soft: #15202f;
    --line:       rgba(240, 238, 230, 0.10);
    --accent:     #ffa14a;
    --accent-deep:#ff8a1f;
    --teal:       #4cc4c2;
    --teal-soft:  #163030;
    --shadow-1:  0 1px 2px rgba(0,0,0,.4), 0 1px 4px rgba(0,0,0,.25);
    --shadow-2:  0 6px 22px rgba(0,0,0,.4), 0 2px 6px rgba(0,0,0,.25);
  }
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body, h1, h2, p, ul, figure { margin: 0; }
button { font: inherit; cursor: pointer; }
a { color: var(--teal); }

/* ---------- Page ---------- */
html, body {
  background: var(--paper);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
               "Helvetica Neue", "Noto Sans", "Noto Sans Devanagari",
               "Noto Sans Bengali", "Noto Sans Tamil", "Noto Sans Telugu",
               "Noto Sans Gujarati", "Noto Sans Gurmukhi", "Noto Sans Kannada",
               "Noto Sans Malayalam", "Noto Sans Oriya", "Noto Naskh Arabic",
               Arial, sans-serif;
  font-size: var(--fs-md);
  line-height: 1.55;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(1200px 600px at 100% -10%, rgba(255, 138, 31, .08), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(14, 124, 123, .08), transparent 60%),
    var(--paper);
}

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap-md);
  padding: var(--gap-md) var(--gap-lg);
  border-bottom: 1px solid var(--line);
  background: color-mix(in oklab, var(--paper) 80%, transparent);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--ink);
  font-weight: 700;
  letter-spacing: -0.01em;
}
.brand-mark { width: 32px; height: 32px; color: var(--teal); flex: none; }
.brand-name { font-size: var(--fs-lg); }
.brand-accent { color: var(--accent); }

.status {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  background: var(--paper-soft);
  font-size: var(--fs-xs);
  color: var(--ink-soft);
  border: 1px solid var(--line);
}
.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--ink-soft);
  flex: none;
}
.status-dot[data-state="idle"]       { background: var(--ink-soft); }
.status-dot[data-state="connecting"] { background: var(--accent); animation: pulse-dot 1.2s infinite; }
.status-dot[data-state="live"]       { background: #29c46a; box-shadow: 0 0 0 4px rgba(41,196,106,.18); }
.status-dot[data-state="error"]      { background: var(--danger); }

@keyframes pulse-dot { 50% { opacity: 0.35; } }

/* ---------- Stage ---------- */
.stage {
  flex: 1;
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--gap-xl) var(--gap-lg);
  display: flex;
  flex-direction: column;
  gap: var(--gap-xl);
}

/* ---------- Hero ---------- */
.hero { max-width: 56rem; }
.hero-title {
  font-size: var(--fs-xxl);
  line-height: 1.05;
  letter-spacing: -0.02em;
  font-weight: 800;
}
.hero-title-accent {
  color: var(--accent);
  display: inline-block;
}
.hero-sub {
  margin-top: var(--gap-md);
  color: var(--ink-soft);
  font-size: var(--fs-md);
  max-width: 44rem;
}

/* ---------- Panels ---------- */
.panels {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--gap-lg);
}

/* >= 920px: side-by-side */
@media (min-width: 920px) {
  .panels { grid-template-columns: 1fr 1fr; }
}

/* On very wide screens, cap absolute panel width with the container */

.panel {
  background: var(--paper-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--gap-lg);
  display: flex;
  flex-direction: column;
  gap: var(--gap-md);
  box-shadow: var(--shadow-1);
  transition: box-shadow .2s ease, transform .2s ease;
}
.panel:hover { box-shadow: var(--shadow-2); }

.panel-head {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.panel-tag {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: var(--accent);
  color: white;
}
.panel-tag-alt { background: var(--teal); }
.panel-title {
  font-size: var(--fs-lg);
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* ---------- Fields ---------- */
.field { display: flex; flex-direction: column; gap: 0.35rem; }
.field-label {
  font-size: var(--fs-xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.field-input {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  padding: 0.85rem 1rem;
  font-size: var(--fs-md);
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  transition: border-color .15s, box-shadow .15s;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--ink-soft) 50%),
    linear-gradient(135deg, var(--ink-soft) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 2.5rem;
}
.field-input:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 138, 31, 0.22);
}

/* ---------- Mic ---------- */
.mic-btn {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  align-self: center;
  width: clamp(120px, 16vw, 180px);
  height: clamp(120px, 16vw, 180px);
  border-radius: 50%;
  border: none;
  background: linear-gradient(160deg, var(--accent) 0%, var(--accent-deep) 100%);
  color: white;
  font-weight: 600;
  font-size: var(--fs-sm);
  box-shadow: 0 12px 30px rgba(255, 138, 31, .28), inset 0 -3px 0 rgba(0,0,0,.08);
  transition: transform .15s ease, box-shadow .2s ease;
  margin-block: var(--gap-sm);
}
.mic-btn:hover { transform: translateY(-2px); }
.mic-btn:active { transform: translateY(0); }
.mic-btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; }

.mic-icon { width: 38%; height: 38%; }
.mic-label { font-size: var(--fs-xs); letter-spacing: 0.06em; text-transform: uppercase; }

.mic-ring {
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  opacity: 0;
  pointer-events: none;
}
.mic-btn[aria-pressed="true"] .mic-ring {
  animation: pulse-ring 1.4s ease-out infinite;
}
@keyframes pulse-ring {
  0%   { transform: scale(0.95); opacity: 0.5; }
  100% { transform: scale(1.25); opacity: 0; }
}

/* ---------- Meter ---------- */
.meter {
  display: flex;
  align-items: end;
  justify-content: center;
  gap: 4px;
  height: 28px;
  margin-top: -0.5rem;
}
.meter-bar {
  width: 6px;
  height: 8px;
  background: var(--line);
  border-radius: 3px;
  transition: height .12s ease;
}
.mic-btn[aria-pressed="true"] ~ .meter .meter-bar {
  background: var(--accent);
  animation: meter-dance 0.9s ease-in-out infinite;
}
.mic-btn[aria-pressed="true"] ~ .meter .meter-bar:nth-child(1) { animation-delay: 0s; }
.mic-btn[aria-pressed="true"] ~ .meter .meter-bar:nth-child(2) { animation-delay: .15s; }
.mic-btn[aria-pressed="true"] ~ .meter .meter-bar:nth-child(3) { animation-delay: .30s; }
.mic-btn[aria-pressed="true"] ~ .meter .meter-bar:nth-child(4) { animation-delay: .45s; }
.mic-btn[aria-pressed="true"] ~ .meter .meter-bar:nth-child(5) { animation-delay: .60s; }
@keyframes meter-dance {
  0%, 100% { height: 6px; }
  50%      { height: 26px; }
}

/* ---------- Output toggles ---------- */
.output-toggles {
  display: flex;
  gap: var(--gap-sm);
  flex-wrap: wrap;
}
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.8rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: var(--fs-sm);
  cursor: pointer;
  user-select: none;
  transition: border-color .15s, background .15s;
}
.toggle:has(input:checked) {
  border-color: var(--teal);
  background: var(--teal-soft);
  color: var(--teal);
}
.toggle input { accent-color: var(--teal); }

/* ---------- Caption box ---------- */
.caption-box {
  min-height: 9rem;
  max-height: 20rem;
  overflow-y: auto;
  padding: var(--gap-md);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  font-size: clamp(1.05rem, 0.9rem + 0.5vw, 1.4rem);
  line-height: 1.5;
  scroll-behavior: smooth;
  scrollbar-width: thin;
}
.caption-placeholder {
  color: var(--ink-soft);
  font-style: italic;
}
.caption-line {
  margin-bottom: 0.4rem;
  animation: fade-in .25s ease;
}
.caption-line.partial { opacity: 0.6; font-style: italic; }
@keyframes fade-in { from { opacity: 0; transform: translateY(4px); } }

/* ---------- Audio ---------- */
.audio-out {
  width: 100%;
  margin-top: var(--gap-sm);
}

/* ---------- Metrics ---------- */
.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--gap-md);
  padding: var(--gap-md) var(--gap-lg);
  background: var(--paper-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}
.metric { display: flex; flex-direction: column; gap: 0.15rem; }
.metric-label {
  font-size: var(--fs-xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.metric-value {
  font-size: var(--fs-lg);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ---------- Footer ---------- */
.footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  padding: var(--gap-md);
  font-size: var(--fs-xs);
  color: var(--ink-soft);
  border-top: 1px solid var(--line);
}
.footer-sep { color: var(--line); }

/* ---------- Summary button ---------- */
.summary-btn {
  padding: 0.5rem 1.2rem;
  border: 1px solid var(--teal);
  border-radius: var(--radius-md);
  background: var(--teal-soft);
  color: var(--teal);
  font-size: var(--fs-sm);
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, opacity .15s;
}
.summary-btn:hover:not(:disabled) { background: var(--teal); color: white; }
.summary-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.metric-action { justify-content: center; align-items: flex-start; }

/* ---------- Summary box ---------- */
.summary-box {
  padding: var(--gap-lg);
  background: var(--paper-soft);
  border: 1px solid var(--teal);
  border-radius: var(--radius-lg);
  animation: fade-in .3s ease;
}
.summary-title {
  font-size: var(--fs-lg);
  font-weight: 700;
  color: var(--teal);
  margin-bottom: var(--gap-md);
}
.summary-content {
  font-size: var(--fs-md);
  line-height: 1.65;
  white-space: pre-wrap;
}

/* ---------- Responsive tweaks ---------- */
@media (max-width: 520px) {
  .topbar { padding: var(--gap-sm) var(--gap-md); }
  .stage  { padding: var(--gap-lg) var(--gap-md); }
  .panel  { padding: var(--gap-md); border-radius: var(--radius-md); }
  .brand-name { font-size: var(--fs-md); }
}

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
