/* ============================================
   SPELLMAKER.AI — Art Deco Ministry Style
   Mobile-first (375px), then desktop adaptation
   ============================================ */

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

:root {
  /* Palette — muted, antique, not screaming */
  --bg-deep: #0c1015;
  --bg-body: #182020;
  --bg-card: #141e1e;
  --bg-input: #111c1b;
  --bg-warning: #2a1215;
  --border-dark: #1c2a2a;
  --border-gold: rgba(168, 132, 56, 0.30);
  --gold: #a8843a;
  --gold-bright: #c9a54e;
  --gold-light: #d4b76a;
  --gold-muted: rgba(168, 132, 56, 0.5);
  --gold-dim: rgba(168, 132, 56, 0.2);
  --gold-subtle: rgba(168, 132, 56, 0.08);
  --text-primary: #c8c0ae;
  --text-secondary: #8a8070;
  --text-muted: #5a5448;
  --red: #8b3a3a;
  --red-text: #c47070;
  --radius: 4px;
  --font-display: "Cinzel Decorative", "Cinzel", Georgia, serif;
  --font-heading: "Cinzel", Georgia, serif;
  --font-body: "Crimson Text", Georgia, serif;
  --font-ui: "Inter", -apple-system, sans-serif;
}

html { font-size: 16px; scroll-padding-top: 100px; }

body {
  font-family: var(--font-body);
  background: var(--bg-body);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.65;
  overflow-x: hidden;
}

/* ==================
   ART DECO BACKGROUND
   Larger diamond grid + gradient fade from top
   ================== */
.bg-pattern {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    /* Gradient: solid dark at top → transparent below to reveal grid */
    linear-gradient(
      180deg,
      var(--bg-deep) 0%,
      var(--bg-deep) 12%,
      rgba(13,17,23,0.7) 25%,
      transparent 45%
    ),
    /* Diagonal lines going right — larger spacing */
    repeating-linear-gradient(
      45deg,
      transparent,
      transparent 90px,
      rgba(168,132,56,0.18) 90px,
      rgba(168,132,56,0.18) 90.5px
    ),
    /* Diagonal lines going left */
    repeating-linear-gradient(
      -45deg,
      transparent,
      transparent 90px,
      rgba(168,132,56,0.18) 90px,
      rgba(168,132,56,0.18) 90.5px
    );
}

/* ==================
   HEADER
   ================== */
header {
  position: relative;
  z-index: 50;
  padding: 18px 20px 12px;
  background: rgba(12,16,21,0.95);
  text-align: center;
}

.header-inner {
  max-width: 600px;
  margin: 0 auto;
}

.logo {
  font-family: "Cinzel", Georgia, serif;
  font-size: 16px;
  font-weight: 700;
  color: var(--gold-bright);
  letter-spacing: 4px;
  text-align: center;
  margin-bottom: 8px;
}

.header-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.header-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Language dropdown */
.lang-select {
  appearance: none;
  background: transparent;
  border: 1px solid var(--gold-dim);
  color: var(--gold);
  padding: 4px 24px 4px 10px;
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 1px;
  cursor: pointer;
  border-radius: 3px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23a8843a'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
}

.lang-select:focus { outline: none; border-color: var(--gold-muted); }

.lang-select option {
  background: var(--bg-deep);
  color: var(--text-primary);
}

/* User area */
.user-area {
  font-size: 13px;
  color: var(--text-secondary);
  font-family: var(--font-ui);
}
.user-area .balance { color: var(--gold-bright); font-weight: 600; }

/* ==================
   MAIN CONTENT
   ================== */
main {
  max-width: 600px;
  margin: 0 auto;
  padding: 20px 20px;
  position: relative;
  z-index: 1;
}

/* ==================
   ORNAMENTAL LINE
   ================== */
.ornament-line {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: center;
  margin: 14px 0;
}

.ornament-line .line {
  flex: 0 1 100px;
  height: 1.5px;
  background: var(--gold-muted);
}

.ornament-line .diamond {
  color: var(--gold-bright);
  font-size: 12px;
  opacity: 0.7;
  line-height: 1;
}

/* ==================
   HERO
   ================== */
.hero {
  text-align: center;
  margin-bottom: 28px;
}

.ministry-line-1,
.ministry-line-2 {
  font-family: var(--font-ui);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: var(--text-muted);
}

.ministry-line-1 { margin-bottom: 1px; }
.ministry-line-2 { margin-bottom: 0; }

.hero h2 {
  font-family: "Cinzel", Georgia, serif;
  font-size: 34px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.5px;
  line-height: 1.25;
  font-variant: small-caps;
}

