/* ==========================================================================
   FateHalo — reading tools
   Styles for the three guided reading pages: Astrology, Tarot, Chinese
   Divination. Loaded only by services.html, astrology.html, tarot.html and
   bazi.html, after style.css. Reuses the tokens defined in style.css.
   ========================================================================== */

/* ---------------------------------------------------------- 3-up step strip */
.steps--3 { grid-template-columns: repeat(3, 1fr); }

/* ------------------------------------------------------------- choice cards */
.choices {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(3, 1fr);
  margin: 0;
  padding: 0;
  border: 0;
}
.choices--2 { grid-template-columns: repeat(2, 1fr); }

.choice {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 26px 24px 24px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.3s var(--ease), box-shadow 0.3s var(--ease),
              transform 0.3s var(--ease);
}
.choice:hover { border-color: var(--gold-500); transform: translateY(-2px); }
.choice input { position: absolute; opacity: 0; width: 0; height: 0; }

.choice__tick {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 22px;
  height: 22px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  display: grid;
  place-items: center;
  transition: background 0.24s var(--ease), border-color 0.24s var(--ease);
}
.choice__tick svg { width: 12px; height: 12px; color: #fff; opacity: 0; transition: opacity 0.24s var(--ease); }

.choice__num {
  font-family: var(--font-display);
  font-size: 1.5rem;
  line-height: 1;
  color: var(--gold-500);
  margin-bottom: 12px;
}
.choice__name {
  font-family: var(--font-display);
  font-size: 1.32rem;
  font-weight: 500;
  color: var(--ink);
  margin: 0 0 6px;
}
.choice__meta {
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 12px;
}
.choice__desc { font-size: 0.9rem; color: var(--ink-soft); margin: 0; }

.choice:has(input:checked) { border-color: var(--gold-600); box-shadow: var(--shadow-md); }
.choice:has(input:checked) .choice__tick { background: var(--gold-600); border-color: var(--gold-600); }
.choice:has(input:checked) .choice__tick svg { opacity: 1; }
.choice:has(input:focus-visible) { outline: 2px solid var(--gold-500); outline-offset: 3px; }

/* JS fallback for browsers without :has() — readings.js mirrors the checked state */
.choice.is-checked { border-color: var(--gold-600); box-shadow: var(--shadow-md); }
.choice.is-checked .choice__tick { background: var(--gold-600); border-color: var(--gold-600); }
.choice.is-checked .choice__tick svg { opacity: 1; }

/* ------------------------------------------------------- instant readout box */
.readout {
  display: grid;
  gap: 18px;
  padding: 22px 24px;
  background: var(--gold-050);
  border: 1px solid rgba(201, 164, 76, 0.42);
  border-radius: var(--radius-sm);
}
.readout[hidden] { display: none; }
.readout__head {
  font-size: 0.7rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold-600);
}
.readout__grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.readout__item { display: grid; gap: 4px; }
.readout__k { font-size: 0.68rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); }
.readout__v { font-family: var(--font-display); font-size: 1.24rem; font-weight: 500; color: var(--ink); }
.readout__note { font-size: 0.8rem; color: var(--muted); margin: 0; }

/* ------------------------------------------------------------- inline notice */
.notice {
  display: none;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 18px;
  border: 1px solid rgba(169, 134, 58, 0.45);
  border-radius: var(--radius-sm);
  background: var(--gold-050);
  font-size: 0.9rem;
  color: var(--ink-soft);
}
.notice.is-visible { display: flex; }
.notice svg { flex: 0 0 auto; width: 16px; height: 16px; margin-top: 2px; color: var(--gold-600); }

/* ---------------------------------------------------------------- draw panel */
/* .card sets height:100% so equal-height cards line up inside a grid. The draw
   panel lives inside the stepped tool form (.form is a grid) and grows when a
   spread is dealt — inheriting height:100% there stretches it past its own
   content box, and it bleeds down over the next step's heading. It must hug
   its content instead. */
.drawpanel {
  height: auto;
  min-height: 0;
  background: var(--navy-900);
  border-color: transparent;
  padding: clamp(24px, 3vw, 38px);
}
.drawpanel:hover { transform: none; box-shadow: none; border-color: transparent; }

.drawbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px 20px;
  margin-bottom: 30px;
}
.drawbar__hint { font-size: 0.875rem; color: rgba(255, 255, 255, 0.6); margin: 0; }

/* ------------------------------------------------- card tiles (the spread tray) */
.spread {
  list-style: none;
  margin: 0 0 34px;
  padding: 0;
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
}
.spread[hidden] { display: none; }

/* The Celtic Cross is one figure, not a row of tiles: it spans the whole tray,
   centres, and shrinks with the column. */
.spread .tarot-cross {
  grid-column: 1 / -1;
  justify-self: center;
  display: block;
  max-width: 100%;
  height: auto;
}

.tc {
  display: grid;
  gap: 9px;
  align-content: start;
}
/* A single-card spread is still one card, not one card blown up to the width
   of the whole tray: cap it and centre it so it stays a card. */
.tc:only-child {
  max-width: 240px;
  justify-self: center;
  width: 100%;
}
.tc__pos {
  font-size: 0.63rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.52);
  min-height: 2.4em;
}
.tc__pos b { color: var(--gold-400); font-weight: 500; }

/* The tile is a card, not a plaque: the painted face fills the top, the
   lettering sits beneath it on the navy stock — the layout chatarot and the
   classical decks use. */
.tc__card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px 10px 14px;
  text-align: center;
  background: linear-gradient(158deg, var(--navy-700), var(--navy-900));
  border: 1px solid rgba(201, 164, 76, 0.55);
  border-radius: var(--radius);
  box-shadow: 0 18px 40px rgba(8, 13, 28, 0.35);
  animation: tcDeal 0.62s var(--ease) both;
  animation-delay: calc(var(--i, 0) * 110ms);
}
.tc__imgwrap {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 5;
  border-radius: calc(var(--radius) - 5px);
  overflow: hidden;
  background: rgba(8, 13, 28, 0.45);
}
.tc__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.tc__card.is-reversed .tc__img { transform: rotate(180deg); }
.tc__card::after {
  content: "";
  position: absolute;
  inset: 6px;
  border: 1px solid rgba(201, 164, 76, 0.22);
  border-radius: calc(var(--radius) - 3px);
  pointer-events: none;
}
.tc__num {
  font-family: var(--font-display);
  font-size: 0.86rem;
  letter-spacing: 0.2em;
  color: var(--gold-400);
}
.tc__name {
  font-family: var(--font-display);
  font-size: 1.12rem;
  font-weight: 500;
  line-height: 1.24;
  color: #fff;
}
.tc__suit { font-size: 1.05rem; color: var(--gold-400); letter-spacing: 0.1em; }
.tc__flag {
  font-size: 0.6rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.55);
}
.tc__card.is-reversed .tc__name { transform: rotate(180deg); }

@keyframes tcDeal {
  from { opacity: 0; transform: translateY(16px) rotateY(-16deg); }
  to   { opacity: 1; transform: none; }
}

/* ------------------------------------------------------ the floating deck */
/* 78 face-down cards adrift in a slow, shallow drift.  Placement and sway are
   separated: the button owns position (left/top plus a fixed tilt), the inner
   span owns the oscillation, so the flip can use the transform chain too. */
.deck-hint {
  margin: 0 0 18px;
  text-align: center;
  font-size: 0.92rem;
  color: rgba(255, 255, 255, 0.74);
}
.deck-hint b { color: var(--gold-400); font-weight: 500; }

.deck-fan {
  position: relative;
  height: clamp(340px, 46vw, 540px);
  margin-bottom: 34px;
  overflow-y: auto;
  overflow-x: hidden;
  border: 1px dashed rgba(217, 189, 114, 0.28);
  border-radius: var(--radius);
  background:
    radial-gradient(ellipse at 50% 38%, rgba(201, 164, 76, 0.08), transparent 62%),
    rgba(8, 13, 28, 0.35);
  scrollbar-width: thin;
  scrollbar-color: rgba(217, 189, 114, 0.35) transparent;
}
.deck-fan__cloud { position: relative; width: 100%; }

