/*
   Premium Zen & Warm Minimalism Aesthetic
   Design System for I Ching — Reflexión Local
   v2.0 — Matte Paper UI Edition
*/

:root {
  /* Warm Minimalism Palette */
  --ink-black: hsl(240, 6%, 12%);
  /* Soft off-black */
  --paper-white: hsl(42, 30%, 96%);
  /* Warm ivory / light stone */
  --paper-texture: hsl(42, 25%, 92%);
  /* Deeper ivory for contrast */
  --accent: hsl(156, 30%, 42%);
  /* Serene Muted Jade */
  --indigo: hsl(215, 30%, 35%);
  /* Quiet Slate Blue */
  --gold: hsl(38, 30%, 60%);
  /* Subdued earthy gold */

  /* Semantic Tokens */
  --bg: var(--paper-white);
  --text: var(--ink-black);
  --text-muted: hsla(240, 6%, 12%, 0.55);

  /* Opaque Surfaces (No glassmorphism) */
  --panel-bg: hsl(40, 35%, 98%);
  --panel-border: hsla(240, 6%, 12%, 0.08);
  /* Matte Depth: very short, diffuse, almost imperceptible */
  --panel-shadow: 0 4px 12px -2px hsla(240, 6%, 12%, 0.03), 0 1px 3px 0 hsla(240, 6%, 12%, 0.02);

  --accent-soft: hsla(156, 30%, 42%, 0.06);

  /* Typography */
  --font-serif: "Shippori Mincho", "Spectral", Cochin, Georgia, serif;
  /* Elegant display */
  --font-sans: "Outfit", system-ui, -apple-system, sans-serif;
  /* Clean body */

  --radius-lg: 24px;
  --radius-md: 12px;
  --radius-sm: 8px;

  --page-max-w: 920px;
  /* Slightly narrower for focus */

  /* Effects */
  --sumi-filter: url(#sumi-e-brush);
}

/* Dark Mode - Muted Fog / Ink */
:root[data-theme="ink"] {
  --bg: hsl(240, 8%, 10%);
  --text: hsl(42, 20%, 90%);
  --text-muted: hsla(42, 20%, 90%, 0.5);

  --panel-bg: hsl(240, 8%, 14%);
  --panel-border: hsla(42, 20%, 90%, 0.06);
  --panel-shadow: 0 4px 12px -2px hsla(0, 0%, 0%, 0.2), 0 1px 3px 0 hsla(0, 0%, 0%, 0.1);

  --accent: hsl(156, 25%, 55%);
  --accent-soft: hsla(156, 25%, 55%, 0.1);

  --paper-texture: hsl(240, 8%, 8%);
  --gold: hsl(38, 25%, 50%);
}

/* --- Base & Reset --- */
*,
*::before,
*::after {
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* --- Layout --- */
html {
  margin: 0;
  padding: 0;
  width: 100%;
  min-height: 100vh;
  overflow-x: hidden;
  /* Background on html ensures art-bg-layer (z-index:-2) is visible on iOS Safari */
  background: var(--bg);
  transition: background 0.8s cubic-bezier(0.25, 1, 0.5, 1);
}

body {
  margin: 0;
  padding: 0;
  width: 100%;
  min-height: 100vh;
  overflow-x: hidden;
  /* transparent so #art-bg-layer with z-index:-2 shows through on all browsers */
  background: transparent;
  color: var(--text);
  font-family: var(--font-sans);
  line-height: 1.7;
  transition: color 0.8s cubic-bezier(0.25, 1, 0.5, 1);
  font-size: clamp(16px, 1.05vw + 12px, 18px);
  -webkit-tap-highlight-color: transparent;
  /* better mobile feel */
}

/* --- Art Background Layer (ukiyo-e / sumi-e paintings) --- */
/* Use top/right/bottom/left instead of `inset` for broader mobile browser compatibility */
#art-bg-layer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: -2;
  overflow: hidden;
  /* Prevent iOS Safari rubber-band effect from leaving gaps */
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
}

#art-bg-layer img {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  opacity: 0;
  transition: opacity 2s cubic-bezier(0.25, 1, 0.5, 1);
  will-change: opacity;
}

/* Paper/ink overlay — keeps text readable over the painting */
#art-bg-overlay {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: -1;
  pointer-events: none;
  /* Light mode: warm ivory veil, 82% opacity */
  background: hsla(42, 25%, 96%, 0.83);
  transition: background 0.8s cubic-bezier(0.25, 1, 0.5, 1);
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
}

[data-theme="ink"] #art-bg-overlay {
  /* Dark mode: deep ink veil, 80% opacity */
  background: hsla(240, 8%, 10%, 0.80);
}

/* Attribution badge (bottom-right, barely visible) */
#art-bg-attr {
  position: fixed;
  bottom: 8px;
  right: 12px;
  z-index: 9998;
  font-size: 0.58rem;
  opacity: 0.22;
  font-family: var(--font-serif);
  color: var(--text);
  pointer-events: none;
  letter-spacing: 0.04em;
  max-width: 380px;
  text-align: right;
  line-height: 1.4;
  transition: opacity 0.4s ease;
}

#art-bg-attr:hover {
  opacity: 0.6;
  pointer-events: auto;
}

.app-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: clamp(16px, 4vw, 40px) 16px;
  align-items: center;
  overflow-x: hidden;
  /* Strict no horizontal scroll */
}

.content-wrapper {
  width: 100%;
  max-width: var(--page-max-w);
  z-index: 5;
}

/* --- Typography --- */
a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid hsla(156, 30%, 42%, 0.2);
  transition: all 0.3s ease;
}

a:hover {
  color: hsl(156, 30%, 32%);
  border-bottom-color: var(--accent);
}

[data-theme="ink"] a {
  color: hsl(156, 40%, 60%);
  border-bottom-color: hsla(156, 40%, 60%, 0.2);
}

[data-theme="ink"] a:hover {
  color: hsl(156, 40%, 75%);
  border-bottom-color: hsl(156, 40%, 75%);
}

h1,
h2,
h3,
h4,
.serif {
  font-family: var(--font-serif);
  font-weight: 500;
  letter-spacing: -0.01em;
}

.muted {
  opacity: 0.6;
  color: var(--text);
}

.hexTitle {
  font-family: var(--font-serif);
  font-size: clamp(1.8rem, 5vw, 2.8rem);
  margin-bottom: 0.5rem;
  color: var(--text);
  font-weight: 500;
}

