/* ============================
   Movement Intelligence — POC
   ============================ */

:root {
  --bg: #faf8f5;
  --bg-warm: #f5f0eb;
  --text: #3d3530;
  --text-light: #7a6e66;
  --text-muted: #a39890;
  --accent-sage: #8fa68e;
  --accent-sage-light: #b5c9b4;
  --accent-rose: #c4908a;
  --accent-rose-light: #dbb5b0;
  --accent-terra: #b8806e;
  --accent-terra-light: #d4a999;
  --accent-bronze: #a07850;
  --border: #e8e2dc;
  --border-light: #f0ebe6;
  --shadow: rgba(61, 53, 48, 0.08);
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 16px;
  --transition: 0.25s ease;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-weight: 500;
  line-height: 1.2;
}

/* ============================
   HERO
   ============================ */

#hero {
  position: relative;
  width: 100%;
  height: clamp(340px, 45vw, 540px);
  overflow: hidden;
  display: flex;
  align-items: center;
}

.hero-image-wrap {
  position: absolute;
  inset: 0;
  z-index: 0;
}

.hero-bg {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: right center;
}

.hero-content {
  position: relative;
  z-index: 1;
  padding: 3rem 4rem;
  max-width: 600px;
}

.hero-title {
  font-size: clamp(2.2rem, 4vw, 3.4rem);
  color: var(--text);
  margin-bottom: 0.75rem;
  letter-spacing: -0.02em;
}

.hero-subtitle {
  font-size: clamp(0.95rem, 1.4vw, 1.15rem);
  color: var(--text-light);
  margin-bottom: 1.75rem;
  line-height: 1.7;
  font-weight: 300;
}

.hero-subtitle em {
  font-style: italic;
  color: var(--accent-terra);
}

/* ============================
   BUTTONS
   ============================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.75rem;
  border-radius: var(--radius);
  border: none;
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}

.btn-primary {
  background: var(--accent-sage);
  color: #fff;
  box-shadow: 0 2px 8px rgba(143, 166, 142, 0.3);
}
.btn-primary:hover {
  background: #7d9a7c;
  box-shadow: 0 4px 16px rgba(143, 166, 142, 0.35);
  transform: translateY(-1px);
}
.btn-primary:disabled {
  background: var(--border);
  color: var(--text-muted);
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
}

.btn-ghost {
  background: transparent;
  color: var(--text-light);
  border: 1px solid var(--border);
  padding: 0.5rem 1.25rem;
  font-size: 0.82rem;
}
.btn-ghost:hover {
  border-color: var(--text-muted);
  color: var(--text);
}

/* ============================
   SECTION HEADER
   ============================ */

.section-header {
  text-align: center;
  padding: 3rem 2rem 1.5rem;
}

.section-header h2 {
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  color: var(--text);
  margin-bottom: 0.5rem;
}

.section-header p {
  color: var(--text-light);
  font-size: 0.95rem;
  max-width: 520px;
  margin: 0 auto;
  font-weight: 300;
}

/* ============================
   BODY MAP GRID
   ============================ */

.body-map-grid {
  display: grid;
  grid-template-columns: 240px 1fr 260px;
  gap: 1.5rem;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1.5rem 3rem;
  align-items: start;
}

/* ============================
   CONTROLS PANEL (left)
   ============================ */

.controls-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  position: sticky;
  top: 1rem;
}

.control-group {
  background: #fff;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: 0 1px 4px var(--shadow);
}

.control-group h4 {
  font-family: 'Inter', sans-serif;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
}

/* Pill toggle group */
.pill-group {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.pill {
  padding: 0.4rem 0.85rem;
  border-radius: 50px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text-light);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  font-family: 'Inter', sans-serif;
  user-select: none;
}
.pill:hover {
  border-color: var(--accent-sage);
  color: var(--accent-sage);
}
.pill.active {
  background: var(--accent-sage);
  border-color: var(--accent-sage);
  color: #fff;
}
.pill.active:hover {
  background: #7d9a7c;
}

/* Equipment chips (multi-select) */
.chip {
  padding: 0.35rem 0.75rem;
  border-radius: 50px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text-light);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  font-family: 'Inter', sans-serif;
  user-select: none;
}
.chip:hover {
  border-color: var(--accent-terra);
  color: var(--accent-terra);
}
.chip.active {
  background: var(--accent-terra);
  border-color: var(--accent-terra);
  color: #fff;
}

/* Divider */
.control-divider {
  height: 1px;
  background: var(--border-light);
  margin: 0.25rem 0;
}