.deck-card {
  position: absolute;
  left: var(--x, 50%);
  top: var(--y, 50%);
  width: var(--cw, 56px);
  aspect-ratio: 3 / 5;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  transform: translate(-50%, -50%) rotate(var(--r, 0deg));
  perspective: 700px;
  -webkit-tap-highlight-color: transparent;
}
.deck-card:focus-visible {
  outline: 2px solid var(--gold-400);
  outline-offset: 3px;
  border-radius: 6px;
}
.deck-card__drift {
  display: block;
  width: 100%;
  height: 100%;
  animation: deckFloat var(--d, 8s) ease-in-out var(--dl, 0s) infinite alternate;
  will-change: transform;
}
.deck-card__flip {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.48s var(--ease);
}
.deck-card.is-picked .deck-card__flip { transform: rotateY(180deg); }

.deck-card__back,
.deck-card__face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 6px;
  overflow: hidden;
}
.deck-card__back {
  background: linear-gradient(158deg, var(--navy-700), var(--navy-900));
  border: 1px solid rgba(217, 189, 114, 0.5);
  box-shadow: 0 6px 16px rgba(8, 13, 28, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
}
.deck-card__back img {
  width: 84%;
  height: 90%;
  object-fit: cover;
  border-radius: 4px;
  opacity: 0.94;
}
.deck-card__face {
  transform: rotateY(180deg);
  background: linear-gradient(158deg, var(--navy-700), var(--navy-900));
  border: 1px solid rgba(217, 189, 114, 0.55);
  box-shadow: 0 8px 20px rgba(8, 13, 28, 0.5);
}
.deck-card__face img { width: 100%; height: 100%; object-fit: cover; display: block; }
.deck-card.is-reversed .deck-card__face img { transform: rotate(180deg); }

.deck-card.is-picked { cursor: default; z-index: 6; }
.deck-card.is-picked .deck-card__back {
  box-shadow: 0 0 0 2px var(--gold-400), 0 8px 20px rgba(8, 13, 28, 0.55);
}

@media (hover: hover) {
  .deck-card:not(.is-picked):hover { z-index: 8; }
  .deck-card:not(.is-picked):hover .deck-card__drift {
    animation: none;
    transform: scale(1.07);
    transition: transform 0.22s var(--ease);
  }
  .deck-card:not(.is-picked):hover .deck-card__back {
    box-shadow: 0 0 0 1px rgba(217, 189, 114, 0.75), 0 12px 26px rgba(8, 13, 28, 0.6);
  }
}

/* Once the spread is complete the untouched cards step back: still adrift,
   but dimmed and deaf to clicks. */
.deck-fan.is-done .deck-card { pointer-events: none; }
.deck-fan.is-done .deck-card:not(.is-picked) {
  opacity: 0.26;
  filter: grayscale(0.45);
}
.deck-fan.is-done .deck-card.is-picked { z-index: 6; }

@keyframes deckFloat {
  from { transform: translate3d(0, 0, 0) rotate(0deg); }
  to   { transform: translate3d(var(--dx, 5px), var(--dy, -10px), 0) rotate(var(--dr, 2.5deg)); }
}

/* The face sailing from the fan into its slot in the tray. */
.deck-ghost {
  position: fixed;
  z-index: 90;
  pointer-events: none;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid rgba(217, 189, 114, 0.55);
  box-shadow: 0 14px 34px rgba(8, 13, 28, 0.55);
}

@media (prefers-reduced-motion: reduce) {
  .deck-card__drift { animation: none; }
  .deck-card__flip { transition: none; }
  .tc__card { animation: none; }
}

/* ------------------------------------------------------------------ spread list */
.spreadlist { display: grid; gap: 16px; }
.spreadrow {
  display: grid;
  grid-template-columns: 46px 1fr auto;
  gap: 16px;
  align-items: baseline;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line-on-dark);
}
.spreadrow:last-child { border-bottom: 0; padding-bottom: 0; }
.spreadrow__n {
  font-family: var(--font-display);
  font-size: 1.2rem;
  color: var(--gold-400);
}
.spreadrow__label { color: rgba(255, 255, 255, 0.86); font-size: 0.95rem; }
.spreadrow__hint { color: rgba(255, 255, 255, 0.5); font-size: 0.82rem; text-align: right; }

