/* ==========================================================================
   Murray Storm Website CSS - Space/Earth/Sci-Fi Theme
   Custom styles for The Fall of Earth book promotion
   ========================================================================== */

/* ==========================================================================
   1. CSS CUSTOM PROPERTIES (VARIABLES)
   ========================================================================== */

:root {
    /* Color palette inspired by The Fall of Earth book cover */
    --deep-space: #0A0E12;           /* Deeper space background */
    --earth-blue: #152233;           /* Darker blue from Earth */
    --orbital-teal: #2D4A5C;         /* Orbital teal */
    --stellar-silver: #C0C0C0;       /* Stellar silver */
    --space-gray: #4A5568;           /* Space gray */
    --light-cream: #EEEEEE;          /* Light gray background */
    --text-dark: #1A202C;            /* Dark text */
    --muted-text: #718096;           /* Muted text color */
    --horizon-blue: #4299E1;         /* Horizon blue accent */
    
    /* Vibrant colors inspired by Earth's city lights */
    --city-gold: #FFB800;            /* Bright golden city lights */
    --amber-glow: #FF8C42;           /* Warm amber glow */
    --electric-yellow: #FFC947;      /* Electric city yellow */
    --warm-orange: #FF7A00;          /* Warm orange lights */
}

/* ==========================================================================
   2. BASE STYLES
   ========================================================================== */

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: var(--text-dark);
    background-color: var(--light-cream);
}

/* ==========================================================================
   3. ACCESSIBILITY STYLES
   ========================================================================== */

/* Skip to main content link */
.visually-hidden-focusable:focus {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 9999;
    padding: 8px 16px;
    background: var(--earth-blue);
    color: white;
    text-decoration: none;
    border-radius: 4px;
    font-weight: bold;
    border: 2px solid white;
}

/* Screen reader only text */
.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;
}

/* Focus states for accessibility */
.btn:focus,
.card:focus,
a:focus {
    outline: 3px solid var(--orbital-teal);
    outline-offset: 2px;
}

/* ==========================================================================
   4. TYPOGRAPHY
   ========================================================================== */

h1, h2, h3, h4, h5, h6 {
    color: var(--text-dark);
    font-weight: 600;
}

.lead {
    font-size: 1.2rem;
    font-weight: 400;
    color: var(--text-dark);
}

.text-muted {
    color: var(--muted-text) !important;
}

.text-white-50 {
    color: rgba(255, 255, 255, 0.7) !important;
}

/* ==========================================================================
   5. LAYOUT SECTIONS
   ========================================================================== */

section {
    padding: 4rem 0;
}

