﻿/* ============================================================
   BAZI — DESIGN SYSTEM
   Base: #0a0a0f  Accent: #c9a84c  Mobile-first 375px
   ============================================================ */

/* === RESET & BASE ========================================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:           #0d0d1a;
  --surface:      #16162a;
  --card:         #1d1d32;
  --card-hover:   #252542;
  --accent:       #c9a84c;
  --accent-light: #e8c96c;
  --accent-dim:   rgba(201,168,76,0.2);
  --text:         #f2eeea;
  --text-muted:   #a4a2b8;
  --border:       rgba(240,237,232,0.14);
  --border-accent:rgba(201,168,76,0.45);
  --radius:       12px;
  --radius-lg:    18px;
  --radius-full:  9999px;
  --nav-h:        56px;
  --page-px:      20px;
  --ease:         cubic-bezier(0.22, 1, 0.36, 1);
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* === TYPOGRAPHY ============================================ */
h1, h2, h3, h4 { line-height: 1.2; }
p { line-height: 1.6; }
em { font-style: italic; }
code {
  font-family: 'Courier New', monospace;
  font-size: 0.85em;
  background: rgba(255,255,255,0.08);
  padding: 2px 6px;
  border-radius: 4px;
}

/* === NAV =================================================== */
.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--page-px);
  background: rgba(13,13,26,0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  z-index: 100;
}

.nav-logo {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.02em;
}

.nav-btn {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}
.nav-btn:hover { border-color: var(--accent); color: var(--accent); }

/* === VIEWS ================================================= */
.view {
  display: none;
  min-height: 100dvh;
  padding-top: var(--nav-h);
  animation: fadeIn 0.3s var(--ease);
}
.view.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* === HERO ================================================== */
.hero {
  position: relative;
  min-height: calc(100dvh - var(--nav-h));
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 60px var(--page-px);
}

.hero-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  pointer-events: none;
  opacity: 0.55;
}
.hero-orb-1 {
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(201,168,76,0.4), transparent 70%);
  top: -80px; right: -120px;
}
.hero-orb-2 {
  width: 300px; height: 300px;
  background: radial-gradient(circle, rgba(80,60,140,0.5), transparent 70%);
  bottom: 20px; left: -80px;
}
.hero-orb-3 {
  width: 200px; height: 200px;
  background: radial-gradient(circle, rgba(201,168,76,0.2), transparent 70%);
  top: 40%; left: 30%;
}

.hero-content {
  position: relative;
  text-align: center;
  max-width: 480px;
  z-index: 1;
}

.hero-eyebrow {
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 16px;
}

.hero-title {
  font-size: clamp(2.2rem, 8vw, 3rem);
  font-weight: 700;
  line-height: 1.1;
  background: linear-gradient(135deg, #f0ede8 0%, var(--accent-light) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 20px;
}

.hero-subtitle {
  font-size: 1rem;
  color: var(--text-muted);
  max-width: 360px;
  margin: 0 auto 36px;
}

.btn-hero { width: 100%; max-width: 320px; margin: 0 auto; }

.hero-note {
  margin-top: 14px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* === PAGE HEADER =========================================== */
.page-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px var(--page-px) 12px;
}

.back-btn {
  flex-shrink: 0;
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}
.back-btn:hover { border-color: var(--accent); color: var(--accent); }

.page-title {
  font-size: 1.1rem;
  font-weight: 600;
}

/* === FORM ================================================== */
.step-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 8px 0 24px;
}

.dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--border);
  transition: background 0.25s, transform 0.25s;
}
.dot.active {
  background: var(--accent);
  transform: scale(1.25);
}

.step {
  display: none;
  padding: 0 var(--page-px) 40px;
  animation: fadeIn 0.25s var(--ease);
}
.step.active { display: block; }

.step-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.step-desc {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 24px;
}

/* Date inputs */
.date-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1.4fr;
  gap: 12px;
  margin-bottom: 8px;
}

.date-field { display: flex; flex-direction: column; gap: 6px; }
.date-field--wide { /* nothing extra */ }

.date-field label {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

.date-field input {
  height: 52px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
  font-size: 1.1rem;
  font-weight: 500;
  text-align: center;
  padding: 0 8px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  -moz-appearance: textfield;
}
.date-field input::-webkit-outer-spin-button,
.date-field input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.date-field input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(201,168,76,0.15); }
.date-field input::placeholder { color: var(--text-muted); }

/* Time grid */
.time-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 8px;
}

