:root {
  --ink: rgba(244, 220, 199, 1);
  --ink-dim: rgba(244, 233, 239, 0.72);
  --gold: #e8b7a0;
  --maroon: #2a0f1d;
  --ui-fade: 1400ms;
  --content-y: 43vh;
  --band: 24vh;
  --circle-size: 60vh;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-fade: cubic-bezier(0.4, 0, 0.2, 1);
  --ink-blue: #627c8e;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #1a0a14;
  color: var(--ink);
  font-family: "Mulish", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  position: fixed;
  inset: 0;
  touch-action: none;
}

/* Background + gradient layers (behind the canvas) */
.bg-layer {
  position: fixed;
  inset: 0;
  z-index: 0;
  opacity: 1;
  pointer-events: none;
}

#intro {
  color: var(--ink-blue);
  font-size: 0.7rem;
  line-height: 1.42;
}

@media (min-width: 768px) {
  #intro {
    font-size: 0.9rem;
    line-height: 1.5;
  }
}

#bg img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gradient {
  z-index: 1;
  background: radial-gradient(
    96.11% 100% at 50% 0%,
    rgba(70, 49, 119, 0) 0%,
    rgba(8, 2, 13, 0.72) 52.88%
  );
}

#circle {
  position: fixed;
  left: 50%;
  top: var(--content-y);
  width: var(--circle-size);
  height: var(--circle-size);
  margin: calc(var(--circle-size) / -2) 0 0 calc(var(--circle-size) / -2);
  z-index: 2;
  opacity: 0.7;
  transition: opacity var(--ui-fade) var(--ease-fade);
  pointer-events: none;
  animation: circle-turn 105s linear infinite;
}

#circle.reading-active {
  opacity: 1;
}

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

/* Canvas renders the cards */
#stage {
  position: fixed;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  z-index: 2;
  opacity: 1;
  transition: opacity var(--ui-fade) var(--ease-fade);
}

body.about-open #stage {
  opacity: 0;
  pointer-events: none;
}

#aboutPanel {
  position: fixed;
  left: 50%;
  top: var(--content-y);
  width: var(--card-width);
  height: var(--card-height);
  z-index: 3;
  transform: translate(-50%, -50%);
  padding: 1.25rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  scrollbar-width: thin;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  background: transparent;
  color: var(--ink);
  font-size: clamp(0.65rem, 1vh, 1rem);
  font-weight: 100;
  line-height: 1.5;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity var(--ui-fade) var(--ease-fade),
    visibility var(--ui-fade);
}

body.about-open #aboutPanel {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

#aboutPanel h2 {
  margin-bottom: 0.75rem;
  color: rgba(108, 100, 135, 1);
  font-size: 0.5rem;
  font-weight: 600;
}

#aboutPanel p + p,
.about-links {
  margin-top: 0.75rem;
}

.about-links {
  display: grid;
  gap: 0.25rem;
}

.about-links a {
  color: inherit;
  text-underline-offset: 3px;
}

.ui-layer {
  position: fixed;
  left: 0;
  right: 0;
  z-index: 3;
  pointer-events: none;
  opacity: 0;
  transform: translateY(14px);
  transition:
    opacity var(--ui-fade) var(--ease-fade),
    transform var(--ui-fade) var(--ease-fade);
}

.ui-layer.show {
  opacity: 1;
  transform: translateY(0);
}

/* Branding stays above the cards throughout the reading. */
#masthead {
  top: 3rem;
  text-align: center;
  padding: 0 1rem;
  transform: none;
  animation: logo-in 900ms var(--ease-fade) both;
}

@media (min-width: 768px) {
  #masthead {
    top: 11vh;
  }
}

#logo {
  width: min(43vw, 215px);
  height: auto;
  max-height: 10vh;
  object-fit: contain;
}

#logoFallback .title,
#logoFallback .subtitle {
  display: block;
}

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

.title {
  font-family: "Cormorant SC", serif;
  font-weight: 700;
  font-size: clamp(2.2rem, 8vw, 3.5rem);
  line-height: 1.1;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-shadow:
    0 2px 30px rgba(0, 0, 0, 0.55),
    0 0 60px rgba(232, 183, 160, 0.25);
}

.subtitle {
  font-family: "Mulish", system-ui, sans-serif;
  font-weight: 900;
  font-size: clamp(1rem, 2.6vw, 1rem);
  line-height: 1.17;
  text-align: center;
  text-transform: uppercase;
  color: var(--ink-dim);
}

