/*##############################################################################
# Script:        tarot.css           (stylesheet, loaded by frontend/pages/wisdom.html)
# Created by:    Matthew Boucher
# Start date:    2026-10-20
# Location:      <project root>/frontend/css/tarot.css   (main script: <project root>/aiacolyte.py)
# Description:   The Digital Tarot Cards tab of /wisdom: the page background while it is open (the "Tarot" picture,
#                darkened, body.is-tarot), its banner picture (the library), its two tabs (Ask the cards, Card pictures), the deck picker,
#                the reading form (the question), the cards dealt face
#                down and turned over in 3D (a reversed card turns upside down), each card's meaning under it, the AI's
#                spell conjured while the mirror is asked (a rune circle turning both ways, glow and sparks, then a flash),
#                the reading in the Magic Mirror (an oval silver frame, dark glowing glass), the card search, the deck as a grid of cards grouped by arcana and suit, the card dialog (the full front and back side by side, and what the card means), and the
#                admin class's tools under each card and its deck manager. Cards keep a 3:5 portrait shape. Without
#                motion (prefers-reduced-motion) the cards turn at once. Stacks on a phone.
# Reads:         the colour and font tokens of styles.css
# Writes:        nothing
# Arguments:     none (a stylesheet cannot take flags); aiacolyte.py --checkup confirms it is in place
##############################################################################*/
.tarot h2 {
  margin: 0 0 0.6rem;
  font-family: var(--font-display);
  font-size: 1.25rem;
  letter-spacing: 0.04em;
  color: var(--gold-bright);
}

.tarot-reading,
.tarot-deck {
  margin: 0 0 2.6rem;
}

/* ---------- the whole page's background while the tarot tab is open (wisdom.js sets body.is-tarot) ---------- */
/* the owner's "Tarot: reflection, insight, guidance, growth" picture (2026-10-21), fixed behind the page and darkened so every word stays easy to read; a fixed layer rather than
   background-attachment: fixed, which phones ignore */
html body.is-tarot::before {   /* html: wins over the /wisdom page background whatever the file order */
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    linear-gradient(to bottom, rgba(10, 8, 7, 0.8), rgba(10, 8, 7, 0.9) 40%, rgba(10, 8, 7, 0.96)),
    url("/static/assets/img/tarot-guide.webp") center 35% / cover no-repeat;
  animation: tarot-bg-in 0.6s ease both;
}

@media (max-width: 800px) {
  html body.is-tarot::before {
    background:
      linear-gradient(to bottom, rgba(10, 8, 7, 0.8), rgba(10, 8, 7, 0.9) 40%, rgba(10, 8, 7, 0.96)),
      url("/static/assets/img/tarot-guide-768.webp") center 35% / cover no-repeat;
  }
}

@keyframes tarot-bg-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  html body.is-tarot::before { animation: none; }
}

/* ---------- the banner picture at the top of the tarot tab ---------- */
.tarot-banner {
  position: relative;
  margin: 0 0 1.4rem;
  overflow: hidden;
  border-radius: 14px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5), 0 0 0 1px var(--line);
}

.tarot-banner img {
  display: block;
  width: 100%;
  height: clamp(200px, 40vw, 500px);
  object-fit: cover;
  object-position: 50% 58%;   /* the three cards and the mirror stay in view */
}

.tarot-banner::after {   /* a soft fade into the page below */
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 30%;
  background: linear-gradient(to bottom, transparent, rgba(17, 14, 11, 0.55));
  pointer-events: none;
}

/* ---------- the two tabs (Ask the cards, Card pictures) and the deck picker ---------- */
.tarot-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 14px;
  border-bottom: 1px solid var(--line);
}

.tarot-tabs__tab {
  appearance: none;
  cursor: pointer;
  margin-bottom: -1px;
  padding: 0.55em 1.1em;
  font-family: var(--font-display);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px 8px 0 0;
}

.tarot-tabs__tab:hover {
  color: var(--gold-bright);
}

.tarot-tabs__tab:focus-visible {
  outline: 2px solid var(--gold-bright);
  outline-offset: 2px;
}

.tarot-tabs__tab[aria-selected="true"] {
  color: var(--gold-bright);
  border-color: var(--line);
  border-bottom-color: var(--ink-1);
  background: rgba(227, 176, 75, 0.06);
}

.tarot-reading[hidden],
.tarot-deck[hidden],
.tarot-admin[hidden] {
  display: none;
}

.tarot-deckbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin: 0 0 18px;
}

.tarot-deckbar label {
  font-family: var(--font-display);
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  color: var(--gold);
}