/* --- Utility Layout --- */
.row {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.vstack {
  display: flex;
  flex-direction: column;
  gap: clamp(14px, 3.5vw, 28px);
}

.hstack {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* --- Divider --- */
.divider {
  height: 1px;
  background: var(--panel-border);
  margin: 4px 0;
  border: none;
}

/* --- Card --- */
.card {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  padding: clamp(20px, 4vw, 36px);
  box-shadow: var(--panel-shadow);
  position: relative;
  overflow: hidden;
  transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1), box-shadow 0.4s cubic-bezier(0.25, 1, 0.5, 1);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px -4px hsla(240, 6%, 12%, 0.05), 0 2px 6px 0 hsla(240, 6%, 12%, 0.03);
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 14px 28px;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.25, 1, 0.5, 1);
  border: 1px solid var(--panel-border);
  background: var(--panel-bg);
  color: var(--text);
  gap: 10px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  letter-spacing: 0.02em;
  text-decoration: none;
  white-space: nowrap;
  min-height: 44px;
  /* Accessibility: min touch target */
}

.btn:hover:not(:disabled) {
  transform: translateY(-2px) scale(1.015);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
  background: var(--bg);
  color: var(--text);
}

.btn:active:not(:disabled) {
  transform: translateY(0) scale(0.975);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn--primary {
  background: var(--accent);
  color: var(--bg);
  border: 1px solid transparent;
  box-shadow: 0 2px 8px -2px hsla(156, 30%, 42%, 0.3);
  position: relative;
  overflow: hidden;
}

.btn--primary::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg,
      transparent 40%,
      hsla(0, 0%, 100%, 0.18) 50%,
      transparent 60%);
  background-size: 200% 100%;
  background-position: 200% 0;
  transition: background-position 0.5s ease;
  pointer-events: none;
}

.btn--primary:hover:not(:disabled)::after {
  background-position: -200% 0;
  transition: background-position 0.55s ease;
}

.btn--primary:hover:not(:disabled) {
  background: hsl(156, 30%, 38%);
  color: var(--bg);
  box-shadow: 0 8px 22px -4px hsla(156, 30%, 42%, 0.45);
  transform: translateY(-2px) scale(1.02);
}

.btn--ghost {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text);
  box-shadow: none;
}

.btn--ghost:hover:not(:disabled) {
  background: var(--panel-border);
  box-shadow: none;
  transform: none;
}

/* --- Callout --- */
.callout {
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  position: relative;
}

/* --- Form Fields --- */
.input-field {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  font-family: var(--font-sans);
  font-size: clamp(1rem, 2.5vw, 1.1rem);
  color: var(--text);
  outline: none;
  transition: all 0.3s ease;
  line-height: 1.6;
}

.input-field:focus {
  border-color: var(--accent);
  background: var(--bg);
  box-shadow: 0 0 0 3px var(--accent-soft), 0 0 0 1px hsla(156, 30%, 42%, 0.15);
  transition: box-shadow 0.3s ease, border-color 0.2s ease;
}

/* Ripple animation for .btn click micro-interactions */
@keyframes ripple-spread {
  to {
    transform: translate(-50%, -50%) scale(180);
    opacity: 0;
  }
}

.input-field::placeholder {
  opacity: 0.4;
}

select.input-field {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='currentColor' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  padding-right: 40px;
}

/* --- Seal Badge --- */
.seal {
  width: 56px;
  height: 56px;
  background: var(--accent);
  color: var(--bg);
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-family: var(--font-sans);
  font-weight: 600;
  box-shadow: none;
  flex-shrink: 0;
}

/* --- Sage Container --- */
.sage-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: clamp(24px, 6vw, 48px);
  animation: fadeIn 0.8s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.sage-avatar {
  width: clamp(110px, 14vw, 160px);
  height: clamp(110px, 14vw, 160px);
  background: var(--panel-bg);
  border-radius: 50%;
  padding: 12px;
  position: relative;
  margin-bottom: -16px;
  z-index: 10;
  border: 1px solid var(--panel-border);
  box-shadow: var(--panel-shadow);
  overflow: hidden;
  transition: transform 0.15s ease-out;
}

.sage-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
  filter: saturate(1.05) contrast(1.05) var(--sumi-filter);
  animation: sage-breathing 5s ease-in-out infinite;
}

@keyframes sage-breathing {

  0%,
  100% {
    transform: scale(1.0);
    filter: saturate(1.05) contrast(1.05) var(--sumi-filter) brightness(1);
  }

  50% {
    transform: scale(1.04);
    filter: saturate(1.1) contrast(1.08) var(--sumi-filter) brightness(1.04);
  }
}

.sage-avatar::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.1);
  animation: ink-pulse 8s linear infinite;
  pointer-events: none;
  z-index: 1;
}

@keyframes ink-pulse {
  0% {
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.05);
  }

  50% {
    box-shadow: inset 0 0 30px var(--accent-soft);
  }

  100% {
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.05);
  }
}

.fox-speech-bubble {
  position: relative;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  padding: clamp(16px, 3.5vw, 24px);
  border-radius: 16px;
  max-width: 480px;
  width: 100%;
  text-align: center;
  font-size: clamp(0.9rem, 2.2vw, 1.05rem);
  font-family: var(--font-serif);
  line-height: 1.6;
  z-index: 5;
  box-shadow: 0 10px 30px hsla(240, 6%, 12%, 0.08), 0 4px 12px hsla(240, 6%, 12%, 0.04);
  margin-top: 12px;
}

.fox-speech-bubble::before {
  content: '';
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%) rotate(45deg);
  width: 16px;
  height: 16px;
  background: var(--panel-bg);
  border-left: 1px solid var(--panel-border);
  border-top: 1px solid var(--panel-border);
  border-radius: 3px 0 0 0;
  z-index: -1;
}

.fox-speech-bubble .muted-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  opacity: 0.55;
  display: block;
  margin-bottom: 8px;
  font-family: var(--font-sans);
}

.toss-oracle-text {
  min-height: 3.2em;
  /* Prevents layout jumps when text types out */
  display: flex;
  align-items: center;
  justify-content: center;
}

/* --- Coin Stage --- */
.coin-stage {
  display: flex;
  justify-content: center;
  gap: clamp(16px, 5vw, 56px);
  margin: clamp(32px, 8vw, 70px) 0;
  perspective: 1400px;
  perspective-origin: 50% 42%;
}