/* ---------------------------------------------------- dark-section adjustments */
.section--navy .choice,
.section--dark .choice { background: rgba(255, 255, 255, 0.04); border-color: var(--line-on-dark); }
.section--navy .choice__name,
.section--dark .choice__name { color: #fff; }
.section--navy .choice__desc,
.section--dark .choice__desc { color: rgba(255, 255, 255, 0.66); }
.section--navy .choice__meta,
.section--dark .choice__meta { color: rgba(255, 255, 255, 0.5); }
.section--navy .choice__tick,
.section--dark .choice__tick { border-color: rgba(255, 255, 255, 0.28); }
.section--navy .choice:has(input:checked),
.section--dark .choice:has(input:checked) { border-color: var(--gold-400); background: rgba(201, 164, 76, 0.08); }
.section--navy .choice.is-checked,
.section--dark .choice.is-checked { border-color: var(--gold-400); background: rgba(201, 164, 76, 0.08); }

/* ---------------------------------------------------------- ledger / summary */
.ledger {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0;
  border-top: 1px solid var(--line);
}
.ledger li {
  display: grid;
  grid-template-columns: 190px 1fr;
  gap: 18px;
  padding: 14px 0;
  margin: 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.95rem;
}
.ledger__k {
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  padding-top: 3px;
}
.ledger__v { color: var(--ink); }
.ledger__v em { color: var(--muted); font-style: normal; }

/* ------------------------------------------------ place combobox (birth) */
/* The two birth-data forms suggest places from the offline index.  The list is
   drawn by the page rather than by a native <datalist> — a datalist is painted
   by the browser, so it cannot be styled, does not refresh while an IME
   composition is still open, and behaves differently in every engine. */
.combo { position: relative; }

.combo .input { padding-right: 46px; }

.combo__caret {
  position: absolute;
  top: 0;
  right: 4px;
  height: 100%;
  width: 40px;
  display: grid;
  place-items: center;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.26s var(--ease), transform 0.26s var(--ease);
}
.combo__caret svg { display: block; width: 13px; height: 8px; }
.combo.is-open .combo__caret { color: var(--gold-600); transform: rotate(180deg); }

.combo__list {
  position: absolute;
  z-index: 60;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  margin: 0;
  padding: 6px;
  list-style: none;
  max-height: min(330px, 48vh);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--paper);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}
.combo__list[hidden] { display: none; }

.combo__opt {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  line-height: 1.35;
  color: var(--ink);
  cursor: pointer;
}
.combo__opt b { font-weight: 500; color: var(--gold-600); }
.combo__zh { font-size: 0.88rem; color: var(--muted); }
.combo__cc {
  margin-left: auto;
  padding-left: 10px;
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}
.combo__opt.is-active { background: var(--gold-050); }
.combo__none {
  padding: 10px 12px;
  font-size: 0.84rem;
  color: var(--muted);
}

/* ------------------------------------------------------------- small helpers */
.toolnote {
  font-size: 0.82rem;
  color: var(--muted);
  margin: 10px 0 0;
}
.section--navy .toolnote,
.section--dark .toolnote { color: rgba(255, 255, 255, 0.55); }

.pathgrid { display: grid; gap: 24px; grid-template-columns: repeat(3, 1fr); }

.path { display: flex; flex-direction: column; }
.path__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}
.path__n {
  font-family: var(--font-display);
  font-size: 2rem;
  line-height: 1;
  color: var(--gold-500);
}
.path__tag {
  font-size: 0.65rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}
.path .check-list { margin-bottom: 22px; }
.path .btn { margin-top: auto; }

/* --------------------------------------------------------------- responsive */
@media (max-width: 1080px) {
  .readout__grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 980px) {
  .choices, .choices--2, .pathgrid, .steps--3 { grid-template-columns: 1fr; }
  .spreadrow { grid-template-columns: 34px 1fr; }
  .spreadrow__hint { grid-column: 2; text-align: left; }
  .ledger li { grid-template-columns: 1fr; gap: 4px; }
  .readout__grid { grid-template-columns: 1fr; }
}

@media (max-width: 680px) {
  .spread { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .tc__name { font-size: 1rem; }
  .choice { padding: 22px 20px; }
}
