/* ============================================================================
 * panels.css — three-panel swipeable layout
 *
 * Sits on top of style.css. Restructures the page from a single vertical
 * scroll into three side-by-side panels:
 *   - LEFT   : Pie chart · Bibliography · Auto-cast note · Footer
 *   - MIDDLE : Cast (Ask anything) · Reading                    [default]
 *   - RIGHT  : Recurring Energy · Journal
 *
 * Viewport-size behaviour:
 *   <900px  : full swipe mode (track translates X to switch panels)
 *   900–1399: middle + right side-by-side; left below, full width
 *   ≥1400px : all three columns side-by-side, no swipe
 * ========================================================================== */

/* ============================================================================
 * Root layout: lock the body to viewport height in swipe mode so each panel
 * scrolls independently. The header is sticky inside this flex column.
 * ========================================================================== */
html, body {
  height: 100%;
  margin: 0;
}
body.panels-app {
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.topbar.panels-topbar {
  position: relative;   /* override sticky — flex column handles placement */
  flex-shrink: 0;
}

/* ============================================================================
 * Persistent dot indicator. Now sits inline under the brand tagline ("NOTHING
 * IS RANDOM.") so it's part of the masthead rather than a separate row.
 * The legacy standalone .panel-dots styling is kept below for safety, but
 * .panel-dots-inline strips the row chrome (background, border, padding) so
 * it tucks tight against the tagline.
 * ========================================================================== */
.panel-dots {
  flex-shrink: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 14px;
  padding: 6px 0 8px 0;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  z-index: 9;
}
.panel-dots-inline {
  padding: 4px 0 0 0;
  background: transparent;
  border-bottom: none;
  gap: 12px;
  z-index: auto;
}
.panel-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  border: 1px solid var(--muted);
  background: transparent;
  padding: 0;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.2s;
  position: relative;
}
.panel-dot::before {
  /* enlarged hit target without enlarging the visual */
  content: '';
  position: absolute;
  inset: -10px;
}
.panel-dot.is-active {
  background: var(--gold);
  border-color: var(--gold);
  transform: scale(1.25);
}
.panel-dot:hover { border-color: var(--text); }
.panel-dot-label {
  font-size: calc(10px * var(--text-scale));
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-family: var(--vogue);
  font-weight: 700;
  margin: 0 4px;
}
.panel-dot-label.is-active { color: var(--gold); }
@media (max-width: 480px) {
  /* On the smallest screens hide the text labels — dots alone are enough. */
  .panel-dot-label { display: none; }
}

/* ============================================================================
 * Panels viewport: the swipeable area.
 * .panels-track holds three panels at 100% width each, translateX selects.
 * ========================================================================== */
.panels-viewport {
  flex: 1;
  position: relative;
  overflow: hidden;
  /* Prevent two-finger horizontal trackpad gestures on macOS from triggering
   * back-navigation while inside the viewport. */
  overscroll-behavior-x: contain;
}

.panels-track {
  display: flex;
  width: 300%;
  height: 100%;
  transform: translate3d(0, 0, 0);
  transition: transform 0.32s cubic-bezier(0.22, 0.61, 0.36, 1);
  will-change: transform;
}
.panels-track.no-transition { transition: none; }
.panels-track.is-dragging { transition: none; }

.panel {
  width: calc(100% / 3);    /* one-third of 300% = one viewport width */
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;       /* 2026-06: prevent enlarged text from turning the
                             * panel into a horizontal-scroll container that
                             * swallows the swipe gesture. Without an explicit
                             * value, overflow-y:auto forces computed
                             * overflow-x to `auto`, which captured the drag
                             * after the first swipe at the largest text size. */
  overscroll-behavior: contain;
  /* touch-action: pan-y allows iOS WKWebView to handle vertical scroll
   * natively while leaving horizontal gestures available for our JS
   * pointer-event swipe handler on .panels-viewport. Without this, on iOS
   * the browser would treat the gesture as ambiguous and swallow the
   * horizontal motion into native scroll arbitration, making swipes feel
   * unreliable. */
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
  padding: 0 0 20px 0;
}
.panel > .wrap {
  padding-top: 4px;
}
.panel > .wrap > .card:first-child { margin-top: 0; }

/* The card max-width inside panels is narrower than the original site (which
 * had 1100px) because each panel is one viewport wide and we want a single
 * column of content. */
.panel .wrap {
  max-width: 720px;
  margin: 0 auto;
  padding-left: 18px;
  padding-right: 18px;
}

/* ============================================================================
 * Swipe strip: legacy invisible overlay. Now neutralised — gesture listeners
 * live on .panels-viewport itself (see panels.js). The strip is kept in the
 * DOM for backwards compatibility but is fully transparent to pointer events
 * so it doesn't eat clicks on buttons in the cast card.
 * ========================================================================== */