.coin-3d {
  width: clamp(72px, 12vw, 110px);
  height: clamp(72px, 12vw, 110px);
  position: relative;
  cursor: default;
  will-change: transform;
  /* No transform-style here — spin is handled inside .coin-spin-inner */
}

/* Inner wrapper: owns the 3D backface flip and spin animation axis */
.coin-spin-inner {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  will-change: transform;
}

.coin-face {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  border-radius: 50%;
  filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.38)) drop-shadow(0 2px 4px rgba(0, 0, 0, 0.22));
  overflow: hidden;
}

.coin-face img {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 50%;
  object-fit: cover;
}

.coin-3d:hover .coin-spin-inner {
  transform: translateY(-3px) !important;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

.coin-back {
  transform: rotateY(180deg);
}

/* === Coin Toss Animation — Clean Physics Rewrite ===
   Strategy:
   - Separate spin axis (rotateY only) from vertical arc (translateY only)
   - No rotateX — it mixed the axes and caused gimbal jitter
   - Shadow keyframe adds depth illusion without extra 3D complexity
   - End state set by JS transition, not animation fill-mode, to avoid conflict
*/

@keyframes coin-spin-y {
  0% {
    transform: rotateY(0deg);
  }

  100% {
    transform: rotateY(var(--full-spin, 1440deg));
  }
}

/* Parabolic flight. Keyframe density does the physics: the coin covers
   ground quickly right after launch and just before landing, and lingers
   near the apex — the way real gravity looks. A faint rotateZ lean keeps it
   from feeling like a rigid elevator. */
@keyframes coin-arc {
  0% {
    transform: translateY(0) rotateZ(0deg) scale(1);
  }

  8% {
    /* anticipation: a brief crouch before the launch */
    transform: translateY(5px) rotateZ(-2deg) scale(1.05, 0.92);
  }

  24% {
    transform: translateY(-44px) rotateZ(-3deg) scale(0.98, 1.03);
  }

  40% {
    transform: translateY(-62px) rotateZ(-1deg) scale(1);
  }

  52% {
    /* apex — motion slows here, so the eye reads real weight */
    transform: translateY(-66px) rotateZ(1deg) scale(1);
  }

  64% {
    transform: translateY(-60px) rotateZ(2deg) scale(1);
  }

  80% {
    transform: translateY(-34px) rotateZ(3deg) scale(1.01, 0.99);
  }

  93% {
    /* impact: squash on landing */
    transform: translateY(0) rotateZ(1deg) scale(1.06, 0.9);
  }

  100% {
    transform: translateY(0) rotateZ(0deg) scale(1);
  }
}

@keyframes coin-shadow {
  0% {
    filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.38)) drop-shadow(0 2px 4px rgba(0, 0, 0, 0.22));
  }

  38% {
    filter: drop-shadow(0 20px 32px rgba(0, 0, 0, 0.18)) drop-shadow(0 6px 12px rgba(0, 0, 0, 0.12));
  }

  100% {
    filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.38)) drop-shadow(0 2px 4px rgba(0, 0, 0, 0.22));
  }
}

/* Wrapper: controls the arc + shadow — no transform-style needed */
.coin-toss-wrapper {
  position: relative;
  display: contents;
  /* transparent layout wrapper */
}

/* Apply arc animation to the outer .coin-3d container.
   `linear` so the parabola's physics come purely from the keyframe spacing
   (an easing here would re-ease every segment and cause stutter). */
.tossing {
  animation:
    coin-arc var(--toss-dur, 900ms) linear forwards;
}

/* Spin applied inside via a new inner element targeting .coin-spin-inner.
   Ease-out so the coin clearly decelerates and settles onto its final face. */
.tossing .coin-spin-inner {
  animation:
    coin-spin-y var(--toss-dur, 900ms) cubic-bezier(0.16, 0.62, 0.24, 1) forwards;
}

/* Shadow on the coin face during toss */
.tossing .coin-face {
  animation:
    coin-shadow var(--toss-dur, 900ms) cubic-bezier(0.33, 0, 0.66, 1) forwards;
}

/* --- Hex Visual (Accumulator) --- */
.hex-accumulator {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
}

.hex-visual {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  padding: 20px 28px;
  background: var(--accent-soft);
  border-radius: var(--radius-md);
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.04);
  border: 1px solid var(--panel-border);
}

.hex-line {
  height: 14px;
  width: 160px;
  background: var(--text);
  border-radius: 3px;
  position: relative;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.1);
  transition: background 0.3s ease;
}

.hex-line.yin {
  background: transparent;
  display: flex;
  gap: 22px;
  box-shadow: none;
}

.hex-line.yin::before,
.hex-line.yin::after {
  content: '';
  flex: 1;
  background: var(--text);
  border-radius: 3px;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.1);
}

/* Moving lines pulse animation */
.hex-line.moving {
  animation: line-pulse 1.5s ease-in-out infinite;
}

.hex-line.yang.moving {
  background: var(--accent);
}

.hex-line.yin.moving::before,
.hex-line.yin.moving::after {
  background: var(--accent);
}

@keyframes line-pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.6;
  }
}

/* --- Ink Transition --- */
.ink-transition-overlay {
  position: fixed;
  inset: 0;
  background: var(--text);
  z-index: 10000;
  pointer-events: none;
  opacity: 0;
  clip-path: circle(0% at 50% 50%);
  transition: clip-path 0.8s cubic-bezier(0.77, 0, 0.175, 1), opacity 0.3s;
}

.ink-transition-overlay.active {
  opacity: 1;
  clip-path: circle(150% at 50% 50%);
  pointer-events: all;
}

.ink-transition-overlay.fade-out {
  opacity: 0;
  clip-path: circle(150% at 50% 50%);
  transition: opacity 0.6s ease-out;
}