/* ==================
   GENERATOR / INPUT
   ================== */

/* Art Deco frame around textarea */
.input-frame {
  border: 2px solid var(--border-gold);
  padding: 3px;
  border-radius: 2px;
}

.input-frame textarea {
  width: 100%;
  display: block;
  background: var(--bg-input);
  border: 1px solid var(--border-dark);
  border-radius: 1px;
  color: var(--text-primary);
  padding: 16px;
  font-size: 16px;
  font-family: var(--font-body);
  resize: none;
  transition: border-color 0.3s;
  line-height: 1.6;
}

.input-frame textarea:focus {
  outline: none;
  border-color: var(--gold-dim);
}

.input-frame textarea::placeholder {
  color: var(--text-muted);
  font-style: italic;
}

/* CAST button — metallic gold bar */
#cast-btn {
  display: block;
  width: 100%;
  margin-top: 16px;
  padding: 18px;
  border: 1px solid rgba(220,190,100,0.4);
  border-radius: 4px;
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 8px;
  text-transform: uppercase;
  cursor: pointer;
  color: #1a1408;
  position: relative;
  overflow: hidden;
  /* Rich gold gradient — more metallic, more shine */
  background: linear-gradient(
    170deg,
    #f5e6a8 0%,
    #e8cc6e 12%,
    #d4af37 28%,
    #c9a033 45%,
    #b8922e 55%,
    #d4af37 70%,
    #e8cc6e 85%,
    #f0d878 100%
  );
  box-shadow:
    0 3px 12px rgba(180,140,40,0.35),
    0 1px 3px rgba(0,0,0,0.3),
    inset 0 1px 0 rgba(255,255,255,0.3),
    inset 0 -2px 4px rgba(120,90,20,0.2);
  transition: all 0.2s;
  text-shadow: 0 1px 1px rgba(255,255,255,0.2);
}

/* Shimmer sweep animation */
#cast-btn::after {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 60%;
  height: 100%;
  background: linear-gradient(
    100deg,
    transparent 0%,
    rgba(255,255,255,0.15) 40%,
    rgba(255,255,255,0.3) 50%,
    rgba(255,255,255,0.15) 60%,
    transparent 100%
  );
  animation: shimmer 3s ease-in-out infinite;
}

@keyframes shimmer {
  0% { left: -100%; }
  100% { left: 200%; }
}

#cast-btn:hover {
  background: linear-gradient(
    170deg,
    #faeeb8 0%,
    #f0d878 12%,
    #debb44 28%,
    #d4af37 45%,
    #c9a033 55%,
    #debb44 70%,
    #f0d878 85%,
    #f5e6a8 100%
  );
  box-shadow:
    0 5px 20px rgba(200,160,50,0.4),
    0 2px 6px rgba(0,0,0,0.2),
    inset 0 1px 0 rgba(255,255,255,0.4);
}

#cast-btn:active {
  transform: translateY(1px);
  box-shadow: 0 1px 4px rgba(0,0,0,0.4), inset 0 2px 4px rgba(100,80,20,0.3);
}

#cast-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none;
  animation: none;
}

#cast-btn:disabled::after { animation: none; }

.limit-info {
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 10px;
  font-family: var(--font-ui);
}

/* ==================
   CASTING ANIMATION
   ================== */
.animation-area {
  text-align: center;
  padding: 50px 0;
}

.casting-circles {
  position: relative;
  width: 220px;
  height: 220px;
  margin: 0 auto 24px;
  /* Gradient backdrop to hide diamond pattern behind circles */
  background: radial-gradient(circle, var(--bg-body) 45%, transparent 70%);
}

.circle {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px solid var(--gold-dim);
}

.circle-1 {
  inset: 25px;
  border-color: var(--gold-muted);
  border-width: 1.5px;
  animation: spin 4s linear infinite;
}

.circle-2 {
  inset: 5px;
  border-style: dashed;
  border-color: var(--gold-dim);
  border-width: 1px;
  animation: spin 6s linear infinite reverse;
}

.circle-3 {
  inset: 45px;
  border-color: var(--gold-muted);
  border-width: 1.5px;
  animation: spin 3s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.casting-star {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 40px;
  color: var(--gold-bright);
  animation: star-pulse 2s ease-in-out infinite;
  text-shadow: 0 0 30px rgba(168,132,56,0.5);
}

@keyframes star-pulse {
  0%, 100% { opacity: 1; transform: translate(-50%,-50%) scale(1); }
  50% { opacity: 0.5; transform: translate(-50%,-50%) scale(1.2); }
}

.casting-progress {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 12px;
}

.progress-track {
  width: 120px;
  height: 3px;
  background: var(--gold-dim);
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--gold);
  width: 0%;
  animation: fill 2.5s ease-out forwards;
}

