/* ============================
   PAPYRUS IRIOSHY-SEI
   Design Tokens & Styles
   ============================ */

:root {
  /* Type Scale */
  --text-xs:   clamp(0.75rem,  0.7rem  + 0.25vw, 0.875rem);
  --text-sm:   clamp(0.875rem, 0.8rem  + 0.35vw, 1rem);
  --text-base: clamp(1rem,     0.95rem + 0.25vw, 1.125rem);
  --text-lg:   clamp(1.125rem, 1rem    + 0.75vw, 1.5rem);
  --text-xl:   clamp(1.5rem,   1.2rem  + 1.25vw, 2.25rem);
  --text-2xl:  clamp(2rem,     1.2rem  + 2.5vw,  3.5rem);

  /* Spacing */
  --space-1:  0.25rem;
  --space-2:  0.5rem;
  --space-3:  0.75rem;
  --space-4:  1rem;
  --space-5:  1.25rem;
  --space-6:  1.5rem;
  --space-8:  2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;

  /* Radius */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-full: 9999px;

  /* Transitions */
  --transition-interactive: 180ms cubic-bezier(0.16, 1, 0.3, 1);

  /* Fonts */
  --font-display: 'Zodiak', 'Georgia', serif;
  --font-body: 'Cormorant Garamond', 'Georgia', serif;

  /* Mystic Dark Palette */
  --color-bg:             #0a0a0f;
  --color-surface:        #111118;
  --color-surface-2:      #18181f;
  --color-surface-offset: #1a1a24;
  --color-border:         #2a2a38;
  --color-divider:        #222230;

  /* Text */
  --color-text:           #e8e4d9;
  --color-text-muted:     #9e9a8e;
  --color-text-faint:     #5a574e;

  /* Gold Accent */
  --color-primary:        #c9a84c;
  --color-primary-hover:  #dabb66;
  --color-primary-active: #b08e3a;
  --color-primary-highlight: rgba(201, 168, 76, 0.12);

  /* Deep Purple (secondary) */
  --color-secondary:      #5a3d7a;
  --color-secondary-hover:#7a55a0;

  /* Error */
  --color-error: #a13544;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.5);
  --shadow-gold: 0 0 30px rgba(201, 168, 76, 0.15);

  /* Content widths */
  --content-narrow: 640px;
  --content-default: 960px;
  --content-wide: 1200px;
}

/* ============================
   GLOBAL LAYOUT
   ============================ */

body {
  background: var(--color-bg);
  color: var(--color-text);
  overflow: hidden;
}

.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1),
              visibility 0.6s;
  padding: var(--space-6);
  overflow-y: auto;
}

.screen.active {
  opacity: 1;
  visibility: visible;
}

/* ============================
   SCREEN 1: WELCOME
   ============================ */

.welcome-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
}

.sacred-geometry {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 600px;
  height: 600px;
  border-radius: 50%;
  background: radial-gradient(ellipse at center,
    rgba(201, 168, 76, 0.06) 0%,
    rgba(90, 61, 122, 0.04) 40%,
    transparent 70%);
  animation: pulse-glow 6s ease-in-out infinite;
}

@keyframes pulse-glow {
  0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 0.6; }
  50% { transform: translate(-50%, -50%) scale(1.1); opacity: 1; }
}

.welcome-content {
  position: relative;
  z-index: 1;
  text-align: center;
  max-width: var(--content-narrow);
}

.logo-mark {
  margin: 0 auto var(--space-6);
  width: 100px;
  height: 100px;
  animation: logo-float 4s ease-in-out infinite;
}

@keyframes logo-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.logo-svg {
  width: 100%;
  height: 100%;
}

.title-main {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--color-primary);
  letter-spacing: 0.06em;
  margin-bottom: var(--space-2);
  text-shadow: 0 0 40px rgba(201, 168, 76, 0.3);
}

.subtitle {
  font-family: var(--font-body);
  font-size: var(--text-lg);
  color: var(--color-text-muted);
  font-style: italic;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: var(--space-1);
}

.subtitle-desc {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--color-text-faint);
  letter-spacing: 0.08em;
  margin-bottom: var(--space-8);
}

.welcome-text {
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--color-text-muted);
  line-height: 1.8;
  margin: 0 auto var(--space-6);
  max-width: 480px;
}

.author-credit {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--color-primary);
  font-style: italic;
  margin-bottom: var(--space-10);
  letter-spacing: 0.05em;
}

