.tool-wrap { width: min(calc(100% - 2 * var(--gutter)), 960px); margin-inline: auto; }
.tool-wrap > .breadcrumb { margin-block: 12px; }
.fortune-hero {
  --hero-dark: #1c1412;
  position: relative;
  isolation: isolate;
  display: grid;
  align-items: center;
  min-height: clamp(345px, 32vw, 445px);
  background: var(--hero-dark);
  color: #fff9ee;
  overflow: hidden;
}
.hafez-hero { --hero-dark: #20151b; }
.quran-hero { --hero-dark: #111f1d; }
.tarot-hero { --hero-dark: #211620; }
.coffee-hero { --hero-dark: #231611; }
.abjad-hero { --hero-dark: #222217; }
.daily-hero { --hero-dark: #1a2335; }
.fortune-image {
  position: absolute;
  inset: 0 auto 0 0;
  z-index: -1;
  width: min(72%, 1010px);
  mask-image: linear-gradient(to right, #000 57%, transparent 100%);
}
.fortune-image img { width: 100%; height: 100%; object-fit: cover; object-position: center 50%; }
.hafez-hero .fortune-image { width: min(70%, 850px); }
.hafez-hero img { object-position: center 55%; }
.fortune-copy { padding-block: 54px; }
.fortune-copy h1 {
  max-width: 15em;
  width: min(53%, 600px);
  font-size: clamp(2rem, 3.9vw, 3.5rem);
  line-height: 1.32;
  text-wrap: balance;
  font-weight: 820;
}
.fortune-copy p { width: min(50%, 420px); margin-block: 14px 23px; color: #eee5d8; line-height: 1.95; }
.fortune-jump { background: #efdaaa; color: #252219; border-radius: 8px; }
.fortune-jump:hover { background: #fff0c9; }
.fortune-jump span { font-size: 1.08rem; }
.fortune-hero :focus-visible { outline-color: #ffe4a4; }
.fortune-content > .prose { width: min(100%, 76ch); }
.fortune-content .interactive { margin-block-start: 24px; }
.fortune-content .interactive .result { scroll-margin-block: 22px; }
.scene-panel { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); align-items: stretch; padding: 0; }
.hafez-panel { position: relative; }
.hafez-panel [data-draw]::after { content: ''; position: absolute; inset: 0; z-index: 1; border-radius: var(--radius); }
.scene-controls { padding: var(--panel-space); align-content: center; min-width: 0; }
.ritual-scene {
  min-height: 220px;
  border-start-end-radius: inherit;
  border-end-end-radius: inherit;
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
  isolation: isolate;
}
.scene-art { width: min(100%, 365px); aspect-ratio: 1.67; position: relative; direction: ltr; }

.hafez-scene { background: radial-gradient(ellipse at 30% 30%, #f0e1bc, #dfe2ce 70%); }
.quran-scene { background: linear-gradient(145deg, #dfd9b8, #c7d5c4 66%); }
.scene-arch {
  position: absolute;
  left: 12%; top: 5%; width: 57%; height: 84%;
  border-radius: 50% 50% 0 0 / 48% 48% 0 0;
  border: 1px solid #88745063;
  background: linear-gradient(145deg, #fff3ccaa, #cfcaac55);
}
.scene-arch::after { content: ''; position: absolute; inset: 6px; border: 1px solid #a3906659; border-radius: inherit; }
.scene-table {
  position: absolute; left: 8%; right: 8%; bottom: 9%; height: 11%;
  border-radius: 50%; background: radial-gradient(ellipse, #70512b5b, #99734a00 72%);
}
.scene-cast {
  position: absolute; inset: auto auto 6% 50%; height: 92%; aspect-ratio: 1; overflow: hidden;
  transform: translateX(-50%); transform-origin: 50% 92%;
}
.hafez-scene .scene-arch { left: 25%; width: 50%; }
.scene-cast img { width: 300%; max-width: none; height: 100%; }
.scene-book {
  --cover: #243d31;
  position: absolute; inset: auto auto 12% 42%; width: 50%; height: 35%;
  perspective: 440px;
}
.book-spread { position: absolute; inset: 0; transform: rotateX(22deg) rotateZ(-6deg); transform-style: preserve-3d; }
.book-stack, .book-leaf { position: absolute; inset: 0 0 0 50%; border-radius: 3px 5px 5px 3px; }
.book-stack {
  background: linear-gradient(90deg, #c1ac80, #fbefd0 22%, #f4dfb1 95%);
  border: 2px solid var(--cover); border-block-end: 6px solid #b19565;
  box-shadow: 3px 9px 12px #493e2d38;
}
.book-stack::after, .book-verso::after {
  content: ''; position: absolute; inset: 11% 12%; border: 1px solid #a279435c; border-radius: 2px;
  pointer-events: none;
}
.book-leaf { transform: rotateY(0deg); transform-origin: left center; transform-style: preserve-3d; }
.book-leaf::before {
  content: ''; position: absolute; inset: 0; border-radius: inherit;
  border: 1px solid #af8f4d; background: var(--cover); backface-visibility: hidden;
  box-shadow: inset 0 0 0 5px var(--cover), inset 0 0 0 6px #bf9a54ad;
}
.book-verso {
  position: absolute; inset: 0; border-radius: inherit; transform: rotateY(180deg); backface-visibility: hidden;
  background: linear-gradient(90deg, #f4dfb0 75%, #ccb583);
  border: 2px solid var(--cover); border-block-end: 5px solid #af9465;
  box-shadow: inset 0 0 0 7px #f2dfb5, inset 0 0 0 8px #bb9a62;
}
.quran-scene .scene-arch { left: 28%; width: 44%; }
.quran-scene .scene-book { --cover: #22473b; inset: auto auto 16% 8%; width: 84%; height: 58%; }
.quran-scene .book-spread { transform: rotateX(12deg); }
.quran-scene .book-stack::after, .quran-scene .book-verso::after { inset: 6%; }
.folio-script {
  position: absolute; inset: 13% 10%; display: grid; align-content: center; overflow: hidden;
  font: 610 clamp(.56rem, 1.6vw, .75rem)/1.55 'Traditional Arabic', Vazirmatn, serif;
  color: #44301d; text-align: center; text-wrap: pretty;
}
.folio-dense .folio-script { font-size: .6rem; line-height: 1.45; }
.scene-stand { position: absolute; inset: auto 17% 6%; height: 30%; }
.scene-stand::before, .scene-stand::after {
  content: ''; position: absolute; inset: 37% 0; border-radius: 2px; background: #725232;
  box-shadow: inset 0 2px 0 #bd9860;
}
.scene-stand::before { transform: rotate(20deg); }
.scene-stand::after { transform: rotate(-20deg); }
.scene-beam {
  position: absolute; inset: 5% 26% 23%;
  background: linear-gradient(175deg, #fff2c67a, #fff2c600);
  clip-path: polygon(35% 0, 64% 0, 100% 100%, 0 100%);
  opacity: .3;
}

.coffee-scene { background: radial-gradient(ellipse at 48% 28%, #f5e9d7, #dac4aa 95%); }
.scene-saucer {
  position: absolute; inset: auto 14% 8%; height: 33%; border-radius: 50%;
  background: radial-gradient(ellipse, #c8aa89 30%, #ebd4b5 35% 61%, #396050 62% 65%, #f3dfbc 67% 75%);
  box-shadow: inset 0 2px 3px #fff4d8, 0 6px 0 -2px #b99670, 0 11px 16px #67493044;
}
.cup-shadow {
  position: absolute; inset: auto 25% 12%; height: 22%; border-radius: 50%;
  background: radial-gradient(ellipse, #6d452887, #6d452800 70%);
}
.scene-cup {
  position: absolute; left: 50%; bottom: 14%; width: auto; height: 82%; aspect-ratio: 1;
  transform-style: preserve-3d; transform: translateX(-50%) rotateX(180deg);
}
.cup-under, .cup-top { position: absolute; inset: 0; backface-visibility: hidden; }
.cup-under { transform: rotateX(180deg); }
.cup-under img, .cup-top img { width: 100%; height: 100%; }
.cup-top [data-grounds] {
  position: absolute; left: 44%; top: 46%; width: 38%; aspect-ratio: 1;
  display: grid; place-items: center; opacity: 0;
  transform: translate(-50%, -50%) rotate(-9deg);
  color: #532916; mix-blend-mode: multiply;
  background-image: radial-gradient(circle at 21% 72%, #583522a1 .7px, transparent 1.35px),
    radial-gradient(circle at 58% 24%, #58352287 .65px, transparent 1.4px);
  background-size: 7px 8px, 11px 9px;
  mask-image: radial-gradient(ellipse, #000 35%, #000b 57%, transparent 74%);
}
.cup-top .icon { width: 75%; height: auto; stroke-width: 2.8px; filter: drop-shadow(.5px .5px 1px #6e371e7a); }

.abjad-scene { background: radial-gradient(ellipse, #ede2bf, #cec398); }
.ink-paper {
  position: absolute; inset: 10% 24% 12% 21%; display: grid; align-content: center; justify-items: center; gap: 0;
  transform: rotate(-7deg); color: #28291e; border-radius: 2px;
  background: linear-gradient(155deg, #fff4d8, #e8d3a2); box-shadow: 2px 5px 10px #79603a48;
}
.ink-paper::before { content: ''; position: absolute; inset: 10px; border: 1px solid #aa875759; }
.ink-paper b { position: relative; direction: rtl; line-height: 1.35; font-size: clamp(2rem, 6vw, 3.1rem); }
.ink-paper span { font-size: 1.1rem; font-weight: 690; color: #684c2a; }
.ink-pot {
  position: absolute; top: 15%; right: 12%; width: 18%; height: 33%; border-radius: 40% 41% 47% 46%;
  background: radial-gradient(ellipse at 40% 7%, #282117 29%, #bd9a63 31%, #79532e 44%, #32251a 85%);
  box-shadow: 2px 4px 9px #503c2b50;
}
.ink-pen {
  position: absolute; bottom: 26%; left: 29%; width: 56%; height: 5%;
  background: linear-gradient(180deg, #b88b4a, #7c552d 85%);
  transform: rotate(19deg); transform-origin: 8% 50%; border-radius: 20px;
}
.ink-pen::after {
  content: ''; position: absolute; inset: 0 auto 0 -6%; width: 10%;
  background: #353026; clip-path: polygon(0 100%, 48% 0, 100% 0, 100% 100%);
}
.abjad-scene[data-motion] .ink-pen { transform: translate(12%, -85%) rotate(31deg); }

.ritual-scene[data-motion] .book-leaf { transform: rotateY(-168deg); }
.hafez-scene[data-motion] .scene-cast img { transform: translateX(-66.666667%); }
.ritual-scene[data-motion] .scene-beam { opacity: 1; }
.coffee-scene[data-motion] .scene-cup { transform: translate(-50%, -2%) rotateX(0deg) rotateZ(-5deg); }
.coffee-scene[data-motion] [data-grounds] { opacity: .9; }

@media (prefers-reduced-motion: no-preference) {
  .quran-scene[data-motion="playing"] .book-leaf { animation: open-book 800ms cubic-bezier(.2,.69,.25,1) both; }
  .quran-scene[data-motion="playing"] .scene-beam { animation: light-page 800ms ease-out both; }
  .hafez-scene[data-motion="playing"] .scene-cast img { animation: open-divan 760ms steps(1, end) both; }
  .hafez-scene[data-motion="playing"] .scene-cast { animation: lean-poet 760ms ease-out both; }
  .coffee-scene[data-motion="playing"] .scene-cup { animation: flip-cup 920ms cubic-bezier(.32,.38,.23,1) both; }
  .coffee-scene[data-motion="playing"] .cup-shadow { animation: lift-shadow 920ms ease both; }
  .coffee-scene[data-motion="playing"] [data-grounds] { animation: settle-grounds 920ms ease-out both; }
  .ritual-scene[data-motion="playing"] .ink-pen { animation: write-letter 630ms ease-in-out both; }
  .ritual-scene[data-motion="playing"] .ink-paper b,
  .ritual-scene[data-motion="playing"] .ink-paper span { animation: appear-ink 630ms ease both; }
}
@keyframes open-book { from, 12% { transform: rotateY(0deg); } to { transform: rotateY(-168deg); } }
@keyframes lean-poet { from, to { transform: translateX(-50%); } 50% { transform: translateX(-50%) rotate(2deg); } }
@keyframes open-divan {
  from { transform: translateX(0); }
  27% { transform: translateX(-33.333333%); }
  65%, to { transform: translateX(-66.666667%); }
}
@keyframes light-page { from { opacity: .3; } to { opacity: 1; } }
@keyframes flip-cup {
  from { transform: translate(-50%, 0) rotateX(180deg); }
  20% { transform: translate(-53%, -10%) rotateX(185deg) rotateZ(-4deg); }
  53% { transform: translate(-46%, -28%) rotateX(73deg) rotateZ(6deg); }
  78% { transform: translate(-51%, -9%) rotateX(-14deg) rotateZ(-9deg); }
  to { transform: translate(-50%, -2%) rotateX(0deg) rotateZ(-5deg); }
}
@keyframes lift-shadow { 43% { opacity: .4; transform: scale(.76); } }
@keyframes settle-grounds { from, 55% { opacity: 0; } to { opacity: .9; } }
@keyframes write-letter {
  from { transform: rotate(19deg); }
  32% { transform: translate(34%, -285%) rotate(-14deg); }
  73% { transform: translate(-7%, -124%) rotate(23deg); }
  to { transform: translate(12%, -85%) rotate(31deg); }
}
@keyframes appear-ink { from, 30% { opacity: 0; } to { opacity: 1; } }

.deck { max-width: 536px; }
.tarot-card {
  display: block; position: relative; min-width: 0; min-height: 44px; aspect-ratio: 5 / 7;
  padding: 0; border: 0; background: none; color: #f9e7b9; perspective: 420px;
}
.tarot-card:disabled { cursor: default; }
.tarot-faces {
  position: absolute; inset: 0; transform-style: preserve-3d; border-radius: 8px;
  transition: transform 450ms cubic-bezier(.2,.65,.25,1);
}
.tarot-card.is-open .tarot-faces { transform: rotateY(180deg); }
.tarot-back, .tarot-front {
  position: absolute; inset: 0; display: grid; align-content: center; justify-items: center; gap: 4px;
  border-radius: inherit; backface-visibility: hidden; border: 1px solid #82718d;
}
.tarot-back { background: #463754; box-shadow: inset 0 0 0 5px #463754, inset 0 0 0 6px #c4a574af; }
.tarot-card:not(:disabled):hover .tarot-back { background: #5c496a; }
.tarot-front {
  background: #f2e8dc; color: #483653; transform: rotateY(180deg);
  border-color: #c7aa87; padding: 4px; font-size: clamp(.65rem, 1.6vw, .87rem); line-height: 1.35;
}
.tarot-faces .icon { width: clamp(15px, 3.7vw, 30px); height: auto; }

@media (max-width: 720px) {
  .fortune-hero { min-height: 0; }
  .fortune-copy { grid-row: 1; padding-block: 29px 19px; }
  .fortune-copy h1, .fortune-copy p { width: 100%; }
  .fortune-copy p { margin-block: 9px 15px; }
  .fortune-image, .hafez-hero .fortune-image {
    position: relative; grid-row: 2; z-index: 0; width: 100%;
    height: clamp(185px, 58vw, 290px); margin-block-start: -8px;
    mask-image: linear-gradient(to bottom, transparent, #000 20%);
  }
  .fortune-copy { position: relative; z-index: 1; }
  .scene-panel { grid-template-columns: 1fr; }
  .ritual-scene { min-height: 160px; border-radius: 0 0 var(--radius) var(--radius); }
  .scene-art { width: min(100%, 310px); }
  .fortune-content .interactive { margin-block-start: 18px; }
}

@media (max-width: 374px) {
  [data-tarot].interaction-box { padding-inline: 14px; }
}