/* --- Premium Fade In Animation --- */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in {
  animation: fadeIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* Staggered Reveal for Reading Views */
.reveal-section {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.85s cubic-bezier(0.2, 0.8, 0.2, 1), transform 0.85s cubic-bezier(0.2, 0.8, 0.2, 1);
  will-change: opacity, transform;
}

.reveal-section.visible {
  opacity: 1;
  transform: translateY(0);
}

/* === IMMERSIVE SCREEN SYSTEM === */

.immersive-shell {
  min-height: 100vh;
  width: 100%;
  display: flex;
  flex-direction: column;
}

.immersive-screen {
  min-height: 100vh;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: clamp(24px, 5vw, 60px) clamp(16px, 4vw, 40px);
  position: relative;
  overflow: visible;
}

/* HOME: atmospheric oracle screen */
.screen-home {
  background:
    radial-gradient(ellipse at 30% 20%, hsla(215, 30%, 35%, 0.07) 0%, transparent 55%),
    radial-gradient(ellipse at 75% 80%, hsla(156, 30%, 42%, 0.05) 0%, transparent 50%),
    transparent;
}

.home-hero {
  width: 100%;
  max-width: 560px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(20px, 4vw, 36px);
  text-align: center;
}

.home-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.home-brand-glyph {
  font-size: clamp(2.8rem, 7vw, 4.5rem);
  font-family: var(--font-serif);
  color: var(--accent);
  line-height: 1;
  opacity: 0.9;
  animation: glyph-entrance 1.2s cubic-bezier(0.16, 1, 0.3, 1) both, glyph-float 6s ease-in-out 1.5s infinite;
  display: inline-block;
  will-change: transform;
}

@keyframes glyph-entrance {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.88);
  }

  to {
    opacity: 0.9;
    transform: translateY(0) scale(1);
  }
}

@keyframes glyph-float {

  0%,
  100% {
    transform: translateY(0px);
  }

  50% {
    transform: translateY(-6px);
  }
}

.home-brand-title {
  font-size: clamp(0.85rem, 2vw, 1.1rem);
  font-family: var(--font-serif);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text);
  opacity: 0;
  margin: 0;
  font-weight: 400;
  animation: title-fade-in 1.6s cubic-bezier(0.16, 1, 0.3, 1) 0.3s both;
}

@keyframes title-fade-in {
  from {
    opacity: 0;
    letter-spacing: 0.5em;
  }

  to {
    opacity: 0.5;
    letter-spacing: 0.22em;
  }
}

.home-form-card {
  width: 100%;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  padding: clamp(24px, 5vw, 40px);
  box-shadow: 0 8px 40px -8px hsla(240, 6%, 12%, 0.06);
  display: flex;
  flex-direction: column;
  gap: 20px;
  animation: card-rise 0.9s cubic-bezier(0.16, 1, 0.3, 1) 0.15s both;
}

@keyframes card-rise {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* TOSS: ritual center-stage screen */
.screen-toss {
  background:
    radial-gradient(ellipse at 50% 40%, hsla(215, 30%, 35%, 0.05) 0%, transparent 60%),
    transparent;
  justify-content: flex-start;
  padding-top: clamp(40px, 8vh, 80px);
}

.toss-ritual {
  width: 100%;
  max-width: 520px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(20px, 4vw, 32px);
}

.toss-oracle-text {
  min-height: 44px;
  font-family: var(--font-serif);
  font-size: 0.95rem;
  opacity: 0;
  font-style: italic;
  text-align: center;
  max-width: 380px;
  line-height: 1.65;
  animation: oracle-text-in 1s cubic-bezier(0.16, 1, 0.3, 1) 0.4s both;
}

@keyframes oracle-text-in {
  from {
    opacity: 0;
    transform: translateY(10px);
    filter: blur(4px);
  }

  to {
    opacity: 0.55;
    transform: translateY(0);
    filter: blur(0);
  }
}

.toss-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 100%;
}

/* Mode toggle pill */
.toss-mode-toggle {
  display: flex;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 100px;
  padding: 3px;
  gap: 2px;
}

.toss-mode-btn {
  padding: 8px 22px;
  border-radius: 100px;
  border: none;
  background: transparent;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 500;
  opacity: 0.5;
  cursor: pointer;
  transition: all 0.25s ease;
  letter-spacing: 0.04em;
}

.toss-mode-btn.active {
  background: var(--text);
  color: var(--bg);
  opacity: 1;
}

/* Manual coin row */
.manual-coins-row {
  display: flex;
  gap: 16px;
  justify-content: center;
  align-items: center;
}

.manual-coin-btn {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  border: 2px solid var(--panel-border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  font-family: var(--font-serif);
  background: var(--panel-bg);
  position: relative;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.manual-coin-btn:hover {
  transform: scale(1.08);
}

.manual-coin-btn:active {
  transform: scale(0.94);
}

.manual-coin-btn.yang {
  border-color: hsl(38, 60%, 50%);
  background: hsla(38, 60%, 50%, 0.06);
  box-shadow: 0 0 0 0 hsla(38, 60%, 50%, 0.4);
  animation: coin-pulse-yang 2.5s ease-in-out infinite;
}

.manual-coin-btn.yin {
  border-color: hsl(215, 35%, 50%);
  background: hsla(215, 35%, 50%, 0.06);
}

@keyframes coin-pulse-yang {

  0%,
  100% {
    box-shadow: 0 0 0 0 hsla(38, 60%, 50%, 0.35);
  }

  50% {
    box-shadow: 0 0 0 8px hsla(38, 60%, 50%, 0);
  }
}



/* READING: scrollable revelation screen */
.screen-reading {
  min-height: 100vh;
  align-items: stretch;
  justify-content: flex-start;
  padding: 0;
}

.reading-sticky-header {
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  background: hsla(42, 30%, 96%, 0.88);
  border-bottom: 1px solid var(--panel-border);
  padding: 14px clamp(20px, 5vw, 60px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  animation: header-drop 0.6s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes header-drop {
  from {
    opacity: 0;
    transform: translateY(-100%);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

:root[data-theme="ink"] .reading-sticky-header {
  background: hsla(240, 8%, 10%, 0.9);
}

.reading-sticky-hex-name {
  font-family: var(--font-serif);
  font-size: clamp(0.9rem, 2.2vw, 1.1rem);
  font-weight: 500;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
}

.reading-sticky-glyph {
  font-size: 1.4rem;
  color: var(--accent);
  line-height: 1;
}

.reading-content {
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  padding: clamp(32px, 6vw, 80px) clamp(16px, 4vw, 40px) clamp(60px, 10vw, 120px);
  display: flex;
  flex-direction: column;
  gap: clamp(40px, 8vw, 80px);
}

/* Reveal animation for reading sections */
.reveal-section {
  opacity: 0;
  transform: translateY(28px);
  transition:
    opacity 0.75s cubic-bezier(0.16, 1, 0.3, 1),
    transform 0.75s cubic-bezier(0.16, 1, 0.3, 1);
}

.reveal-section.visible {
  opacity: 1;
  transform: translateY(0);
}

.reveal-section:nth-child(1) {
  transition-delay: 0.05s;
}

.reveal-section:nth-child(2) {
  transition-delay: 0.10s;
}

.reveal-section:nth-child(3) {
  transition-delay: 0.15s;
}

.reveal-section:nth-child(4) {
  transition-delay: 0.20s;
}

.reveal-section:nth-child(5) {
  transition-delay: 0.25s;
}

.reveal-section:nth-child(6) {
  transition-delay: 0.30s;
}

.reveal-section:nth-child(7) {
  transition-delay: 0.35s;
}

.reading-section-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--accent);
  font-family: var(--font-sans);
  font-weight: 600;
  margin-bottom: 12px;
  display: block;
}

.reading-divider {
  width: 0px;
  height: 1px;
  background: var(--accent);
  opacity: 0.4;
  margin: 0 auto;
  transition: width 1.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.reveal-section.visible .reading-divider {
  width: 40px;
}

.reading-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 20px;
  padding-top: clamp(24px, 5vw, 48px);
}

.reading-question-echo {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 0.9rem;
  opacity: 0.55;
  border-left: 2px solid var(--accent);
  padding: 8px 16px;
  text-align: left;
  max-width: 400px;
  margin: 0 auto;
  line-height: 1.6;
  position: relative;
  overflow: hidden;
}

.reading-question-echo::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  width: 2px;
  height: 0;
  background: var(--accent);
  animation: border-draw 1.2s cubic-bezier(0.16, 1, 0.3, 1) 0.5s forwards;
}

@keyframes border-draw {
  from {
    height: 0;
  }

  to {
    height: 100%;
  }
}

/* --- Reading Components --- */
.reading-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.reading-judgment {
  padding: 16px 20px;
  background: var(--accent-soft);
  border-radius: var(--radius-md);
  border-left: 3px solid var(--accent);
}

.reading-question-echo {
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--panel-border);
  background: var(--panel-bg);
}

/* --- Interactive Book Reader --- */
.book-reader {
  width: 100%;
}

.book-container {
  width: 100%;
  position: relative;
  background: var(--bg);
}

.book-page {
  background-color: var(--bg);
  padding: clamp(20px, 4vw, 36px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  box-shadow: var(--panel-shadow);
  position: relative;
  min-height: 400px;
}

/* Subtle page texture */
.book-page::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.6' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E");
  pointer-events: none;
  border-radius: inherit;
  opacity: 0.5;
}

.page-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--panel-border) transparent;
  position: relative;
  z-index: 1;
}

