:root {
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  /* Center when it fits; when content is taller than the viewport, "safe" aligns
     to the top instead of clipping the top off-screen, and the page scrolls. */
  justify-content: safe center;
  padding: 1rem 1rem 3rem;
  background: radial-gradient(circle at 50% 20%, #2b1a4a 0%, #0f0a1e 70%);
  color: #f3ecff;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  text-align: center;
}

main {
  width: 100%;
  max-width: 46rem;
}

h1 {
  font-size: clamp(1.5rem, 6vw, 2.5rem);
  margin: 0 0 0.4rem;
}

.subtitle {
  font-size: clamp(1rem, 3.5vw, 1.25rem);
  opacity: 0.85;
  margin: 0.4rem 0;
}

.status {
  font-size: 0.95rem;
  opacity: 0.6;
}

.build {
  font-size: 0.8rem;
  opacity: 0.4;
  margin-top: 1.25rem;
}

#lang-switch {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  display: flex;
  gap: 0.35rem;
}

.lang {
  font-size: 1.4rem;
  line-height: 1;
  padding: 0.2rem 0.4rem;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  opacity: 0.55;
  transition: opacity 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

/* The switcher is a link per language (the active one is a plain span), so the
   anchors need the browser's link styling removed. */
a.lang {
  text-decoration: none;
  color: inherit;
}

span.lang {
  cursor: default;
}

.lang:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.lang.active {
  opacity: 1;
  border-color: #b48bf0;
  background: rgba(180, 139, 240, 0.18);
}

button#draw {
  margin: 1rem 0 0.5rem;
  padding: 0.75rem 2rem;
  font-size: 1.1rem;
  font-family: inherit;
  color: #f3ecff;
  background: linear-gradient(135deg, #6d4bd6, #a06be0);
  border: 1px solid #b48bf0;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
  box-shadow: 0 0 18px rgba(160, 107, 224, 0.4);
}

button#draw:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 0 28px rgba(160, 107, 224, 0.7);
}

button#draw:disabled {
  cursor: progress;
  opacity: 0.65;
}

#result {
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.reading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  width: 100%;
}

.card-col {
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Interpretation panel — appears to the right of the card on wide screens,
   below it on narrow ones. Hidden until a reading exists. */
.interpretation {
  text-align: left;
  max-width: 24rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(180, 139, 240, 0.25);
  border-radius: 12px;
  padding: 1rem 1.15rem;
}

#result:not(.has-reading) .interpretation {
  display: none;
}

.interp-heading {
  font-size: 0.8rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.7;
  margin: 0 0 0.5rem;
}

.interp-text {
  margin: 0;
  line-height: 1.55;
  font-size: clamp(0.95rem, 2.6vw, 1.05rem);
}

.interp-text.loading {
  opacity: 0.6;
  font-style: italic;
}

.listen {
  margin-top: 0.85rem;
  padding: 0.4rem 0.9rem;
  font-size: 0.9rem;
  font-family: inherit;
  color: #f3ecff;
  background: rgba(180, 139, 240, 0.16);
  border: 1px solid rgba(180, 139, 240, 0.5);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, opacity 0.15s ease;
}

.listen:hover:not(:disabled) {
  background: rgba(180, 139, 240, 0.3);
}

.listen:disabled {
  cursor: progress;
  opacity: 0.6;
}

.listen.playing {
  background: rgba(180, 139, 240, 0.4);
  border-color: #b48bf0;
}

@media (min-width: 620px) {
  .reading {
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
  }
  .card-col {
    flex: 0 0 auto;
  }
  .interpretation {
    flex: 0 1 20rem;
  }
}

.card-frame {
  /* Sized by the SMALLER of a height budget and a width budget, so the whole
     card always fits: never taller than 52% of the viewport, never wider than
     74vw (the third term bounds the derived width), never past its natural size.
     The vh line is a fallback for engines without dvh. */
  aspect-ratio: 300 / 524;
  /* Height budget = viewport minus the fixed chrome (title, button, the three
     description lines, marker, paddings ≈ 22rem), also bounded by a width budget
     (third term) and a natural max — so the card + description fit together on
     screen. A 150px floor keeps the card usable on very short viewports; below
     that the page scrolls gracefully (safe-center) rather than clipping. */
  height: max(150px, min(420px, 100vh - 22rem, 74vw * 524 / 300));
  height: max(150px, min(420px, 100dvh - 22rem, 74vw * 524 / 300));
  width: auto;
  max-width: 74vw;
  margin: 0 auto 0.75rem;
  border-radius: 12px;
  overflow: hidden;
  background: linear-gradient(135deg, #2a1c48, #3d2a63);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
}

/* The deck back — the card that has not been drawn yet. Fills the frame before
   the first draw and while the deck is being "consulted", so those states read
   as a face-down card rather than an empty slot. Scoped to #result because the
   reference pages' static frame always has a face in it.
   The art was padded to the frame's exact 300:524 when it was cut down for the
   web, so cover neither stretches it nor crops the gold border. Keep that ratio
   if the art is ever re-exported. */
#result .card-frame {
  background-image: url("/assets/card-back.jpg");
  background-size: cover;
  background-repeat: no-repeat;
}

