/* ==========================================================================
   Chinese Zodiac — CIO Factory
   Design system: orient-luxury (near-black + gold, parchment light mode)
   plus a cinnabar-red "seal ink" accent layered in for this app's deep
   classic-Chinese signature (the imperial seal / 印 chop motif).
   Token source: portable orient-luxury-core.css pattern, inlined here
   until the shared snippet is wired in via <link>.
   ========================================================================== */

:root {
  --ol-bg: #09080b;
  --ol-surface: #131015;
  --ol-surface-raised: #1a1620;
  --ol-border: rgba(201, 168, 76, 0.22);
  --ol-border-soft: rgba(201, 168, 76, 0.12);
  --ol-text: #ece6d8;
  --ol-text-dim: #a89f8f;
  --ol-text-faint: #6b6459;

  --ol-gold: #c9a84c;
  --ol-gold-dim: rgba(201, 168, 76, 0.55);
  --ol-gold-bg: rgba(201, 168, 76, 0.08);

  --ol-seal: #a3272a;
  --ol-seal-bright: #c73a3d;
  --ol-seal-bg: rgba(163, 39, 42, 0.1);

  --ol-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  --ol-radius: 4px;
  --ol-grain-opacity: 0.5;
}

html[data-theme="light"] {
  --ol-bg: #f0ebe0;
  --ol-surface: #f9f5ea;
  --ol-surface-raised: #ffffff;
  --ol-border: rgba(138, 104, 32, 0.28);
  --ol-border-soft: rgba(138, 104, 32, 0.14);
  --ol-text: #2b2418;
  --ol-text-dim: #6b5f4a;
  --ol-text-faint: #96876c;

  --ol-gold: #8a6820;
  --ol-gold-dim: rgba(138, 104, 32, 0.5);
  --ol-gold-bg: rgba(138, 104, 32, 0.08);

  --ol-seal: #9c2b2b;
  --ol-seal-bright: #b83a3a;
  --ol-seal-bg: rgba(156, 43, 43, 0.08);

  --ol-shadow: 0 18px 44px rgba(120, 100, 60, 0.16);
  --ol-grain-opacity: 0.22;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--ol-bg);
  color: var(--ol-text);
  min-height: 100%;
}

body {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 18px;
  line-height: 1.5;
  position: relative;
  transition: background 0.35s ease, color 0.35s ease;
}

h1, h2, h3 { font-family: "Cinzel", Georgia, serif; font-weight: 600; margin: 0; }

.hanzi { font-family: "Noto Serif SC", "PingFang SC", "Songti SC", serif; }

.eyebrow, .ol-label, button, .tab-btn, .field-label {
  font-family: "Syne", "Segoe UI", sans-serif;
}

.mono, .data-value, .year-num, .cycle-num {
  font-family: "IBM Plex Mono", monospace;
}

/* -------------------------------------------------------------------- */
/* Grain overlay                                                         */
/* -------------------------------------------------------------------- */
.ol-grain {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
  mix-blend-mode: soft-light;
  opacity: var(--ol-grain-opacity);
}

.ol-toast-layer {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ol-toast {
  background: var(--ol-surface-raised);
  border: 1px solid var(--ol-border);
  color: var(--ol-text);
  padding: 12px 18px;
  border-radius: var(--ol-radius);
  box-shadow: var(--ol-shadow);
  font-size: 15px;
  max-width: 320px;
}
.ol-toast.is-error { border-color: var(--ol-seal); color: var(--ol-seal-bright); }

/* -------------------------------------------------------------------- */
/* Layout shell                                                          */
/* -------------------------------------------------------------------- */
.wrap {
  position: relative;
  z-index: 2;
  max-width: 980px;
  margin: 0 auto;
  padding: 48px 24px 80px;
}

.top-bar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 36px;
  flex-wrap: wrap;
}

.eyebrow {
  font-size: 12px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ol-gold);
  margin: 0 0 8px;
}

.title {
  font-size: 40px;
  letter-spacing: 0.03em;
  color: var(--ol-text);
}
.title .accent { color: var(--ol-gold); }
.title .seal-char {
  color: var(--ol-seal);
  font-size: 0.7em;
  margin-left: 10px;
  vertical-align: middle;
}

.subtitle {
  color: var(--ol-text-dim);
  font-size: 18px;
  margin: 10px 0 0;
  max-width: 520px;
}

.theme-toggle {
  background: transparent;
  border: 1px solid var(--ol-border);
  color: var(--ol-text);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
  flex-shrink: 0;
}
.theme-toggle:hover { border-color: var(--ol-gold); color: var(--ol-gold); transform: rotate(20deg); }
.theme-toggle svg { width: 20px; height: 20px; }

/* -------------------------------------------------------------------- */
/* Zodiac wheel — signature element                                      */
/* Twelve 时辰 (double-hour) positions arranged like a traditional        */
/* Chinese day-clock, Rat at the top (midnight), running clockwise.       */
/* -------------------------------------------------------------------- */
.wheel-panel {
  display: flex;
  align-items: center;
  gap: 36px;
  background: var(--ol-surface);
  border: 1px solid var(--ol-border-soft);
  border-radius: var(--ol-radius);
  padding: 28px 32px;
  margin-bottom: 32px;
  flex-wrap: wrap;
}