.page-content::-webkit-scrollbar {
  width: 4px;
}

.page-content::-webkit-scrollbar-thumb {
  background: var(--panel-border);
  border-radius: 10px;
}

.page-footer {
  text-align: center;
  font-size: 10px;
  opacity: 0.25;
  margin-top: 12px;
  font-family: var(--font-serif);
  letter-spacing: 0.08em;
  flex-shrink: 0;
}

.book-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 20px;
  padding: 0 16px;
  flex-wrap: wrap;
}

.book-nav-indicator {
  font-family: var(--font-serif);
  font-size: 0.85rem;
  opacity: 0.6;
  min-width: 60px;
  text-align: center;
}

/* --- I-Ching Visuals --- */
.zen-vertical {
  writing-mode: vertical-rl;
  text-orientation: upright;
  max-height: 60vh;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 16px;
  line-height: 2;
  letter-spacing: 0.15em;
  font-family: var(--font-serif);
  border-right: 1px solid var(--panel-border);
  scrollbar-width: thin;
  scrollbar-color: var(--panel-border) transparent;
}

/* --- History Card --- */
.history-card {
  transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.history-card:hover {
  transform: translateX(6px);
  border-color: var(--accent);
  box-shadow: 0 4px 20px -4px hsla(156, 30%, 42%, 0.15), -3px 0 0 var(--accent);
}

/* --- Enso Loader --- */
.enso-container {
  display: grid;
  place-items: center;
  margin: 20px auto;
  width: 100px;
  height: 100px;
}

.enso-svg {
  width: 100%;
  height: 100%;
  filter: var(--sumi-filter);
  transform: rotate(-90deg);
}

.enso-circle {
  fill: none;
  stroke: var(--text);
  stroke-width: 7;
  stroke-linecap: round;
  stroke-dasharray: 283;
  stroke-dashoffset: 283;
  animation: enso-draw 2s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes enso-draw {
  0% {
    stroke-dashoffset: 283;
    opacity: 0;
  }

  20% {
    opacity: 1;
  }

  100% {
    stroke-dashoffset: 40;
    opacity: 0.85;
  }
}

/* --- Modal Dialog --- */
dialog.modal {
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  background: var(--panel-bg);
  color: var(--text);
  padding: clamp(24px, 5vw, 40px);
  max-width: 480px;
  width: calc(100vw - 40px);
  box-shadow: var(--panel-shadow);
  animation: modal-slide-up 0.45s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes modal-slide-up {
  from {
    opacity: 0;
    transform: translateY(32px) scale(0.97);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

dialog.modal::backdrop {
  background: hsla(240, 6%, 12%, 0.5);
  animation: backdrop-in 0.3s ease both;
}

@keyframes backdrop-in {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

dialog.modal .hexTitle {
  font-size: 1.4rem;
}

/* --- Paper Texture (grained.js target) --- */
#grained-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 9999;
  pointer-events: none;
  opacity: 0.05;
}

/* --- Shao Yong Circle --- */
.shaoYongContainer {
  width: 100%;
  max-width: 500px;
  margin: 20px auto;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: visible;
}

.shaoYongCircle {
  width: 100%;
  height: auto;
  max-height: 500px;
}

/* --- Mobile Adjustments --- */
@media (max-width: 850px) {
  body {
    font-size: 16px;
  }

  .book-scene {
    perspective: none;
  }

  .book {
    height: auto;
    position: static;
    transform: none !important;
    max-width: 100%;
  }

  .book-front {
    display: none;
  }

  .book-inside {
    position: static;
    transform: none;
    box-shadow: none;
    padding: 16px;
    border: none;
    background: transparent;
    overflow: visible;
  }

  .book-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
  }

  .book-page {
    position: static !important;
    width: 100% !important;
    height: auto !important;
    min-height: auto !important;
  }

  .coin-stage {
    gap: clamp(10px, 5vw, 24px);
  }

  .coin-3d {
    width: clamp(64px, 22vw, 90px);
    height: clamp(64px, 22vw, 90px);
  }

  .manual-coin-btn {
    width: clamp(68px, 24vw, 84px);
    height: clamp(68px, 24vw, 84px);
  }

  .book-nav {
    gap: 10px;
  }
}

@media (max-width: 480px) {
  .book-cover-seal {
    width: 70px;
    height: 70px;
    font-size: 32px;
  }

  .book-cover-title {
    font-size: 2rem;
  }

  .history-card {
    flex-wrap: wrap;
  }

  .history-card>div:last-child {
    display: none;
  }
}



@media (max-width: 720px) {
  .immersive-screen {
    min-height: auto;
    padding: clamp(16px, 4vw, 28px) clamp(12px, 3vw, 20px);
    overflow: visible;
  }

  .screen-toss {
    padding-top: clamp(18px, 4vh, 32px);
  }

  .toss-ritual {
    gap: 16px;
    max-width: 100%;
  }

  .manual-coins-row {
    gap: 10px;
    width: 100%;
  }

  .toss-actions {
    max-width: 100% !important;
  }

  .hex-line {
    width: min(140px, 60vw);
  }

  .reading-sticky-header {
    padding: 10px 12px;
  }

  .reading-content {
    padding: 22px 12px 56px;
    gap: 28px;
  }
}

@media (max-width: 480px) {
  .coin-stage {
    gap: 8px;
    margin: 18px 0 14px;
  }

  .toss-mode-btn {
    padding: 8px 12px;
    font-size: 0.76rem;
  }

  .manual-coins-row {
    gap: 8px;
  }
}

/* --- Large screens: keep the ritual centred and give it room to breathe --- */
@media (min-width: 1024px) {

  /* Vertically centre the toss ritual instead of pinning it to the top,
     so it no longer floats in a sea of empty space on big displays. */
  .screen-toss {
    justify-content: center;
    padding-top: clamp(40px, 6vh, 72px);
    padding-bottom: clamp(40px, 6vh, 72px);
  }

  .toss-ritual {
    max-width: 640px;
    gap: clamp(28px, 3.5vh, 44px);
  }

  /* Larger, more present avatar and coins on desktop. */
  #tossAvatarTarget {
    width: 184px !important;
    height: 184px !important;
  }

  .coin-stage {
    gap: 64px;
    margin: clamp(40px, 6vh, 72px) 0;
    perspective: 1600px;
  }

  .coin-3d {
    width: 128px;
    height: 128px;
  }

  .fox-speech-bubble {
    max-width: 540px;
    font-size: 1.05rem;
  }
}

@media (min-width: 1440px) {
  .toss-ritual {
    max-width: 720px;
  }

  #tossAvatarTarget {
    width: 208px !important;
    height: 208px !important;
  }

  .coin-3d {
    width: 140px;
    height: 140px;
  }

  .coin-stage {
    gap: 72px;
  }
}

/* --- Print Styles (PDF Export) --- */
@media print {

  .bubble-menu-root,
  .ink-transition-overlay,
  canvas,
  #install-banner,
  #app-splash,
  .book-nav,
  #btnSave,
  #btnPDF,
  #btnClose,
  #btnSave2,
  #btnClose2,
  #btnShare {
    display: none !important;
  }

  body {
    background: white !important;
    color: black !important;
    font-size: 12pt;
  }

  .book-inside {
    box-shadow: none;
    border: none;
    padding: 0;
  }

  .book-page {
    box-shadow: none;
    border: 1px solid #ddd;
    page-break-inside: avoid;
    margin-bottom: 20px;
  }

  .card {
    box-shadow: none;
    border: 1px solid #ddd;
    backdrop-filter: none;
  }

  .reveal-section {
    opacity: 1 !important;
    transform: none !important;
  }
}

/* ═══════════════════════════════════════════════════════════
   PREMIUM POLISH v3.0
   ═══════════════════════════════════════════════════════════ */

/* --- Cursor Blink (Typewriter component) --- */
@keyframes cursor-blink {

  0%,
  100% {
    opacity: 0.7;
  }

  50% {
    opacity: 0;
  }
}

/* --- Scroll Read Progress Indicator --- */
#read-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 0%;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), hsl(156, 40%, 60%));
  z-index: 10001;
  pointer-events: none;
  transition: width 0.1s linear;
  opacity: 0;
  border-radius: 0 2px 2px 0;
}

