/*!
 * HEA-World Reachy Mini App Prototype
 * Copyright (c) 2026 HEA-World contributors
 * SPDX-License-Identifier: MIT
 * This file is intended to be extracted into a separate open-source repository.
 */

:root {
  color-scheme: dark;
  --bg: #101513;
  --surface: #1a211f;
  --surface-soft: #161c1a;
  --surface-strong: #242d2a;
  --text: #f4f7f3;
  --muted: #aab7b1;
  --border: #3b4944;
  --accent: #5ed2bd;
  --accent-strong: #91eadb;
  --accent-text: #10201d;
  --warning: #ffc063;
  --shadow: 0 20px 56px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(94, 210, 189, 0.06), transparent 260px),
    var(--bg);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  line-height: 1.45;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 0 18px;
  color: var(--accent-text);
  background: var(--accent);
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  background: var(--accent-strong);
}

button:disabled {
  cursor: wait;
  opacity: 0.62;
}

button.secondary {
  color: var(--text);
  background: var(--surface-strong);
  border: 1px solid var(--border);
}

button.prompt-chip {
  min-height: 36px;
  padding: 0 12px;
  color: var(--text);
  background: var(--surface-strong);
  border: 1px solid var(--border);
  font-size: 0.88rem;
  font-weight: 800;
}

button.prompt-chip:hover {
  color: var(--accent-text);
  background: var(--accent);
  border-color: var(--accent);
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  background: var(--surface);
}

textarea {
  min-height: 132px;
  resize: vertical;
}

.app-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 28px 24px 40px;
}

.workspace {
  display: grid;
  gap: 22px;
}

.hero {
  display: grid;
  gap: 24px;
  padding: 4px 0 8px;
}

.hero-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  color: var(--muted);
  font-weight: 900;
  text-decoration: none;
}

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

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--accent);
  background: var(--surface);
  font-size: 0.78rem;
  letter-spacing: 0;
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(340px, 0.95fr) minmax(430px, 1.05fr);
  gap: 24px;
  align-items: stretch;
}

.hero-copy,
.robot-showcase {
  min-width: 0;
}

.hero-copy {
  display: grid;
  align-content: center;
  gap: 18px;
  padding: clamp(6px, 2vw, 20px) 0;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  max-width: 11ch;
  font-size: clamp(2.4rem, 5.5vw, 5.7rem);
  line-height: 0.98;
}

h2 {
  font-size: 1rem;
}

.hero-lede,
.hero-sublede {
  margin: 0;
  color: var(--text);
  font-size: clamp(1.1rem, 1.5vw, 1.35rem);
  font-weight: 900;
}

.hero-sublede {
  color: var(--muted);
  font-size: clamp(1rem, 1.25vw, 1.18rem);
}

.flow-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}

.flow-steps li {
  display: grid;
  gap: 8px;
  min-height: 92px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-weight: 900;
}

.flow-steps span {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  color: var(--accent-text);
  background: var(--accent);
  font-size: 0.85rem;
}

.status-strip {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  gap: 10px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface-strong);
  font-weight: 700;
  white-space: nowrap;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted);
}

.status-dot[data-state="connected"] {
  background: #18a058;
}

.status-dot[data-state="busy"] {
  background: var(--warning);
}

.status-dot[data-state="error"] {
  background: #d94d4d;
}

.control-grid {
  display: grid;
  grid-template-columns: minmax(260px, 0.75fr) minmax(300px, 0.9fr) minmax(420px, 1.35fr);
  gap: 18px;
  align-items: start;
}

.panel,
.robot-showcase {
  display: grid;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.section-heading {
  display: grid;
  gap: 3px;
}

.section-kicker {
  margin: 0;
  color: var(--accent);
  font-size: 0.74rem;
  font-weight: 900;
  text-transform: uppercase;
}

.panel-chat {
  grid-column: span 1;
  grid-row: span 2;
}

.panel-cues {
  min-height: 260px;
}

.advanced-panel,
.panel-log {
  grid-column: 1 / -1;
}

.advanced-panel {
  gap: 16px;
}

.panel-log {
  min-height: 0;
}

summary {
  cursor: pointer;
  color: var(--text);
  font-weight: 900;
}

.advanced-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  padding-top: 14px;
}

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
}

.toggle-row input {
  width: 18px;
  height: 18px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.prompt-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.video-frame {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 410px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background:
    linear-gradient(145deg, rgba(12, 124, 111, 0.1), transparent 46%),
    var(--surface-soft);
}

video {
  width: 100%;
  height: 100%;
  min-height: 410px;
  object-fit: cover;
}

.mock-stage {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  gap: 12px;
  padding: 20px;
  text-align: center;
}

.mock-robot {
  --head-roll: 0deg;
  --head-pitch: 0deg;
  --head-yaw: 0deg;
  --body-yaw: 0deg;
  --antenna-left: 0deg;
  --antenna-right: 0deg;
  position: relative;
  display: grid;
  place-items: center;
  width: min(310px, 78vw);
  min-height: 248px;
  transform: rotate(var(--body-yaw));
  transform-origin: 50% 78%;
  transition: transform 180ms ease;
}

.mock-head {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  justify-items: center;
  width: 210px;
  height: 160px;
  padding: 40px 36px 32px;
  border: 2px solid var(--border);
  border-radius: 28px 28px 24px 24px;
  background: var(--surface);
  box-shadow:
    inset 0 -10px 20px rgba(12, 124, 111, 0.08),
    0 18px 30px rgba(24, 31, 28, 0.18);
  transform:
    rotateZ(var(--head-roll))
    rotateX(var(--head-pitch))
    rotateY(var(--head-yaw));
  transition:
    box-shadow 180ms ease,
    transform 180ms ease;
}

.mock-neck {
  width: 74px;
  height: 34px;
  margin-top: -4px;
  border: 2px solid var(--border);
  border-top: 0;
  border-radius: 0 0 18px 18px;
  background: var(--surface-strong);
}

.mock-antenna {
  position: absolute;
  top: 18px;
  width: 64px;
  height: 24px;
  border-radius: 999px;
  background: var(--accent);
  transform-origin: 50% 100%;
  transition: transform 180ms ease;
}

.mock-antenna::after {
  position: absolute;
  top: -5px;
  right: -5px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--warning);
  content: "";
}