/* ============================
   SACRED BUTTON
   ============================ */

.btn-sacred {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4) var(--space-10);
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 500;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--color-bg);
  background: linear-gradient(135deg, var(--color-primary), #d4b85e);
  border: none;
  border-radius: var(--radius-full);
  cursor: pointer;
  overflow: hidden;
  transition: transform var(--transition-interactive),
              box-shadow var(--transition-interactive);
}

.btn-sacred:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-gold), 0 6px 20px rgba(201, 168, 76, 0.3);
}

.btn-sacred:active {
  transform: translateY(0);
}

.btn-sacred:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-sacred .btn-glow {
  position: absolute;
  inset: -2px;
  border-radius: inherit;
  background: linear-gradient(135deg, transparent, rgba(255,255,255,0.2), transparent);
  opacity: 0;
  transition: opacity 0.3s;
}

.btn-sacred:hover .btn-glow {
  opacity: 1;
  animation: shimmer 2s linear infinite;
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.btn-small {
  padding: var(--space-2) var(--space-6);
  font-size: var(--text-xs);
}

/* Back button */
.btn-back {
  position: absolute;
  top: var(--space-6);
  left: var(--space-6);
  color: var(--color-text-muted);
  z-index: 10;
  padding: var(--space-2);
  border-radius: var(--radius-full);
  transition: color var(--transition-interactive),
              background var(--transition-interactive);
}

.btn-back:hover {
  color: var(--color-primary);
  background: var(--color-primary-highlight);
}

/* ============================
   SCREEN 2: ACCESS GATE
   ============================ */

.access-content {
  text-align: center;
  max-width: var(--content-default);
  width: 100%;
}

.section-title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--color-primary);
  margin-bottom: var(--space-3);
  letter-spacing: 0.04em;
}

.access-desc {
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--color-text-muted);
  margin-bottom: var(--space-10);
  max-width: 500px;
  margin-inline: auto;
}

.access-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--space-6);
  margin-bottom: var(--space-10);
}

.access-card {
  position: relative;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-8) var(--space-6);
  text-align: center;
  transition: border-color var(--transition-interactive),
              box-shadow var(--transition-interactive);
}

.access-card:hover {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-gold);
}

.access-card.featured {
  border-color: var(--color-primary);
  background: linear-gradient(180deg, rgba(201,168,76,0.06) 0%, var(--color-surface) 40%);
}

.badge-popular {
  position: absolute;
  top: calc(-1 * var(--space-3));
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-primary);
  color: var(--color-bg);
  font-family: var(--font-display);
  font-size: var(--text-xs);
  font-weight: 500;
  padding: var(--space-1) var(--space-4);
  border-radius: var(--radius-full);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
}

.access-icon {
  font-size: 2rem;
  display: block;
  margin-bottom: var(--space-2);
}

.access-card h3 {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: var(--space-4);
}

.access-price {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--color-primary);
  margin-bottom: var(--space-2);
}

.price-period {
  font-size: var(--text-sm);
  font-weight: 400;
  color: var(--color-text-muted);
}

.access-detail {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-6);
  line-height: 1.6;
}

.divider-line {
  width: 100%;
  max-width: 300px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--color-border), transparent);
  margin: 0 auto var(--space-8);
}

.code-section {
  max-width: 400px;
  margin: 0 auto;
}

.code-label {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-4);
}

.code-input-wrap {
  display: flex;
  gap: var(--space-3);
  align-items: center;
}

.code-input-wrap input {
  flex: 1;
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: var(--text-base);
  text-align: center;
  letter-spacing: 0.2em;
}

.code-input-wrap input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-highlight);
}

.code-input-wrap input::placeholder {
  color: var(--color-text-faint);
  letter-spacing: 0.1em;
}

.code-error {
  font-size: var(--text-xs);
  color: var(--color-error);
  margin-top: var(--space-2);
  min-height: 1.5em;
}

/* ============================
   SCREEN 3: KEY INPUT
   ============================ */

.key-content {
  text-align: center;
  max-width: var(--content-narrow);
}

.key-desc {
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--color-text-muted);
  line-height: 1.8;
  margin-bottom: var(--space-10);
  max-width: 400px;
  margin-inline: auto;
}

.key-input-area {
  margin-bottom: var(--space-10);
}

.key-input {
  width: 160px;
  padding: var(--space-4) var(--space-6);
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  color: var(--color-primary);
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 700;
  text-align: center;
  letter-spacing: 0.15em;
  -moz-appearance: textfield;
  appearance: textfield;
}