#read-progress.visible {
  opacity: 1;
}

/* --- Overscroll / Pull-to-refresh prevention --- */
html {
  overscroll-behavior-y: none;
  /* Status bar theme-color bleed fix on installed PWA */
  background-color: var(--bg);
}

/* Smooth overscroll color for installed PWA */
@supports (overscroll-behavior: none) {
  html {
    overscroll-behavior: none;
  }
}

/* --- Bubble Menu Premium Styling --- */
.bubble-btn-icon {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  border-radius: 50%;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.bubble-btn-label {
  font-size: 0.82rem;
  font-weight: 500;
  opacity: 0.9;
}

/* --- Focus visible styles (keyboard navigation) --- */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

button:focus:not(:focus-visible),
a:focus:not(:focus-visible) {
  outline: none;
}

/* --- Safe area insets for notched phones --- */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .bubble-menu-root {
    bottom: calc(clamp(16px, 4vw, 32px) + env(safe-area-inset-bottom, 0px));
    right: calc(clamp(16px, 4vw, 32px) + env(safe-area-inset-right, 0px));
  }

  .toss-actions {
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
}

/* --- Swipe gesture hint (reading screen back swipe) --- */
.swipe-hint {
  position: fixed;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 48px;
  background: var(--accent);
  border-radius: 0 4px 4px 0;
  opacity: 0;
  z-index: 200;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.swipe-hint.active {
  opacity: 0.5;
}

/* --- Premium scrollbar styling (Webkit) --- */
::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--panel-border);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--panel-border) transparent;
}

/* --- Text selection color --- */
::selection {
  background: hsla(156, 30%, 42%, 0.25);
  color: var(--text);
}

/* --- HistoryView: wrap safe on mobile --- */
@media (max-width: 480px) {
  .history-card {
    flex-wrap: wrap;
  }

  .history-card>div:last-child {
    display: none;
  }
}

/* --- Glossary Trigram Filters --- */
.trigram-filter-bar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0 12px;
  scrollbar-width: none;
  -ms-overflow-style: none;
  mask-image: linear-gradient(to right, black 85%, transparent);
}

