/* ============================================================
   ENNEAGRAM 142857 — STYLE SYSTEM
   ============================================================ */

:root {
  --bg-deep:    #050810;
  --bg-mid:     #0a0f1e;
  --bg-panel:   #0f1628;
  --gold:       #f0c040;
  --gold-dim:   #a07820;
  --gold-glow:  rgba(240,192,64,0.35);
  --cyan:       #40c8f0;
  --cyan-dim:   #1a6080;
  --purple:     #a060f0;
  --purple-dim: #4a1a80;
  --rose:       #f06090;
  --green:      #60d090;
  --yang-col:   #f0a030;
  --yin-col:    #6090f0;
  --triad-col:  #a0e060;
  --text-main:  #e8e0d0;
  --text-sub:   #a09080;
  --text-dim:   #504840;
  --border:     rgba(240,192,64,0.2);
  --font-serif: 'Noto Serif JP', serif;
  --font-sans:  'Noto Sans JP', sans-serif;
  --font-en:    'IM Fell English', serif;
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--bg-deep);
  color: var(--text-main);
  font-family: var(--font-sans);
  overflow-x: hidden;
  min-height: 100vh;
}

/* ===== SCREEN SYSTEM ===== */
.screen {
  display: none;
  min-height: 100vh;
  position: relative;
}
.screen.active { display: flex; flex-direction: column; }

/* ===== INTRO ===== */
#screen-intro {
  align-items: center;
  justify-content: center;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 2rem;
  padding: 2rem;
}

.cosmos-bg {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

#canvas-stars {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.enneagram-symbol-static {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(70vw, 70vh);
  height: min(70vw, 70vh);
  opacity: 0.25;
  animation: slow-spin 60s linear infinite;
}
@keyframes slow-spin { to { transform: translate(-50%, -50%) rotate(360deg); } }

.intro-content {
  position: relative;
  z-index: 10;
  text-align: center;
  max-width: 680px;
  padding: 2rem;
}

.intro-badge {
  display: inline-block;
  border: 1px solid var(--gold-dim);
  color: var(--gold);
  font-size: 0.7rem;
  letter-spacing: 0.3em;
  padding: 0.3rem 1rem;
  border-radius: 2rem;
  margin-bottom: 1.5rem;
  font-family: var(--font-en);
}

.intro-title {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  margin-bottom: 1.5rem;
}

.title-en {
  font-family: var(--font-en);
  font-size: clamp(2.5rem, 8vw, 4.5rem);
  color: var(--gold);
  letter-spacing: 0.4em;
  text-shadow: 0 0 30px var(--gold-glow), 0 0 60px rgba(240,192,64,0.2);
  line-height: 1;
}

.title-ja {
  font-family: var(--font-serif);
  font-size: clamp(1rem, 3vw, 1.4rem);
  color: var(--text-main);
  letter-spacing: 0.5em;
  font-weight: 300;
}

.title-sub {
  font-family: var(--font-sans);
  font-size: 0.8rem;
  color: var(--text-sub);
  letter-spacing: 0.3em;
  font-weight: 300;
}

.intro-desc {
  font-size: 0.92rem;
  line-height: 2;
  color: var(--text-sub);
  margin-bottom: 2rem;
  font-weight: 300;
}
.intro-desc strong { color: var(--text-main); font-weight: 400; }

.cycle-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 2rem;
  font-family: var(--font-en);
  font-size: 1.1rem;
}

.cycle-num {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 0.95rem;
  border: 1px solid;
  transition: transform 0.3s;
}
.cycle-num:hover { transform: scale(1.2); }
.cycle-num.yang  { color: var(--yang-col); border-color: var(--yang-col); box-shadow: 0 0 8px rgba(240,160,48,0.4); }
.cycle-num.yin   { color: var(--yin-col);  border-color: var(--yin-col);  box-shadow: 0 0 8px rgba(96,144,240,0.4); }
.cycle-num.triad { color: var(--triad-col);border-color: var(--triad-col);box-shadow: 0 0 8px rgba(160,224,96,0.4); }
.cycle-arrow { color: var(--text-dim); font-size: 0.7rem; }
.cycle-sep { color: var(--gold-dim); font-size: 1.4rem; margin: 0 0.5rem; }