.swipe-strip {
  position: absolute;
  top: 0;
  left: 20%;
  width: 60%;
  height: 100%;
  z-index: 5;
  pointer-events: none;
  background: transparent;
}
.swipe-strip.passthrough {
  pointer-events: none;
}

/* ============================================================================
 * Swipe hint overlay: dark scrim + finger + curved arrows. Plays on load
 * up to 6 times across visits; persistent replay button.
 * ========================================================================== */
.swipe-hint {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.42);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.swipe-hint.is-showing {
  opacity: 1;
  pointer-events: auto;
}

.swipe-hint-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  color: #fff;
  text-align: center;
  user-select: none;
  -webkit-user-select: none;
}
.swipe-hint-graphic {
  width: 180px;
  height: 120px;
  position: relative;
}
.swipe-hint-graphic .arrow-left,
.swipe-hint-graphic .arrow-right {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 38px;
  height: 38px;
  color: rgba(255, 255, 255, 0.9);
}
.swipe-hint-graphic .arrow-left  { left: 0; }
.swipe-hint-graphic .arrow-right { right: 0; }

.swipe-hint-graphic .finger {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 72px;
  height: 72px;
  color: #fff;
  animation: swipe-finger 2.2s ease-in-out infinite;
}
@keyframes swipe-finger {
  0%   { transform: translate(-50%, -50%) translateX(-26px) rotate(-6deg); }
  25%  { transform: translate(-50%, -50%) translateX( 0px)  rotate( 0deg); }
  50%  { transform: translate(-50%, -50%) translateX( 26px) rotate( 6deg); }
  75%  { transform: translate(-50%, -50%) translateX( 0px)  rotate( 0deg); }
  100% { transform: translate(-50%, -50%) translateX(-26px) rotate(-6deg); }
}
.swipe-hint-graphic .arrow-left  { animation: swipe-arrow-l 2.2s ease-in-out infinite; }
.swipe-hint-graphic .arrow-right { animation: swipe-arrow-r 2.2s ease-in-out infinite; }
@keyframes swipe-arrow-l {
  0%, 100% { opacity: 0.4; transform: translateY(-50%) translateX(0); }
  50%      { opacity: 1.0; transform: translateY(-50%) translateX(-6px); }
}
@keyframes swipe-arrow-r {
  0%, 100% { opacity: 0.4; transform: translateY(-50%) translateX(0); }
  50%      { opacity: 1.0; transform: translateY(-50%) translateX(6px); }
}

.swipe-hint-label {
  font-family: var(--vogue);
  font-style: italic;
  font-size: calc(18px * var(--text-scale));
  letter-spacing: 0.06em;
}
.swipe-hint-sublabel {
  font-family: var(--sans);
  font-size: calc(12px * var(--text-scale));
  color: rgba(255, 255, 255, 0.7);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* "or tap dots" — secondary affordance shown below the swipe finger graphic
 * in the same overlay. Tells users they can navigate by tapping the dot
 * indicator at the top of the page if swipes aren't working for them
 * (cracked screen, gloves, moisture, etc.). */
.swipe-hint-or {
  font-family: var(--vogue);
  font-style: italic;
  font-size: calc(14px * var(--text-scale));
  color: rgba(255, 255, 255, 0.5);
  letter-spacing: 0.08em;
  margin-top: 4px;
}
.swipe-hint-dots-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 28px;          /* widen so the bigger dots have breathing room */
  margin-top: 6px;
  /* Reserve vertical room so the absolutely-positioned finger glyph
   * (which sits above the target dot) doesn't overlap the "or" label. */
  padding-top: 56px;
  position: relative;
}
.swipe-hint-dot {
  width: 18px;        /* up from 10px — far more obvious affordance */
  height: 18px;
  border-radius: 50%;
  background: transparent;
  border: 2px solid rgba(255, 255, 255, 0.85);
  position: relative;
}
.swipe-hint-dot.is-target {
  background: var(--gold);
  border-color: var(--gold);
  width: 22px;        /* and the target dot a bit bigger again */
  height: 22px;
  box-shadow: 0 0 0 0 rgba(201, 162, 39, 0.5);
  animation: swipe-hint-dot-pulse 1.6s ease-out infinite;
}
@keyframes swipe-hint-dot-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(201, 162, 39, 0.55); }
  70%  { box-shadow: 0 0 0 14px rgba(201, 162, 39, 0); }
  100% { box-shadow: 0 0 0 0 rgba(201, 162, 39, 0); }
}

/* Finger glyph hovering above the target dot. The finger animates
 * downward to "tap" the dot, then lifts back up. Loop matches the
 * ripple cycle below for a coherent rhythm. */