.key-input::-webkit-inner-spin-button,
.key-input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.key-input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 4px var(--color-primary-highlight),
              var(--shadow-gold);
}

.key-input::placeholder {
  color: var(--color-text-faint);
}

.key-hint {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  margin-top: var(--space-3);
}

/* ============================
   SCREEN 4: RITUAL
   ============================ */

.ritual-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-8);
}

.ritual-circle {
  position: relative;
  width: 260px;
  height: 260px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ritual-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.ritual-ring-1 {
  animation: spin-slow 8s linear infinite;
  transform-origin: 150px 150px;
}

.ritual-ring-2 {
  animation: spin-slow 5s linear infinite reverse;
  transform-origin: 150px 150px;
}

@keyframes spin-slow {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.ritual-eye {
  font-size: 3rem;
  z-index: 1;
  animation: pulse-eye 2s ease-in-out infinite;
}

@keyframes pulse-eye {
  0%, 100% { transform: scale(1); opacity: 0.8; }
  50% { transform: scale(1.15); opacity: 1; }
}

.ritual-text {
  font-family: var(--font-body);
  font-size: var(--text-lg);
  color: var(--color-primary);
  font-style: italic;
  letter-spacing: 0.06em;
  text-align: center;
  animation: text-fade 3s ease-in-out infinite;
}

@keyframes text-fade {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

/* ============================
   SCREEN 5: RESULT
   ============================ */

.result-container {
  text-align: center;
  max-width: var(--content-wide);
  width: 100%;
  padding-bottom: var(--space-16);
}

.result-title {
  margin-bottom: var(--space-10);
}

/* Cards Row */
.cards-row {
  display: flex;
  justify-content: center;
  gap: var(--space-6);
  margin-bottom: var(--space-10);
  flex-wrap: wrap;
}

/* Papyrus Card */
.papyrus-card {
  width: 200px;
  height: 300px;
  perspective: 800px;
  cursor: default;
}

.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.papyrus-card.revealed .card-inner {
  transform: rotateY(180deg);
}

.card-back,
.card-front {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.card-back {
  background: linear-gradient(135deg, #1a1824, #0d0b14);
  border: 2px solid var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-gold);
}

.card-back-pattern {
  display: flex;
  align-items: center;
  justify-content: center;
}

.hieroglyph {
  font-size: 3rem;
  opacity: 0.5;
  color: var(--color-primary);
}

.card-front {
  transform: rotateY(180deg);
  background: linear-gradient(180deg, #1a1824, #0f0d16);
  border: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--space-3);
}

.card-label {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-primary);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-bottom: var(--space-2);
}

.card-image-area {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: var(--radius-sm);
}

.card-placeholder {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, rgba(201,168,76,0.08), rgba(90,61,122,0.08));
  border: 1px dashed rgba(201,168,76,0.2);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius-sm);
}

.card-number {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--color-primary);
  opacity: 0.8;
  letter-spacing: 0.05em;
}

.card-title {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text);
  margin-top: var(--space-2);
  min-height: 2.4em;
  display: flex;
  align-items: center;
  text-align: center;
  line-height: 1.3;
  word-spacing: 0.05em;
  overflow-wrap: break-word;
  word-break: break-word;
  hyphens: auto;
  padding-inline: var(--space-1);
}

/* Reading Area */
.reading-area {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: var(--space-6);
  max-width: 900px;
  margin: 0 auto var(--space-10);
  text-align: left;
  opacity: 0;
  transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.reading-area.visible {
  opacity: 1;
}

.reading-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
}

.reading-card h4 {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: var(--space-3);
}

.reading-label {
  color: var(--color-primary);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: var(--text-xs);
}

.reading-card-name {
  color: var(--color-text);
  font-weight: 700;
}

.reading-subtitle {
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--color-text-muted);
  font-style: italic;
  margin-bottom: var(--space-2);
}

.reading-keywords {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  color: var(--color-primary);
  letter-spacing: 0.05em;
  margin-bottom: var(--space-3);
  opacity: 0.8;
}

.reading-divider {
  font-size: var(--text-sm);
  color: var(--color-text-faint);
  text-align: center;
  margin-bottom: var(--space-3);
  letter-spacing: 0.1em;
}

.reading-text {
  font-family: var(--font-body);
  font-size: var(--text-lg);
  color: var(--color-text);
  line-height: 1.8;
  font-style: italic;
}