.btn-start {
  background: linear-gradient(135deg, var(--gold) 0%, #c08020 100%);
  color: var(--bg-deep);
  border: none;
  padding: 0.9rem 3rem;
  font-size: 1rem;
  font-family: var(--font-serif);
  font-weight: 700;
  border-radius: 0.3rem;
  cursor: pointer;
  letter-spacing: 0.2em;
  box-shadow: 0 0 30px var(--gold-glow);
  transition: all 0.3s;
  margin-bottom: 1rem;
}
.btn-start:hover {
  box-shadow: 0 0 50px rgba(240,192,64,0.6);
  transform: translateY(-2px);
}

.intro-note {
  font-size: 0.75rem;
  color: var(--text-dim);
  letter-spacing: 0.2em;
}

/* ===== QUESTION SCREEN ===== */
#screen-question {
  background: var(--bg-mid);
  align-items: stretch;
}

.q-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-deep);
  flex-wrap: wrap;
}

.q-logo {
  font-family: var(--font-en);
  color: var(--gold);
  font-size: 0.85rem;
  letter-spacing: 0.4em;
  opacity: 0.7;
  flex-shrink: 0;
}

.q-progress-wrap {
  flex: 1;
  min-width: 120px;
}

.q-progress-bar {
  height: 3px;
  background: var(--bg-panel);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 0.25rem;
}

.q-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold) 0%, var(--cyan) 100%);
  border-radius: 2px;
  transition: width 0.5s cubic-bezier(0.4,0,0.2,1);
  box-shadow: 0 0 8px var(--gold-glow);
}

.q-progress-text {
  font-size: 0.7rem;
  color: var(--text-sub);
  letter-spacing: 0.15em;
  text-align: right;
}

.q-cycle-indicator {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  padding: 0.3rem 0.7rem;
  border-radius: 0.2rem;
  flex-shrink: 0;
}
.ci-label { font-size: 0.6rem; color: var(--text-dim); letter-spacing: 0.2em; margin-right: 0.2rem; }
.ci-step  { font-size: 1rem; color: var(--gold); font-family: var(--font-en); font-weight: bold; }
.ci-sep   { color: var(--text-dim); font-size: 0.7rem; }
.ci-total { font-size: 0.75rem; color: var(--text-sub); }

.q-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.5rem;
  max-width: 700px;
  margin: 0 auto;
  width: 100%;
}

.q-section-badge {
  font-size: 0.7rem;
  letter-spacing: 0.3em;
  padding: 0.25rem 0.8rem;
  border-radius: 2rem;
  margin-bottom: 1rem;
  border: 1px solid;
  transition: all 0.5s;
}
.q-section-badge.yang  { color: var(--yang-col);  border-color: var(--yang-col); }
.q-section-badge.yin   { color: var(--yin-col);   border-color: var(--yin-col); }
.q-section-badge.triad { color: var(--triad-col); border-color: var(--triad-col); }

.q-number {
  font-family: var(--font-en);
  font-size: 0.75rem;
  color: var(--gold-dim);
  letter-spacing: 0.3em;
  margin-bottom: 0.8rem;
}

.q-text {
  font-family: var(--font-serif);
  font-size: clamp(1rem, 2.5vw, 1.25rem);
  font-weight: 400;
  line-height: 1.8;
  text-align: center;
  margin-bottom: 0.75rem;
  color: var(--text-main);
  min-height: 3rem;
  transition: opacity 0.3s;
}

.q-context {
  font-size: 0.8rem;
  color: var(--text-sub);
  text-align: center;
  margin-bottom: 2rem;
  font-style: italic;
  min-height: 1.2em;
}

.q-options {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 2rem;
}

.opt-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1.2rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  cursor: pointer;
  transition: all 0.25s;
  position: relative;
  overflow: hidden;
}
.opt-item::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, var(--gold-glow) 0%, transparent 100%);
  opacity: 0;
  transition: opacity 0.25s;
}
.opt-item:hover { border-color: var(--gold-dim); }
.opt-item:hover::before { opacity: 1; }
.opt-item input { display: none; }
.opt-item.selected { border-color: var(--gold); background: rgba(240,192,64,0.08); }
.opt-item.selected::before { opacity: 1; }

