/* =============================================================
   main.css — ZawJiMystic Global Styles
   CSS Custom Properties, Typography, Shared Components
   ============================================================= */

/* ── CSS Custom Properties (Design Tokens) ── */
:root {
  /* Backgrounds */
  --bg-primary: radial-gradient(circle at top left, rgba(157, 78, 221, 0.18), transparent 32rem), linear-gradient(135deg, #0d0221 0%, #171b3d 48%, #062824 100%);
  --bg-card: rgba(255, 255, 255, 0.075);
  --bg-card-hover: rgba(255, 255, 255, 0.11);
  --bg-card-alt: rgba(255, 255, 255, 0.055);
  --bg-input: rgba(255, 255, 255, 0.095);
  --bg-overlay: rgba(0, 0, 0, 0.85);

  /* Primary Colors */
  --color-primary: #9d4edd;
  --color-primary-light: #c77dff;
  --color-primary-dark: #7b2d8b;
  --color-accent: #2dd4bf;
  --color-accent-soft: rgba(45, 212, 191, 0.16);

  /* Text */
  --text-primary: #f0e6ff;
  --text-secondary: #d3c8e9;
  --text-muted: #a597c3;

  /* Stars */
  --star-filled: #c77dff;
  --star-empty: #3d2f5a;

  /* Status */
  --color-success: #4ade80;
  --color-error: #f87171;
  --color-warning: #fbbf24;

  /* Borders */
  --border-color: rgba(211, 200, 233, 0.22);
  --border-color-strong: rgba(45, 212, 191, 0.52);
  --border-radius-sm: 8px;
  --border-radius-md: 16px;
  --border-radius-lg: 24px;
  --border-radius-full: 9999px;

  /* Shadows */
  --shadow-card: 0 14px 36px rgba(0, 0, 0, 0.26);
  --shadow-glow: 0 0 30px rgba(157, 78, 221, 0.3);
  --shadow-glow-strong: 0 0 40px rgba(157, 78, 221, 0.5);

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  --space-3xl: 64px;

  /* Typography */
  --font-myanmar: 'Noto Sans Myanmar', 'Pyidaungsu', 'Myanmar Text', sans-serif;
  --font-latin: 'Inter', 'Segoe UI', system-ui, sans-serif;

  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.875rem;
  --text-4xl: 2.25rem;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
  --transition-slow: 400ms ease;
}

/* ── Reset & Base ── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

* {
  -webkit-tap-highlight-color: rgba(157, 78, 221, 0.3);
}

body {
  font-family: var(--font-myanmar);
  font-size: var(--text-base);
  color: var(--text-primary);
  background: var(--bg-primary);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-wrap: anywhere;
}

/* ── Container ── */
.container {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 0 clamp(16px, 5vw, 24px);
}

@media (min-width: 640px) {
  .container {
    padding: 0 var(--space-lg);
  }
}

@media (min-width: 1024px) {
  .container {
    max-width: 720px;
  }
}

@media (min-width: 1440px) {
  .container {
    max-width: 800px;
  }
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  font-family: var(--font-myanmar);
  font-size: var(--text-base);
  font-weight: 700;
  border: none;
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  padding: 12px var(--space-lg);
  min-height: 48px;
  transition: background var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast);
  text-decoration: none;
  line-height: 1.35;
  white-space: normal;
}

.btn:focus-visible {
  outline: 2px solid var(--color-primary-light);
  outline-offset: 3px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

.btn-primary {
  background: linear-gradient(135deg, var(--color-primary-dark), var(--color-primary) 58%, #1fbfaf);
  color: #ffffff;
  box-shadow: var(--shadow-glow);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

.btn-lg {
  font-size: var(--text-lg);
  padding: var(--space-md) var(--space-xl);
  border-radius: var(--border-radius-sm);
}

.btn-full {
  width: 100%;
}

/* ── Section Headings ── */
.section-title {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-primary-light);
  margin-bottom: var(--space-md);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(to right, var(--border-color), transparent);
  margin-left: var(--space-sm);
}

/* ── Error Messages ── */
.error-msg {
  display: block;
  font-size: var(--text-sm);
  color: var(--color-error);
  margin-top: var(--space-xs);
  min-height: 1.2em;
}

.error-banner {
  background: rgba(248, 113, 113, 0.15);
  border: 1px solid var(--color-error);
  border-radius: var(--border-radius-sm);
  color: var(--color-error);
  padding: var(--space-md);
  margin-bottom: var(--space-md);
  font-size: var(--text-sm);
}

.error-banner a {
  color: var(--color-error);
  text-decoration: underline;
}

/* ── Loading Overlay ── */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-slow), visibility var(--transition-slow);
}

