/* ==========================================================================
   Anka — Direction A · Celestial Night
   Luxe gold on near-black indigo. Cormorant display, real starfield,
   astronomical glyphs. Tokens lifted directly from the design board.
   ========================================================================== */

:root {
  --bg:            #0a0b1a;
  --bg-deep:       #070814;
  --gold:          #e7c887;
  --gold-bright:   #f3dca0;
  --gold-soft:     #dcb96f;
  --gold-glow:     #f7e3aa;
  --gold-dim:      #cbb07a;
  --ink-on-gold:   #1a1330;
  --text:          #ECE9F5;
  --text-soft:     #a9a4c2;
  --text-muted:    #8b85a0;
  --text-faint:    #7e7896;
  --warn:          #e3a98c;
  --line:          rgba(255, 255, 255, .07);

  --serif: 'Cormorant Garamond', Georgia, serif;
  --sans:  'Manrope', system-ui, -apple-system, sans-serif;

  --starfield:
    radial-gradient(1.4px 1.4px at 8% 12%, rgba(255,255,255,.85), transparent 60%),
    radial-gradient(1px 1px at 22% 30%, rgba(255,255,255,.6), transparent 60%),
    radial-gradient(1.2px 1.2px at 40% 8%, rgba(255,255,255,.7), transparent 60%),
    radial-gradient(1px 1px at 58% 24%, rgba(255,255,255,.5), transparent 60%),
    radial-gradient(1.3px 1.3px at 74% 12%, rgba(255,255,255,.75), transparent 60%),
    radial-gradient(1px 1px at 88% 30%, rgba(255,255,255,.5), transparent 60%),
    radial-gradient(1px 1px at 16% 62%, rgba(255,255,255,.4), transparent 60%),
    radial-gradient(1.2px 1.2px at 62% 70%, rgba(255,255,255,.45), transparent 60%),
    radial-gradient(1px 1px at 90% 64%, rgba(255,255,255,.35), transparent 60%),
    radial-gradient(1.3px 1.3px at 46% 90%, rgba(255,255,255,.45), transparent 60%),
    radial-gradient(1px 1px at 33% 48%, rgba(255,255,255,.35), transparent 60%),
    radial-gradient(1.1px 1.1px at 70% 44%, rgba(255,255,255,.4), transparent 60%);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--text);
  background-color: var(--bg);
  background-image:
    var(--starfield),
    radial-gradient(120% 70% at 50% -8%, rgba(74, 64, 140, .5), transparent 62%),
    radial-gradient(100% 60% at 50% 108%, rgba(74, 64, 140, .3), transparent 60%);
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* ---- Shell ------------------------------------------------------------- */
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 26px clamp(20px, 6vw, 64px);
  max-width: 1100px;
  margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.brand .mark { color: var(--gold); font-size: 20px; }
