/**
 * Oráculo del I Ching - Hoja de estilos canónica
 * Estética zen oriental: laca oscura, monedas de bronce con orificio cuadrado,
 * caligrafía china y acentos en bermellón y oro.
 */

:root {
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-heading: 'Outfit', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Paleta oriental oscura */
  --bg-page: #0a0d14;
  --bg-surface: #111724;
  --bg-surface-elevated: #1a2235;
  --bg-altar: radial-gradient(circle at center, #1b253b 0%, #0d131f 70%, #070a10 100%);
  --border-color: rgba(148, 163, 184, 0.16);
  --border-glow: rgba(217, 119, 6, 0.35);

  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-bright: #ffffff;

  /* Acentos tradicionales */
  --bronze-gold: #d97706;
  --bronze-gold-glow: rgba(217, 119, 6, 0.5);
  --cinnabar-red: #e11d48;
  --cinnabar-glow: rgba(225, 29, 72, 0.45);
  --jade-green: #10b981;
  --celestial-cyan: #38bdf8;

  /* Trazos yin y yang */
  --yang-color: #fbbf24;
  --yin-color: #94a3b8;
  --changing-color: #f43f5e;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="light"] {
  --bg-page: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #f1f5f9;
  --bg-altar: radial-gradient(circle at center, #fdfaf6 0%, #f1ebe1 70%, #e2d9cb 100%);
  --border-color: rgba(51, 65, 85, 0.16);
  --border-glow: rgba(180, 83, 9, 0.3);

  --text-main: #0f172a;
  --text-muted: #475569;
  --text-bright: #020617;

  --bronze-gold: #b45309;
  --bronze-gold-glow: rgba(180, 83, 9, 0.25);
  --cinnabar-red: #be123c;
  --yang-color: #b45309;
  --yin-color: #475569;
}

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

body {
  font-family: var(--font-body);
  background-color: var(--bg-page);
  color: var(--text-main);
  overflow-x: clip;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.6;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 700;
  line-height: 1.25;
  color: var(--text-bright);
}

/* Layout principal */
.tool-layout {
  max-width: 1200px;
  width: 100%;
  margin: 1.5rem auto 3rem;
  padding: 0 1rem;
  flex: 1;
}

.tool-with-sidebar {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
}

.tool-main-content {
  flex: 1 1 0%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

/* Tarjeta intro */
.tool-intro-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.tool-intro-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--cinnabar-red), var(--bronze-gold), var(--cinnabar-red));
}

.tool-intro-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.tool-intro-title {
  font-size: 1.65rem;
  color: var(--text-bright);
}

.tool-intro-subtitle {
  font-size: 0.95rem;
  color: var(--bronze-gold);
  font-family: var(--font-heading);
  font-weight: 600;
  display: block;
  margin-top: 0.2rem;
}

.tool-intro-desc {
  color: var(--text-muted);
  font-size: 0.95rem;
  max-width: 850px;
}

/* MESA DE CONSULTA DEL I CHING */
.iching-altar-card {
  background: var(--bg-altar);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2rem 1.5rem;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: inset 0 0 50px rgba(0, 0, 0, 0.6);
  min-height: 440px;
}

/* Marca de agua Bagua (Trigramas concéntricos) */
.bagua-watermark {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 380px;
  height: 380px;
  opacity: 0.05;
  pointer-events: none;
  z-index: 1;
}

[data-theme="light"] .bagua-watermark {
  opacity: 0.08;
}

.bagua-watermark svg {
  width: 100%;
  height: 100%;
  fill: currentColor;
}

/* Área central de las 3 monedas chinas */
.coins-stage-area {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1.5rem;
  margin: 1.5rem 0;
  z-index: 2;
  perspective: 1000px;
}

/* MONEDA CHINA DE BRONCE CON ORIFICIO CUADRADO */
.chinese-coin-box {
  width: 82px;
  height: 82px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #f59e0b 0%, #b45309 60%, #78350f 100%);
  border: 3px solid #d97706;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.4), inset 0 2px 3px rgba(255, 255, 255, 0.3), inset 0 -3px 5px rgba(0, 0, 0, 0.6);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  transition: transform 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.chinese-coin-box.tossing {
  animation: coinSpin 0.7s ease-in-out forwards;
}

@keyframes coinSpin {
  0% { transform: translateY(0) rotateX(0deg) rotateY(0deg) scale(1); }
  50% { transform: translateY(-70px) rotateX(720deg) rotateY(360deg) scale(1.15); }
  100% { transform: translateY(0) rotateX(1440deg) rotateY(720deg) scale(1); }
}