/* Background alternation for sections */
section:nth-child(even) {
    background: linear-gradient(180deg, #E8E8E8 0%, var(--light-cream) 100%);
}

/* Light background styling */
.bg-light {
    background: linear-gradient(180deg, var(--light-cream) 0%, #E8E8E8 100%) !important;
}

/* Privacy and Terms page styling */
.privacy-terms-bg-light {
    background: var(--light-cream) !important;
    position: relative;
}

.privacy-terms-bg-white {
    background: white !important;
    position: relative;
}

/* ==========================================================================
   6. COLOR OVERRIDES FOR ACCESSIBILITY
   ========================================================================== */

/* Black text on warm cream background */
.bg-light,
.bg-light *:not(.btn):not(.card),
section:nth-child(even),
section:nth-child(even) *:not(.btn):not(.card) {
    color: #000000 !important;
}

/* Ensure headings are black on cream backgrounds */
.bg-light h1, .bg-light h2, .bg-light h3, .bg-light h4, .bg-light h5, .bg-light h6,
section:nth-child(even) h1, section:nth-child(even) h2, section:nth-child(even) h3, 
section:nth-child(even) h4, section:nth-child(even) h5, section:nth-child(even) h6 {
    color: #000000 !important;
}

/* Ensure muted text is readable on cream background */
.bg-light .text-muted,
section:nth-child(even) .text-muted {
    color: var(--text-dark) !important;
}

/* ==========================================================================
   7. HERO SECTION
   ========================================================================== */

.hero-section {
    background: linear-gradient(135deg, var(--deep-space) 0%, var(--earth-blue) 50%, var(--orbital-teal) 100%);
    min-height: 70vh;
    display: flex;
    align-items: center;
    position: relative;
    overflow: hidden;
}

/* Animated star field background */
.hero-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(circle at 15% 25%, rgba(192,192,192,0.4) 1px, transparent 1px),
        radial-gradient(circle at 85% 15%, rgba(192,192,192,0.3) 0.5px, transparent 0.5px),
        radial-gradient(circle at 35% 75%, rgba(192,192,192,0.5) 1.5px, transparent 1.5px),
        radial-gradient(circle at 75% 85%, rgba(192,192,192,0.2) 0.8px, transparent 0.8px),
        radial-gradient(circle at 55% 35%, rgba(192,192,192,0.3) 1px, transparent 1px),
        radial-gradient(circle at 25% 65%, rgba(192,192,192,0.4) 0.7px, transparent 0.7px),
        radial-gradient(circle at 90% 55%, rgba(192,192,192,0.2) 1.2px, transparent 1.2px),
        radial-gradient(circle at 10% 85%, rgba(192,192,192,0.3) 0.9px, transparent 0.9px);
    background-size: 250px 250px, 180px 180px, 320px 320px, 200px 200px, 280px 280px, 150px 150px, 220px 220px, 190px 190px;
    animation: spaceTimeShift 25s ease-in-out infinite;
    opacity: 1.0;
}

.hero-section > .container {
    position: relative;
    z-index: 1;
}

.hero-section h1 {
    font-weight: 700;
    letter-spacing: 1px;
    margin-bottom: 1rem;
    color: white !important;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.hero-section .lead {
    font-size: 1.25rem;
    opacity: 0.95;
    color: white !important;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.2);
}

/* ==========================================================================
   8. ANIMATIONS
   ========================================================================== */

/* Subtle space-time distortion animation */
@keyframes spaceTimeShift {
    0%, 100% { 
        transform: translate(0, 0) scale(1);
        background-position: 0% 0%, 20% 10%, 40% 30%, 60% 50%, 80% 70%, 10% 90%, 90% 20%, 30% 80%;
    }
    25% { 
        transform: translate(-8px, -4px) scale(1.01);
        background-position: 5% 5%, 25% 15%, 35% 25%, 65% 45%, 75% 75%, 15% 85%, 85% 25%, 25% 75%;
    }
    50% { 
        transform: translate(4px, -8px) scale(0.99);
        background-position: -5% 10%, 30% 5%, 45% 35%, 55% 55%, 85% 65%, 5% 95%, 95% 15%, 35% 85%;
    }
    75% { 
        transform: translate(-4px, 6px) scale(1.005);
        background-position: 10% -5%, 15% 20%, 50% 20%, 70% 40%, 70% 80%, 20% 80%, 80% 30%, 40% 70%;
    }
}

@keyframes gentleStarShift {
    0%, 100% { 
        transform: translate(0, 0);
        background-position: 0% 0%, 50% 50%, 100% 0%;
    }
    50% { 
        transform: translate(5px, -3px);
        background-position: 20% 10%, 30% 70%, 80% 20%;
    }
}

@keyframes space-shimmer {
    0% { background-position: -200px 0; }
    100% { background-position: calc(200px + 100%) 0; }
}

/* ==========================================================================
   9. BOOK COVER STYLING
   ========================================================================== */

.book-cover-container {
    position: relative;
}

.book-cover-container a {
    display: inline-block;
    outline: none;
}

.book-cover-container a:focus {
    outline: none;
}

.book-cover-container a:focus .book-cover-image {
    outline: 3px solid var(--orbital-teal);
    outline-offset: 2px;
}

.book-cover-image {
    max-width: 100%;
    max-height: 80vh;
    height: auto;
    border-radius: 12px !important;
    transition: all 0.3s ease;
    border: 3px solid var(--stellar-silver);
}

.book-cover-image:hover {
    transform: translateY(-5px) scale(1.02);
    box-shadow: 0 15px 30px rgba(0,0,0,0.2) !important;
}

.book-cover-image.loading {
    background: linear-gradient(90deg, white 0px, var(--stellar-silver) 50px, white 100px);
    background-size: 200px 100%;
    animation: space-shimmer 1.5s infinite;
}

/* ==========================================================================
   10. BUTTON STYLES
   ========================================================================== */

.btn {
    font-weight: 600;
    letter-spacing: 0.5px;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    transition: all 0.3s ease;
    text-decoration: none;
    border: 2px solid transparent;
}

.btn-lg {
    font-size: 1.1rem;
    padding: 1rem 2rem;
}

/* Primary buttons */
.btn-primary {
    background: linear-gradient(135deg, var(--city-gold) 0%, var(--amber-glow) 100%);
    border-color: var(--city-gold);
    color: white;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--electric-yellow) 0%, var(--warm-orange) 100%);
    border-color: var(--electric-yellow);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(255, 184, 0, 0.4);
}