.time-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 14px 6px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: center;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
  min-height: 80px;
  user-select: none;
}
.time-cell:hover {
  border-color: var(--accent);
  background: var(--card-hover);
  box-shadow: 0 0 0 1px rgba(201,168,76,0.15);
}
.time-cell.selected {
  border-color: var(--accent);
  background: rgba(201,168,76,0.15);
  box-shadow: 0 0 0 1px rgba(201,168,76,0.25);
}

.tc-glyph { font-size: 1.25rem; margin-bottom: 3px; color: rgba(240,237,232,0.38); line-height: 1; }
.tc-name  { font-size: 0.78rem; font-weight: 600; color: var(--accent); letter-spacing: 0.02em; }
.tc-range { font-size: 0.78rem; font-weight: 400; color: var(--text); margin-top: 3px; }
.tc-unknown { font-size: 0.85rem; font-weight: 500; color: var(--text-muted); }

/* Toggle buttons */
.toggle-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.toggle-btn {
  flex: 1;
  min-width: 100px;
  height: 48px;
  padding: 0 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}
.toggle-btn:hover { border-color: var(--accent-dim); color: var(--text); }
.toggle-btn.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent-light);
}

.calendar-section { margin-top: 8px; }
.section-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 12px;
}

/* Error */
.field-error {
  min-height: 20px;
  font-size: 0.82rem;
  color: #e87070;
  margin-bottom: 16px;
}

/* Step nav */
.step-next { width: 100%; margin-top: 8px; }

.step-row {
  display: flex;
  gap: 12px;
  margin-top: 16px;
}
.step-row .btn-outline { flex: 0 0 80px; }
.step-row .btn-primary { flex: 1; }

/* === BUTTONS =============================================== */
.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 52px;
  padding: 0 28px;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-full);
  color: #0a0a0f;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  letter-spacing: 0.01em;
}
.btn-primary:hover { background: var(--accent-light); }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-outline {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 52px;
  padding: 0 24px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}
.btn-outline:hover { border-color: var(--text-muted); color: var(--text); }

.btn-new { width: 100%; }

/* === LOADING =============================================== */
.loading-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100dvh - var(--nav-h));
  gap: 24px;
  padding: var(--page-px);
}

.loading-trigram {
  font-size: 4rem;
  animation: pulse-glow 2s ease-in-out infinite;
  color: var(--accent);
  line-height: 1;
}

@keyframes pulse-glow {
  0%, 100% { opacity: 0.5; filter: drop-shadow(0 0 8px var(--accent)); }
  50%       { opacity: 1;   filter: drop-shadow(0 0 24px var(--accent-light)); }
}