.tarot-deckbar select {
  min-width: 220px;
  padding: 0.4em 0.6em;
  font: inherit;
  font-size: 1.05rem;
  color: var(--text);
  background: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.tarot-deckbar select:focus-visible {
  outline: 2px solid var(--gold-bright);
  outline-offset: 2px;
}

.tarot-deckbar__style {
  font-style: italic;
  color: var(--text-faint);
}

/* ---------- the form ---------- */
.tarot-ask {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px 22px;
  align-items: end;
  max-width: 900px;
}

.tarot-question {
  margin: 0;
}

.tarot-ask .admin-actions {
  margin: 0;
}

/* ---------- the cards drawn ---------- */
.tarot-spread {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 230px));
  justify-content: center;
  gap: 28px;
  margin: 1.8rem 0 0.6rem;
}

.tarot-slot {
  margin: 0;
  text-align: center;
  animation: tarot-deal 0.45s var(--ease) both;
}

.tarot-slot:nth-child(2) { animation-delay: 0.12s; }
.tarot-slot:nth-child(3) { animation-delay: 0.24s; }

@keyframes tarot-deal {
  from { opacity: 0; transform: translateY(-18px) rotate(-3deg); }
  to { opacity: 1; transform: none; }
}

.tarot-slot__pos {
  margin-bottom: 0.6rem;
  font-family: var(--font-display);
  font-size: 0.82rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
}

.tarot-card {
  aspect-ratio: 3 / 5;
  perspective: 1200px;
}

.tarot-card__inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.7s var(--ease);
}

.tarot-card img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 12px;
  backface-visibility: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45), 0 0 0 1px var(--line);
  background: var(--indigo-deep);
}

.tarot-card__front {
  transform: rotateY(180deg);
}

.tarot-slot.is-turned .tarot-card__inner {
  transform: rotateY(180deg);
}

.tarot-slot.is-turned.is-reversed .tarot-card__inner {
  transform: rotateY(180deg) rotateZ(180deg);
}

.tarot-slot__meaning {
  margin-top: 0.9rem;
  animation: tarot-fade 0.4s ease both;
}

.tarot-slot__meaning h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.05rem;
  color: var(--gold-bright);
}

.tarot-slot__side {
  margin: 0.1rem 0 0.35rem;
  font-style: italic;
  color: var(--text-faint);
}

.tarot-slot__meaning p:last-child {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.45;
  color: var(--text);
}

@keyframes tarot-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.tarot-ai {
  max-width: 760px;
  margin: 1.6rem auto 0;
  text-align: center;
}

/* the spell conjured while the Magic Mirror is asked: a rune circle turning both ways, a pulsing glow and sparks */
.tarot-conjure {
  position: relative;
  width: min(240px, 70vw);
  aspect-ratio: 1;
  margin: 0.6rem auto 0.4rem;
  animation: tarot-conjure-in 0.7s var(--ease) both;
}

.tarot-conjure[hidden] {
  display: none;
}

.tarot-conjure__circle {
  width: 100%;
  height: 100%;
  overflow: visible;
  filter: drop-shadow(0 0 10px rgba(227, 176, 75, 0.55)) drop-shadow(0 0 22px rgba(140, 200, 255, 0.35));
}

.tarot-conjure__outer,
.tarot-conjure__inner,
.tarot-conjure__glow,
.tarot-conjure__star {
  transform-box: view-box;
  transform-origin: 120px 120px;
}

.tarot-conjure__outer { animation: tarot-turn 9s linear infinite; }
.tarot-conjure__inner { animation: tarot-turn 6s linear infinite reverse; }
.tarot-conjure__glow { animation: tarot-pulse 1.6s ease-in-out infinite; }
.tarot-conjure__star { animation: tarot-pulse 1.1s ease-in-out infinite; }

.tarot-conjure__spark {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 6px;
  height: 6px;
  margin: -3px 0 0 -3px;
  border-radius: 50%;
  background: #fff6d8;
  box-shadow: 0 0 8px 2px rgba(246, 216, 139, 0.9), 0 0 16px 4px rgba(140, 200, 255, 0.5);
  opacity: 0;
  animation: tarot-spark 1.8s ease-out infinite;
}

.tarot-conjure__spark:nth-of-type(2n) { animation-delay: 0.45s; }
.tarot-conjure__spark:nth-of-type(3n) { animation-delay: 0.9s; }
.tarot-conjure__spark:nth-of-type(4n) { animation-delay: 1.3s; }

/* the flash as the spell becomes the mirror */
.tarot-conjure.is-fading {
  animation: tarot-conjure-out 0.6s ease-in forwards;
}

.tarot-conjure__words {
  min-height: 1.6em;
  margin: 0.2rem 0 0;
  font-family: var(--font-display);
  font-size: 0.95rem;
  letter-spacing: 0.06em;
  color: var(--gold-bright);
  text-shadow: 0 0 10px rgba(227, 176, 75, 0.45);
}