.mock-antenna-left {
  left: 34px;
  transform: rotate(calc(-28deg + var(--antenna-left)));
}

.mock-antenna-right {
  right: 34px;
  transform: rotate(calc(28deg + var(--antenna-right)));
}

.mock-eye {
  display: grid;
  place-items: center;
  width: 34px;
  height: 50px;
  border-radius: 999px;
  background: var(--accent);
  transition:
    height 160ms ease,
    transform 160ms ease,
    background 160ms ease;
}

.mock-eye span {
  width: 11px;
  height: 14px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.76);
}

.mock-mouth {
  grid-column: 1 / -1;
  width: 64px;
  height: 30px;
  margin-top: 8px;
  border-bottom: 6px solid var(--accent);
  border-radius: 0 0 999px 999px;
  transition:
    border-color 160ms ease,
    height 160ms ease,
    transform 160ms ease,
    width 160ms ease;
}

.mock-robot[data-cue="warm_smile"] .mock-head {
  box-shadow:
    inset 0 -10px 20px rgba(12, 124, 111, 0.12),
    0 18px 32px rgba(12, 124, 111, 0.24);
}

.mock-robot[data-cue="warm_smile"] .mock-mouth,
.mock-robot[data-cue="celebrate"] .mock-mouth,
.mock-robot[data-cue="agree"] .mock-mouth {
  width: 76px;
  height: 34px;
}

.mock-robot[data-cue="thinking"] .mock-eye-left,
.mock-robot[data-cue="listen"] .mock-eye-left {
  transform: translateY(-2px);
}

.mock-robot[data-cue="thinking"] .mock-mouth,
.mock-robot[data-cue="caution"] .mock-mouth {
  width: 46px;
  height: 10px;
  border-bottom-color: var(--muted);
  transform: translateY(4px);
}

.mock-robot[data-cue="agree"] {
  animation: cue-nod 520ms ease;
}

.mock-robot[data-cue="celebrate"] {
  animation: cue-celebrate 620ms ease;
}

.mock-robot[data-cue="explain"],
.mock-robot[data-cue="goodbye"] {
  animation: cue-sway 720ms ease;
}

.mock-robot[data-cue="listen"] .mock-head {
  box-shadow:
    inset 0 -10px 20px rgba(12, 124, 111, 0.08),
    0 18px 34px rgba(164, 93, 0, 0.18);
}

.mock-robot[data-cue="caution"] .mock-eye {
  height: 30px;
  background: var(--warning);
}

.preview-status {
  display: grid;
  gap: 4px;
  justify-items: center;
  width: 100%;
}

#preview-cue,
#mock-pose {
  max-width: 100%;
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

#preview-cue {
  color: var(--text);
}

.answer {
  min-height: 180px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-strong);
  white-space: pre-wrap;
}

.cue-list,
.event-log {
  display: grid;
  gap: 8px;
  max-height: 420px;
  margin: 0;
  padding: 0;
  overflow: auto;
  list-style: none;
}

.cue-list li,
.event-log li {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-strong);
}

.cue-meta,
.event-meta {
  color: var(--muted);
  font-size: 0.82rem;
}

.event-log code {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

@media (max-width: 1120px) {
  .hero-grid,
  .control-grid {
    grid-template-columns: 1fr 1fr;
  }

  .panel-chat,
  .panel-cues,
  .panel-log {
    grid-column: 1 / -1;
  }
}

@media (max-width: 720px) {
  .app-shell {
    padding: 14px;
  }

  .hero-nav,
  .hero-grid,
  .flow-steps,
  .split,
  .control-grid,
  .advanced-grid {
    grid-template-columns: 1fr;
  }

  .hero-nav {
    align-items: flex-start;
    flex-direction: column;
  }

  h1 {
    max-width: 100%;
    font-size: clamp(2.35rem, 12vw, 4rem);
  }

  .status-strip {
    width: 100%;
    justify-content: center;
  }

  .button-row {
    flex-direction: column;
  }

  .video-frame,
  video {
    min-height: 330px;
  }

  .mock-robot {
    transform: scale(0.78) rotate(var(--body-yaw));
  }
}

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

@keyframes cue-nod {
  0%,
  100% {
    transform: rotate(var(--body-yaw)) translateY(0);
  }

  42% {
    transform: rotate(var(--body-yaw)) translateY(6px);
  }
}

@keyframes cue-celebrate {
  0%,
  100% {
    transform: rotate(var(--body-yaw)) translateY(0);
  }

  28% {
    transform: rotate(calc(var(--body-yaw) + 7deg)) translateY(-5px);
  }

  62% {
    transform: rotate(calc(var(--body-yaw) - 7deg)) translateY(-3px);
  }
}

@keyframes cue-sway {
  0%,
  100% {
    transform: rotate(var(--body-yaw));
  }

  35% {
    transform: rotate(calc(var(--body-yaw) + 5deg));
  }

  70% {
    transform: rotate(calc(var(--body-yaw) - 5deg));
  }
}