/* ============================
   FOOTER
   ============================ */

.app-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-3) var(--space-6);
  font-family: var(--font-body);
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  z-index: 50;
  background: linear-gradient(to top, var(--color-bg), transparent);
  pointer-events: none;
}

.app-footer a {
  color: var(--color-text-faint);
  text-decoration: none;
  pointer-events: auto;
  transition: color var(--transition-interactive);
}

.app-footer a:hover {
  color: var(--color-text-muted);
}

/* ============================
   RESPONSIVE
   ============================ */

@media (max-width: 768px) {
  .screen {
    padding: var(--space-4);
  }

  .title-main {
    font-size: clamp(1.5rem, 1rem + 3vw, 2.5rem);
  }

  .logo-mark {
    width: 80px;
    height: 80px;
  }

  .access-options {
    grid-template-columns: 1fr;
    max-width: 340px;
    margin-inline: auto;
  }

  .access-card {
    padding: var(--space-6) var(--space-4);
  }

  #screen-access {
    padding-top: var(--space-16);
  }

  .cards-row {
    gap: var(--space-4);
  }

  .papyrus-card {
    width: 140px;
    height: 210px;
  }

  .card-number {
    font-size: var(--text-xl);
  }

  .reading-area {
    grid-template-columns: 1fr;
  }

  .app-footer {
    flex-direction: column;
    gap: var(--space-1);
    text-align: center;
  }

  .btn-sacred {
    padding: var(--space-3) var(--space-8);
  }

  .code-input-wrap {
    flex-direction: column;
  }

  .welcome-text {
    font-size: var(--text-sm);
  }
}

@media (max-width: 420px) {
  .papyrus-card {
    width: 100px;
    height: 150px;
  }

  .card-label {
    font-size: 0.625rem;
  }

  .hieroglyph {
    font-size: 1.5rem;
  }

  .card-title {
    font-size: 0.6rem;
    line-height: 1.15;
  }
}

/* ============================
   STAR PARTICLES (Background)
   ============================ */

.particle {
  position: fixed;
  width: 2px;
  height: 2px;
  background: var(--color-primary);
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
  animation: twinkle var(--duration) var(--delay) ease-in-out infinite;
  z-index: 0;
}

@keyframes twinkle {
  0%, 100% { opacity: 0; }
  50% { opacity: 0.6; }
}

/* ============================
   DRAWS REMAINING BADGE
   ============================ */
.draws-remaining-badge {
  display: inline-block;
  background: linear-gradient(135deg, rgba(201,168,76,0.15), rgba(201,168,76,0.05));
  border: 1px solid rgba(201,168,76,0.3);
  color: var(--color-primary);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  padding: var(--space-2) var(--space-5);
  border-radius: var(--radius-full);
  margin-bottom: var(--space-4);
  letter-spacing: 0.05em;
}

/* ============================
   PAYMENT SUCCESS OVERLAY
   ============================ */
.payment-success-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 10, 15, 0.92);
  backdrop-filter: blur(12px);
  opacity: 0;
  transition: opacity 0.4s ease;
}

.payment-success-overlay.visible {
  opacity: 1;
}

.payment-success-box {
  text-align: center;
  padding: var(--space-12) var(--space-8);
  max-width: 420px;
  width: 90%;
  background: var(--color-surface);
  border: 1px solid rgba(201,168,76,0.2);
  border-radius: var(--radius-xl);
  box-shadow: 0 0 60px rgba(201,168,76,0.08);
  animation: success-enter 0.6s ease-out 0.2s both;
}

@keyframes success-enter {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.payment-success-icon {
  font-size: 3.5rem;
  margin-bottom: var(--space-4);
  animation: icon-glow 2s ease-in-out infinite;
}

@keyframes icon-glow {
  0%, 100% { text-shadow: 0 0 10px rgba(201,168,76,0.3); }
  50% { text-shadow: 0 0 25px rgba(201,168,76,0.6); }
}

.payment-success-box h2 {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  color: var(--color-primary);
  margin-bottom: var(--space-3);
  font-weight: 600;
}

.payment-plan-name {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  color: var(--color-text);
  margin-bottom: var(--space-2);
  font-weight: 500;
}

.payment-success-box p {
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--color-muted);
  margin-bottom: var(--space-6);
  line-height: 1.6;
}

.payment-success-box .btn-sacred {
  margin-top: var(--space-4);
}