.loading-spinner {
  width: 32px; height: 32px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.loading-spinner.sm {
  width: 18px; height: 18px;
  border-width: 2px;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-text {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.report-intro {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-style: italic;
  padding: 4px var(--page-px) 0;
}

/* Report main scroll */
.report-scroll {
  padding: 0 var(--page-px) 60px;
}

/* Day Master card */
.day-master-card {
  display: flex;
  align-items: center;
  gap: 16px;
  background: linear-gradient(135deg, var(--card), #1a1a2e);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 28px;
}

.dm-element {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--accent-dim);
  border: 2px solid var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
  color: var(--accent-light);
  font-weight: 700;
}

.dm-info { display: flex; flex-direction: column; gap: 4px; }

.dm-label {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent-light);
}

.dm-tagline {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.dm-descriptor {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.55;
  margin-top: 6px;
}

/* Pillars grid */
.section {
  margin-bottom: 32px;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.pillars-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.pillar-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 8px;
  text-align: center;
}

.pillar-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.pillar-stem, .pillar-branch {
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--accent-light);
}

.pillar-desc {
  font-size: 0.58rem;
  color: var(--text-muted);
  margin-bottom: 6px;
  line-height: 1.3;
  white-space: nowrap;
}

.pillar-stem-en, .pillar-branch-en {
  font-size: 0.62rem;
  color: var(--text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Narrative cards */
.narrative-section {}

.narrative-loading {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 0.88rem;
}

.narrative-content {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.narrative-content.hidden { display: none; }

.narrative-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}

.narrative-summary {
  background: linear-gradient(135deg, var(--card), rgba(201,168,76,0.08));
  border-color: var(--accent);
  border-left: 4px solid var(--accent);
}
.narrative-summary .nc-title { color: var(--accent-light); }
.narrative-summary .nc-body { font-size: 1.02rem; font-weight: 500; line-height: 1.7; }

.nc-title {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 10px;
}

.nc-body {
  font-size: 0.92rem;
  color: var(--text);
  line-height: 1.65;
}

.narrative-unavailable {
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.88rem;
  color: var(--text-muted);
}
.narrative-unavailable.hidden { display: none; }

/* Facts list */
.facts-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.fact-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.88rem;
}

.fact-key {
  font-weight: 600;
  color: var(--text-muted);
  flex-shrink: 0;
  min-width: 120px;
  font-size: 0.82rem;
}

.fact-val { color: var(--text); }

/* Luck cycles */
.cycles-scroll {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 8px;
  scrollbar-width: none;
}
.cycles-scroll::-webkit-scrollbar { display: none; }

.cycle-card {
  flex: 0 0 110px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 8px;
  text-align: center;
}

.cycle-card.current {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.cycle-badge {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 2px;
}

.cycle-years {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}

.cycle-animal {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--accent-light);
  line-height: 1.2;
  margin-bottom: 3px;
}

.cycle-glyph {
  font-size: 0.82rem;
  color: rgba(240,237,232,0.32);
  line-height: 1;
  margin-bottom: 2px;
}

.cycle-en {
  font-size: 0.6rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.report-footer {
  margin-top: 32px;
}

/* === HISTORY =============================================== */
.history-list {
  padding: 0 var(--page-px) 40px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.history-item:hover { border-color: var(--accent-dim); background: var(--card); }

.hi-icon {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  color: var(--accent-light);
  font-weight: 700;
  flex-shrink: 0;
}

.hi-info { flex: 1; min-width: 0; }

.hi-dm {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hi-date {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.hi-arrow {
  color: var(--text-muted);
  flex-shrink: 0;
}

.history-empty {
  padding: 60px var(--page-px);
  text-align: center;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}
.history-empty.hidden { display: none; }

/* === PAYMENT VIEW ========================================== */
.payment-scroll {
  padding: 0 var(--page-px) 60px;
}

.paywall-section {
  margin-top: 8px;
  background: var(--surface);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.paywall-header {
  text-align: center;
  padding: 28px var(--page-px) 20px;
  background: linear-gradient(180deg, rgba(201,168,76,0.08) 0%, transparent 100%);
  border-bottom: 1px solid var(--border);
}

.paywall-lock {
  font-size: 2rem;
  margin-bottom: 12px;
}

.paywall-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--accent-light);
  margin-bottom: 8px;
}

.paywall-subtitle {
  font-size: 0.87rem;
  color: var(--text-muted);
  max-width: 280px;
  margin: 0 auto;
}

.paywall-features {
  list-style: none;
  padding: 20px var(--page-px);
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-bottom: 1px solid var(--border);
}

.paywall-features li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  color: var(--text);
}

.pf-check {
  color: var(--accent);
  font-weight: 700;
  flex-shrink: 0;
}

.paywall-cta {
  padding: 24px var(--page-px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.price-badge {
  display: inline-block;
  background: var(--accent);
  color: #0a0a0f;
  font-size: 1.25rem;
  font-weight: 800;
  padding: 6px 20px;
  border-radius: var(--radius-full);
  letter-spacing: 0.01em;
}

.paywall-btn {
  width: 100%;
  max-width: 320px;
}

.paywall-note {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
}

/* === HISTORY lock icon ===================================== */
.hi-icon.locked {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text-muted);
}

/* === UTILITIES ============================================= */
.hidden { display: none !important; }

/* === DESKTOP TWEAKS (≥640px) ============================== */
@media (min-width: 640px) {
  :root { --page-px: 32px; }

  .hero-title { font-size: 3rem; }
  .hero-subtitle { font-size: 1.05rem; }

  .time-grid { grid-template-columns: repeat(4, 1fr); }

  .pillars-grid { gap: 12px; }
  .pillar-card { padding: 16px 10px; }
  .pillar-stem, .pillar-branch { font-size: 1.2rem; }

  .report-scroll { max-width: 680px; margin: 0 auto; }
}

/* === SECTION INTRO ========================================= */
.section-intro {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-style: italic;
  line-height: 1.55;
  margin-top: -6px;
  margin-bottom: 14px;
}

/* === DAY MASTER LABEL ROW ================================== */
.dm-label-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* === INFO TIP TOOLTIP ====================================== */
.info-tip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  border-radius: var(--radius-full);
  border: 1px solid var(--accent);
  color: var(--accent);
  font-size: 0.6rem;
  font-weight: 700;
  cursor: help;
  flex-shrink: 0;
  position: relative;
  user-select: none;
  line-height: 1;
}

.info-tip::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  width: 230px;
  background: var(--card);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 0.75rem;
  font-weight: 400;
  line-height: 1.5;
  color: var(--text);
  text-transform: none;
  letter-spacing: normal;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  z-index: 50;
  white-space: normal;
}

.info-tip:hover::after,
.info-tip:focus::after,
.info-tip.open::after {
  opacity: 1;
}