.brand .word {
  font-family: var(--serif);
  font-size: 26px;
  font-weight: 600;
  letter-spacing: .18em;
  color: var(--gold-bright);
}
.nav-links { display: flex; align-items: center; gap: 30px; font-size: 14px; color: #c9c4dc; }
.nav-links a:hover { color: var(--gold-bright); }
.nav-cta {
  border: 1px solid rgba(231, 200, 135, .4);
  color: var(--gold-bright);
  padding: 9px 20px;
  border-radius: 30px;
  transition: background .2s, border-color .2s;
}
.nav-cta:hover { background: rgba(231, 200, 135, .12); border-color: var(--gold); }

/* Language picker */
.lang-select {
  appearance: none;
  -webkit-appearance: none;
  font: inherit;
  font-size: 13px;
  color: #c9c4dc;
  background: rgba(255, 255, 255, .04);
  border: 1px solid rgba(231, 200, 135, .28);
  border-radius: 30px;
  padding: 8px 30px 8px 14px;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23c9c4dc' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  transition: border-color .2s, color .2s;
}
.lang-select:hover { border-color: var(--gold); color: var(--gold-bright); }
.lang-select:focus-visible { outline: none; border-color: var(--gold); }
.lang-select option { background: #14132a; color: #e9e6f5; }

.view { display: none; }
.view.is-active { display: block; animation: rise .5s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ---- Hero / Calculator ------------------------------------------------- */
.hero {
  text-align: center;
  padding: 48px clamp(20px, 6vw, 44px) 8px;
  max-width: 760px;
  margin: 0 auto;
}
.eyebrow {
  font-size: 12px; letter-spacing: .32em; text-transform: uppercase;
  color: var(--gold); font-weight: 600;
}
.hero h1 {
  font-family: var(--serif);
  font-size: clamp(38px, 7vw, 58px);
  line-height: 1.08; font-weight: 500;
  color: var(--text); margin: 22px 0 0; letter-spacing: -.01em;
}
.hero p {
  font-size: 17px; color: var(--text-soft); line-height: 1.6;
  margin: 22px auto 0; max-width: 540px;
}

.card {
  max-width: 620px;
  margin: 42px auto 0;
  background: rgba(255, 255, 255, .035);
  border: 1px solid rgba(231, 200, 135, .22);
  border-radius: 20px;
  padding: clamp(26px, 5vw, 36px) clamp(22px, 5vw, 40px);
  backdrop-filter: blur(4px);
}

.field { margin-bottom: 22px; }
.field-label {
  font-size: 11px; letter-spacing: .16em; text-transform: uppercase;
  color: var(--text-muted); font-weight: 600; margin-bottom: 9px; display: block;
}
.field input {
  width: 100%;
  background: rgba(255, 255, 255, .04);
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 12px;
  padding: 15px 18px;
  font-size: 17px; font-family: var(--sans);
  color: var(--text);
  transition: border-color .2s, box-shadow .2s;
}
.field input::placeholder { color: var(--text-faint); }
.field input:focus {
  outline: none;
  border-color: rgba(231, 200, 135, .55);
  box-shadow: 0 0 0 4px rgba(231, 200, 135, .1);
}
.field input.accent { border-color: rgba(231, 200, 135, .45); }
/* normalise the native date control on the dark theme */
.field input[type="date"] { color-scheme: dark; }
.field input.invalid { border-color: rgba(227, 169, 140, .7); }

.field-row { display: flex; gap: 18px; }
.field-row .field { flex: 1; margin-bottom: 22px; }
.field-row .field.grow { flex: 1.1; }

.segmented { display: flex; gap: 10px; }
.seg {
  flex: 1; text-align: center;
  background: rgba(255, 255, 255, .03);
  border: 1px solid rgba(255, 255, 255, .1);
  color: var(--text-soft);
  padding: 13px; border-radius: 11px;
  font-size: 14px; cursor: pointer;
  transition: background .2s, border-color .2s, color .2s;
}
.seg:hover { border-color: rgba(231, 200, 135, .35); }
.seg.is-on {
  background: rgba(231, 200, 135, .14);
  border-color: rgba(231, 200, 135, .5);
  color: var(--gold-bright); font-weight: 600;
}

.btn-primary {
  width: 100%;
  background: linear-gradient(180deg, var(--gold-bright), var(--gold-soft));
  color: var(--ink-on-gold);
  text-align: center; padding: 17px; border: none; border-radius: 13px;
  font-size: 16px; font-weight: 700; letter-spacing: .02em;
  font-family: var(--sans); cursor: pointer;
  box-shadow: 0 14px 30px -10px rgba(231, 200, 135, .5);
  transition: transform .15s, box-shadow .2s;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 18px 40px -10px rgba(231, 200, 135, .6); }
.btn-primary:active { transform: translateY(0); }
.form-note { text-align: center; font-size: 13px; color: var(--text-faint); margin-top: 16px; }
.form-error {
  color: var(--warn); font-size: 13px; text-align: center;
  margin-top: 14px; min-height: 16px;
}

/* ---- Result ------------------------------------------------------------ */
.result {
  max-width: 860px;
  margin: 0 auto;
  padding: 8px clamp(20px, 5vw, 56px) 72px;
}
.result-head { text-align: center; margin-bottom: 40px; }
.result-head .eyebrow { letter-spacing: .3em; }
.result-head h2 {
  font-family: var(--serif);
  font-size: clamp(36px, 6vw, 52px); font-weight: 500;
  color: var(--text); margin: 14px 0 0; letter-spacing: -.01em;
}
.result-head .sub { font-size: 15px; color: var(--text-soft); margin: 10px 0 0; }

.grid-caption {
  text-align: center; margin-bottom: 18px;
  font-family: var(--serif); font-style: italic; font-size: 22px; color: var(--gold-dim);
}

.lo-shu {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 14px; width: min(448px, 100%); margin: 0 auto;
}
.cell {
  position: relative; aspect-ratio: 1; border-radius: 15px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.cell .glyph { position: absolute; top: 9px; right: 11px; font-size: 14px; }
.cell .num {
  font-family: var(--serif); font-size: clamp(32px, 8vw, 44px);
  font-weight: 600; line-height: 1;
}
.cell .planet {
  font-size: 9px; letter-spacing: .12em; text-transform: uppercase; margin-top: 7px;
}
.cell.missing {
  border: 1px dashed rgba(255, 255, 255, .1);
  background: rgba(255, 255, 255, .012);
}
.cell.missing .glyph { color: var(--gold); opacity: .22; }
.cell.missing .num { color: rgba(255, 255, 255, .13); }
.cell.missing .planet { color: rgba(255, 255, 255, .22); }
.cell.present {
  border: 1px solid rgba(231, 200, 135, .4);
  background: rgba(231, 200, 135, .07);
}
.cell.present .glyph { color: var(--gold); opacity: .85; }
.cell.present .num { color: var(--gold-bright); }
.cell.present .planet { color: #9a92b0; }
.cell.repeated {
  border: 1px solid rgba(231, 200, 135, .55);
  background: rgba(231, 200, 135, .1);
  box-shadow: 0 0 26px -4px rgba(231, 200, 135, .4),
              inset 0 0 18px -8px rgba(231, 200, 135, .4);
}
.cell.repeated .glyph { color: var(--gold-bright); }
.cell.repeated .num { color: var(--gold-glow); font-weight: 700; letter-spacing: .04em; }
.cell.repeated .planet { color: var(--gold-dim); }

.chips { display: flex; justify-content: center; flex-wrap: wrap; gap: 12px; margin-top: 24px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 13px; padding: 8px 16px; border-radius: 30px;
}
.chip.gold {
  color: var(--gold-bright);
  background: rgba(231, 200, 135, .1);
  border: 1px solid rgba(231, 200, 135, .35);
}
.chip.plain {
  color: var(--text-soft);
  background: rgba(255, 255, 255, .04);
  border: 1px solid rgba(255, 255, 255, .1);
}

.cores {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 16px; margin-top: 46px;
}
.core {
  background: rgba(255, 255, 255, .035);
  border: 1px solid rgba(231, 200, 135, .2);
  border-radius: 15px; padding: 22px 20px; text-align: center;
}
.core .core-label {
  font-size: 10px; letter-spacing: .16em; text-transform: uppercase;
  color: var(--text-muted); font-weight: 600;
}
.core .core-num {
  font-family: var(--serif); font-size: 54px; font-weight: 600;
  color: var(--gold-bright); line-height: 1; margin: 8px 0;
}
.core .core-planet { font-size: 13px; color: var(--gold-dim); }
.core.neutral { border-color: rgba(255, 255, 255, .1); }
.core.neutral .core-num { color: var(--text); }
.core.neutral .core-planet { color: var(--text-soft); }
.tag {
  margin-top: 8px; font-size: 10px; border-radius: 20px;
  padding: 3px 10px; display: inline-block;
}
.tag.challenging { color: var(--warn); background: rgba(227, 169, 140, .12); border: 1px solid rgba(227, 169, 140, .3); }
.tag.supportive { color: #9fd6b0; background: rgba(120, 200, 150, .1); border: 1px solid rgba(120, 200, 150, .3); }
.tag.neutral { color: var(--text-soft); background: rgba(255, 255, 255, .05); border: 1px solid rgba(255, 255, 255, .12); }

.readings { margin-top: 44px; display: flex; flex-direction: column; gap: 20px; }
.reading {
  display: flex; gap: 20px; align-items: flex-start;
  border-top: 1px solid var(--line); padding-top: 24px;
}
.reading .r-glyph {
  font-family: var(--serif); font-size: 34px; color: var(--gold);
  line-height: 1; min-width: 54px; text-align: center;
}
.reading h3 {
  font-family: var(--serif); font-size: 24px; font-weight: 600;
  color: var(--text); margin: 0 0 6px;
}
.reading p { font-size: 15px; line-height: 1.65; color: var(--text-soft); margin: 0; }

.lucky {
  margin-top: 34px;
  background: rgba(255, 255, 255, .03);
  border: 1px solid rgba(231, 200, 135, .18);
  border-radius: 15px; padding: 20px 26px;
  display: flex; flex-wrap: wrap; gap: 22px 44px; align-items: center;
}
.lucky .lucky-title { font-family: var(--serif); font-style: italic; font-size: 18px; color: var(--gold-dim); }
.lucky .lucky-item span.k {
  font-size: 10px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--text-muted); display: block; margin-bottom: 3px;
}
.lucky .lucky-item span.v { font-size: 15px; color: var(--text); }
.lucky .lucky-item span.v.gold { color: var(--gold-bright); }

.actions { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 32px; }
.actions button {
  flex: 1; min-width: 160px; text-align: center; padding: 15px;
  border-radius: 12px; font-size: 15px; font-family: var(--sans);
  cursor: pointer; transition: transform .15s, box-shadow .2s, background .2s;
}
.actions button:active { transform: translateY(1px); }
.act-primary {
  background: linear-gradient(180deg, var(--gold-bright), var(--gold-soft));
  color: var(--ink-on-gold); border: none; font-weight: 700;
}
.act-secondary {
  background: rgba(255, 255, 255, .04);
  border: 1px solid rgba(231, 200, 135, .35);
  color: var(--gold-bright); font-weight: 600;
}
.act-tertiary {
  background: rgba(255, 255, 255, .04);
  border: 1px solid rgba(255, 255, 255, .12);
  color: #c9c4dc;
}
.actions button:hover { box-shadow: 0 12px 28px -14px rgba(231, 200, 135, .5); }

.back-link {
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--text-soft); font-size: 14px; margin-bottom: 8px; cursor: pointer;
}
.back-link:hover { color: var(--gold-bright); }

/* ---- History ----------------------------------------------------------- */
#history-list { display: flex; flex-direction: column; gap: 12px; margin-top: 8px; }
.history-item {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
  width: 100%; text-align: left; cursor: pointer;
  background: rgba(255, 255, 255, .035);
  border: 1px solid rgba(231, 200, 135, .2);
  border-radius: 14px; padding: 18px 22px;
  font-family: var(--sans);
  transition: border-color .2s, background .2s, transform .15s;
}
.history-item:hover {
  border-color: rgba(231, 200, 135, .5);
  background: rgba(231, 200, 135, .07);
  transform: translateY(-2px);
}
.history-item .hi-name { font-family: var(--serif); font-size: 22px; color: var(--gold-bright); }
.history-item .hi-meta { font-size: 13px; color: var(--text-soft); }
.history-empty { color: var(--text-muted); font-size: 15px; text-align: center; padding: 30px 0; }

/* ---- Toast ------------------------------------------------------------- */
.toast {
  position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%) translateY(20px);
  background: rgba(20, 16, 40, .92);
  border: 1px solid rgba(231, 200, 135, .4);
  color: var(--gold-bright);
  padding: 12px 22px; border-radius: 30px; font-size: 14px;
  backdrop-filter: blur(8px);
  opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s;
  z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.footer {
  text-align: center; color: var(--text-faint); font-size: 12px;
  padding: 20px; max-width: 1100px; margin: 0 auto;
}

/* ---- Nav: signed-in state --------------------------------------------- */
.nav-user { display: inline-flex; align-items: center; gap: 16px; }
/* The display rule above would otherwise override the [hidden] attribute the
   JS toggles, leaving "Sign out" visible while logged out. */
.nav-user[hidden] { display: none; }
.nav-user-name { color: var(--gold-bright); font-weight: 600; }
.nav-user #nav-signout { color: var(--text-soft); }
.nav-user #nav-signout:hover { color: var(--gold-bright); }

/* ---- Info sections (How it works / Numbers) --------------------------- */
.info-section { max-width: 880px; margin: 86px auto 0; padding: 0 clamp(20px, 5vw, 24px); scroll-margin-top: 90px; }
.info-head { text-align: center; margin-bottom: 34px; }
.info-title {
  font-family: var(--serif); font-weight: 500; letter-spacing: -.01em;
  font-size: clamp(28px, 5vw, 40px); color: var(--text); margin: 14px 0 0;
}
.info-sub { font-size: 16px; color: var(--text-soft); line-height: 1.6; margin: 14px auto 0; max-width: 480px; }

.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.step {
  background: rgba(255, 255, 255, .035);
  border: 1px solid rgba(231, 200, 135, .2);
  border-radius: 16px; padding: 28px 24px;
}
.step-num {
  width: 38px; height: 38px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--serif); font-size: 20px; font-weight: 600;
  color: var(--gold-bright);
  border: 1px solid rgba(231, 200, 135, .45);
  background: rgba(231, 200, 135, .1);
  margin-bottom: 16px;
}
.step h3 { font-family: var(--serif); font-size: 22px; font-weight: 600; color: var(--text); margin: 0 0 8px; }
.step p { font-size: 14px; line-height: 1.6; color: var(--text-soft); margin: 0; }

.num-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.num-card {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  background: rgba(255, 255, 255, .03);
  border: 1px solid rgba(231, 200, 135, .18);
  border-radius: 14px; padding: 26px 14px 22px;
  transition: border-color .2s, background .2s, transform .15s;
}
.num-card:hover {
  border-color: rgba(231, 200, 135, .45);
  background: rgba(231, 200, 135, .07);
  transform: translateY(-2px);
}
/* The sign sits in a circular gold medallion — larger and clearer. */
.num-glyph {
  width: 66px; height: 66px; padding: 15px; margin-bottom: 14px;
  color: var(--gold);
  border: 1px solid rgba(231, 200, 135, .32);
  border-radius: 50%;
  background: rgba(231, 200, 135, .06);
  transition: color .2s, border-color .2s, background .2s;
}
.num-card:hover .num-glyph {
  color: var(--gold-bright);
  border-color: rgba(231, 200, 135, .6);
  background: rgba(231, 200, 135, .12);
}
.num-n { font-family: var(--serif); font-size: 34px; font-weight: 600; color: var(--gold-bright); line-height: 1.1; }
.num-planet { font-size: 13px; color: var(--gold-dim); margin-top: 2px; }
.num-trait { font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--text-muted); margin-top: 6px; }

/* ---- Modal (auth) ------------------------------------------------------ */
body.modal-open { overflow: hidden; }
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(5, 6, 16, .72); backdrop-filter: blur(4px); }
.modal-card {
  position: relative; z-index: 1;
  width: min(440px, 100%);
  background: linear-gradient(180deg, rgba(20, 18, 42, .96), rgba(12, 11, 28, .96));
  border: 1px solid rgba(231, 200, 135, .3);
  border-radius: 20px; padding: clamp(26px, 5vw, 38px);
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .7);
  animation: rise .35s ease both;
}
.modal-close {
  position: absolute; top: 16px; right: 18px;
  background: none; border: none; color: var(--text-muted);
  font-size: 26px; line-height: 1; cursor: pointer; transition: color .2s;
}
.modal-close:hover { color: var(--gold-bright); }
.modal-title { font-family: var(--serif); font-weight: 500; font-size: 30px; color: var(--text); margin: 12px 0 24px; }
.modal-card .field { margin-bottom: 18px; }
.modal-card .btn-primary { margin-top: 6px; }
.auth-switch { text-align: center; font-size: 14px; color: var(--text-soft); margin-top: 20px; }
.auth-switch a { color: var(--gold-bright); margin-left: 6px; }
.auth-switch a:hover { text-decoration: underline; }

/* ---- Responsive -------------------------------------------------------- */
@media (max-width: 720px) {
  .nav-links { gap: 16px; }
  /* Hide the in-page scroll links on mobile; keep the auth controls reachable. */
  .nav-links a[data-scroll] { display: none; }
  .cores { grid-template-columns: repeat(2, 1fr); }
  .field-row { flex-direction: column; gap: 0; }
  .steps { grid-template-columns: 1fr; }
  .info-section { margin-top: 64px; }
}

/* ---- Print (PDF report) ------------------------------------------------ */
@media print {
  body { background: #0a0b1a; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .nav, .actions, .back-link, .toast, .footer, .modal { display: none !important; }
  .view { display: none !important; }
  #view-result.is-active { display: block !important; }
}
