/* ============================================================
   NekoGen V2 — BASE
   Reset, typography, layout primitives, loader, skeleton.
   ============================================================ */

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

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

body {
    background-color: var(--color-bg);
    background-image:
        radial-gradient(ellipse 80% 50% at 50% -10%, rgba(var(--color-primary-rgb), 0.09), transparent),
        radial-gradient(ellipse 60% 40% at 90% 110%, rgba(var(--color-secondary-rgb), 0.05), transparent);
    background-attachment: fixed;
    color: var(--color-text);
    font-family: var(--font-sans);
    font-size: var(--text-base);
    line-height: var(--leading-normal);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ---------- Typography ---------- */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    font-weight: 700;
    line-height: var(--leading-tight);
    letter-spacing: -0.01em;
    color: var(--color-text);
}

h1 { font-size: var(--text-4xl); }
h2 { font-size: var(--text-3xl); }
h3 { font-size: var(--text-2xl); }
h4 { font-size: var(--text-xl); }
h5 { font-size: var(--text-lg); }
h6 { font-size: var(--text-base); }

p { color: var(--color-text-dim); }

a {
    color: var(--color-primary-soft);
    text-decoration: none;
    transition: color var(--transition-fast);
}
a:hover { color: var(--color-secondary); }

strong { color: var(--color-text); font-weight: 600; }
small { font-size: var(--text-sm); color: var(--color-text-muted); }

code, pre {
    font-family: var(--font-mono);
    font-size: 0.9em;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xs);
    padding: 0.15em 0.4em;
}

img, svg, video { max-width: 100%; height: auto; display: block; }
ul, ol { list-style: none; }
button { font-family: inherit; }
input, select, textarea { font-family: inherit; }

::selection {
    background: rgba(var(--color-primary-rgb), 0.35);
    color: var(--color-text);
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--color-bg); }
::-webkit-scrollbar-thumb {
    background: var(--color-surface-brighter);
    border-radius: var(--radius-full);
    border: 2px solid var(--color-bg);
}
::-webkit-scrollbar-thumb:hover { background: rgba(var(--color-primary-rgb), 0.5); }

/* ---------- Layout primitives ---------- */
.app-layout {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.main-content { flex: 1; width: 100%; }

.container {
    width: 100%;
    max-width: 1240px;
    margin-inline: auto;
    padding-inline: var(--space-lg);
}

.container-narrow { max-width: 860px; }
.container-wide { max-width: 1440px; }

.section { padding-block: var(--space-3xl); }
.section-sm { padding-block: var(--space-2xl); }

/* Section headings pattern */
.section-tag {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: var(--text-xs);
    font-weight: 600;
    letter-spacing: var(--tracking-wider);
    text-transform: uppercase;
    color: var(--color-primary-soft);
    background: rgba(var(--color-primary-rgb), 0.09);
    border: 1px solid rgba(var(--color-primary-rgb), 0.25);
    border-radius: var(--radius-full);
    padding: 0.35rem 0.9rem;
    margin-bottom: var(--space-md);
}

.section-title {
    font-size: clamp(1.75rem, 4vw, var(--text-3xl));
    margin-bottom: var(--space-sm);
}

.section-subtitle {
    color: var(--color-text-dim);
    font-size: var(--text-lg);
    max-width: 640px;
}

.text-gradient {
    background: var(--grad-text);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
}

/* ---------- Utilities ---------- */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }
.text-center { text-align: center; }
.mt-lg { margin-top: var(--space-lg); }
.mb-lg { margin-bottom: var(--space-lg); }
.hidden { display: none !important; }
.sr-only {
    position: absolute; width: 1px; height: 1px;
    margin: -1px; padding: 0; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Glass panel ---------- */
.glass {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: var(--glass-border);
    border-radius: var(--radius-lg);
}

/* ---------- Global loader ---------- */
.global-loader {
    position: fixed;
    inset: 0;
    z-index: var(--z-loader);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-bg);
    opacity: 1;
    visibility: visible;
    transition: opacity 0.45s var(--ease-out), visibility 0.45s;
}

body:not(.loading) .global-loader { opacity: 0; visibility: hidden; pointer-events: none; }

.loader-content { text-align: center; }

.loader-spinner {
    width: 52px;
    height: 52px;
    margin: 0 auto var(--space-md);
    border-radius: 50%;
    border: 2px solid rgba(var(--color-primary-rgb), 0.15);
    border-top-color: var(--color-primary);
    border-right-color: var(--color-secondary);
    animation: spin 0.8s linear infinite;
    box-shadow: var(--glow-primary);
}

.loader-text {
    font-family: var(--font-display);
    font-size: var(--text-xs);
    letter-spacing: var(--tracking-wider);
    text-transform: uppercase;
    color: var(--color-text-muted);
    animation: pulse-soft 1.6s ease-in-out infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse-soft { 0%, 100% { opacity: 0.45; } 50% { opacity: 1; } }

/* ---------- Skeleton loading ---------- */
.skeleton {
    position: relative;
    overflow: hidden;
    background: var(--color-surface);
    border-radius: var(--radius-sm);
    min-height: 1em;
}
.skeleton::after {
    content: '';
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.06), transparent);
    animation: skeleton-sweep 1.4s infinite;
}
@keyframes skeleton-sweep { to { transform: translateX(100%); } }

.skeleton-text { height: 0.9em; margin-block: 0.35em; }
.skeleton-avatar { width: 44px; height: 44px; border-radius: 50%; }
.skeleton-card { height: 180px; border-radius: var(--radius-lg); }

/* ---------- Scanlines (subtle, decorative) ---------- */
.scanlines {
    position: fixed;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    background: repeating-linear-gradient(
        to bottom,
        transparent 0 3px,
        rgba(0, 0, 0, 0.06) 3px 4px
    );
    opacity: 0.35;
    mix-blend-mode: overlay;
}

/* ---------- Focus visibility (a11y) ---------- */
:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
    border-radius: var(--radius-xs);
}

/* ---------- Responsive base ---------- */
@media (max-width: 768px) {
    .container { padding-inline: var(--space-md); }
    .section { padding-block: var(--space-2xl); }
    h1 { font-size: var(--text-3xl); }
    h2 { font-size: var(--text-2xl); }
}

/* ---------- Section header (shared pattern) ---------- */
.section-header { margin-bottom: var(--space-2xl); }
.section-header.text-center .section-subtitle { margin-inline: auto; }

/* ---------- Support FAB ---------- */
.support-fab {
    position: fixed;
    right: var(--space-lg);
    bottom: var(--space-lg);
    z-index: var(--z-dropdown);
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    font-size: 0.9rem;
    font-weight: 600;
    color: #fff;
    background: rgba(15, 15, 20, 0.6);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 100px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.05);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.support-fab:hover {
    transform: translateY(-3px) scale(1.02);
    background: rgba(25, 25, 30, 0.8);
    border-color: var(--neon-secondary);
    box-shadow: 0 15px 35px rgba(0,0,0,0.6), 0 0 20px rgba(var(--neon-secondary-rgb), 0.3);
}
.support-fab i { 
    font-size: 1.1rem; 
    color: var(--neon-secondary);
}

@media (max-width: 560px) {
    .support-fab { right: var(--space-md); bottom: var(--space-md); padding: 12px; border-radius: 50%; }
    .support-fab-label { display: none; }
    .support-fab i { margin: 0; }
}