/* Light buttons */
.btn-light {
    background: linear-gradient(135deg, white 0%, #FFF8E7 100%);
    border-color: var(--city-gold);
    color: var(--text-dark);
    border-width: 2px;
}

.btn-light:hover {
    background: linear-gradient(135deg, var(--electric-yellow) 0%, var(--city-gold) 100%);
    border-color: var(--amber-glow);
    color: white;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.2);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(255, 184, 0, 0.3);
}

/* Outline buttons */
.btn-outline-secondary {
    border-color: var(--space-gray);
    color: var(--space-gray);
}

.btn-outline-secondary:disabled {
    border-color: var(--horizon-blue) !important;
    color: var(--horizon-blue) !important;
    background-color: transparent !important;
    opacity: 0.7;
}


/* Disabled state for placeholder links */
a[aria-disabled="true"] {
    cursor: not-allowed;
    opacity: 0.8;
}

a[aria-disabled="true"]:hover {
    transform: none;
    box-shadow: none;
}

/* ==========================================================================
   11. ICON STYLES
   ========================================================================== */

.bi {
    font-size: 1.1em;
}

/* Button icon color overrides */
.btn-primary .bi::before,
.btn-primary .bi {
    color: white !important;
}

.btn-light .bi::before,
.btn-light .bi {
    color: inherit !important;
}

.text-white.bi::before,
.text-white.bi {
    color: white !important;
}

i[style*="color:white"]::before {
    color: white !important;
}

/* SVG icon filters */
.btn-primary img {
    filter: brightness(0) saturate(100%) invert(100%);
}

.btn img[alt="Bluesky"] {
    filter: brightness(0) saturate(100%) invert(100%);
}


/* ==========================================================================
   12. CARD STYLES
   ========================================================================== */

.card {
    border-radius: 12px;
    transition: all 0.3s ease;
    border: 1px solid var(--space-gray);
    background-color: white;
}

.card:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(26, 43, 61, 0.15) !important;
    border-color: var(--orbital-teal);
}

.card-title {
    color: var(--text-dark);
    font-weight: 600;
}

.card-text.text-muted {
    color: var(--muted-text) !important;
}

/* ==========================================================================
   13. CALL-TO-ACTION SECTIONS
   ========================================================================== */

.bg-primary {
    background: linear-gradient(135deg, var(--deep-space) 0%, var(--earth-blue) 100%) !important;
    position: relative;
    overflow: hidden;
}

.bg-primary::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(circle at 25% 30%, rgba(192,192,192,0.2) 1px, transparent 1px),
        radial-gradient(circle at 75% 70%, rgba(192,192,192,0.15) 0.8px, transparent 0.8px),
        radial-gradient(circle at 45% 20%, rgba(192,192,192,0.25) 0.5px, transparent 0.5px);
    background-size: 200px 200px, 180px 180px, 150px 150px;
    animation: gentleStarShift 30s ease-in-out infinite;
    opacity: 0.9;
    z-index: 0;
}

.bg-primary > .container {
    position: relative;
    z-index: 1;
}

.bg-primary h2,
.bg-primary .lead {
    color: white !important;
}

/* ==========================================================================
   14. FOOTER STYLES
   ========================================================================== */

footer {
    background: linear-gradient(135deg, var(--earth-blue) 0%, var(--deep-space) 100%) !important;
}

footer a {
    transition: color 0.3s ease;
}

footer a:hover {
    color: var(--stellar-silver) !important;
}

footer .text-white-50 {
    color: white !important;
}

footer .text-white-50:hover {
    color: var(--stellar-silver) !important;
}

/* ==========================================================================
   15. AUTHOR SECTION
   ========================================================================== */

.author-buttons .btn {
    min-width: 140px;
    white-space: nowrap;
}

.author-photo {
    border: 4px solid var(--stellar-silver);
    transition: all 0.3s ease;
}

.author-photo:hover {
    transform: scale(1.05);
    border-color: var(--orbital-teal);
}

/* ==========================================================================
   16. NAVBAR STYLES
   ========================================================================== */

.navbar-brand {
    font-size: 1.5rem;
    color: var(--text-dark) !important;
    letter-spacing: 0.5px;
    font-weight: 600;
}

/* ==========================================================================
   17. LINK STYLES
   ========================================================================== */

a {
    color: var(--earth-blue);
}

a:hover {
    color: var(--orbital-teal);
}

/* ==========================================================================
   18. SHADOW UTILITIES
   ========================================================================== */

.shadow-lg {
    box-shadow: 0 1rem 3rem rgba(26, 43, 61, 0.175) !important;
}

.shadow-sm {
    box-shadow: 0 0.125rem 0.25rem rgba(26, 43, 61, 0.075) !important;
}

/* ==========================================================================
   19. SPACING UTILITIES
   ========================================================================== */