@keyframes tarot-turn {
  to { transform: rotate(360deg); }
}

@keyframes tarot-pulse {
  0%, 100% { opacity: 0.55; transform: scale(0.92); }
  50% { opacity: 1; transform: scale(1.08); }
}

@keyframes tarot-spark {
  0% { opacity: 0; transform: rotate(var(--a)) translateY(-20px) scale(0.4); }
  20% { opacity: 1; }
  100% { opacity: 0; transform: rotate(var(--a)) translateY(-120px) scale(1.1); }
}

@keyframes tarot-conjure-in {
  from { opacity: 0; transform: scale(0.6) rotate(-30deg); }
  to { opacity: 1; transform: none; }
}

@keyframes tarot-conjure-out {
  0% { opacity: 1; transform: scale(1); filter: brightness(1); }
  40% { opacity: 1; transform: scale(1.12); filter: brightness(2.2); }
  100% { opacity: 0; transform: scale(1.5); filter: brightness(3) blur(6px); }
}

@media (prefers-reduced-motion: reduce) {
  .tarot-conjure,
  .tarot-conjure__outer,
  .tarot-conjure__inner,
  .tarot-conjure__glow,
  .tarot-conjure__star,
  .tarot-conjure__spark {
    animation: none;
  }

  .tarot-conjure__spark {
    display: none;
  }
}

/* the Magic Mirror's answer: an oval silver-and-gold frame around dark, faintly glowing glass */
.tarot-mirror {
  position: relative;
  max-width: 640px;
  margin: 1.4rem auto 0;
  padding: 18px;
  border-radius: 50% / 22%;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(255, 255, 255, 0.35), transparent 40%),
    linear-gradient(145deg, #f6d88b, #a8792a 35%, #e8e4dc 55%, #8f7a52 75%, #f6d88b);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55), 0 0 40px rgba(140, 200, 255, 0.12);
  animation: tarot-mirror-wake 1.2s ease both;
}

.tarot-mirror[hidden] {
  display: none;
}

.tarot-mirror__title {
  position: absolute;
  top: -0.9rem;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.2rem 1rem;
  font-family: var(--font-display);
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--ink-1);
  background: var(--gold);
  border-radius: 999px;
}

.tarot-mirror__glass {
  padding: 2.4rem 2.6rem 2.2rem;
  border-radius: 50% / 20%;
  text-align: center;
  color: #e8f1ff;
  background:
    radial-gradient(ellipse at 50% 35%, rgba(140, 200, 255, 0.22), transparent 65%),
    radial-gradient(ellipse at 50% 120%, rgba(43, 39, 102, 0.9), transparent 70%),
    #0d1024;
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.85), inset 0 0 6px rgba(255, 255, 255, 0.25);
}

.tarot-mirror__glass p {
  margin: 0 0 0.9rem;
  font-size: 1.14rem;
  font-style: italic;
  line-height: 1.6;
  text-shadow: 0 0 12px rgba(140, 200, 255, 0.45);
  animation: tarot-mirror-words 1.6s ease both;
}

.tarot-mirror__glass p:nth-child(2) { animation-delay: 0.5s; }
.tarot-mirror__glass p:nth-child(3) { animation-delay: 1s; }
.tarot-mirror__glass p:nth-child(n + 4) { animation-delay: 1.4s; }

.tarot-mirror__glass p:last-child {
  margin-bottom: 0;
}

@keyframes tarot-mirror-wake {
  from { opacity: 0; transform: scale(0.96); filter: blur(4px); }
  to { opacity: 1; transform: none; filter: none; }
}

@keyframes tarot-mirror-words {
  from { opacity: 0; filter: blur(3px); }
  to { opacity: 1; filter: none; }
}

@media (max-width: 720px) {
  .tarot-mirror { padding: 12px; border-radius: 40px; }
  .tarot-mirror__glass { padding: 2rem 1.2rem 1.6rem; border-radius: 30px; }
}

@media (prefers-reduced-motion: reduce) {
  .tarot-mirror, .tarot-mirror__glass p { animation: none; }
}

/* ---------- the search ---------- */
.tarot-search {
  max-width: 420px;
  margin: 0.4rem 0 0.2rem;
}

.tarot-grid[hidden],
.tarot-group[hidden],
.tarot-grid li[hidden],
.tarot-tile[hidden] {
  display: none;
}

/* ---------- the deck ---------- */
.tarot-group {
  margin: 1.4rem 0 0.7rem;
  padding-bottom: 0.3rem;
  font-family: var(--font-display);
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  color: var(--gold);
  border-bottom: 1px solid var(--line);
}

