/* ============================================================
   KARKA PHYSICS — COMPONENTS
   Reusable UI primitives. Each component owns its
   appearance, padding, and interaction states.
   ============================================================ */

/* ============================================================
   LEFT RAIL (chapter panel)
   ============================================================ */
.left-rail {
  position: relative;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--color-border-rail);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-card);
  padding: 20px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  transition:
    opacity 0.24s var(--ease),
    transform 0.24s var(--ease),
    padding 0.24s var(--ease);
}

.rail-collapse-btn {
  position: absolute;
  right: -13px;
  top: 24px;
  width: 28px;
  height: 28px;
  border: 1px solid var(--color-border-soft);
  background: var(--color-panel);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-rail-btn);
  color: var(--color-muted-strong);
  cursor: pointer;
  z-index: 5;
  font-weight: 900;
  display: grid;
  place-items: center;
}

.rail-collapse-btn span {
  display: block;
  transition: transform 0.24s var(--ease);
}

.app-shell.rail-collapsed .rail-collapse-btn span {
  transform: rotate(180deg);
}

.app-shell.rail-collapsed .left-rail {
  padding: 18px 13px;
}

.app-shell.rail-collapsed .brand-copy,
.app-shell.rail-collapsed .chapter-section-title,
.app-shell.rail-collapsed .chapter-label,
.app-shell.rail-collapsed .ethan-card-copy {
  opacity: 0;
  width: 0;
  overflow: hidden;
}

.app-shell.rail-collapsed .brand-row,
.app-shell.rail-collapsed .ethan-card {
  justify-content: center;
}

.app-shell.rail-collapsed .chapter-list button {
  justify-content: center;
  padding: 12px 6px;
}

.app-shell.rail-collapsed .chapter-num {
  min-width: auto;
}

.app-shell.rail-collapsed .brand-mark {
  width: 44px;
  height: 44px;
}

/* ============================================================
   BRAND
   ============================================================ */
.brand-row {
  display: flex;
  gap: var(--space-md);
  align-items: center;
}

.brand-copy {
  min-width: 0;
  transition: opacity var(--duration-fast) var(--ease);
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  background: var(--color-accent);
  color: var(--color-panel);
  display: grid;
  place-items: center;
  font-family: var(--font-serif);
  font-size: 24px;
  font-weight: 600;
  overflow: hidden;
  flex: 0 0 auto;
}

.brand-name {
  font-weight: 800;
}

.brand-sub {
  font-size: 12px;
  color: var(--color-muted);
  margin-top: 2px;
}

/* ============================================================
   IMAGE SLOT — shows initial letter until image loads
   ============================================================ */
.image-slot {
  position: relative;
  background: linear-gradient(135deg, var(--color-accent), var(--color-accent-light));
  display: grid;
  place-items: center;
  overflow: hidden;
}

.image-slot img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}

.image-slot img[src]:not([src=""]) {
  display: block;
}

.image-slot img[src]:not([src=""]) + .slot-letter {
  display: none;
}

.slot-letter {
  color: var(--color-panel);
  font-weight: 900;
}

/* ============================================================
   CHAPTER LIST
   ============================================================ */
.chapter-section-title {
  font-size: 12px;
  color: var(--color-muted);
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin: 28px 0 10px;
  transition: opacity var(--duration-fast) var(--ease);
}

.chapter-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  min-height: 0;
  overflow-y: auto;
  padding-right: var(--space-xs);
  max-height: calc(100vh - 250px);
}

.chapter-list button {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--color-muted-strong);
  border-radius: var(--radius-md);
  padding: 12px 13px;
  cursor: pointer;
}

.chapter-list button.active,
.chapter-list button:hover {
  background: var(--color-accent-bg);
  color: var(--color-accent);
  font-weight: 800;
}

.chapter-list button.disabled-chapter {
  opacity: 0.55;
}

.chapter-num {
  font-weight: 900;
  min-width: 24px;
}

.chapter-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

/* ============================================================
   ETHAN CARD (left rail footer)
   ============================================================ */
.ethan-card {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--color-accent-mist);
  border: 1px solid var(--color-border-accent);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
}

.ethan-card span {
  display: block;
  color: var(--color-muted);
  font-size: 12px;
  margin-top: 2px;
}

.ethan-card-copy {
  transition: opacity var(--duration-fast) var(--ease);
}