/* The back is clickable (app.js draws from it), so say so — but only in the one
   state where the click does something: not mid-shuffle, not on a face-up card.
   The draw button stays the keyboard/assistive path, so the deck deliberately
   takes no tab stop of its own. */
#result:not(.suspense):not(.revealed) .card-frame {
  cursor: pointer;
}

/* Face up: drop the back. The scans vary a little in ratio, so object-fit
   leaves a sliver of frame at one edge — showing deck art there would look
   like a misprint rather than a card. */
#result.revealed .card-frame {
  background-image: none;
}

.card-img {
  width: 100%;
  height: 100%;
  object-fit: contain; /* show the full card face — never crop the art */
  display: block;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.4s ease;
}

.card-name {
  font-size: clamp(1.4rem, 6vw, 2.4rem);
  font-weight: 700;
  line-height: 1.05;
  margin: 0;
  color: #e9d8ff;
  text-shadow: 0 0 20px rgba(180, 139, 240, 0.6);
  overflow-wrap: break-word;
}

.card-number {
  font-size: 1rem;
  letter-spacing: 0.08em;
  opacity: 0.6;
  margin: 0.4rem 0 0;
  text-transform: uppercase;
}

.card-orientation {
  font-size: clamp(1rem, 4vw, 1.35rem);
  letter-spacing: 0.04em;
  margin: 0.5rem 0 0;
  opacity: 0.9;
  text-transform: uppercase;
}

/* Anticipation: dim and pulse while the cards are "consulted".
   The image hides (falls back to its base opacity:0), leaving the frame's
   placeholder gradient pulsing. */
#result.suspense .card-frame {
  animation: pulse 0.9s ease-in-out infinite alternate;
}

#result.suspense .card-name {
  opacity: 0.55;
  animation: pulse 0.6s ease-in-out infinite alternate;
}

#result.suspense .card-orientation {
  opacity: 0.6;
  font-style: italic;
  text-transform: none;
}

@keyframes pulse {
  from { opacity: 0.35; transform: scale(0.97); }
  to   { opacity: 0.75; transform: scale(1.03); }
}

/* Reveal: settle in with a soft pop. */
#result.revealed .card-img {
  opacity: 1;
}

#result.revealed .card-frame {
  animation: reveal 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

#result.revealed .card-name {
  animation: reveal 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes reveal {
  from { opacity: 0; transform: scale(0.6) rotate(-6deg); }
  to   { opacity: 1; transform: scale(1) rotate(0); }
}

/* The "direction": an upside-down draw flips the card image 180°. */
#result.revealed.reversed .card-img {
  transform: rotate(180deg);
}

/* Very short viewports (e.g. landscape phones): trim non-essential chrome so the
   card and its description still fit together on one screen. */
@media (max-height: 480px) {
  h1 { font-size: 1.4rem; margin-bottom: 0.15rem; }
  .subtitle { display: none; }
  button#draw { margin: 0.5rem 0; padding: 0.5rem 1.5rem; }
  .card-name { font-size: 1.3rem; }
  .card-number { margin-top: 0.2rem; }
  .card-orientation { font-size: 0.95rem; margin-top: 0.25rem; }
  .build { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  #result.suspense .card-frame,
  #result.suspense .card-name,
  #result.revealed .card-frame,
  #result.revealed .card-name,
  button#draw {
    animation: none;
    transition: none;
  }
  /* Keep the reversal readable without the spin transition. */
  .card-img {
    transition: opacity 0.3s ease;
  }
}

/* Collapsed about/FAQ block. Closed by default so it stays out of the way, but
   it is real content in the DOM — accordion text is indexed at full weight,
   unlike CSS-hidden copy, which is a spam-policy violation. */
.about {
  margin: 2.5rem auto 0;
  max-width: 42rem;
  text-align: left;
  border-top: 1px solid rgba(180, 139, 240, 0.25);
  padding-top: 1rem;
}

.about > summary {
  cursor: pointer;
  list-style: none;
  font-size: 0.95rem;
  opacity: 0.7;
  text-align: center;
  padding: 0.4rem;
  border-radius: 8px;
}

.about > summary::-webkit-details-marker {
  display: none;
}