.trigram-filter-bar::-webkit-scrollbar {
  display: none;
}

.trigram-btn {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 54px;
  height: 62px;
  border-radius: var(--radius-sm);
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  color: var(--text);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  padding: 8px;
}

.trigram-btn span {
  font-size: 1.5rem;
  line-height: 1;
}

.trigram-btn small {
  font-size: 0.62rem;
  font-family: var(--font-serif);
  opacity: 0.6;
  margin-top: 2px;
}

.trigram-btn:hover {
  border-color: var(--accent);
  background: var(--bg);
}

.trigram-btn.active {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
  box-shadow: 0 4px 12px hsla(156, 30%, 42%, 0.25);
}

.trigram-btn.active small {
  color: inherit;
  opacity: 0.9;
}

/* ═══════════════════════════════════════════════════════════
   PREFERS-REDUCED-MOTION
   All animations and transitions gracefully disabled
   ═══════════════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .reveal-section {
    opacity: 1 !important;
    transform: none !important;
  }

  .ink-transition-overlay {
    display: none !important;
  }

  .home-brand-glyph {
    animation: none !important;
    opacity: 0.9;
  }

  .home-brand-title {
    animation: none !important;
    opacity: 0.5;
  }

  .home-form-card {
    animation: none !important;
    opacity: 1;
  }

  .enso-circle {
    animation: none !important;
    stroke-dashoffset: 40;
    opacity: 0.85;
  }

  .fade-in {
    animation: none !important;
    opacity: 1;
  }

  #app-splash {
    display: none !important;
  }
}

/* --- Traditional Perspectives Section --- */
.traditional-section {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  padding: clamp(20px, 4vw, 36px);
  margin-top: 24px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--panel-shadow);
}

.traditional-section::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--gold);
  opacity: 0.6;
}

.traditional-title {
  font-family: var(--font-serif);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--gold);
  margin-bottom: 20px;
  display: block;
}

.traditional-entry {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 24px;
}

.traditional-entry:last-child {
  margin-bottom: 0;
}

.traditional-label {
  font-weight: 600;
  font-size: 0.85rem;
  opacity: 0.7;
  display: flex;
  align-items: center;
  gap: 8px;
}

.traditional-label::after {
  content: "";
  height: 1px;
  flex: 1;
  background: var(--panel-border);
  opacity: 0.5;
}

.traditional-text {
  font-family: var(--font-serif);
  font-size: 0.95rem;
  line-height: 1.8;
  opacity: 0.9;
  font-style: italic;
}

/* Modal specific traditional styles */
.modal-traditional {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--panel-border);
}

/* --- Zen Donation Card Styles --- */
.donation-zen-card {
  background: linear-gradient(135deg, var(--panel-bg), var(--accent-soft));
  border: 1px solid hsla(156, 30%, 42%, 0.18);
  border-radius: var(--radius-md);
  padding: clamp(22px, 4.5vw, 36px);
  margin: 32px 0 16px;
  box-shadow: var(--panel-shadow);
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: relative;
  overflow: hidden;
  transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1), border-color 0.4s ease;
}

.donation-zen-card:hover {
  transform: translateY(-2px);
  border-color: hsla(156, 30%, 42%, 0.4);
}

.donation-zen-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--gold));
  opacity: 0.85;
}

.donation-zen-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.donation-zen-heart {
  font-size: 1.8rem;
  line-height: 1;
  display: inline-block;
  animation: heart-breath 3.5s ease-in-out infinite;
  transform-origin: center;
}

@keyframes heart-breath {
  0%, 100% {
    transform: scale(1);
    filter: drop-shadow(0 0 2px rgba(255, 90, 95, 0));
  }
  50% {
    transform: scale(1.15);
    filter: drop-shadow(0 0 6px rgba(255, 90, 95, 0.35));
  }
}

.donation-zen-title {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-weight: 600;
  margin: 0;
  color: var(--text);
  letter-spacing: -0.01em;
}

.donation-zen-text {
  font-family: var(--font-serif);
  font-size: 0.92rem;
  line-height: 1.75;
  opacity: 0.88;
  margin: 0;
}

.donation-zen-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 8px;
}

.donation-amount-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.btn-donate-amount {
  background: var(--panel-bg);
  color: var(--text);
  border: 1px solid hsla(156, 30%, 42%, 0.3);
  border-radius: var(--radius-sm, 10px);
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.92rem;
  padding: 12px 8px;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.btn-donate-amount:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 4px 14px hsla(156, 30%, 42%, 0.18);
}

.btn-donate-amount .amount {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--accent);
}

.btn-donate-amount .hint {
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.6;
}

.btn-donate-zen {
  background: var(--accent);
  color: hsl(42, 30%, 96%);
  border: 1px solid transparent;
  border-radius: var(--radius-sm, 10px);
  font-weight: 600;
  font-size: 0.9rem;
  padding: 12px 22px;
  text-decoration: none;
  text-align: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 4px 12px hsla(156, 30%, 42%, 0.22);
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.btn-donate-zen:hover {
  transform: translateY(-2px);
  background: hsl(156, 36%, 36%);
  box-shadow: 0 6px 18px hsla(156, 30%, 42%, 0.32);
}

[data-theme="ink"] .btn-donate-zen:hover {
  background: hsl(156, 25%, 65%);
}

/* Sticky-header support chip ☕ */
.support-chip {
  background: transparent;
  border: 1px solid hsla(156, 30%, 42%, 0.35);
  color: var(--accent);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  font-family: var(--font-sans);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}

.support-chip:hover {
  background: var(--accent-soft);
  transform: translateY(-1px);
}

/* Subtle home footer note */
.home-support-note {
  font-family: var(--font-serif);
  font-size: 0.72rem;
  text-align: center;
  opacity: 0.55;
  margin-top: 18px;
  line-height: 1.6;
}

.home-support-note a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px solid hsla(156, 30%, 42%, 0.3);
}

.home-support-note a:hover {
  opacity: 0.85;
}

/* --- PWA Custom Install Banner --- */
.pwa-install-banner {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  padding: 20px 24px;
  position: relative;
  box-shadow: var(--panel-shadow);
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: slide-up 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
  margin-top: 24px;
}

.pwa-install-banner::after {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--accent);
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

.pwa-install-banner-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.pwa-install-banner-close {
  background: transparent;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
  line-height: 1;
  transition: color 0.2s ease;
}

.pwa-install-banner-close:hover {
  color: var(--text);
}