@keyframes fill { to { width: 100%; } }

.progress-pct {
  font-family: var(--font-ui);
  font-size: 11px;
  color: var(--gold-muted);
  min-width: 30px;
}

.casting-text {
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--text-secondary);
  font-style: italic;
  transition: opacity 0.3s ease;
}

/* ==================
   SPELL RESULT CARD
   ================== */
.result-area { margin-top: 24px; }

/* Outer Art Deco frame */
.card-frame {
  border: 2px solid var(--border-gold);
  padding: 4px;
  border-radius: 2px;
}

.card-inner {
  background: var(--bg-card);
  border: 1px solid var(--border-dark);
  padding: 20px 18px 14px;
  position: relative;
  text-align: center;
}

/* Corner accents inside card */
.card-inner::before,
.card-inner::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border-color: var(--gold-dim);
  border-style: solid;
}

.card-inner::before {
  top: 6px; left: 6px;
  border-width: 1px 0 0 1px;
}

.card-inner::after {
  bottom: 6px; right: 6px;
  border-width: 0 1px 1px 0;
}

.spell-header {
  text-align: center;
  margin-bottom: 8px;
}

.spell-category {
  font-family: var(--font-ui);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-muted);
}

.spell-name {
  font-family: "Cinzel", Georgia, serif;
  font-size: 28px;
  font-weight: 700;
  color: var(--gold-bright);
  text-align: center;
  letter-spacing: 2px;
  line-height: 1.2;
  margin-bottom: 4px;
}

.spell-pronunciation {
  text-align: center;
  font-size: 14px;
  color: var(--text-muted);
  font-style: italic;
  margin-bottom: 8px;
}

.spell-field { margin-bottom: 6px; }

.field-label {
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 2px;
  display: inline;
}

.spell-field p {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
  display: inline;
}

/* Warning box — subtle, not screaming */
.spell-warning-box {
  background: rgba(80,30,30,0.25);
  border: 1px solid rgba(120,50,50,0.25);
  border-radius: 3px;
  padding: 8px 12px;
  margin: 8px 0 4px;
}