/* Build button */
.build-btn-wrap {
  padding: 0.5rem 0 0;
}

.btn-build {
  width: 100%;
  padding: 0.85rem 1rem;
  font-size: 0.92rem;
  font-weight: 600;
  border-radius: var(--radius);
}

/* ============================
   BODY MAP CENTER
   ============================ */

.body-map-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}

.body-map-container {
  position: relative;
  width: 100%;
  max-width: 700px;
  user-select: none;
}

.body-map-container img {
  width: 100%;
  height: auto;
  display: block;
  transition: opacity 0.4s ease;
}

.body-map-container .body-img {
  position: relative;
  z-index: 0;
}

.body-map-container .muscle-img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: auto;
  z-index: 1;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

.body-map-container .muscle-img.visible {
  opacity: 1;
}

.body-map-container svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
}

.body-map-container svg polygon {
  fill: rgba(143, 166, 142, 0.0);
  stroke: transparent;
  stroke-width: 0.3;
  cursor: pointer;
  transition: fill 0.2s ease, stroke 0.2s ease;
}

.body-map-container svg polygon:hover {
  fill: rgba(143, 166, 142, 0.18);
  stroke: var(--accent-sage);
}

.body-map-container svg polygon.selected {
  fill: rgba(143, 166, 142, 0.28);
  stroke: var(--accent-sage);
  stroke-width: 0.4;
}

.body-map-container svg polygon.deviation-highlight {
  fill: rgba(196, 144, 138, 0.22);
  stroke: var(--accent-rose);
  stroke-width: 0.35;
}

.body-map-container svg polygon.selected.deviation-highlight {
  fill: rgba(170, 140, 130, 0.3);
  stroke: var(--accent-rose);
}

/* View/Layer overlay */
.body-map-overlay {
  position: absolute;
  top: 0.6rem;
  left: 0.6rem;
  z-index: 5;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: var(--radius);
  padding: 0.5rem 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  box-shadow: 0 1px 6px var(--shadow);
  border: 1px solid var(--border-light);
}

.overlay-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.overlay-label {
  font-family: 'Inter', sans-serif;
  font-size: 0.58rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  min-width: 2.8rem;
}

.overlay-pills {
  display: flex;
  gap: 0.25rem;
}

.overlay-pill {
  padding: 0.25rem 0.6rem;
  border-radius: 50px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.7);
  color: var(--text-light);
  font-size: 0.7rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  font-family: 'Inter', sans-serif;
  user-select: none;
  line-height: 1.3;
}
.overlay-pill:hover {
  border-color: var(--accent-sage);
  color: var(--accent-sage);
}
.overlay-pill.active {
  background: var(--accent-sage);
  border-color: var(--accent-sage);
  color: #fff;
}
.overlay-pill.active:hover {
  background: #7d9a7c;
}

/* Tooltip */
.body-tooltip {
  position: absolute;
  z-index: 10;
  background: rgba(61, 53, 48, 0.92);
  color: #fff;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  line-height: 1.4;
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.15s ease, transform 0.15s ease;
  max-width: 220px;
  white-space: normal;
}

.body-tooltip.visible {
  opacity: 1;
  transform: translateY(0);
}

.body-tooltip .tooltip-name {
  font-weight: 600;
  margin-bottom: 0.15rem;
}

.body-tooltip .tooltip-muscles {
  font-size: 0.7rem;
  opacity: 0.8;
}

/* ============================
   INFO PANEL (right)
   ============================ */

.info-panel {
  position: sticky;
  top: 1rem;
}

.info-panel-inner {
  background: #fff;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: 0 1px 4px var(--shadow);
}

.info-panel h3 {
  font-size: 1.1rem;
  margin-bottom: 0.75rem;
  color: var(--text);
}

.selected-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.selected-list-empty {
  color: var(--text-muted);
  font-size: 0.82rem;
  font-style: italic;
}

.selected-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.65rem;
  border-radius: 50px;
  background: rgba(143, 166, 142, 0.1);
  border: 1px solid rgba(143, 166, 142, 0.25);
  font-size: 0.78rem;
  color: var(--text);
}

.selected-tag .remove-tag {
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1;
  transition: color var(--transition);
}
.selected-tag .remove-tag:hover {
  color: var(--accent-rose);
}

.selection-summary h4 {
  font-family: 'Inter', sans-serif;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

#muscles-targeted {
  font-size: 0.8rem;
  color: var(--text-light);
  line-height: 1.5;
}