.opt-dot {
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  border: 1.5px solid var(--text-dim);
  flex-shrink: 0;
  transition: all 0.25s;
  position: relative;
  z-index: 1;
}
.opt-item.selected .opt-dot {
  border-color: var(--gold);
  background: var(--gold);
  box-shadow: 0 0 8px var(--gold-glow);
}

.opt-label {
  font-size: 0.9rem;
  color: var(--text-sub);
  transition: color 0.25s;
  position: relative;
  z-index: 1;
}
.opt-item.selected .opt-label,
.opt-item:hover .opt-label { color: var(--text-main); }

.q-nav {
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: center;
}

.btn-prev, .btn-next {
  padding: 0.6rem 1.6rem;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  border-radius: 0.3rem;
  cursor: pointer;
  transition: all 0.25s;
  letter-spacing: 0.1em;
}

.btn-prev {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-sub);
}
.btn-prev:hover:not(:disabled) { border-color: var(--text-sub); color: var(--text-main); }
.btn-prev:disabled { opacity: 0.3; cursor: default; }

.btn-next {
  background: var(--gold);
  border: none;
  color: var(--bg-deep);
  font-weight: 700;
  box-shadow: 0 0 15px var(--gold-glow);
}
.btn-next:hover { box-shadow: 0 0 25px rgba(240,192,64,0.6); transform: translateX(2px); }
.btn-next:disabled { opacity: 0.4; cursor: default; transform: none; }

.harmonic-indicator {
  margin-top: 1.5rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.8s;
}
.harmonic-indicator.visible { opacity: 1; }
.harmonic-inner {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 1.2rem;
  border: 1px solid rgba(160,96,240,0.4);
  border-radius: 2rem;
  background: rgba(160,96,240,0.1);
}
.harmonic-icon { color: var(--purple); font-size: 1.2rem; animation: pulse-icon 1.5s ease-in-out infinite; }
@keyframes pulse-icon { 0%,100%{opacity:1;transform:scale(1)} 50%{opacity:0.5;transform:scale(0.9)} }
.harmonic-text { font-size: 0.75rem; color: var(--purple); letter-spacing: 0.2em; font-family: var(--font-en); }

.q-mini-diagram {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  width: 100px;
  height: 100px;
  opacity: 0.4;
  pointer-events: none;
}

/* ===== RESULT SCREEN ===== */
#screen-result {
  background: var(--bg-deep);
  overflow: hidden;
}

.result-cosmos {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}
#canvas-result-stars { width: 100%; height: 100%; }

.result-wrap {
  position: relative;
  z-index: 1;
  max-width: 800px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

.result-header {
  text-align: center;
  margin-bottom: 2rem;
  padding-top: 1rem;
}

.result-code-badge {
  display: inline-block;
  font-family: var(--font-en);
  font-size: 0.75rem;
  letter-spacing: 0.4em;
  color: var(--gold-dim);
  border: 1px solid var(--gold-dim);
  padding: 0.25rem 1rem;
  border-radius: 2rem;
  margin-bottom: 0.8rem;
}

.result-title {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  color: var(--text-sub);
  font-weight: 300;
  letter-spacing: 0.4em;
}

/* Primary Card */
.result-primary-card {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  background: var(--bg-panel);
  border: 1px solid var(--gold-dim);
  border-radius: 1rem;
  padding: 1.5rem;
  margin-bottom: 2rem;
  box-shadow: 0 0 40px rgba(240,192,64,0.1), inset 0 1px 0 rgba(255,255,255,0.05);
  animation: card-appear 0.8s ease-out;
}
@keyframes card-appear {
  from { opacity:0; transform: translateY(20px); }
  to   { opacity:1; transform: translateY(0); }
}

.rpc-glyph {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-en);
  font-size: 2.5rem;
  font-weight: bold;
  flex-shrink: 0;
  box-shadow: 0 0 25px currentColor;
  transition: box-shadow 0.5s;
}