.tarot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 14px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tarot-thumb {
  display: grid;
  gap: 6px;
  width: 100%;
  padding: 0;
  font: inherit;
  color: var(--text-dim);
  text-align: center;
  background: none;
  border: 0;
  cursor: pointer;
}

.tarot-thumb img {
  width: 100%;
  height: auto;
  aspect-ratio: 3 / 5;
  object-fit: cover;
  border-radius: 8px;
  background: var(--indigo-deep);
  box-shadow: 0 0 0 1px var(--line);
  transition: transform 0.2s var(--ease), box-shadow 0.2s ease;
}

.tarot-thumb span {
  font-size: 0.95rem;
  line-height: 1.2;
}

.tarot-thumb:hover img,
.tarot-thumb:focus-visible img {
  transform: translateY(-4px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4), 0 0 0 1px var(--gold);
}

.tarot-thumb:hover span,
.tarot-thumb:focus-visible span {
  color: var(--gold-bright);
}

.tarot-thumb:focus-visible {
  outline: 2px solid var(--gold-bright);
  outline-offset: 4px;
  border-radius: 8px;
}

/* ---------- the card dialog: full front and back, and what the card means ---------- */
.tarot-dialog {
  width: min(980px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  padding: 1.4rem;
  color: var(--text);
  background: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.tarot-dialog::backdrop {
  background: rgba(5, 4, 3, 0.8);
}

.tarot-dialog__close {
  float: right;
  width: 36px;
  height: 36px;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--text-dim);
  background: none;
  border: 1px solid var(--line);
  border-radius: 50%;
  cursor: pointer;
}

.tarot-dialog__close:hover {
  color: var(--gold-bright);
  border-color: var(--gold);
}

.tarot-dialog__pics {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin: 0.4rem 0 1.2rem;
}

.tarot-dialog__pics figure {
  flex: 1 1 0;
  min-width: 0;
  max-width: 300px;
  margin: 0;
  text-align: center;
}

.tarot-dialog__pics figure[hidden] {
  display: none;
}

.tarot-dialog__pics a {
  display: block;
  border-radius: 12px;
}

.tarot-dialog__pics a:focus-visible {
  outline: 2px solid var(--gold-bright);
  outline-offset: 4px;
}

.tarot-dialog__pics img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 12px;
  background: var(--indigo-deep);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.5), 0 0 0 1px var(--line);
}

.tarot-dialog__pics figcaption {
  margin-top: 0.5rem;
  font-family: var(--font-display);
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
}

.tarot-dialog__text {
  max-width: 68ch;
  margin: 0 auto;
}

.tarot-dialog h3 {
  margin: 0.2rem 0 0.8rem;
  font-family: var(--font-display);
  font-size: 1.5rem;
  color: var(--gold-bright);
}

.tarot-dialog h4 {
  margin: 0.9rem 0 0.2rem;
  font-family: var(--font-display);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  color: var(--gold);
}

.tarot-dialog p {
  margin: 0 0 0.6rem;
  font-size: 1.1rem;
  line-height: 1.55;
}

.tarot-dialog__text [hidden] {
  display: none;
}

/* ---------- the admin class: tools on each card, and the decks ---------- */
.tarot-grid--admin {
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 18px;
}

.tarot-tile {
  display: grid;
  gap: 6px;
  align-content: start;
}

.tarot-tile__src {
  font-size: 0.85rem;
  font-style: italic;
  text-align: center;
  color: var(--text-faint);
}

.tarot-tile__src--upload,
.tarot-tile__src--import { color: var(--arcane); }
.tarot-tile__src--ai { color: var(--gold); }

.tarot-tile__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}

.tarot-decks-admin {
  margin: 0 0 1.2rem;
  padding: 0.9rem 1.2rem;
}

.tarot-decks-admin summary {
  cursor: pointer;
  font-family: var(--font-display);
  font-size: 0.9rem;
  letter-spacing: 0.06em;
  color: var(--gold);
}

.tarot-decks-admin[open] summary {
  margin-bottom: 0.8rem;
}

.tarot-deck-form {
  margin-bottom: 1rem;
}

.tarot-deck-form h3 {
  margin: 0 0 0.4rem;
  font-family: var(--font-display);
  font-size: 0.95rem;
  color: var(--gold-bright);
}

@media (max-width: 720px) {
  .tarot-ask {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .tarot-spread {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 18px;
  }

  .tarot-spread .tarot-slot:nth-child(3) {
    grid-column: 1 / -1;
    justify-self: center;
    width: min(220px, 60%);
  }

  .tarot-grid {
    grid-template-columns: repeat(auto-fill, minmax(86px, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  .tarot-slot,
  .tarot-slot__meaning {
    animation: none;
  }

  .tarot-card__inner,
  .tarot-thumb img {
    transition: none;
  }
}

/*##############################################################################
# End of tarot.css
##############################################################################*/
