/* ================================================================
   Espacio Calma — Módulo de contención emocional
   Auto-contenido: no modifica clases ni variables existentes de app.css
   ================================================================ */

/* ── FAB: oculto — los accesos directos están en la pantalla de inicio ── */
.calma-fab {
  display: none;
}

/* ── Home: fila horizontal de accesos rápidos ────────────────────── */
.calma-home-header {
  margin-bottom: 14px;
}

.calma-home-subtitle {
  font-family: 'Dancing Script', cursive;
  font-size: 1rem;
  color: #9b7bc4;
  margin-top: 2px;
  font-weight: 600;
}

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

.calma-home-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 104px;
  border-radius: 22px;
  padding: 18px 12px 14px;
  border: none;
  cursor: pointer;
  transition: transform .18s, box-shadow .18s;
  box-shadow: 0 4px 18px rgba(0, 0, 0, .1);
}

/* 5ª tarjeta ocupa todo el ancho, orientación horizontal */
.calma-home-card:nth-child(5) {
  grid-column: 1 / -1;
  flex-direction: row;
  min-height: 72px;
  gap: 16px;
  justify-content: center;
}

.calma-home-card:active {
  transform: scale(0.94);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .08);
}

/* Gradientes únicos por módulo */
.calma-home-card:nth-child(1) { background: linear-gradient(145deg, #f9aed1, #e74fa0); }
.calma-home-card:nth-child(2) { background: linear-gradient(145deg, #9de4c0, #3dba80); }
.calma-home-card:nth-child(3) { background: linear-gradient(145deg, #ffc99c, #ff8258); }
.calma-home-card:nth-child(4) { background: linear-gradient(145deg, #c9b8f0, #9068cc); }
.calma-home-card:nth-child(5) { background: linear-gradient(135deg, #96d8f2, #4cb8de); }

.calma-home-icon {
  font-size: 2.6rem;
  line-height: 1;
  filter: drop-shadow(0 2px 5px rgba(0, 0, 0, .18));
}

.calma-home-name {
  font-size: .82rem;
  font-weight: 700;
  color: white;
  text-align: center;
  line-height: 1.2;
  text-shadow: 0 1px 4px rgba(0, 0, 0, .22);
  letter-spacing: .01em;
}

.calma-home-card:nth-child(5) .calma-home-icon {
  font-size: 2.2rem;
}

.calma-home-card:nth-child(5) .calma-home-name {
  font-size: .92rem;
}

/* ── Modal principal: sobrescribe el fondo gris de .fs-modal ─────── */
#modal-calma {
  background: linear-gradient(160deg, #ede7f6 0%, #e8f4fd 55%, #fce4ec 100%);
  display: flex;
  flex-direction: column;
}

/* ── Calma Header (reemplaza .fs-modal-header, sin su fondo blanco) ─ */
.calma-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(14px + env(safe-area-inset-top, 0px)) 14px 14px;
  background: rgba(255, 255, 255, 0.52);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.72);
  flex-shrink: 0;
}

.calma-back-btn {
  background: rgba(255, 255, 255, 0.72);
  border: none;
  color: #7b5ea7;
  font-size: .88rem;
  font-weight: 700;
  padding: 7px 12px;
  border-radius: 10px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

.calma-title-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}

#calma-title {
  font-family: 'Dancing Script', cursive;
  font-size: 1.3rem;
  color: #3d2c6e;
  text-align: center;
  font-weight: 600;
  line-height: 1.2;
}

.calma-subtitle {
  font-size: .72rem;
  color: #9b7bc4;
  letter-spacing: .04em;
  text-align: center;
  line-height: 1;
  transition: opacity .2s;
}

.calma-subtitle.hidden {
  opacity: 0;
  pointer-events: none;
}

.calma-close-btn {
  background: rgba(255, 255, 255, 0.72);
  border: none;
  border-radius: 50%;
  width: 34px;
  height: 34px;
  font-size: 1rem;
  color: #6b7280;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

/* ── Hub: Selector de módulos ────────────────────────────────────── */
.calma-hub {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 20px 16px calc(32px + env(safe-area-inset-bottom, 0px));
}

.calma-hub-intro {
  text-align: center;
  margin-bottom: 24px;
}

.calma-hub-emoji {
  font-size: 3.2rem;
  display: block;
  margin-bottom: 10px;
}

.calma-hub-title {
  font-family: 'Dancing Script', cursive;
  font-size: 1.55rem;
  color: #3d2c6e;
  margin-bottom: 6px;
}

.calma-hub-subtitle {
  font-size: .92rem;
  color: #7b7b98;
  line-height: 1.5;
  max-width: 280px;
  margin: 0 auto;
}

.calma-modules-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.calma-module-card {
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 18px;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: 0 2px 14px rgba(150, 120, 200, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.88);
  text-align: left;
  cursor: pointer;
  transition: transform .18s, box-shadow .18s;
  width: 100%;
}

.calma-module-card:active {
  transform: scale(0.97);
  box-shadow: 0 1px 6px rgba(150, 120, 200, 0.08);
}

.calma-module-icon {
  font-size: 2.2rem;
  line-height: 1;
  flex-shrink: 0;
}

.calma-module-info {
  flex: 1;
  min-width: 0;
}

.calma-module-name {
  font-size: 1rem;
  font-weight: 700;
  color: #3d2c6e;
  margin-bottom: 3px;
}

.calma-module-desc {
  font-size: .8rem;
  color: #8a87a0;
  line-height: 1.4;
}

.calma-module-arrow {
  color: #c0b0e0;
  font-size: 1.1rem;
  flex-shrink: 0;
}

/* ── Panel base (cada módulo ocupa todo el espacio disponible) ───── */
.calma-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

/* ── MÓDULO 1: Respiración — hereda los colores originales (magenta/rosa) ── */
#calma-panel-respiracion .breathe-body {
  padding-bottom: calc(32px + env(safe-area-inset-bottom, 0px));
}

/* ── MÓDULO 2: Enraizamiento ─────────────────────────────────────── */
#calma-ground-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px 24px calc(28px + env(safe-area-inset-bottom, 0px));
  text-align: center;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.ground-step-number {
  font-size: 5.5rem;
  font-weight: 900;
  line-height: 1;
  background: linear-gradient(135deg, #9c6dd6, #6aade4);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
}

.ground-step-sense {
  font-size: .88rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: #9b7bc4;
  margin-bottom: 18px;
}

.ground-step-instruction {
  font-size: 1.25rem;
  font-weight: 300;
  color: #3d2c6e;
  line-height: 1.55;
  margin-bottom: 36px;
  max-width: 300px;
}

.ground-step-emoji {
  font-size: 3.8rem;
  margin-bottom: 24px;
  display: block;
}

.ground-progress {
  display: flex;
  gap: 8px;
  margin-bottom: 32px;
}

.ground-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(155, 123, 196, .22);
  transition: background .3s;
}

.ground-dot.active {
  background: #9b7bc4;
}

.calma-next-btn {
  background: linear-gradient(135deg, #b8a9e8, #9acce8);
  color: white;
  border-radius: 50px;
  padding: 14px 38px;
  font-size: 1rem;
  font-weight: 700;
  box-shadow: 0 4px 20px rgba(150, 120, 200, .28);
  transition: transform .18s;
  border: none;
  cursor: pointer;
}

.calma-next-btn:active {
  transform: scale(0.96);
}

.ground-done-title {
  font-family: 'Dancing Script', cursive;
  font-size: 2.4rem;
  color: #4a3570;
  margin-bottom: 14px;
}

.ground-done-text {
  font-size: 1rem;
  color: #6b7280;
  line-height: 1.65;
  margin-bottom: 32px;
  max-width: 280px;
}

/* ── MÓDULO 3: Lienzo de Descarga ────────────────────────────────── */
.calma-canvas-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.canvas-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, .62);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.canvas-color-swatches {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.canvas-color-swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid transparent;
  transition: transform .15s, border-color .15s;
  flex-shrink: 0;
}

.canvas-color-swatch.selected {
  border-color: white;
  box-shadow: 0 0 0 2px rgba(155, 123, 196, .65);
  transform: scale(1.18);
}

.canvas-sizes {
  display: flex;
  gap: 5px;
}

.canvas-size-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .8);
  font-size: .7rem;
  font-weight: 700;
  color: #4a3570;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color .15s, transform .15s;
}

.canvas-size-btn.selected {
  border-color: #9b7bc4;
  transform: scale(1.1);
}

.canvas-clear-btn {
  background: rgba(255, 255, 255, .8);
  border-radius: 10px;
  padding: 6px 12px;
  font-size: .78rem;
  font-weight: 600;
  color: #9b7bc4;
  cursor: pointer;
  border: none;
  margin-left: auto;
}

#calma-canvas {
  flex: 1;
  touch-action: none;
  cursor: crosshair;
  display: block;
  min-height: 0;
}

/* ── MÓDULO 4: Colorear ──────────────────────────────────────────── */
.calma-color-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.color-palette-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: rgba(255, 255, 255, .62);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  overflow-x: auto;
  flex-shrink: 0;
  -webkit-overflow-scrolling: touch;
}

.color-palette-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
  cursor: pointer;
}

.color-palette-swatch {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid transparent;
  transition: transform .15s, border-color .15s;
}

.color-palette-swatch.selected {
  border-color: white;
  box-shadow: 0 0 0 2px rgba(155, 123, 196, .65);
  transform: scale(1.15);
}

.color-palette-num {
  font-size: .7rem;
  font-weight: 700;
  color: #7b5ea7;
}

.color-instruction {
  padding: 6px 16px 4px;
  font-size: .78rem;
  color: #9b7bc4;
  text-align: center;
  background: rgba(255, 255, 255, .4);
  flex-shrink: 0;
}

.calma-svg-wrap {
  flex: 1;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  -webkit-overflow-scrolling: touch;
}

#calma-color-svg {
  max-width: 100%;
  max-height: 100%;
  width: min(320px, calc(100vw - 32px));
  height: auto;
  touch-action: pan-x pan-y;
}

.color-region {
  cursor: pointer;
  stroke: #4a3570;
  stroke-width: 1.8;
  stroke-linejoin: round;
  transition: opacity .15s;
}

.color-region:active {
  opacity: 0.6;
}

.color-number {
  font-family: 'Lato', sans-serif;
  font-size: 13px;
  font-weight: 900;
  fill: #9b7bc4;
  text-anchor: middle;
  dominant-baseline: middle;
  pointer-events: none;
  user-select: none;
}

/* ── MÓDULO 5: Burbujas ──────────────────────────────────────────── */
.calma-bubbles-body {
  flex: 1;
  position: relative;
  overflow: hidden;
  min-height: 0;
}

#calma-bubbles-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: pointer;
}

.bubbles-hint {
  position: absolute;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  left: 0;
  right: 0;
  text-align: center;
  font-size: .82rem;
  color: rgba(75, 53, 112, .45);
  pointer-events: none;
}