/* No custom spacing utilities currently needed */

/* ==========================================================================
   20. SPECIFIC COMPONENT STYLES
   ========================================================================== */

/* Format card icons */
.format-card-icon {
    color: var(--orbital-teal);
    font-size: 2rem;
    font-weight: bold;
}

/* Coming Soon text */
.coming-soon-text {
    color: var(--earth-blue);
}

/* Author photo sizing */
.author-photo-sized {
    max-width: 200px;
    width: 100%;
}

/* Social media icons */
.social-icon {
    width: 16px;
    height: 16px;
    filter: brightness(0) saturate(100%) invert(100%);
}

/* Region Selector */
.region-selector {
    text-align: center;
}

.region-tabs {
    padding: 0;
    margin: 0;
}

.region-tab {
    background: white;
    border: 2px solid var(--space-gray);
    color: var(--text-dark);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 50px;
}

.region-tab:hover {
    background: linear-gradient(135deg, #F5F5F5 0%, #E8E8E8 100%);
    border-color: var(--orbital-teal);
    transform: translateY(-1px);
}

.region-tab.active {
    background: linear-gradient(135deg, var(--city-gold) 0%, var(--amber-glow) 100%);
    border-color: var(--city-gold);
    color: white !important;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.2);
}

.region-tab:focus {
    outline: 3px solid var(--orbital-teal);
    outline-offset: 2px;
}

/* ==========================================================================
   21. RESPONSIVE DESIGN
   ========================================================================== */

@media (max-width: 768px) {
    .hero-section {
        min-height: 80vh;
        text-align: center;
    }
    
    .hero-section h1 {
        font-size: 2.5rem;
    }
    
    section {
        padding: 3rem 0;
    }
    
    .book-cover-image {
        max-width: 280px;
        margin: 0 auto;
    }
    
    footer .col-md-6 {
        text-align: center !important;
    }
}

@media (max-width: 576px) {
    .author-buttons {
        flex-direction: column;
        align-items: center;
    }
    
    .author-buttons .btn {
        width: 100%;
        max-width: 200px;
    }
}

/* Center "More Platforms" card when it appears alone on larger screens */
@media (min-width: 992px) {
    #available-formats .row.g-4 {
        justify-content: center;
    }
    #available-formats .row.g-4 .col-lg-4:nth-child(7) {
        flex: 0 0 auto;
        width: 33.333333%;
        max-width: 350px;
    }
}


/* ==========================================================================
   22. SAFARI MOBILE SAFE AREA HANDLING
   ========================================================================== */

/* Safari-specific fix for white bars in landscape orientation on mobile devices */
@supports(padding: max(0px)) {
    /* Only target Safari on mobile devices */
    @media screen and (max-width: 768px) and (-webkit-min-device-pixel-ratio: 1) {
        /* Force correct body background */
        body {
            background-color: var(--light-cream) !important;
            padding-left: env(safe-area-inset-left);
            padding-right: env(safe-area-inset-right);
        }
        
        /* Force correct hero section background */
        .hero-section {
            background: linear-gradient(135deg, var(--deep-space) 0%, var(--earth-blue) 50%, var(--orbital-teal) 100%) !important;
            margin-left: calc(-1 * env(safe-area-inset-left));
            margin-right: calc(-1 * env(safe-area-inset-right));
            padding-left: env(safe-area-inset-left);
            padding-right: env(safe-area-inset-right);
        }
        
        /* Force correct footer background */
        footer {
            background: linear-gradient(135deg, var(--earth-blue) 0%, var(--deep-space) 100%) !important;
            margin-left: calc(-1 * env(safe-area-inset-left));
            margin-right: calc(-1 * env(safe-area-inset-right));
            padding-left: env(safe-area-inset-left);
            padding-right: env(safe-area-inset-right);
        }
        
        /* Force correct CTA section background */
        .bg-primary {
            background: linear-gradient(135deg, var(--deep-space) 0%, var(--earth-blue) 100%) !important;
            margin-left: calc(-1 * env(safe-area-inset-left));
            margin-right: calc(-1 * env(safe-area-inset-right));
            padding-left: env(safe-area-inset-left);
            padding-right: env(safe-area-inset-right);
        }
        
        /* Force correct light cream sections background */
        .bg-light,
        section:nth-child(even) {
            background: linear-gradient(180deg, var(--light-cream) 0%, #E8E8E8 100%) !important;
            margin-left: calc(-1 * env(safe-area-inset-left));
            margin-right: calc(-1 * env(safe-area-inset-right));
            padding-left: env(safe-area-inset-left);
            padding-right: env(safe-area-inset-right);
        }
    }
}