.loading-overlay.visible {
  opacity: 1;
  visibility: visible;
}

.loading-content {
  text-align: center;
  padding: var(--space-lg);
}

.loading-spinner {
  display: block;
  margin-bottom: var(--space-md);
}

.loading-spinner__orbit {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.loading-spinner__img {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  filter: drop-shadow(0 0 20px rgba(157, 78, 221, 0.4));
  position: relative;
  z-index: 1;
}

.loading-spinner__dot {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-primary-light);
  box-shadow: 0 0 12px rgba(199, 125, 255, 0.9), 0 0 24px rgba(199, 125, 255, 0.4);
  left: 50%;
  top: 50%;
  margin: -4px 0 0 -4px;
  animation: orbit 2.5s linear infinite;
  animation-delay: calc(var(--i, 0) * -0.625s);
}

@keyframes orbit {
  from { transform: rotate(0deg) translateX(72px); }
  to   { transform: rotate(360deg) translateX(72px); }
}

.loading-text {
  font-size: var(--text-base);
  color: var(--text-secondary);
  letter-spacing: 0;
  line-height: 1.7;
}

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

/* ── Toast Notification ── */
.toast {
  position: fixed;
  bottom: var(--space-xl);
  left: var(--space-md);
  right: var(--space-md);
  transform: translateY(20px);
  background: rgba(74, 222, 128, 0.15);
  border: 1px solid var(--color-success);
  color: var(--color-success);
  padding: var(--space-sm) var(--space-lg);
  border-radius: var(--border-radius-full);
  font-size: var(--text-sm);
  font-weight: 700;
  z-index: 10000;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-base), transform var(--transition-base), visibility var(--transition-base);
  text-align: center;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}

/* ── Top Navigation ── */
.top-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) clamp(12px, 4vw, 24px);
  border-bottom: 1px solid var(--border-color);
  background: rgba(13, 2, 33, 0.95);
  position: sticky;
  top: 0;
  z-index: 100;
}

@supports (backdrop-filter: blur(12px)) {
  .top-nav {
    background: rgba(13, 2, 33, 0.8);
    backdrop-filter: blur(12px);
  }
}

.nav-back {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  text-decoration: none;
  padding: var(--space-sm);
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  transition: color var(--transition-fast);
}

@media (hover: hover) {
  .nav-back:hover {
    color: var(--text-primary);
  }
}

.nav-logo {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--color-primary-light);
  text-decoration: none;
  min-height: 44px;
  min-width: 44px;
  justify-content: center;
}

/* ── Footer ── */
.site-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-xs) var(--space-md);
  padding: var(--space-xl) var(--space-md);
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.site-footer a {
  color: var(--text-secondary);
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

@media (hover: hover) {
  .site-footer a:hover {
    color: var(--color-accent);
  }
}

@media (min-width: 640px) {
  .btn-lg {
    font-size: var(--text-xl);
    padding: var(--space-md) var(--space-2xl);
  }

  .section-title {
    font-size: var(--text-xl);
  }

  .toast {
    left: 50%;
    right: auto;
    transform: translateX(-50%) translateY(20px);
    white-space: nowrap;
  }

  .toast.show {
    transform: translateX(-50%) translateY(0);
  }
}

/* ── Utility Classes ── */
.hidden { display: none !important; }
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }

/* ── Reduced Motion ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ── Skip to content ── */
.skip-link {
  position: absolute;
  top: -100%;
  left: var(--space-md);
  background: var(--color-primary-light);
  color: #0d0221;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--border-radius-sm);
  font-weight: 700;
  z-index: 10000;
  text-decoration: none;
}
.skip-link:focus {
  top: var(--space-sm);
}

/* ── Focus Indicators ── */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible,
.lucky-item:focus-visible,
.prediction-card:focus-visible {
  outline: 2px solid var(--color-primary-light);
  outline-offset: 3px;
}

@media (hover: hover) {
  .btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow-strong);
  }
}

/* ── Accessibility ── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── Scrollbar (optional aesthetic) ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: #0d0221; }
::-webkit-scrollbar-thumb { background: var(--color-primary-dark); border-radius: 3px; }