/* Orificio cuadrado central */
.coin-square-hole {
  width: 24px;
  height: 24px;
  background: var(--bg-altar);
  border: 1.5px solid #78350f;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.8);
  position: relative;
  z-index: 3;
}

/* Inscripciones en la moneda */
.coin-inscription {
  position: absolute;
  font-family: 'Segoe UI Historic', 'SimSun', serif;
  font-size: 0.72rem;
  font-weight: 700;
  color: #fef3c7;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}
.coin-insc-top { top: 6px; }
.coin-insc-bottom { bottom: 6px; }
.coin-insc-left { left: 8px; }
.coin-insc-right { right: 8px; }

.coin-value-badge {
  position: absolute;
  bottom: -10px;
  background: #0f172a;
  border: 1px solid var(--bronze-gold);
  color: var(--bronze-gold);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.1rem 0.4rem;
  border-radius: 10px;
}

/* PROGRESO DE CONSTRUCCIÓN DE LÍNEAS (Línea 1 abajo a Línea 6 arriba) */
.hexagram-building-column {
  display: flex;
  flex-direction: column-reverse; /* Línea 1 en la base */
  gap: 0.75rem;
  width: 100%;
  max-width: 320px;
  margin: 1.5rem 0;
  z-index: 2;
}

.hexagram-line-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  width: 100%;
}

.line-pos-label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  width: 60px;
  text-align: right;
  flex-shrink: 0;
}

/* Trazo Yang (Línea continua entera) */
.line-visual-yang {
  flex: 1;
  height: 14px;
  background: var(--yang-color);
  border-radius: 4px;
  box-shadow: 0 2px 8px var(--bronze-gold-glow);
  position: relative;
}

/* Trazo Yin (Línea quebrada partida en dos) */
.line-visual-yin {
  flex: 1;
  display: flex;
  gap: 18px;
  height: 14px;
}

.line-visual-yin .yin-segment {
  flex: 1;
  height: 100%;
  background: var(--yin-color);
  border-radius: 4px;
}

/* Indicador de mutación (Línea mutante 6 o 9) */
.line-visual-yang.is-changing {
  background: var(--changing-color);
  box-shadow: 0 0 12px var(--cinnabar-glow);
}
.line-visual-yang.is-changing::after {
  content: "⚪";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 8px;
  color: #ffffff;
}

.line-visual-yin.is-changing .yin-segment {
  background: var(--changing-color);
  box-shadow: 0 0 12px var(--cinnabar-glow);
}
.line-visual-yin.is-changing::after {
  content: "✕";
  position: absolute;
  left: calc(50% - 6px);
  font-size: 11px;
  color: var(--cinnabar-red);
  font-weight: bold;
}

/* Ranura vacía (pendiente de lanzar) */
.line-visual-empty {
  flex: 1;
  height: 14px;
  border: 1px dashed rgba(148, 163, 184, 0.25);
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.15);
}

/* Botones de acción del altar */
.altar-controls-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
  z-index: 2;
  width: 100%;
  margin-top: 1rem;
}

.btn-toss-action {
  background: linear-gradient(135deg, #e11d48 0%, #be123c 100%);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.25);
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 700;
  padding: 0.85rem 2rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 4px 16px rgba(225, 29, 72, 0.4);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  min-height: 48px;
}

.btn-toss-action:hover {
  background: linear-gradient(135deg, #f43f5e 0%, #e11d48 100%);
  transform: translateY(-2px);
  box-shadow: 0 6px 22px rgba(244, 63, 94, 0.55);
}

.btn-sub-action {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  font-family: var(--font-heading);
  font-size: 0.92rem;
  font-weight: 600;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 42px;
}

.btn-sub-action:hover {
  border-color: var(--bronze-gold);
  color: var(--bronze-gold);
}

/* SECCIÓN DE INTERPRETACIÓN DUAL (PRIMARIO Y DERIVADO) */
.reading-dual-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.5rem;
  width: 100%;
}

.hexagram-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  position: relative;
}

.hexagram-card.primary-card {
  border-color: var(--bronze-gold);
  box-shadow: 0 0 20px rgba(217, 119, 6, 0.15);
}

.hexagram-card.mutated-card {
  border-color: var(--cinnabar-red);
  box-shadow: 0 0 20px rgba(225, 29, 72, 0.15);
}

.hex-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.hex-chinese-char {
  font-family: 'Segoe UI Historic', 'SimSun', serif;
  font-size: 3.2rem;
  line-height: 1;
  color: var(--bronze-gold);
}

.hexagram-card.mutated-card .hex-chinese-char {
  color: var(--cinnabar-red);
}

.hex-titles {
  flex: 1;
}