.ethan-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-accent), var(--color-accent-light));
  color: var(--color-panel);
  display: grid;
  place-items: center;
  font-weight: 900;
  flex: 0 0 auto;
}

.ethan-avatar.large {
  width: 54px;
  height: 54px;
  font-size: 20px;
}

/* ============================================================
   LESSON HEADER
   ============================================================ */
.eyebrow {
  color: var(--color-accent);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.lesson-header h1 {
  font-family: var(--font-serif);
  font-size: 40px;
  line-height: 1;
  margin: var(--space-sm) 0;
}

.lesson-header p {
  margin: 0;
  color: var(--color-muted);
  font-size: 15px;
}

.progress-pill {
  white-space: nowrap;
  background: var(--color-panel);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-pill);
  border-radius: var(--radius-pill);
  padding: 11px 15px;
  color: var(--color-muted-strong);
  font-size: 13px;
  font-weight: 800;
}

/* ============================================================
   MIC BUTTON (voice trigger)
   ============================================================ */
.mic-btn {
  position: relative;
  width: 52px;
  height: 52px;
  border: 0;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--color-accent), var(--color-accent-light));
  color: var(--color-panel);
  box-shadow: var(--shadow-glow-mic);
  cursor: pointer;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.mic-ring {
  position: absolute;
  inset: 7px;
  border-radius: 15px;
  border: 1px solid rgba(255, 255, 255, 0.35);
}

.mic-icon {
  position: relative;
  font-size: 22px;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.mic-btn:hover {
  transform: translateY(-1px);
}

.mic-btn.listening {
  animation: micPulse 1.35s ease-in-out infinite;
}

.mic-btn.listening .mic-ring {
  border-color: rgba(255, 255, 255, 0.82);
  box-shadow: 0 0 0 8px rgba(20, 184, 166, 0.18);
}

@keyframes micPulse {
  0%, 100% {
    box-shadow:
      var(--shadow-glow-mic),
      0 0 0 0 rgba(20, 184, 166, 0.28);
  }
  50% {
    box-shadow:
      var(--shadow-glow-mic),
      0 0 0 12px rgba(20, 184, 166, 0);
  }
}

/* ============================================================
   TABS (subtopic + stage)
   ============================================================ */
.scenario-tab,
.stage-tab {
  border: 1px solid var(--color-border);
  background: var(--color-panel);
  border-radius: var(--radius-md);
  padding: 13px 12px;
  cursor: pointer;
  color: var(--color-muted-strong);
  font-weight: 800;
  box-shadow: var(--shadow-subtle);
}

.scenario-tab.active,
.stage-tab.active {
  background: var(--color-accent);
  color: var(--color-panel);
  border-color: var(--color-accent);
  box-shadow: var(--shadow-glow-accent);
}

.stage-tab {
  width: 100%;
  min-width: 0;
  text-align: center;
  white-space: nowrap;
  padding: 11px 10px;
  font-size: 14px;
  line-height: 1.15;
}

@media (max-width: 1380px) {
  .stage-tab {
    font-size: 13px;
    padding: 10px 7px;
  }
}

/* ============================================================
   VISUAL CARD
   ============================================================ */
.visual-card {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--color-border-card);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-card);
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  min-height: 0;
  position: relative;
}

.visual-topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-lg);
  margin-bottom: 10px;
}

.visual-topbar > div:first-child {
  min-width: 280px;
}

.visual-actions {
  display: flex;
  gap: var(--space-sm);
  align-items: flex-start;
  justify-content: flex-end;
}

.small-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--color-accent);
  font-weight: 900;
}

.visual-topbar h2 {
  font-family: var(--font-serif);
  margin: 5px 0 0;
  font-size: 25px;
}

.viz-scroll-wrap {
  position: relative;
  width: 100%;
}

.viz-scroll-btn {
  position: absolute;
  right: 18px;
  bottom: 16px;
  z-index: 5;
  border: 1px solid #d7e4ef;
  background: rgba(255, 255, 255, 0.96);
  color: var(--color-accent);
  border-radius: var(--radius-pill);
  padding: 10px 14px;
  font-weight: 900;
  box-shadow: var(--shadow-scroll-btn);
  cursor: pointer;
}

.viz-scroll-btn:hover {
  background: #f5fbfa;
}

/* ============================================================
   TEACHER CARD (right column)
   ============================================================ */
