/* ============================================
   Crescent Tales — Global Styles
   A mobile-first Ramadan nights storytelling app
   ============================================ */

/* ---------- Design Tokens ---------- */
:root {
    --primary-bg: #050a14;
    --primary-bg-rgb: 5, 10, 20;
    --card-bg: rgba(26, 42, 68, 0.65);
    --card-bg-solid: #1a2a44;
    --accent-color: #ffd700;
    --accent-orange: #ff8c00;
    --text-color: #ffffff;
    --text-muted: #a0aec0;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --navbar-bg: rgba(5, 10, 20, 0.85);
    --border-subtle: rgba(255, 215, 0, 0.12);
    --border-accent: rgba(255, 215, 0, 0.25);
    --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 4px 15px rgba(255, 215, 0, 0.25);
    --radius-sm: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1.25rem;
    --radius-pill: 2rem;
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
}

/* ---------- Reset & Base ---------- */
*, *::before, *::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    background-color: var(--primary-bg);
    color: var(--text-color);
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 15px;
    line-height: 1.6;
    margin: 0;
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ---------- Loading Screen ---------- */
.loading-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    gap: 1rem;
    background: var(--primary-bg);
}

.loading-moon {
    font-size: 4rem;
    animation: float 3s ease-in-out infinite;
}

.loading-title {
    font-family: 'Amiri', serif;
    font-size: 1.8rem;
    color: var(--accent-color);
    font-weight: 700;
}

.loading-subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* ---------- Starry Sky ---------- */
.starry-sky {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
}

.star {
    position: absolute;
    background: white;
    border-radius: 50%;
    animation: twinkle 3s infinite;
}

.star.small {
    width: 1px;
    height: 1px;
    animation-duration: 2.5s;
}

.star.medium {
    width: 2px;
    height: 2px;
    animation-duration: 3.5s;
    box-shadow: 0 0 2px rgba(255, 255, 255, 0.5);
}

.star.large {
    width: 3px;
    height: 3px;
    animation-duration: 4s;
    box-shadow: 0 0 4px rgba(255, 255, 255, 0.6);
}

.shooting-star {
    position: absolute;
    width: 2px;
    height: 2px;
    background: white;
    border-radius: 50%;
    animation: shoot 3s ease-out infinite;
    box-shadow: 0 0 6px 2px rgba(255, 255, 255, 0.5);
}

.shooting-star::after {
    content: '';
    position: absolute;
    width: 40px;
    height: 1px;
    background: linear-gradient(to left, rgba(255, 255, 255, 0.6), transparent);
    top: 0;
    right: 100%;
}

@keyframes twinkle {
    0%, 100% { opacity: 0; transform: scale(0.5); }
    50% { opacity: 1; transform: scale(1); }
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

@keyframes shoot {
    0% { transform: translate(0, 0) rotate(-45deg); opacity: 1; }
    70% { opacity: 1; }
    100% { transform: translate(300px, 300px) rotate(-45deg); opacity: 0; }
}

.star:nth-child(odd) { animation-delay: 0s; }
.star:nth-child(even) { animation-delay: 1.5s; }
.star:nth-child(3n) { animation-delay: 0.8s; }
.star:nth-child(5n) { animation-delay: 2s; }

/* ---------- Page Layout ---------- */
.page {
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

main {
    flex: 1;
}

.content {
    max-width: 100%;
}

/* ---------- Stepper ---------- */
.stepper-container {
    position: relative;
    width: 100%;
    padding: 0 8%;
}

.stepper-line {
    position: absolute;
    top: 50%;
    left: 8%;
    right: 8%;
    height: 2px;
    background: rgba(45, 55, 72, 0.6);
    z-index: 1;
    border-radius: 1px;
}

.stepper-progress {
    position: absolute;
    top: 50%;
    left: 8%;
    height: 2px;
    background: linear-gradient(90deg, var(--accent-color), var(--accent-orange));
    z-index: 2;
    border-radius: 1px;
    transition: width 0.4s ease;
}

.stepper-icons {
    display: flex;
    justify-content: space-between;
    position: relative;
    z-index: 3;
}

.step-item {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--card-bg-solid);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-normal);
    border: 2px solid rgba(45, 55, 72, 0.6);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.step-item .step-icon {
    font-size: 1.1rem;
    line-height: 1;
}

.step-item.active {
    border-color: var(--accent-color);
    box-shadow: 0 0 12px rgba(255, 215, 0, 0.4);
    /* Solid bg so the orange progress line doesn't bleed through */
    background: #0e2040;
}

.step-item.completed {
    background: linear-gradient(135deg, var(--accent-color), var(--accent-orange));
    border-color: var(--accent-color);
}

/* ---------- Story Pager ---------- */
.story-pager {
    margin-top: 1rem;
}

.pager-dots {
    display: flex;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.5rem 0;
}

.pager-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(45, 55, 72, 0.8);
    cursor: pointer;
    transition: all var(--transition-normal);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.pager-dot.active {
    background: var(--accent-color);
    width: 24px;
    border-radius: 4px;
    box-shadow: 0 0 6px rgba(255, 215, 0, 0.4);
}

/* ---------- Utility ---------- */
.text-center { text-align: center; }

/* ---------- Touch & Mobile ---------- */
button, .night-cell, .story-card, .tonight-card {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

input, select, textarea {
    font-size: 16px; /* Prevent iOS zoom */
}

/* Scrollbar */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: rgba(255, 215, 0, 0.3);
    border-radius: 2px;
}

/* ---------- Blazor Error UI ---------- */
#blazor-error-ui {
    background: rgba(220, 53, 69, 0.9);
    color: white;
    bottom: 0;
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.3);
    display: none;
    left: 0;
    padding: 0.75rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 9999;
    text-align: center;
    font-size: 0.85rem;
    backdrop-filter: blur(10px);
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 1rem;
    top: 0.5rem;
}

#blazor-error-ui .reload {
    color: white;
    text-decoration: underline;
    margin-left: 0.5rem;
}

/* ---------- Responsive ---------- */
@media (max-width: 380px) {
    body { font-size: 14px; }
}

@media (min-width: 481px) {
    body { font-size: 16px; }
}