.wheel-holder { flex-shrink: 0; width: 220px; height: 220px; position: relative; }
.wheel-holder svg { width: 100%; height: 100%; overflow: visible; }

.wheel-ring { fill: none; stroke: var(--ol-border); stroke-width: 1; }
.wheel-tick { stroke: var(--ol-gold-dim); stroke-width: 1; }
.wheel-glyph {
  fill: var(--ol-text-dim);
  font-size: 20px;
  text-anchor: middle;
  dominant-baseline: middle;
  transition: fill 0.4s ease, font-size 0.3s ease;
}
.wheel-glyph.is-active {
  fill: var(--ol-gold);
  font-size: 26px;
}
.wheel-center-glyph {
  fill: var(--ol-seal);
  font-size: 34px;
  text-anchor: middle;
  dominant-baseline: middle;
  opacity: 0.9;
}
.wheel-active-ring {
  fill: none;
  stroke: var(--ol-gold);
  stroke-width: 1.5;
  opacity: 0;
  transition: opacity 0.4s ease;
}
.wheel-active-ring.is-visible { opacity: 0.8; }

.wheel-copy { flex: 1; min-width: 220px; }
.wheel-copy p {
  color: var(--ol-text-dim);
  font-size: 16px;
  margin: 0 0 10px;
}
.wheel-copy .wheel-caption {
  font-family: "Syne", sans-serif;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ol-text-faint);
}

/* -------------------------------------------------------------------- */
/* Tabs                                                                   */
/* -------------------------------------------------------------------- */
.tab-row {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--ol-border-soft);
  margin-bottom: 28px;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--ol-text-dim);
  font-size: 14px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 14px 22px;
  cursor: pointer;
  position: relative;
  transition: color 0.2s ease;
}
.tab-btn:hover { color: var(--ol-text); }
.tab-btn.is-active { color: var(--ol-gold); }
.tab-btn.is-active::after {
  content: "";
  position: absolute;
  left: 22px;
  right: 22px;
  bottom: -1px;
  height: 2px;
  background: var(--ol-gold);
}

.tab-panel { display: none; }
.tab-panel.is-active { display: block; }

/* -------------------------------------------------------------------- */
/* Controls                                                               */
/* -------------------------------------------------------------------- */
.control-card {
  background: var(--ol-surface);
  border: 1px solid var(--ol-border-soft);
  border-radius: var(--ol-radius);
  padding: 28px;
  margin-bottom: 28px;
}

.field-label {
  display: block;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ol-text-faint);
  margin-bottom: 10px;
}

input[type="date"], select.ol-select {
  width: 100%;
  max-width: 320px;
  background: var(--ol-surface-raised);
  border: 1px solid var(--ol-border);
  color: var(--ol-text);
  font-family: "IBM Plex Mono", monospace;
  font-size: 16px;
  padding: 12px 14px;
  border-radius: var(--ol-radius);
  outline: none;
  transition: border-color 0.2s ease;
}
input[type="date"]:focus, select.ol-select:focus {
  border-color: var(--ol-gold);
}
input[type="date"]::-webkit-calendar-picker-indicator {
  filter: var(--date-icon-filter, none);
  cursor: pointer;
  opacity: 0.75;
}
html[data-theme="dark"] input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(0.85) sepia(1) saturate(2) hue-rotate(2deg);
}

select.ol-select {
  appearance: none;
  -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--ol-gold) 50%), linear-gradient(135deg, var(--ol-gold) 50%, transparent 50%);
  background-position: calc(100% - 20px) center, calc(100% - 14px) center;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  cursor: pointer;
}

.hint {
  font-family: "Syne", sans-serif;
  font-size: 12px;
  color: var(--ol-text-faint);
  margin-top: 12px;
}

button.ol-btn {
  background: transparent;
  border: 1px solid var(--ol-gold-dim);
  color: var(--ol-gold);
  font-size: 13px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 12px 22px;
  border-radius: var(--ol-radius);
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
  margin-top: 18px;
}
button.ol-btn:hover { background: var(--ol-gold-bg); }
button.ol-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* -------------------------------------------------------------------- */
/* Result — date mode: the "certificate" card                            */
/* -------------------------------------------------------------------- */
.result-card {
  background: var(--ol-surface);
  border: 1px solid var(--ol-border);
  border-radius: var(--ol-radius);
  padding: 40px;
  position: relative;
  overflow: hidden;
}
.result-card::before {
  content: "";
  position: absolute;
  inset: 10px;
  border: 1px solid var(--ol-border-soft);
  border-radius: 2px;
  pointer-events: none;
}

.result-empty, .result-loading, .result-error {
  padding: 40px;
  text-align: center;
  color: var(--ol-text-faint);
  font-size: 15px;
}
.result-error { color: var(--ol-seal-bright); }