.swipe-hint-finger {
  position: absolute;
  left: 50%;
  bottom: 28px;       /* clears the dot underneath */
  width: 44px;
  height: 56px;
  transform: translateX(-50%);
  /* drop shadow gives the finger 3D pop against the dark overlay */
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4));
  animation: swipe-hint-finger-tap 1.6s ease-in-out infinite;
  z-index: 2;
}
@keyframes swipe-hint-finger-tap {
  0%, 100% { transform: translateX(-50%) translateY(-6px); }
  35%      { transform: translateX(-50%) translateY(2px); }
  55%      { transform: translateX(-50%) translateY(2px); }
}

/* Concentric ripples centred on the target dot. Three rings stagger their
 * expansion so the effect feels like a continuous ripple, not three blips.
 * Sits behind the finger via z-index: 1. */
.swipe-hint-tap {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 80px;
  height: 80px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 1;
}
.swipe-hint-tap .ripple {
  opacity: 0;
  transform-origin: 40px 40px;
  animation: swipe-hint-ripple 1.6s ease-out infinite;
}
.swipe-hint-tap .ripple-2 { animation-delay: 0.2s; }
.swipe-hint-tap .ripple-3 { animation-delay: 0.4s; }
@keyframes swipe-hint-ripple {
  0%   { opacity: 0.0; transform: scale(0.55); }
  20%  { opacity: 0.7; }
  100% { opacity: 0.0; transform: scale(1.4); }
}

/* While the hint is on screen, the panels-track nudges in sync — pattern #3
 * from the brief. We add a class to the track during hint play that runs a
 * matching keyframe. Slide distance tripled again (36→108px) per 2026-05
 * round 2 — the previous 36px nudge still wasn't reading as "there's more
 * either side" to first-time visitors. ~108px is roughly 28% of a 380px
 * viewport, big enough that the next-panel's first card is partially
 * visible through the peek. */
.panels-track.hint-nudge {
  animation: panels-nudge 2.2s ease-in-out infinite;
}
@keyframes panels-nudge {
  0%, 100% { transform: translate3d(calc(-100% / 3 + -108px), 0, 0); }
  50%      { transform: translate3d(calc(-100% / 3 +  108px), 0, 0); }
}

/* Replay button — small, persistent, bottom-left so it doesn't clash with
 * the existing scroll-top FAB at bottom-right. */
.swipe-hint-replay {
  position: fixed;
  left: 14px;
  bottom: 14px;
  z-index: 50;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  font-family: var(--sans);
  font-size: calc(14px * var(--text-scale));
  transition: color 0.15s, border-color 0.15s, transform 0.15s;
}
.swipe-hint-replay:hover {
  color: var(--text);
  border-color: var(--text);
  transform: scale(1.05);
}
.swipe-hint-replay svg { width: 16px; height: 16px; }
/* Hide replay button on desktop where all three columns are visible. */
@media (min-width: 1400px) {
  .swipe-hint-replay { display: none; }
  .swipe-strip { display: none; }
}

/* ============================================================================
 * Desktop ≥1400px: all three columns visible at once. The .panels-track
 * stops translating; we lay panels out in a CSS grid and disable swipe.
 * ========================================================================== */
@media (min-width: 1400px) {
  body.panels-app {
    overflow: auto;
  }
  .panels-viewport {
    overflow: visible;
    height: auto;
  }
  .panels-track {
    display: grid;
    grid-template-columns: 1fr 1.1fr 1fr;
    gap: 20px;
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 20px;
    transform: none !important;
    animation: none !important;
  }
  .panel {
    width: auto;
    height: auto;
    overflow-y: visible;
    padding: 0;
  }
  .panel .wrap {
    max-width: none;
    padding-left: 0;
    padding-right: 0;
  }
  .panel-dots {
    /* Dots stay visible per spec (item 6: "yes, it never turns off") but
     * we can simplify their role on desktop — clicks scroll the relevant
     * panel into view since all are visible. */
    display: flex;
  }
}

/* ============================================================================
 * Mid-range desktop 900–1399px: middle + right side-by-side; left below.
 * Swipe still disabled here; we use vertical scroll of the body.
 * ========================================================================== */
@media (min-width: 900px) and (max-width: 1399.98px) {
  body.panels-app {
    overflow: auto;
  }
  .panels-viewport {
    overflow: visible;
    height: auto;
  }
  .panels-track {
    display: grid;
    grid-template-columns: 1.1fr 1fr;
    grid-template-areas:
      "middle right"
      "left   left";
    gap: 20px;
    width: 100%;
    max-width: 1300px;
    margin: 0 auto;
    padding: 0 20px;
    transform: none !important;
    animation: none !important;
  }
  .panel[data-panel="left"]   { grid-area: left; }
  .panel[data-panel="middle"] { grid-area: middle; }
  .panel[data-panel="right"]  { grid-area: right; }
  .panel {
    width: auto;
    height: auto;
    overflow-y: visible;
    padding: 0;
  }
  .panel .wrap {
    max-width: none;
    padding-left: 0;
    padding-right: 0;
  }
  /* Hide swipe affordances on this breakpoint; everything is visible. */
  .swipe-strip,
  .swipe-hint-replay,
  .swipe-hint { display: none !important; }
  .panel-dots { display: none; }
}