.rpc-type-num {
  font-family: var(--font-en);
  font-size: 0.8rem;
  color: var(--gold-dim);
  letter-spacing: 0.3em;
  margin-bottom: 0.3rem;
}
.rpc-type-name {
  font-family: var(--font-serif);
  font-size: 1.6rem;
  color: var(--gold);
  font-weight: 700;
  margin-bottom: 0.2rem;
}
.rpc-type-en {
  font-family: var(--font-en);
  font-size: 0.9rem;
  color: var(--text-sub);
  font-style: italic;
  margin-bottom: 0.4rem;
}
.rpc-ego {
  font-size: 0.75rem;
  color: var(--purple);
  letter-spacing: 0.2em;
  margin-bottom: 0.6rem;
  padding: 0.2rem 0.6rem;
  border: 1px solid rgba(160,96,240,0.3);
  display: inline-block;
  border-radius: 0.2rem;
}
.rpc-desc {
  font-size: 0.88rem;
  line-height: 1.8;
  color: var(--text-sub);
}

/* Sections */
.result-section {
  margin-bottom: 2.5rem;
  animation: section-appear 0.6s ease-out both;
}
@keyframes section-appear {
  from { opacity:0; transform: translateY(15px); }
  to   { opacity:1; transform: translateY(0); }
}

.result-section-title {
  font-family: var(--font-serif);
  font-size: 1rem;
  font-weight: 400;
  color: var(--gold-dim);
  letter-spacing: 0.3em;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
  margin-bottom: 1.2rem;
}

/* Radar */
.radar-wrap {
  display: flex;
  justify-content: center;
  max-width: 400px;
  margin: 0 auto;
}

/* System Grid */
.system-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.sys-card {
  background: var(--bg-panel);
  border-radius: 0.75rem;
  padding: 1.1rem;
  border: 1px solid;
  transition: transform 0.3s;
}
.sys-card:hover { transform: translateY(-3px); }
.yang-card  { border-color: rgba(240,160,48,0.4); }
.yin-card   { border-color: rgba(96,144,240,0.4); }
.triad-card { border-color: rgba(160,224,96,0.4); }

.sys-card-title {
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  margin-bottom: 0.5rem;
  font-weight: 300;
}
.yang-card  .sys-card-title { color: var(--yang-col); }
.yin-card   .sys-card-title { color: var(--yin-col); }
.triad-card .sys-card-title { color: var(--triad-col); }

.sys-flow {
  font-family: var(--font-en);
  font-size: 1.2rem;
  font-weight: bold;
  margin-bottom: 0.6rem;
}
.yang-card  .sys-flow { color: var(--yang-col); }
.yin-card   .sys-flow { color: var(--yin-col); }
.triad-card .sys-flow { color: var(--triad-col); }

.sys-desc {
  font-size: 0.8rem;
  line-height: 1.7;
  color: var(--text-sub);
}

.harmonic-reset-info {
  background: rgba(160,96,240,0.08);
  border: 1px solid rgba(160,96,240,0.25);
  border-radius: 0.5rem;
  padding: 0.9rem 1.2rem;
  font-size: 0.82rem;
  line-height: 1.8;
  color: var(--text-sub);
}

/* Level */
.level-display {
  text-align: center;
  margin-bottom: 1.5rem;
}

.level-meter {
  height: 8px;
  background: var(--bg-panel);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 0.8rem;
  border: 1px solid var(--border);
}

.level-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--yin-col) 0%, var(--gold) 50%, var(--rose) 100%);
  border-radius: 4px;
  transition: width 1.2s cubic-bezier(0.4,0,0.2,1);
  box-shadow: 0 0 10px currentColor;
}

.level-num {
  font-family: var(--font-en);
  font-size: 3rem;
  color: var(--gold);
  font-weight: bold;
  line-height: 1;
  margin-bottom: 0.3rem;
  text-shadow: 0 0 20px var(--gold-glow);
}

.level-name {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  color: var(--text-main);
  margin-bottom: 0.5rem;
}