/* ============================
   LOADING OVERLAY
   ============================ */

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(250, 248, 245, 0.92);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
}

.loading-overlay.visible {
  display: flex;
}

.loading-inner {
  text-align: center;
}

.breathing-circle {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent-sage-light), var(--accent-sage));
  margin: 0 auto 1.5rem;
  animation: breathe 4s ease-in-out infinite;
  opacity: 0.7;
}

@keyframes breathe {
  0%, 100% { transform: scale(0.85); opacity: 0.5; }
  50% { transform: scale(1.15); opacity: 0.8; }
}

.loading-text {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.4rem;
  color: var(--text);
  margin-bottom: 0.4rem;
}

.loading-subtext {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 300;
}

/* ============================
   SESSION PLAN
   ============================ */

.session-container {
  max-width: 820px;
  margin: 0 auto;
  padding: 3rem 2rem 4rem;
}

.session-header {
  text-align: center;
  margin-bottom: 2.5rem;
}

.session-header h2 {
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  color: var(--text);
  margin-bottom: 0.4rem;
}

.session-header .session-meta {
  font-size: 0.9rem;
  color: var(--text-light);
  font-weight: 300;
}

.session-reasoning {
  background: rgba(143, 166, 142, 0.08);
  border-left: 3px solid var(--accent-sage);
  padding: 1rem 1.25rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin-bottom: 2.5rem;
  font-size: 0.88rem;
  line-height: 1.7;
  color: var(--text-light);
  font-style: italic;
}

/* Phase card */
.phase-card {
  background: #fff;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 1px 6px var(--shadow);
}

.phase-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-light);
}

.phase-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius);
  object-fit: cover;
}

.phase-title {
  font-size: 1.25rem;
  color: var(--text);
}

.phase-time {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 400;
  font-family: 'Inter', sans-serif;
}

/* Exercise card */
.exercise-card {
  padding: 1rem 0;
  border-bottom: 1px solid var(--border-light);
}
.exercise-card:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.exercise-name {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.35rem;
}

.exercise-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.exercise-badge {
  font-size: 0.68rem;
  padding: 0.2rem 0.55rem;
  border-radius: 50px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-dosage {
  background: rgba(143, 166, 142, 0.12);
  color: var(--accent-sage);
}

.badge-type {
  background: rgba(184, 128, 110, 0.12);
  color: var(--accent-terra);
}

.badge-equipment {
  background: rgba(160, 120, 80, 0.12);
  color: var(--accent-bronze);
}

.exercise-cue {
  font-size: 0.85rem;
  color: var(--text-light);
  font-style: italic;
  line-height: 1.6;
  margin-bottom: 0.5rem;
}

.exercise-targets {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.scaling-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.scaling-item {
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  background: var(--bg-warm);
  font-size: 0.73rem;
  line-height: 1.4;
  color: var(--text-light);
}

.scaling-label {
  font-weight: 600;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.2rem;
  display: block;
}
.scaling-label.good { color: var(--accent-sage); }
.scaling-label.better { color: var(--accent-terra); }
.scaling-label.best { color: var(--accent-bronze); }

/* Session actions */
.session-actions {
  text-align: center;
  margin-top: 2rem;
}

/* ============================
   ERROR BANNER
   ============================ */

.error-banner {
  background: rgba(196, 144, 138, 0.12);
  border: 1px solid var(--accent-rose-light);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin: 1rem auto;
  max-width: 600px;
  text-align: center;
  color: var(--text);
  font-size: 0.88rem;
}

.error-banner .error-title {
  font-weight: 600;
  margin-bottom: 0.25rem;
}

/* ============================
   RESPONSIVE
   ============================ */

@media (max-width: 960px) {
  .body-map-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
    padding: 0 1rem 2rem;
  }

  .controls-panel {
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.75rem;
  }

  .control-group {
    flex: 1;
    min-width: 200px;
  }

  .info-panel {
    position: static;
    order: 3;
  }

  .body-map-center {
    order: 1;
  }

  .controls-panel {
    order: 0;
  }

  .body-map-container {
    max-width: 500px;
  }
}

@media (max-width: 600px) {
  .hero-content {
    padding: 2rem 1.5rem;
  }

  .controls-panel {
    flex-direction: column;
  }

  .control-group {
    min-width: 0;
  }

  .scaling-row {
    grid-template-columns: 1fr;
  }

  .session-container {
    padding: 2rem 1rem 3rem;
  }
}