.teacher-card {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--color-border-card);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-card);
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: 14px;
  height: calc(100vh - 210px);
  max-height: calc(100vh - 210px);
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-gutter: stable;
}

.teacher-card::-webkit-scrollbar {
  width: 10px;
}

.teacher-card::-webkit-scrollbar-thumb {
  background: #b9c7d8;
  border-radius: 10px;
}

.teacher-card::-webkit-scrollbar-track {
  background: transparent;
}

.teacher-top {
  display: flex;
  gap: var(--space-md);
  align-items: flex-start;
  margin-top: var(--space-sm);
}

.teacher-top h3 {
  margin: 0 0 5px;
  font-family: var(--font-serif);
  font-size: 22px;
}

.teacher-top p {
  margin: 0;
  color: var(--color-muted-soft);
  line-height: 1.45;
  font-size: 14px;
}

/* ============================================================
   FORMULA BOX
   ============================================================ */
.formula-box {
  background: #f8fbff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 14px;
  overflow: hidden;
}

.formula-label {
  font-size: 11px;
  color: var(--color-muted);
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.formula-stack {
  display: grid;
  gap: var(--space-md);
  margin-top: 10px;
}

.formula-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
  background: var(--color-panel);
  border: 1px solid #e6f0f6;
  border-radius: var(--radius-md);
  padding: 12px 14px;
  min-height: 58px;
}

.formula-row span {
  font-size: 12px;
  color: var(--color-muted);
  font-weight: 800;
  flex: 0 0 42%;
  line-height: 1.35;
}

.formula-row strong {
  font-family: var(--font-serif);
  font-size: clamp(14px, 1.08vw, 20px);
  color: var(--color-accent);
  flex: 1;
  min-width: 0;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: normal;
  line-height: 1.28;
}

.formula-row.amber strong {
  color: var(--color-amber-dark);
}

/* ============================================================
   READOUTS
   ============================================================ */
.readout-grid {
  display: grid;
  gap: 9px;
}

.readout-grid.hidden-readouts {
  display: none;
}

.readout-grid div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  background: var(--color-panel-soft);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 11px 12px;
}

.readout-grid span {
  font-size: 12px;
  color: var(--color-muted);
  font-weight: 800;
}

.readout-grid strong {
  font-size: 16px;
  color: var(--color-ink);
}

/* ============================================================
   BUTTONS
   ============================================================ */
.primary-btn,
.ghost-btn {
  border: 0;
  border-radius: 15px;
  padding: 13px 14px;
  font-weight: 900;
  cursor: pointer;
}

.primary-btn {
  background: var(--color-accent);
  color: var(--color-panel);
}

.primary-btn.compact {
  flex: 0 0 auto;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  min-height: 42px;
}

.play-top {
  background: linear-gradient(135deg, var(--color-accent), var(--color-accent-light));
  box-shadow: var(--shadow-glow-play);
}

.ghost-btn {
  background: #f2f6fa;
  color: #44546a;
  border: 1px solid var(--color-border-faint);
}

.ghost-btn.compact {
  padding: 10px 12px;
  border-radius: 13px;
  font-size: 13px;
  white-space: nowrap;
}

.hidden-control {
  display: none;
}

/* ============================================================
   QUESTION BOX (legacy — quick check now renders in SVG)
   ============================================================ */
.question-box {
  display: none;
}

/* ============================================================
   HOLD INDICATOR
   ============================================================ */
.hold-indicator {
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(90deg, #fffbeb, #fef3c7);
  border: 1px solid #fbbf24;
  border-radius: 14px;
  padding: 10px 16px;
  margin-bottom: 10px;
  font-size: 14px;
  color: #a16207;
  font-weight: 700;
}

.hold-indicator.hidden {
  display: none;
}

.hold-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #f59e0b;
  box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.5);
  animation: holdPulse 1.4s ease-in-out infinite;
}

@keyframes holdPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.5); }
  50%      { box-shadow: 0 0 0 10px rgba(245, 158, 11, 0); }
}

.hold-label {
  font-weight: 800;
}

.hold-reason {
  font-weight: 500;
  color: #92621c;
  font-style: italic;
}

.hold-resume-btn {
  margin-left: auto;
  background: #f59e0b;
  color: #ffffff;
  border: 0;
  border-radius: 10px;
  padding: 8px 16px;
  font-weight: 900;
  cursor: pointer;
  font-size: 13px;
}

.hold-resume-btn:hover {
  background: #d97706;
}