.pwa-install-banner-title {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.pwa-install-banner-text {
  font-size: 0.86rem;
  line-height: 1.6;
  opacity: 0.85;
  margin: 0;
}

.pwa-install-ios-instructions {
  background: var(--paper-texture);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 0.82rem;
  line-height: 1.55;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-left: 2px solid var(--gold);
}

/* --- Daily Wisdom Card on Home --- */
.daily-wisdom-card {
  background: linear-gradient(135deg, var(--panel-bg), var(--paper-texture));
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: var(--panel-shadow);
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
  overflow: hidden;
  transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1), box-shadow 0.4s cubic-bezier(0.25, 1, 0.5, 1);
  margin-top: 24px;
  cursor: pointer;
  text-align: left;
}

.daily-wisdom-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.06);
  border-color: hsla(156, 30%, 42%, 0.3);
}

.daily-wisdom-badge {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.daily-wisdom-badge span {
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse-ring 2s infinite;
}

@keyframes pulse-ring {
  0% { transform: scale(0.95); opacity: 1; }
  50% { transform: scale(1.3); opacity: 0.5; }
  100% { transform: scale(0.95); opacity: 1; }
}

.daily-wisdom-content {
  display: flex;
  align-items: center;
  gap: 16px;
}

.daily-wisdom-glyph {
  font-size: 2.4rem;
  line-height: 1;
  font-family: var(--font-serif);
  color: var(--text);
  opacity: 0.95;
  background: var(--accent-soft);
  width: 54px;
  height: 54px;
  border-radius: 12px;
  display: grid;
  place-items: center;
}

.daily-wisdom-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.daily-wisdom-title {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.daily-wisdom-teaser {
  font-family: var(--font-serif);
  font-size: 0.86rem;
  opacity: 0.8;
  margin: 4px 0 0;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Animations */
@keyframes slide-up {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* --- Toasts --- */
.app-toast {
  position: fixed;
  bottom: calc(28px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--panel-bg);
  color: var(--text);
  border: 1px solid var(--panel-border);
  box-shadow: 0 12px 32px rgba(0,0,0,0.18);
  border-radius: 12px;
  padding: 12px 18px;
  font-family: var(--font-sans);
  font-size: 0.88rem;
  font-weight: 500;
  max-width: min(420px, calc(100% - 32px));
  text-align: center;
  z-index: 10050;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.16,1,0.3,1);
  pointer-events: none;
}
.app-toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }
.app-toast--warn { border-color: hsla(38, 80%, 50%, 0.5); }
.app-toast--ok   { border-color: hsla(156, 30%, 42%, 0.5); }

/* --- SW Update Banner --- */
.sw-update-banner {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-left: 4px solid var(--accent);
  border-radius: 14px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 14px 36px rgba(0,0,0,0.18);
  z-index: 10040;
  max-width: min(460px, calc(100% - 32px));
  animation: slide-up 0.4s cubic-bezier(0.16,1,0.3,1) both;
}
.sw-update-text { display: flex; flex-direction: column; gap: 2px; font-family: var(--font-sans); font-size: 0.85rem; }
.sw-update-text strong { font-size: 0.92rem; }
.sw-update-text span { opacity: 0.7; font-size: 0.78rem; }
.sw-update-actions { display: flex; gap: 8px; flex-shrink: 0; }
.sw-update-actions .btn { padding: 8px 14px; font-size: 0.8rem; }

/* --- Offline indicator dot --- */
html.is-offline body::after {
  content: "● offline";
  position: fixed;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: hsla(0, 0%, 0%, 0.7);
  color: hsl(38, 80%, 65%);
  font-family: var(--font-sans);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  padding: 4px 10px;
  border-radius: 999px;
  z-index: 10060;
  pointer-events: none;
  animation: slide-up 0.25s ease both;
}

/* --- Onboarding card --- */
.onboarding-card {
  background: linear-gradient(135deg, var(--panel-bg), var(--accent-soft));
  border: 1px solid hsla(156, 30%, 42%, 0.22);
  border-radius: var(--radius-md);
  padding: 22px 26px 24px;
  margin: 24px 0 4px;
  width: 100%;
  max-width: 480px;
  box-shadow: var(--panel-shadow);
  position: relative;
  animation: slide-up 0.5s cubic-bezier(0.16,1,0.3,1) both;
}
.onboarding-close {
  position: absolute;
  top: 10px; right: 12px;
  background: transparent; border: none; cursor: pointer;
  font-size: 1.4rem; line-height: 1; opacity: 0.4; padding: 6px;
}
.onboarding-close:hover { opacity: 0.85; }
.onboarding-title {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  margin: 0 0 12px;
  font-weight: 600;
}
.onboarding-steps {
  font-family: var(--font-serif);
  font-size: 0.92rem;
  line-height: 1.7;
  padding-left: 20px;
  margin: 0 0 10px;
}
.onboarding-steps li { margin-bottom: 6px; opacity: 0.92; }
.onboarding-foot {
  font-family: var(--font-serif);
  font-size: 0.8rem;
  font-style: italic;
  opacity: 0.6;
  margin: 12px 0 0;
}

/* --- Generic icon button --- */
.icon-btn {
  position: absolute;
  top: 24px;
  right: 24px;
  z-index: 100;
  padding: 10px;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  opacity: 0.55;
}
.icon-btn:hover { opacity: 1; }

/* --- A11y helpers --- */
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.form-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* --- Utility classes (replace repeated inline styles) --- */
.txt-center { text-align: center; }
.txt-xs     { font-size: 0.72rem; }
.txt-sm     { font-size: 0.82rem; }
.txt-md     { font-size: 0.9rem; }
.muted-50   { opacity: 0.5; }
.muted-70   { opacity: 0.7; }
.muted-85   { opacity: 0.85; }
.mt-12      { margin-top: 12px; }
.mt-16      { margin-top: 16px; }
.mt-24      { margin-top: 24px; }
.gap-8      { gap: 8px; }
.gap-12     { gap: 12px; }
.gap-16     { gap: 16px; }
.flex-wrap  { display: flex; flex-wrap: wrap; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.fluid-100  { width: 100%; }
.btn--xs    { padding: 6px 12px; font-size: 0.75rem; }
.btn--sm    { padding: 8px 16px; font-size: 0.82rem; }
.btn--lg    { padding: 14px 28px; font-size: 1rem; }
.btn--xl    { padding: 18px; font-size: 1.05rem; width: 100%; }
