/*
 * base.css — Coin Catalog v2
 *
 * Core design tokens, global resets, and utility classes.
 * This file is loaded first to provide the foundation for components.
 */

:root {
    /* Spacing System */
    --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: 2.25rem;
    --space-10: 2.75rem;
    --space-12: 3.5rem;

    /* Typography */
    --font-size-xs:   0.75rem;
    --font-size-sm:   0.875rem;
    --font-size-base: 1rem;
    --font-size-lg:   1.125rem;
    --font-size-xl:   1.25rem;
    --font-size-2xl:  1.5rem;
    --font-size-3xl:  1.875rem;

    /* Border Radius */
    --radius-sm:   4px;
    --radius-md:   8px;
    --radius-lg:   12px;
    --radius-xl:   16px;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2 -4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);

    /* Z-Index */
    --z-sticky: 100;
    --z-modal:  1000;
    --z-toast:  2000;

    /* Sticky Layout Heights — country at top:0, section at 56px, type at 96px */
    --header-height:       0px;
    --country-bar-height:  56px;
    --section-bar-top:     56px;
    --type-bar-top:        112px;
}

/* =========================================================================
   Reset & Base Styles
   ========================================================================= */

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

html, body {
    margin: 0;
    padding: 0;
    min-height: 100%;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--color-bg-body);
    color:            var(--color-text-main);
    line-height:      1.5;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

a {
    color:           var(--color-accent);
    text-decoration: none;
}

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

button, input, select, textarea {
    font: inherit;
}

button {
    cursor:     pointer;
    border:     none;
    background: none;
}

/* =========================================================================
   Layout Containers
   ========================================================================= */

.container {
    width:         100%;
    max-width:     1400px;
    margin-left:   auto;
    margin-right:  auto;
    padding-left:  var(--space-4);
    padding-right: var(--space-4);
}

/* =========================================================================
   Global Utilities
   ========================================================================= */

.hidden {
    display: none !important;
}

.sr-only {
    position: absolute;
    width:    1px;
    height:   1px;
    padding:  0;
    margin:   -1px;
    overflow: hidden;
    clip:     rect(0, 0, 0, 0);
    border:   0;
}

.text-center { text-align: center; }
.text-muted  { color: var(--color-text-muted); }

/* =========================================================================
   Splash Screen Styles
   ========================================================================= */

#app-splash {
    position:        fixed;
    inset:           0;
    background:      var(--color-bg-body);
    z-index:         9999;
    display:         flex;
    flex-direction:  column;
    align-items:     center;
    justify-content: center;
    transition:      opacity 0.6s ease, visibility 0.6s;
}

#app-splash.hidden {
    opacity:    0;
    visibility: hidden;
}

.splash-coin {
    width:         80px;
    height:        80px;
    border-radius: 50%;
    margin-bottom: var(--space-6);
    background:    radial-gradient(circle at 30% 30%, #ffd700 0%, #b8860b 60%, #8b6914 100%);
    border:        2px solid rgba(255,215,0,0.3);
    box-shadow:    0 4px 6px rgba(0,0,0,0.2), inset 0 -2px 4px rgba(0,0,0,0.3), inset 0 2px 4px rgba(255,215,0,0.4);
    animation:     pulse 2s infinite ease-in-out;
}

@keyframes pulse {
    0%, 100% { transform: scale(1);   opacity: 1; }
    50%      { transform: scale(1.1); opacity: 0.7; }
}

.splash-label {
    font-size:   var(--font-size-lg);
    font-weight: 600;
    color:       var(--color-text-main);
}

/* =========================================================================
   App Header
   ========================================================================= */

#app-header {
    background:      var(--color-header-bg);
    color:           var(--color-header-text);
    padding:         var(--space-3) var(--space-6);
    display:         flex;
    align-items:     center;
    justify-content: space-between;
    gap:             var(--space-3);
    z-index:         200;
    border-bottom:   1px solid var(--color-border-light);
}

.header-left {
    display:     flex;
    align-items: center;
    gap:         var(--space-2);
}

.app-title {
    margin:      0;
    font-size:   var(--font-size-xl);
    font-weight: 700;
    display:     flex;
    align-items: center;
    gap:         var(--space-2);
    white-space: nowrap;
}

.header-logo {
    width: 160px;
    height: 160px;
    border-radius: 50%;
    flex-shrink:   0;
    margin-top: -30px;
    margin-bottom: -30px;
    position:      relative;
    z-index:       10;
}

.header-right {
    display:     flex;
    align-items: center;
    gap:         var(--space-2);
}

.header-nav {
    display:     flex;
    gap:         var(--space-2);
}

.btn-header {
    font-size:      var(--font-size-sm);
    padding:        var(--space-1) var(--space-3);
    border-radius:  var(--radius-full);
    background:     var(--color-bg-card);
    color:          var(--color-text-main);
    border:         1px solid var(--color-border-light);
    white-space:    nowrap;
    transition:     background var(--transition-fast), border-color var(--transition-fast);
}

.btn-header:hover {
    background:   var(--color-accord-bg);
    border-color: var(--color-accent);
}

.theme-select {
    font-size:      var(--font-size-sm);
    padding:        var(--space-1) var(--space-3);
    border-radius:  var(--radius-full);
    background:     var(--color-bg-card);
    color:          var(--color-text-main);
    border:         1px solid var(--color-border-light);
    cursor:         pointer;
    appearance:     auto;
}

/* Hide the extras container — JS manages visibility of children */
#header-extras {
    display: none;
}

@media (max-width: 768px) {
    .container {
        padding-left:  var(--space-1);
        padding-right: var(--space-1);
    }

    :root {
        --country-bar-height: 48px;
        --header-height: 0px;
        --section-bar-top: 48px;
        --type-bar-top: 100px;
    }
    #app-header {
        display:               grid;
        grid-template-columns: 1fr auto;
        grid-template-rows:    auto auto;
        grid-template-areas:
            "left left"
            "nav right";
        align-items:           center;
        padding:               6px var(--space-3) 8px var(--space-4);
        gap:                   4px;
        border-bottom:         1px solid var(--color-border-light);
    }
    .header-left  { grid-area: left; }
    .header-right { grid-area: right; display: flex; align-items: center; gap: var(--space-1); }
    .header-nav   { grid-area: nav; display: flex; gap: 3px; justify-content: flex-start; flex-wrap: nowrap; }

    .header-logo {
        width:           52px;
        height:          52px;
        margin-bottom:   0;
        transform:       none;
    }
    .app-title {
        font-size:     var(--font-size-sm);
        white-space:   nowrap;
        line-height:   1.1;
        gap:           var(--space-1);
    }
    .header-nav .btn-header {
        font-size:  0.7rem;
        padding:    3px 8px;
    }
    .btn-header {
        font-size:  0.7rem;
    }
    .theme-select {
        font-size:  var(--font-size-xs);
        max-width:  110px;
        padding:    2px 6px;
    }
    /* Remove the ::after pseudo-element — border is on header directly */
    #app-header::after {
        display: none;
    }
}