#about {
  pointer-events: auto;
  cursor: pointer;
  font-size: 0.8rem;
  text-transform: uppercase;
  color: var(--ink-blue);
  text-decoration: none;
  transition:
    transform 260ms var(--ease),
    opacity 260ms var(--ease);
  background: none;
  border: none;
  padding: 0;
}

#about:hover,
#about:focus-visible {
  transform: translateY(-2px);
}

#about:disabled {
  pointer-events: none;
  opacity: 0.4;
}

/* CTA — sits just below the card deck */
#prompt {
  top: calc(var(--content-y) + var(--band) + 1rem);
  bottom: auto;
  display: grid;
  justify-items: center;
  gap: 1rem;
  padding: 0 1rem;
}

.cta {
  pointer-events: auto;
  cursor: pointer;
  font-family: "Mulish", system-ui, sans-serif;
  font-weight: 600;
  font-size: 0.9rem;
  letter-spacing: 0;
  text-transform: uppercase;
  color: var(--ink);
  border: 1px solid rgb(0 0 0 / 48%);
  min-width: 16rem;
  border-radius: 10px;
  padding: 1rem 2.2em;
  transition:
    transform 260ms var(--ease),
    opacity 260ms var(--ease);
  box-shadow: 0px 8px 8px 0px rgba(0, 0, 0, 0.25);
  background: linear-gradient(360deg, #171320 0%, #680511 87.5%);
  margin-bottom: 1rem;
}

.cta:disabled {
  pointer-events: none;
  opacity: 0.4;
}

#prompt:not(.show) .cta {
  pointer-events: none;
}

.cta:not(:disabled):hover,
.cta:not(:disabled):focus-visible {
  transform: translateY(-2px);
}

/* Reading (selected card name + description) — below the card, same as the prompt */
.reading {
  position: relative;
  top: auto;
  width: 100%;
  height: 100%;
  overflow-y: auto;
  touch-action: pan-y;
  color: var(--ink);
  font-size: 0.9rem;
  bottom: auto;
  gap: 0.9rem;
  padding: 0 0.8rem;
  margin: 0 auto;
}

@media (min-width: 768px) {
  .reading {
    max-width: 22.5rem;
  }
}

@media (max-height: 500px) and (orientation: landscape) {
  :root {
    --content-y: 40vh;
  }

  #prompt {
    grid-template-rows: 3.5rem auto;
    gap: 0.5rem;
    top: calc(var(--content-y) + var(--band) + 0.5rem);
  }

  .reading {
    max-width: 48rem;
    font-size: 1rem;
  }

  #logoFallback .title {
    font-size: clamp(1.3rem, 6vh, 2rem);
  }

  #logoFallback .subtitle {
    font-size: 0.75rem;
  }
}

@media (max-height: 600px) {
  #prompt {
    grid-template-rows: 3.5rem auto;
  }
}

.reading.show {
  pointer-events: auto;
}

.card-name {
  font-weight: 900;
  float: left;
}

.card-desc {
  font-weight: 300;
  line-height: 1.45;
  letter-spacing: 0.01em;
  color: var(--ink-dim);
  display: flex;
  text-wrap: balance;
  text-align: center;
}

.separator {
  float: left;
  margin: 0 0.5rem;
}

.again {
  pointer-events: auto;
  cursor: pointer;
  margin-top: 0.4rem;
  font-family: "Mulish", sans-serif;
  font-weight: 300;
  font-size: 0.95rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold);
  background: transparent;
  border: none;
  border-bottom: 1px solid rgba(232, 183, 160, 0.4);
  padding: 0.3em 0.2em;
  transition:
    color 220ms ease,
    border-color 220ms ease;
}

.again:hover,
.again:focus-visible {
  outline: none;
  color: var(--ink);
  border-color: var(--gold);
}

/* Footer */
#colophon {
  bottom: clamp(0.9rem, 2.6vh, 1.6rem);
  text-align: center;
  padding: 0 1.4rem;
  pointer-events: auto;
  z-index: 10;
}

#colophon p {
  font-weight: 200;
  font-size: clamp(0.62rem, 1.9vw, 0.78rem);
  letter-spacing: 0.04em;
  line-height: 1.4;
  color: rgba(244, 233, 239, 0.5);
}

#colophon a {
  color: inherit;
}

@media (prefers-reduced-motion: reduce) {
  #masthead,
  #circle {
    animation: none;
  }
  .ui-layer,
  #stage,
  #aboutPanel {
    transition: none;
  }
}