.hex-number-tag {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.hex-name-title {
  font-size: 1.45rem;
  color: var(--text-bright);
}

.hex-pinyin-sub {
  font-size: 0.9rem;
  color: var(--bronze-gold);
  font-weight: 600;
}

/* Mini gráfico de hexagrama */
.hex-mini-lines {
  display: flex;
  flex-direction: column-reverse;
  gap: 4px;
  width: 48px;
  flex-shrink: 0;
}

.mini-line-yang {
  height: 5px;
  background: var(--yang-color);
  border-radius: 2px;
}

.mini-line-yin {
  height: 5px;
  display: flex;
  gap: 4px;
}
.mini-line-yin span {
  flex: 1;
  background: var(--yin-color);
  border-radius: 2px;
}

/* Trigramas componentes */
.trigrams-composition-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  background: var(--bg-surface-elevated);
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
}

.trigram-pill {
  color: var(--text-main);
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

/* Textos clásicos */
.classic-block {
  background: rgba(0, 0, 0, 0.18);
  border-radius: var(--radius-sm);
  padding: 0.85rem;
  border-left: 3px solid var(--bronze-gold);
}

[data-theme="light"] .classic-block {
  background: rgba(0, 0, 0, 0.03);
}

.classic-block.image-block {
  border-left-color: var(--celestial-cyan);
}

.classic-block-title {
  font-family: var(--font-heading);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-bright);
  margin-bottom: 0.3rem;
}

.classic-block-text {
  font-size: 0.92rem;
  color: var(--text-main);
  line-height: 1.5;
}

/* Líneas mutantes detalladas */
.changing-lines-card {
  background: var(--bg-surface);
  border: 1px solid var(--cinnabar-red);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: 0 4px 16px rgba(225, 29, 72, 0.15);
}

.changing-lines-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-top: 1rem;
}

.changing-line-entry {
  background: var(--bg-surface-elevated);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  border-left: 3px solid var(--cinnabar-red);
  font-size: 0.92rem;
  line-height: 1.5;
}

/* ENCICLOPEDIA DE LOS 64 HEXAGRAMAS */
.encyclopedia-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.encyclopedia-controls {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.search-input-box {
  flex: 1 1 240px;
  height: 42px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0 1rem;
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 0.9rem;
}

.search-input-box:focus {
  outline: none;
  border-color: var(--bronze-gold);
}

.encyclopedia-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 0.85rem;
  margin-top: 1.25rem;
}

.hex-catalog-item {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem 0.75rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
}

.hex-catalog-item:hover {
  transform: translateY(-3px);
  border-color: var(--bronze-gold);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

.catalog-hex-symbol {
  font-size: 2.2rem;
  color: var(--bronze-gold);
  line-height: 1;
  margin-bottom: 0.25rem;
}

.catalog-hex-name {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-bright);
}

.catalog-hex-num {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* GUÍA Y FAQ */
.guide-section {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.faq-accordion {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.faq-item {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.faq-summary {
  padding: 0.85rem 1rem;
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  color: var(--text-bright);
  user-select: none;
}

.faq-content {
  padding: 0 1rem 1rem;
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* MODALES NATIVOS CANÓNICOS */
.fijate-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.fijate-modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.fijate-modal-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 620px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 1.75rem;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
  transform: scale(0.94);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
}

.fijate-modal-overlay.open .fijate-modal-box {
  transform: scale(1);
}

.modal-close-btn {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.4rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close-btn:hover {
  color: var(--text-bright);
  background: var(--bg-surface-elevated);
}

/* Toast de notificación */
.toast-notice {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--bronze-gold);
  color: #080c16;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.9rem;
  padding: 0.6rem 1.4rem;
  border-radius: 30px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 10000;
}

.toast-notice.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* RESPONSIVE DESIGN */
@media (max-width: 900px) {
  .tool-with-sidebar {
    flex-direction: column;
  }
  .tool-ad-sidebar {
    display: none !important;
  }
}

@media (max-width: 640px) {
  .tool-layout {
    padding: 0 0.75rem;
    margin: 1rem auto 2.5rem;
  }

  .tool-intro-card, .iching-altar-card {
    padding: 1.15rem;
  }

  .tool-intro-title {
    font-size: 1.4rem;
  }

  .coins-stage-area {
    gap: 0.75rem;
  }

  .chinese-coin-box {
    width: 68px;
    height: 68px;
  }

  .btn-toss-action {
    width: 100%;
    min-height: 44px;
  }

  .altar-controls-bar {
    flex-direction: column;
    width: 100%;
  }

  .btn-sub-action {
    width: 100%;
    min-height: 42px;
    justify-content: center;
  }

  .reading-dual-grid {
    grid-template-columns: 1fr;
  }
}
