/* SOMANASI Tutor AI · Addis AI
   Palette: Addis blue #245efe is the only accent; everything else is black, white or neutral grey.
   Flat: no gradients, tints or shades. The voice orb (orb.js) keeps the portal's shader. */
:root {
  --blue: #245efe;

  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #fafafa;
  --border: #eaeaea;
  --border-strong: #999999;
  --text: #000000;
  --muted: #666666;
  --accent: var(--blue);
  --accent-text: var(--blue);
  --on-accent: #ffffff;
  --focus: var(--blue);

  --radius: 12px;
  --radius-sm: 8px;
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --surface: #000000;
    --surface-2: #111111;
    --border: #333333;
    --border-strong: #888888;
    --text: #ffffff;
    --muted: #a1a1a1;
    /* Blue text on black is below 4.5:1, so small accent text turns white in dark mode. */
    --accent-text: #ffffff;
    color-scheme: dark;
  }
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
}

[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 16px;
  top: -64px;
  z-index: 10;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--text);
  color: var(--bg);
  font-weight: 600;
  text-decoration: none;
}

.skip-link:focus {
  top: 12px;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* ------------------------------------------------------------ top bar -- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: max(14px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 14px max(16px, env(safe-area-inset-left));
  max-width: 1180px;
  width: 100%;
  margin: 0 auto;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 6px;
  text-decoration: none;
  min-height: 44px;
}

.byline {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.wordmark {
  display: block;
  height: 24px;
  width: auto;
}

.wordmark-mark {
  fill: var(--blue);
}

.wordmark-ink {
  fill: var(--text);
}

.product-tag {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 4px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

/* ------------------------------------------------------------- layout -- */

.layout {
  flex: 1;
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 16px max(16px, env(safe-area-inset-right)) 24px max(16px, env(safe-area-inset-left));
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

@media (min-width: 960px) {
  .layout {
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
    gap: 24px;
  }

  .side {
    position: sticky;
    top: 16px;
  }
}

.stage,
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.stage {
  padding: 22px 18px 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
}

@media (min-width: 600px) {
  .stage {
    padding: 32px;
  }
}

/* -------------------------------------------------------------- intro -- */

.intro {
  text-align: center;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

h1 {
  margin: 0;
  color: var(--text);
  font-size: clamp(28px, 7.5vw, 44px);
  line-height: 1.1;
  letter-spacing: -0.03em;
  font-weight: 700;
  text-wrap: balance;
}

.tagline {
  margin: 8px 0 0;
  font-size: 18px;
  font-weight: 600;
}

.subtitle-alt {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.lead {
  margin: 14px auto 0;
  max-width: 46ch;
  color: var(--muted);
  font-size: 15px;
}

.lead strong {
  color: var(--text);
}

/* ------------------------------------------------------------ pickers -- */

.setup {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin: 0;
}

.picker {
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

.picker legend {
  padding: 0;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 600;
}

.legend-alt {
  margin-left: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.lang-picker legend {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
}

.segmented label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  min-width: 108px;
  padding: 0 18px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 120ms ease, color 120ms ease;
}

.segmented label:hover {
  color: var(--text);
}

.segmented input:checked + label {
  background: var(--text);
  color: var(--bg);
}

.segmented input:focus-visible + label {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.topic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
}

.voice-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 120ms ease, background-color 120ms ease, color 120ms ease;
}

.topic-chip strong {
  font-size: 15px;
  font-weight: 600;
}

.topic-chip small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

.voice-chip {
  flex-direction: row;
  align-items: center;
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
}

.chip:hover {
  border-color: var(--border-strong);
}

input[type="radio"]:checked + .chip {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

input[type="radio"]:checked + .chip small {
  color: var(--on-accent);
}

input[type="radio"]:focus-visible + .chip {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

body:not([data-status="idle"]):not([data-status="error"]):not([data-status="ended"]) .setup {
  display: none;
}

/* ---------------------------------------------------------------- orb -- */

.orb-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
  padding-top: 4px;
}

.orb-stage {
  display: grid;
  place-items: center;
  padding: 8px;
}

/* Mirrors the portal's VoiceOrb markup classes. */
.voice-orb {
  position: relative;
  width: var(--voice-orb-size);
  height: var(--voice-orb-size);
  max-width: 100%;
  flex-shrink: 0;
}

.voice-orb-disc {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: 9999px;
  will-change: transform;
}

.voice-orb-fallback {
  position: absolute;
  inset: 0;
}

.voice-orb-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  transition: opacity 200ms ease;
}

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  padding: 4px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--blue);
  animation: pulse 1.6s ease-in-out infinite;
}

body[data-connection="reconnecting"] .live-dot {
  background: var(--muted);
}

.timer {
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.phase-label {
  margin: 8px 0 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.phase-hint {
  margin: 0;
  max-width: 42ch;
  color: var(--muted);
  font-size: 14px;
}

.session-summary {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.session-summary strong {
  color: var(--text);
}

/* ------------------------------------------------------------ notices -- */

.notice {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--text);
  background: var(--surface);
}

.notice-icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  color: var(--text);
}

.notice p {
  margin: 0;
  flex: 1 1 200px;
  font-size: 14px;
  font-weight: 500;
}

/* ------------------------------------------------------------ buttons -- */

.controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 12px 22px;
  border-radius: 999px;
  border: 1px solid transparent;
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: box-shadow 120ms ease, border-color 120ms ease, transform 80ms ease;
}

.btn:active:not(:disabled) {
  transform: scale(0.98);
}

.btn:disabled {
  cursor: progress;
  opacity: 0.7;
}

.btn svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.btn-primary {
  min-width: min(100%, 240px);
  background: var(--accent);
  color: var(--on-accent);
}

.btn-primary:hover:not(:disabled),
.btn-end:hover:not(:disabled) {
  box-shadow: 0 0 0 3px var(--border);
}

.btn-secondary {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--text);
}

.btn-secondary[aria-pressed="true"] {
  border-color: var(--accent);
  color: var(--accent-text);
}

.btn-end {
  background: var(--text);
  color: var(--bg);
}

.btn-ghost {
  align-self: center;
  background: transparent;
  border-color: var(--text);
  color: var(--text);
}

.spinner {
  display: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-right-color: transparent;
  animation: spin 0.8s linear infinite;
}

body[data-status="connecting"] #startBtn .spinner {
  display: inline-block;
}

body[data-status="connecting"] #startBtn .btn-icon {
  display: none;
}

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

.text-btn {
  min-height: 36px;
  padding: 6px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.text-btn:hover {
  color: var(--text);
}

/* -------------------------------------------------------- side cards -- */

.side {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.card {
  padding: 18px;
  min-width: 0;
}

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

.card-head > div {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.card h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.card-head-alt {
  color: var(--muted);
  font-size: 12px;
}

.suggestion-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.suggestion-list li {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: 14px;
}

.transcript {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 160px;
  max-height: 360px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 2px 2px 4px;
  border-radius: var(--radius-sm);
  scroll-behavior: smooth;
}

@media (min-width: 960px) {
  .transcript {
    max-height: min(52vh, 520px);
  }
}

.transcript-empty {
  margin: auto 0;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.msg {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-width: 88%;
}

.msg-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.msg-text {
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 15px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.msg-agent {
  align-self: flex-start;
}

.msg-agent .msg-text {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-top-left-radius: 4px;
}

.msg-user {
  align-self: flex-end;
  align-items: flex-end;
}

.msg-user .msg-text {
  background: var(--accent);
  color: var(--on-accent);
  border-top-right-radius: 4px;
}

.msg[data-final="false"] .msg-text {
  opacity: 0.72;
}

/* ------------------------------------------------------------- footer -- */

.footer {
  max-width: 1180px;
  width: 100%;
  margin: 0 auto;
  padding: 8px max(16px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.footer p {
  margin: 2px 0;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* The product name is the page heading; on phones the header keeps only "by Addis AI". */
@media (max-width: 440px) {
  .product-tag {
    display: none;
  }
}

@media (max-width: 380px) {
  .wordmark {
    height: 22px;
  }

  .btn {
    padding: 12px 18px;
  }

  .segmented label {
    min-width: 0;
    padding: 0 16px;
  }
}