.about > summary::after {
  content: " ▾";
  opacity: 0.7;
}

.about[open] > summary::after {
  content: " ▴";
}

.about > summary:hover {
  opacity: 1;
}

.about-body {
  font-size: 0.95rem;
  line-height: 1.65;
  opacity: 0.82;
}

.about-body p {
  margin: 0.8rem 0;
}

.faq-heading {
  font-size: 1.05rem;
  margin: 1.6rem 0 0.6rem;
  opacity: 0.95;
}

.faq-q {
  font-size: 0.95rem;
  margin: 1.1rem 0 0.2rem;
  color: #c4a5ff;
}

.faq-a {
  margin: 0.2rem 0 0;
}

/* Link from the draw page into the card reference. Without a real internal
   link the 234 card pages would be orphans, reachable only via the sitemap. */
.cta--index {
  margin-top: 2rem;
}

.cta--index a {
  color: #c4a5ff;
  text-decoration: none;
  font-size: 0.95rem;
  border-bottom: 1px solid rgba(196, 165, 255, 0.4);
  padding-bottom: 2px;
}

.cta--index a:hover {
  color: #f3ecff;
  border-bottom-color: #f3ecff;
}

/* Premium "ask the cards" panel. Hidden until app.js confirms a token, so
   non-subscribers are never shown a teaser they cannot use. */
.ask {
  margin: 2rem auto 0;
  max-width: 34rem;
  text-align: left;
  padding: 1rem 1.15rem;
  border: 1px solid rgba(180, 139, 240, 0.35);
  border-radius: 12px;
  background: rgba(180, 139, 240, 0.07);
}

.ask-heading {
  font-size: 0.8rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.75;
  margin: 0 0 0.6rem;
}

/* Reads above the input, not with the small print below it: this is what the
   feature does, not a caveat about it. */
.ask-intro {
  font-size: 0.9rem;
  line-height: 1.5;
  opacity: 0.85;
  margin: 0 0 0.8rem;
}

.ask form {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
}

#ask-input {
  flex: 1;
  padding: 0.6rem;
  border-radius: 8px;
  border: 1px solid #4a3a6e;
  background: #1a1230;
  color: #f3ecff;
  font: inherit;
  resize: vertical;
}

#ask-submit {
  padding: 0.6rem 1.1rem;
  font-family: inherit;
  color: #f3ecff;
  background: linear-gradient(135deg, #6d4bd6, #a06be0);
  border: 1px solid #b48bf0;
  border-radius: 999px;
  cursor: pointer;
}

#ask-submit:disabled {
  cursor: progress;
  opacity: 0.6;
}

.ask-quota {
  font-size: 0.85rem;
  opacity: 0.65;
  margin: 0.6rem 0 0;
}

/* Echo of the question, so the answer is visibly tied to what was asked. */
.ask-asked {
  margin: 0.8rem 0 0;
  padding-left: 0.8rem;
  border-left: 2px solid rgba(180, 139, 240, 0.5);
  font-style: italic;
  opacity: 0.75;
  font-size: 0.95rem;
}

/* Site-wide disclaimer. Quiet but always present — never hidden behind a
   toggle, since the premium questions invite exactly the kind of question
   that must not be read as advice. */
.disclaimer {
  font-size: 0.78rem;
  line-height: 1.5;
  opacity: 0.5;
  max-width: 40rem;
  margin: 1.75rem auto 0;
}

.ask-disclaimer {
  font-size: 0.75rem;
  opacity: 0.55;
  margin: 0.5rem 0 0;
}

/* Who runs the site. The bottom padding clears the language switcher, which is
   fixed to that corner and would otherwise sit on top of the contact link. */
.site-footer {
  margin: 2.5rem auto 0;
  padding: 0 1rem 4.5rem;
  max-width: 40rem;
  text-align: center;
  font-size: 0.75rem;
  line-height: 1.6;
  opacity: 0.45;
}

.site-footer p {
  margin: 0.2rem 0;
}

.site-footer a {
  color: inherit;
}

.site-footer-links a {
  white-space: nowrap;
}

/* The offer, shown where the beta signup used to be. Same frame as the beta
   block so the panel does not jump when one replaces the other. */
.subscribe {
  margin-top: 0.9rem;
  padding-top: 0.9rem;
  border-top: 1px solid rgba(180, 139, 240, 0.25);
}

.subscribe-notice {
  font-size: 0.85rem;
  line-height: 1.55;
  opacity: 0.85;
  margin: 0 0 0.85rem;
}

.subscribe-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  justify-content: center;
  margin: 0 0 0.6rem;
}