/* ============================================================================
 * Small overrides on the existing cards so they sit comfortably inside
 * the narrower panel column width.
 * ========================================================================== */

/* The result-head was designed against a ~1000px-wide card and uses a 60/40
 * grid with 256px right-padding on the aliases column to clear an absolutely-
 * positioned category pill. Inside a panel the card is at most ~720px wide
 * (and as narrow as ~440px on a 3-col desktop), so that padding eats almost
 * the entire aliases column and "Also known as: ..." wraps one word per line.
 * Force the single-column layout everywhere inside .panels-app and let the
 * cat pill sit inline (the same way it does on mobile <=720px). */
body.panels-app #resultHeader.result-head {
  grid-template-columns: 1fr;
  gap: 8px;
}
body.panels-app #resultHeader .result-col-aliases {
  padding-right: 0;
}
body.panels-app .primary-cat-pill {
  /* Float the category tile at the top-right corner of the result card,
   * taking no flow space so "PRIMARY HEXAGRAM" stays at the top of the
   * card. resultCard already has position:relative so the pill anchors
   * to its corner. Result-col-primary gets a right-pad below to reserve
   * room so long hex titles don't collide with the pill. */
  position: absolute;
  top: 12px;
  right: 14px;
  display: block;
  width: fit-content;
  margin: 0;
  max-width: 45%;
}
body.panels-app #resultHeader .result-col-primary {
  padding-right: 96px;
}

@media (max-width: 899.98px) {
  /* In swipe mode, the leaderboard's category dropdown should anchor sensibly
   * inside the narrower column. */
  .lb-cat-menu { right: 0; left: auto; }
}

/* ============================================================================
 * Empty-state hint shown on the Ask panel before the first cast. Sits in
 * the gap between the cast card and (where the) result card (will be). Disappears once
 * the user has cast at least once; reappears via "Start new reading".
 * ========================================================================== */
.cast-empty-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 18px auto 6px auto;
  padding: 10px 14px;
  color: var(--gold);
  font-family: inherit;
  font-weight: 600;
  font-size: calc(13px * var(--text-scale));
  letter-spacing: 0.02em;
  opacity: 0.95;
  pointer-events: none;
}
.cast-empty-hint svg {
  width: 14px;
  height: 14px;
  flex: 0 0 14px;
  animation: cast-empty-hint-bob 2.4s ease-in-out infinite;
}
@keyframes cast-empty-hint-bob {
  0%, 100% { transform: translateY(0); opacity: 0.5; }
  50%      { transform: translateY(3px); opacity: 1; }
}
body.panels-app .topbar { position: relative; }

/* ============================================================================
 * Left-panel controls (2026-05 round 3): legacy block REMOVED.
 * ----------------------------------------------------------------------------
 * Earlier versions of this file held the .left-panel-controls / lang-stack /
 * theme-switch / .pie-controls-right / .bib-actions rules, but those have
 * since been re-authored in style.css with the right typography (serif label
 * matching .pie-heading), aria-checked-driven switch state (so the theme
 * toggle and hide-banner toggle don't share visual state), right-aligned
 * 5×2 flag grid with JP/RU in the right column, and the standalone
 * bib-actions-standalone row outside the bibliography card. The legacy block
 * here was loading AFTER style.css and silently overriding all of those
 * fixes — that's the source of the "wonky" appearance the user kept
 * reporting. See style.css for the canonical rules.
 * ========================================================================== */

/* Defensive: iOS Safari / Android Chrome can still auto-link long digit
 * sequences in body text even with the format-detection meta tag (the meta
 * applies to phone numbers but UAs occasionally promote year ranges anyway).
 * Force any auto-detected anchor inside the bibliography back to the
 * surrounding text colour so "1000–750 BCE", "1130–1200" etc don't read as
 * broken blue links in dark mode. */
.bibliography a[href^="tel:"],
.bibliography a[x-apple-data-detectors] {
  color: inherit !important;
  text-decoration: none !important;
  pointer-events: none;
  cursor: default;
}

/* In swipe mode, the floating scroll-top button should attach to the
 * currently-active panel rather than the page. We keep the original CSS but
 * tweak the offset so it doesn't collide with the replay button. */
@media (max-width: 1399.98px) {
  .scroll-top-btn {
    /* unchanged from style.css default */
  }
}
