/**
 * TionStation Shared UX Enhanced CSS
 * Dark/Light mode, loading screen, toast notifications, scroll animations
 * @version 2.0.0
 */

/* =====================================================
   CSS CUSTOM PROPERTIES (Theme Tokens)
   ===================================================== */
:root {
    /* Dark theme (default) */
    --tion-bg-primary: #0A0E27;
    --tion-bg-secondary: #151B3D;
    --tion-bg-card: #151B3D;
    --tion-bg-surface: rgba(255, 255, 255, 0.04);
    --tion-text-primary: #FFFFFF;
    --tion-text-secondary: #A0AEC0;
    --tion-text-muted: #718096;
    --tion-accent-1: #0066FF;
    --tion-accent-2: #00D9FF;
    --tion-border: rgba(255, 255, 255, 0.08);
    --tion-shadow: rgba(0, 0, 0, 0.3);
    --tion-gradient: linear-gradient(135deg, #00D9FF 0%, #0066FF 100%);
    --tion-overlay: rgba(10, 14, 39, 0.95);
    --tion-font-primary: 'Noto Sans KR', 'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Light mode overrides */
.tion-light-mode {
    --tion-bg-primary: #F8FAFC;
    --tion-bg-secondary: #FFFFFF;
    --tion-bg-card: #FFFFFF;
    --tion-bg-surface: rgba(0, 0, 0, 0.03);
    --tion-text-primary: #1A202C;
    --tion-text-secondary: #4A5568;
    --tion-text-muted: #718096;
    --tion-border: rgba(0, 0, 0, 0.08);
    --tion-shadow: rgba(0, 0, 0, 0.08);
    --tion-overlay: rgba(248, 250, 252, 0.98);
}

/* Apply theme variables */
.tion-enhanced {
    font-family: var(--tion-font-primary);
}

/* Light mode specific overrides */
.tion-light-mode body,
.tion-light-mode .wp-site-blocks {
    background-color: var(--tion-bg-primary) !important;
    color: var(--tion-text-primary) !important;
}

.tion-light-mode .wp-block-post-content,
.tion-light-mode .entry-content {
    color: var(--tion-text-primary);
}

.tion-light-mode header,
.tion-light-mode .wp-block-template-part {
    background-color: var(--tion-bg-secondary) !important;
    border-bottom: 1px solid var(--tion-border);
}

.tion-light-mode .tion-mobile-nav {
    background: rgba(255, 255, 255, 0.96) !important;
    border-top-color: var(--tion-border) !important;
}

.tion-light-mode .tion-mobile-nav-item {
    color: #718096;
}

.tion-light-mode .tion-mobile-nav-item.active {
    color: #0066FF;
}

.tion-light-mode .tion-mobile-drawer-content {
    background: #FFFFFF !important;
}

.tion-light-mode .tion-drawer-nav-item {
    color: #4A5568;
}

.tion-light-mode .tion-drawer-nav-item:hover {
    background: rgba(0, 102, 255, 0.06);
    color: #1A202C;
}

.tion-light-mode .tion-search-overlay {
    background: rgba(248, 250, 252, 0.98) !important;
}

.tion-light-mode .tion-search-form {
    background: rgba(0, 0, 0, 0.04);
    border-color: rgba(0, 0, 0, 0.1);
}

.tion-light-mode .tion-search-input {
    color: #1A202C;
}

.tion-light-mode .tion-scroll-top {
    background: rgba(255, 255, 255, 0.95);
    border-color: rgba(0, 0, 0, 0.08);
    color: #0066FF;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.tion-light-mode .tion-floating-btn {
    background: rgba(255, 255, 255, 0.95);
    border-color: rgba(0, 0, 0, 0.08);
    color: #4A5568;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

.tion-light-mode .tion-toc-sidebar {
    background: rgba(255, 255, 255, 0.98);
    border-color: rgba(0, 0, 0, 0.06);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.tion-light-mode .tion-toc-link {
    color: #718096;
}

.tion-light-mode .tion-toc-link.active {
    color: #0066FF;
    background: rgba(0, 102, 255, 0.06);
    border-left-color: #0066FF;
}

.tion-light-mode .tion-share-sheet-content {
    background: #FFFFFF;
}

.tion-light-mode .tion-share-sheet-title {
    color: #1A202C;
}

.tion-light-mode .tion-pwa-install-banner {
    background: rgba(255, 255, 255, 0.98);
    border-color: rgba(0, 102, 255, 0.15);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
}

.tion-light-mode .tion-pwa-install-text strong {
    color: #1A202C;
}

/* =====================================================
   LOADING SCREEN
   ===================================================== */
.tion-loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 999999;
    background: #0A0E27;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.tion-loading-screen.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.tion-loading-inner {
    text-align: center;
}

.tion-loading-logo {
    margin-bottom: 30px;
}

.tion-loading-text {
    font-size: 36px;
    font-weight: 900;
    background: linear-gradient(135deg, #00D9FF, #0066FF);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -1px;
}

.tion-loading-station {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: #718096;
    letter-spacing: 6px;
    text-transform: uppercase;
    margin-top: 4px;
}

.tion-loading-bar {
    width: 200px;
    height: 3px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 2px;
    overflow: hidden;
    margin: 0 auto;
}

.tion-loading-bar-inner {
    width: 40%;
    height: 100%;
    background: linear-gradient(90deg, #00D9FF, #0066FF);
    border-radius: 2px;
    animation: loadingSlide 1.2s ease-in-out infinite;
}

@keyframes loadingSlide {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(350%); }
}

/* =====================================================
   TOAST NOTIFICATIONS
   ===================================================== */
.tion-toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

@media (max-width: 768px) {
    .tion-toast-container {
        top: auto;
        bottom: calc(80px + env(safe-area-inset-bottom, 0px));
        right: 16px;
        left: 16px;
        align-items: center;
    }
}

.tion-toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 20px;
    background: rgba(10, 14, 39, 0.95);
    backdrop-filter: blur(15px);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: white;
    font-size: 14px;
    font-weight: 500;
    pointer-events: auto;
    transform: translateX(120%);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
    max-width: 380px;
}

@media (max-width: 768px) {
    .tion-toast {
        transform: translateY(40px);
        max-width: 100%;
    }
    .tion-toast.visible {
        transform: translateY(0) !important;
    }
}

.tion-toast.visible {
    transform: translateX(0);
}

.tion-toast.success {
    border-left: 3px solid #48BB78;
}

.tion-toast.error {
    border-left: 3px solid #FC8181;
}

.tion-toast.info {
    border-left: 3px solid #00D9FF;
}

.tion-toast.warning {
    border-left: 3px solid #F6E05E;
}

.tion-toast-icon {
    font-size: 20px;
    flex-shrink: 0;
}

.tion-toast.success .tion-toast-icon { color: #48BB78; }
.tion-toast.error .tion-toast-icon { color: #FC8181; }
.tion-toast.info .tion-toast-icon { color: #00D9FF; }
.tion-toast.warning .tion-toast-icon { color: #F6E05E; }

.tion-light-mode .tion-toast {
    background: rgba(255, 255, 255, 0.98);
    color: #1A202C;
    border-color: rgba(0, 0, 0, 0.06);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
}

/* =====================================================
   SCROLL ANIMATIONS
   ===================================================== */
.tion-animate {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.tion-animate.tion-visible {
    opacity: 1;
    transform: translateY(0);
}

.tion-animate-left {
    opacity: 0;
    transform: translateX(-30px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.tion-animate-left.tion-visible {
    opacity: 1;
    transform: translateX(0);
}

.tion-animate-right {
    opacity: 0;
    transform: translateX(30px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.tion-animate-right.tion-visible {
    opacity: 1;
    transform: translateX(0);
}

.tion-animate-scale {
    opacity: 0;
    transform: scale(0.9);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.tion-animate-scale.tion-visible {
    opacity: 1;
    transform: scale(1);
}

/* Stagger delays for lists */
.tion-stagger-1 { transition-delay: 0.1s; }
.tion-stagger-2 { transition-delay: 0.2s; }
.tion-stagger-3 { transition-delay: 0.3s; }
.tion-stagger-4 { transition-delay: 0.4s; }
.tion-stagger-5 { transition-delay: 0.5s; }
.tion-stagger-6 { transition-delay: 0.6s; }

/* =====================================================
   IMAGE LAZY LOAD FADE-IN
   ===================================================== */
img {
    transition: opacity 0.3s ease;
}

img[data-src] {
    opacity: 0;
}

img.tion-img-loaded {
    opacity: 1;
}

/* =====================================================
   SMOOTH PAGE TRANSITIONS
   ===================================================== */
.tion-page-transition {
    animation: pageEnter 0.4s ease-out;
}

@keyframes pageEnter {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* =====================================================
   GENERAL TYPOGRAPHY IMPROVEMENTS
   ===================================================== */
.tion-enhanced {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* Word break for Korean text */
.tion-enhanced p,
.tion-enhanced li,
.tion-enhanced td,
.tion-enhanced th {
    word-break: keep-all;
    overflow-wrap: break-word;
}

/* =====================================================
   READING TIME BADGE (shared)
   ===================================================== */
.tion-reading-time-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: rgba(0, 217, 255, 0.08);
    border: 1px solid rgba(0, 217, 255, 0.15);
    border-radius: 50px;
    font-size: 14px;
    color: #00D9FF;
    margin-bottom: 24px;
    font-weight: 500;
}

.tion-reading-time-badge .material-icons-round {
    font-size: 16px;
}

.tion-light-mode .tion-reading-time-badge {
    background: rgba(0, 102, 255, 0.06);
    border-color: rgba(0, 102, 255, 0.12);
    color: #0066FF;
}

/* =====================================================
   FOCUS VISIBLE STYLES (Accessibility)
   ===================================================== */
:focus-visible {
    outline: 2px solid #00D9FF;
    outline-offset: 2px;
    border-radius: 4px;
}

/* =====================================================
   REDUCED MOTION
   ===================================================== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    .tion-animate,
    .tion-animate-left,
    .tion-animate-right,
    .tion-animate-scale {
        opacity: 1;
        transform: none;
    }
}

/* =====================================================
   PRINT STYLES
   ===================================================== */
@media print {
    .tion-mobile-nav,
    .tion-scroll-top,
    .tion-pc-floating-controls,
    .tion-toc-sidebar,
    .tion-loading-screen,
    .tion-reading-progress,
    .tion-pwa-install-banner,
    .tion-toast-container,
    .tion-search-overlay,
    .tion-share-sheet,
    .tion-mobile-drawer {
        display: none !important;
    }

    body {
        background: white !important;
        color: black !important;
    }
}