.buy {
  display: inline-block;
  padding: 0.55rem 1.1rem;
  border-radius: 999px;
  background: rgba(180, 139, 240, 0.18);
  border: 1px solid rgba(180, 139, 240, 0.55);
  color: inherit;
  text-decoration: none;
  font-size: 0.92rem;
  line-height: 1.3;
}

.buy:hover,
.buy:focus-visible {
  background: rgba(180, 139, 240, 0.3);
}

.buy span {
  display: block;
  font-size: 0.72rem;
  opacity: 0.7;
}

/* The access link on the post-checkout page. Long, and the one thing on that
   page worth copying, so it wraps rather than overflowing on a phone. */
.premium-link a {
  font-size: 0.8rem;
  word-break: break-all;
  opacity: 0.85;
}

/* Terms, refunds, privacy. Plain prose at a comfortable reading measure —
   these are pages people arrive at with a specific question, so nothing is
   collapsed and nothing competes with the text. */
.legal {
  max-width: 42rem;
  margin: 0 auto;
  padding: 2.5rem 1.25rem 0;
  text-align: left;
}

.legal h1 {
  font-size: clamp(1.5rem, 4vw, 2rem);
  margin: 0.6rem 0 0.3rem;
}

.legal h2 {
  font-size: 1.05rem;
  margin: 2rem 0 0.5rem;
  opacity: 0.92;
}

.legal p {
  font-size: 0.95rem;
  line-height: 1.65;
  margin: 0 0 0.85rem;
  opacity: 0.82;
}

.legal-home a {
  font-size: 0.8rem;
  opacity: 0.6;
  text-decoration: none;
}

.legal-updated {
  font-size: 0.78rem;
  opacity: 0.5 !important;
  margin-bottom: 1.5rem;
}

/* Beta signup — shown to everyone without a token, which is nearly everyone.
   Set off by a rule rather than a second card: it is part of the ask panel,
   not a competing offer. */
.beta {
  margin-top: 0.9rem;
  padding-top: 0.9rem;
  border-top: 1px solid rgba(180, 139, 240, 0.25);
}

.beta-notice {
  font-size: 0.9rem;
  line-height: 1.5;
  opacity: 0.9;
  margin: 0 0 0.7rem;
}

.beta form {
  display: flex;
  gap: 0.5rem;
}

#beta-email {
  flex: 1 1 auto;
  min-width: 0; /* without this a flex input refuses to shrink below its size */
  padding: 0.5rem 0.7rem;
  color: #f3ecff;
  font: inherit;
  font-size: 0.95rem;
  background: rgba(15, 10, 30, 0.6);
  border: 1px solid rgba(180, 139, 240, 0.4);
  border-radius: 8px;
}

#beta-email::placeholder {
  color: rgba(243, 236, 255, 0.4);
}

#beta-submit {
  flex: 0 0 auto;
  padding: 0.5rem 1.1rem;
  color: #f3ecff;
  font: inherit;
  font-size: 0.9rem;
  background: linear-gradient(135deg, #6d4bd6, #a06be0);
  border: 1px solid #b48bf0;
  border-radius: 999px;
  cursor: pointer;
}

#beta-submit:disabled {
  opacity: 0.6;
  cursor: default;
}

/* The honeypot. Kept out of the layout, out of the tab order and out of the
   accessibility tree — a person should never find it to fill it in. */
.beta-website {
  display: none;
}

.beta-status {
  font-size: 0.85rem;
  margin: 0.6rem 0 0;
  min-height: 1.2em; /* reserve the line so the panel does not jump on submit */
}

.beta-status--done {
  color: #c4a5ff;
}

/* The free draw, offered to someone who has just been told they cannot ask.
   Full-strength text, not small print — it is the thing they can actually do. */
.beta-meanwhile {
  font-size: 0.9rem;
  line-height: 1.5;
  opacity: 0.9;
  margin: 0.7rem 0 0;
}

.beta-draw {
  margin: 0.4rem 0 0;
}

.beta-draw a {
  color: #c4a5ff;
  font-size: 0.95rem;
  text-decoration: none;
}

.beta-draw a:hover {
  text-decoration: underline;
}

/* Narrow screens: the address and its button stop fitting side by side well
   before the question box does — the button's label is a whole phrase. */
@media (max-width: 460px) {
  .beta form {
    flex-direction: column;
    align-items: stretch;
  }
}

/* Link to the channel's video for the drawn card. Hidden unless that card has
   one in the current language. */
.watch {
  margin: 0.85rem 0 0;
  font-size: 0.9rem;
}

.watch a {
  color: #ff6b6b;
  text-decoration: none;
  border-bottom: 1px solid rgba(255, 107, 107, 0.45);
  padding-bottom: 2px;
}

.watch a:hover {
  color: #fff;
  border-bottom-color: #fff;
}