.spell-warning .field-label { color: #c45050; letter-spacing: 1px; }
.spell-warning p { color: var(--text-secondary); }

.card-footer-text {
  font-family: var(--font-body);
  font-size: 12px;
  font-style: italic;
  color: var(--text-muted);
  text-align: center;
  margin-top: 2px;
}

.card-watermark {
  font-family: var(--font-body);
  font-size: 11px;
  color: var(--gold-dim);
  text-align: center;
  margin-top: 8px;
}

/* Details toggle button */
.details-toggle {
  display: block;
  width: 100%;
  background: transparent;
  border: 1px solid var(--gold-dim);
  border-top: none;
  color: var(--gold);
  font-family: var(--font-ui);
  font-size: 12px;
  letter-spacing: 1px;
  padding: 10px;
  cursor: pointer;
  transition: all 0.3s;
  text-align: center;
}

.details-toggle:hover {
  background: var(--gold-subtle);
  color: var(--gold-bright);
}

.details-toggle.expanded {
  border-bottom: none;
}

/* Expanded spell details */
.spell-details {
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.details-inner {
  background: var(--bg-card);
  border: 1px solid var(--gold-dim);
  border-top: none;
  padding: 16px 20px;
  text-align: center;
}

/* ==================
   ACTION BUTTONS
   ================== */
.result-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.btn {
  flex: 1;
  padding: 12px 14px;
  border-radius: var(--radius);
  font-size: 12px;
  font-family: var(--font-ui);
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  text-align: center;
}

.btn-primary {
  background: linear-gradient(
    170deg,
    #f5e6a8 0%, #e8cc6e 12%, #d4af37 28%,
    #c9a033 45%, #b8922e 55%, #d4af37 70%,
    #e8cc6e 85%, #f0d878 100%
  );
  color: #1a1408;
  font-weight: 700;
  font-family: "Cinzel", Georgia, serif;
  letter-spacing: 1px;
  border: 1px solid rgba(220,190,100,0.3);
  box-shadow: 0 2px 8px rgba(180,140,40,0.25), inset 0 1px 0 rgba(255,255,255,0.2);
}

.btn-primary:hover {
  box-shadow: 0 4px 16px rgba(200,160,50,0.35), inset 0 1px 0 rgba(255,255,255,0.3);
}

.btn-secondary {
  background: transparent;
  color: var(--gold);
  border: 1px solid var(--gold-dim);
}

.btn-secondary:hover { border-color: var(--gold-muted); background: var(--gold-subtle); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid rgba(255,255,255,0.06);
}

.btn-ghost:hover { color: var(--text-secondary); border-color: rgba(255,255,255,0.12); }

/* ==================
   MODALS
   ================== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.8);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-content {
  position: relative;
  background: var(--bg-card);
  border: 2px solid var(--border-gold);
  border-radius: 4px;
  padding: 36px 28px;
  max-width: 360px;
  width: 90%;
  text-align: center;
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 14px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
}

.modal-close:hover { color: var(--text-primary); }

.modal-content h3 {
  font-family: "Cinzel", Georgia, serif;
  color: var(--text-primary);
  margin-bottom: 6px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.modal-content p {
  color: var(--text-secondary);
  margin-bottom: 18px;
  font-size: 14px;
}

.modal-content input:not([type="checkbox"]) {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-primary);
  border: 1px solid var(--border-dark);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 15px;
  font-family: var(--font-body);
  margin-bottom: 12px;
}

.modal-content input:focus {
  outline: none;
  border-color: var(--gold-dim);
}

.modal-content .btn { flex: none; width: 100%; }

.auth-consent {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 12px 0;
  font-size: 12px;
  color: var(--text-secondary);
  font-family: var(--font-ui);
  text-align: left;
  cursor: pointer;
}

.auth-consent span {
  min-width: 0;
  word-wrap: break-word;
}

.auth-consent input[type="checkbox"] {
  margin-top: 2px;
  accent-color: var(--gold);
  flex-shrink: 0;
}

.auth-consent a {
  color: var(--gold);
  text-decoration: underline;
}

.auth-consent a:hover { color: var(--gold-bright); }

.auth-status { font-size: 14px; margin-top: 8px; font-family: var(--font-body); }

/* ==================
   FOOTER
   ================== */
footer {
  text-align: center;
  padding: 28px 20px;
  font-size: 10px;
  color: var(--text-muted);
  font-family: var(--font-ui);
  position: relative;
  z-index: 1;
  letter-spacing: 0.3px;
}

footer p + p { margin-top: 2px; }
footer a { color: var(--text-muted); text-decoration: none; }
footer a:hover { color: var(--gold); }

/* ==================
   SHARE MODAL
   ================== */
.share-content {
  max-width: 340px;
}

.share-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.share-btn {
  display: block;
  width: 100%;
  padding: 12px 14px;
  background: transparent;
  border: 1px solid var(--gold-dim);
  border-radius: var(--radius);
  color: var(--gold);
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.share-btn:hover {
  border-color: var(--gold-muted);
  background: var(--gold-subtle);
  color: var(--gold-bright);
}

.share-divider {
  height: 1px;
  background: var(--gold-dim);
  margin: 4px 0 16px;
}

.share-social {
  display: flex;
  justify-content: center;
  gap: 10px;
}

.social-btn {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--gold-dim);
  border-radius: var(--radius);
  color: var(--gold);
  cursor: pointer;
  transition: all 0.2s;
}

.social-btn:hover {
  border-color: var(--gold-muted);
  background: var(--gold-subtle);
  color: var(--gold-bright);
}

.social-btn svg {
  width: 20px;
  height: 20px;
}

/* ==================
   UTILITY
   ================== */
/* Toast notification */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  border: 1px solid var(--border-gold);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 14px;
  padding: 12px 24px;
  border-radius: 6px;
  z-index: 200;
  text-align: center;
  max-width: 90%;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  animation: toast-in 0.3s ease;
}

.toast.toast-error { border-color: rgba(180,60,60,0.4); }
.toast.toast-error .toast-label { color: #c45050; }

.toast-label {
  font-weight: 600;
  color: var(--gold-bright);
  margin-right: 6px;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(20px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.hidden { display: none !important; }

/* ==================
   DESKTOP ADAPTATION
   ================== */
@media (min-width: 640px) {
  header { position: sticky; top: 0; backdrop-filter: blur(12px); }
  main { padding: 60px 32px; }
  .logo { font-size: 17px; letter-spacing: 5px; }
  .hero h2 { font-size: 42px; }
  .ministry-label { font-size: 10px; letter-spacing: 3px; }
  .spell-name { font-size: 32px; }
  .card-inner { padding: 36px 32px; }
  .result-actions { gap: 10px; }
  .btn { padding: 12px 20px; font-size: 13px; }
  #cast-btn { font-size: 20px; padding: 18px; }
  .input-frame textarea { rows: 6; min-height: 180px; }
}

@media (min-width: 900px) {
  main { max-width: 660px; }
  .hero h2 { font-size: 48px; }
}