.result-hero {
  display: flex;
  align-items: center;
  gap: 32px;
  flex-wrap: wrap;
}

.hero-glyph {
  font-family: "Ma Shan Zheng", "Noto Serif SC", serif;
  font-size: 120px;
  line-height: 1;
  color: var(--ol-gold);
  text-shadow: 0 0 40px var(--ol-gold-bg);
  flex-shrink: 0;
}

.hero-meta { flex: 1; min-width: 240px; }

.hero-eyebrow {
  font-family: "Syne", sans-serif;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ol-text-faint);
  margin-bottom: 6px;
}

.hero-title {
  font-size: 34px;
  color: var(--ol-text);
  margin-bottom: 6px;
}
.hero-title .hanzi { color: var(--ol-gold); font-size: 0.85em; margin-left: 10px; }

.hero-fullname {
  color: var(--ol-text-dim);
  font-size: 18px;
  margin-bottom: 4px;
}

.polarity-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: "Syne", sans-serif;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ol-text-dim);
  border: 1px solid var(--ol-border-soft);
  border-radius: 20px;
  padding: 4px 12px;
  margin-top: 10px;
}
.polarity-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.polarity-dot.yin { background: var(--ol-text); }
.polarity-dot.yang { background: var(--ol-gold); }

.divider-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 30px 0;
}
.divider-row .line { flex: 1; height: 1px; background: var(--ol-border-soft); }
.divider-row .glyph { color: var(--ol-gold-dim); font-size: 14px; }

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 22px;
}

.detail-cell .detail-label {
  font-family: "Syne", sans-serif;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ol-text-faint);
  margin-bottom: 6px;
}
.detail-cell .detail-value {
  font-family: "IBM Plex Mono", monospace;
  font-size: 17px;
  color: var(--ol-text);
}
.element-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 8px;
  vertical-align: middle;
  border: 1px solid var(--ol-border);
}

.traits-row {
  margin-top: 28px;
}
.traits-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
  list-style: none;
  padding: 0;
}
.traits-list li {
  border: 1px solid var(--ol-border-soft);
  background: var(--ol-gold-bg);
  color: var(--ol-gold);
  font-family: "Cormorant Garamond", serif;
  font-style: italic;
  font-size: 16px;
  padding: 6px 16px;
  border-radius: 20px;
}

.seal-stamp {
  position: absolute;
  top: 32px;
  right: 36px;
  width: 64px;
  height: 64px;
  border: 2px solid var(--ol-seal);
  border-radius: 6px;
  color: var(--ol-seal);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Noto Serif SC", serif;
  font-size: 30px;
  transform: rotate(-6deg);
  opacity: 0.85;
  mix-blend-mode: var(--seal-blend, normal);
}
html[data-theme="dark"] .seal-stamp { --seal-blend: screen; }
html[data-theme="light"] .seal-stamp { --seal-blend: multiply; }

/* -------------------------------------------------------------------- */
/* Result — animal mode: years grid                                      */
/* -------------------------------------------------------------------- */
.years-head {
  display: flex;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.years-head .hanzi { font-size: 44px; color: var(--ol-gold); }
.years-head h2 { font-size: 26px; }
.years-head .years-sub { color: var(--ol-text-dim); font-size: 15px; }

.years-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 14px;
}

.year-plaque {
  border: 1px solid var(--ol-border);
  background: var(--ol-surface-raised);
  border-radius: var(--ol-radius);
  padding: 16px 12px;
  text-align: center;
  position: relative;
  transition: border-color 0.2s ease, transform 0.2s ease;
}
.year-plaque:hover { border-color: var(--ol-gold); transform: translateY(-2px); }
.year-plaque .year-num {
  font-size: 22px;
  color: var(--ol-text);
  display: block;
}
.year-plaque .year-element {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ol-text-faint);
  margin-top: 6px;
  display: block;
}
.year-plaque .year-current-tag {
  position: absolute;
  top: -9px;
  right: 8px;
  background: var(--ol-seal);
  color: #f5ede0;
  font-family: "Syne", sans-serif;
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 10px;
}

.footnote {
  margin-top: 44px;
  color: var(--ol-text-faint);
  font-size: 13px;
  text-align: center;
  font-family: "Syne", sans-serif;
  letter-spacing: 0.04em;
}
.footnote a { color: var(--ol-gold); text-decoration: none; }

/* -------------------------------------------------------------------- */
/* Responsive                                                             */
/* -------------------------------------------------------------------- */
@media (max-width: 640px) {
  .wrap { padding: 32px 16px 60px; }
  .title { font-size: 30px; }
  .wheel-panel { flex-direction: column; text-align: center; }
  .wheel-copy { text-align: left; }
  .hero-glyph { font-size: 84px; }
  .result-card { padding: 26px; }
  .seal-stamp { top: 18px; right: 18px; width: 52px; height: 52px; font-size: 24px; }
}

/* -------------------------------------------------------------------- */
/* Accessibility                                                          */
/* -------------------------------------------------------------------- */
:focus-visible {
  outline: 2px solid var(--ol-gold);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