.level-desc {
  font-size: 0.85rem;
  line-height: 1.8;
  color: var(--text-sub);
  max-width: 500px;
  margin: 0 auto;
}

.level-steps {
  margin-top: 1rem;
}
.ls-row {
  display: flex;
  gap: 0.4rem;
  justify-content: center;
  flex-wrap: wrap;
}

.ls-step {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  border: 1px solid;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-en);
  font-size: 0.8rem;
  font-weight: bold;
  transition: all 0.3s;
  cursor: default;
}
.ls-step.active {
  box-shadow: 0 0 15px currentColor;
  transform: scale(1.15);
}

/* User Code */
.user-code-display {
  text-align: center;
  font-family: var(--font-en);
  font-size: clamp(2rem, 6vw, 3.5rem);
  color: var(--gold);
  letter-spacing: 0.3em;
  font-weight: bold;
  text-shadow: 0 0 30px var(--gold-glow);
  margin-bottom: 0.8rem;
  padding: 1.2rem;
  border: 1px solid var(--gold-dim);
  border-radius: 0.5rem;
  background: var(--bg-panel);
}

.code-explain {
  font-size: 0.82rem;
  line-height: 1.8;
  color: var(--text-sub);
  text-align: center;
}

/* Wing Arrow Grid */
.wing-arrow-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
}

.wa-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 1rem;
  transition: transform 0.3s;
}
.wa-card:hover { transform: translateY(-2px); }

.wa-title {
  font-size: 0.65rem;
  letter-spacing: 0.25em;
  color: var(--text-dim);
  margin-bottom: 0.4rem;
  text-transform: uppercase;
}

.wa-type {
  font-family: var(--font-serif);
  font-size: 0.95rem;
  color: var(--text-main);
  margin-bottom: 0.3rem;
}

.wa-desc {
  font-size: 0.78rem;
  line-height: 1.6;
  color: var(--text-sub);
}

/* Result Diagram */
.result-diagram-wrap {
  max-width: 360px;
  margin: 0 auto;
}
.result-diagram-wrap svg { width: 100%; height: auto; }

/* Advice */
.advice-body {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 1.5rem;
}

.advice-item {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.2rem;
  align-items: flex-start;
}
.advice-item:last-child { margin-bottom: 0; }

.advice-icon {
  font-size: 1.3rem;
  flex-shrink: 0;
  margin-top: 0.1rem;
}

.advice-text {
  font-size: 0.88rem;
  line-height: 1.8;
  color: var(--text-sub);
}
.advice-text strong { color: var(--text-main); }

/* Footer */
.result-footer {
  text-align: center;
  padding-top: 1rem;
}

.btn-retake {
  background: transparent;
  border: 1px solid var(--gold-dim);
  color: var(--gold-dim);
  padding: 0.7rem 2rem;
  font-family: var(--font-serif);
  font-size: 0.9rem;
  border-radius: 0.3rem;
  cursor: pointer;
  letter-spacing: 0.2em;
  transition: all 0.3s;
}
.btn-retake:hover {
  border-color: var(--gold);
  color: var(--gold);
  box-shadow: 0 0 15px var(--gold-glow);
}

/* ===== UTILS ===== */
.fade-in  { animation: fade-in 0.5s ease-out; }
@keyframes fade-in { from { opacity:0; } to { opacity:1; } }

/* ===== RESPONSIVE ===== */
@media (max-width: 600px) {
  #screen-intro { flex-direction: column; padding: 1rem; }
  .result-primary-card { flex-direction: column; text-align: center; }
  .wing-arrow-grid { grid-template-columns: 1fr; }
  .q-mini-diagram { display: none; }
  .system-grid { grid-template-columns: 1fr; }
}

/* ===== SVG node color classes ===== */
.node-yang  { fill: var(--yang-col); }
.node-yin   { fill: var(--yin-col); }
.node-triad { fill: var(--triad-col); }
.node-base  { fill: rgba(255,255,255,0.3); }

/* ===== scrollbar ===== */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: var(--bg-deep); }
::-webkit-scrollbar-thumb { background: var(--gold-dim); border-radius: 3px; }
