body.page-ready {
    opacity: 1 !important;
}

/* Universal Shimmer Animation */
@keyframes shimmer {
    100% {
        transform: translateX(100%);
    }
}

.shimmer {
    position: relative;
    overflow: hidden;
    background-color: #e2e8f0;
}

/* Default background is handled by head script to prevent flash */
html, body {
    margin: 0;
    padding: 0;
}

/* DEPRECATED: Hide old progress bars from legacy pages to prevent Double Bar bug */
#page-progress-bar, #hdl-progress-bar {
    display: none !important;
    visibility: hidden !important;
}

.dark-mode .shimmer {
    background-color: #1e293b;
}

.shimmer::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 200%;
    height: 100%;
    background: linear-gradient(
        to right,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.3) 30%,
        rgba(255, 255, 255, 0.5) 50%,
        rgba(255, 255, 255, 0.3) 70%,
        rgba(255, 255, 255, 0) 100%
    );
    animation: shimmer-swipe 1.5s infinite linear;
    z-index: 1;
}

.dark-mode .shimmer::after {
    background: linear-gradient(
        to right,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.03) 30%,
        rgba(255, 255, 255, 0.08) 50%,
        rgba(255, 255, 255, 0.03) 70%,
        rgba(255, 255, 255, 0) 100%
    );
}

@keyframes shimmer-swipe {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(50%); }
}

/* Premium Top Progress Bar (GitHub Style) */
#page-bar-loading {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    height: 3px !important;
    width: 0%;
    z-index: 2147483648 !important;
    background: linear-gradient(90deg, #3b82f6, #60a5fa, #3b82f6);
    background-size: 200% 100%;
    /* Sharper shadow to prevent "Double Bar" look */
    box-shadow: 0 1px 3px rgba(59, 130, 246, 0.4); 
    pointer-events: none;
    transition: width 0.3s cubic-bezier(0.1, 0.7, 0.1, 1), opacity 0.4s ease;
    display: block;
}

#page-bar-loading.loading {
    width: 90%;
    transition: width 10s cubic-bezier(0.1, 0.7, 0.1, 1);
}

#page-bar-loading.complete {
    width: 100% !important;
}

/* Transitions are now handled at the bottom of the file for reliability */


/* Skeleton Styles Removed — Unified Reveal Logic at bottom of file */


.dark-mode .skeleton-container {
    background: #0f172a;
}

/* Ghost Components */
.skeleton-header {
    height: 60px;
    display: flex;
    align-items: center;
    padding: 0 40px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.skeleton-logo {
    width: 120px;
    height: 24px;
    background: #e2e8f0;
    border-radius: 4px;
}

.skeleton-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.skeleton-title {
    width: 60%;
    height: 48px;
    background: #e2e8f0;
    border-radius: 8px;
    margin-bottom: 24px;
}

.skeleton-text {
    width: 40%;
    height: 20px;
    background: #e2e8f0;
    border-radius: 4px;
    margin-bottom: 12px;
}

.skeleton-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    width: 80%;
    margin-top: 40px;
}

.skeleton-card {
    height: 120px;
    background: #e2e8f0;
    border-radius: 12px;
}

.skeleton-btns {
    display: flex;
    gap: 16px;
    margin-top: 24px;
}

.skeleton-btn {
    width: 140px;
    height: 44px;
    background: #e2e8f0;
    border-radius: 6px;
}

/* specialized Skeleton Layouts */

/* 1. Article/Content Layout (Blog, Privacy, etc.) */
.skeleton-article .skeleton-body {
    align-items: flex-start;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}

.skeleton-article .skeleton-title {
    width: 80%;
}

.skeleton-article .skeleton-text {
    width: 100%;
}

.skeleton-article .skeleton-grid {
    display: none;
}

/* 2. IDE/Editor Layout */
.skeleton-editor .skeleton-body {
    flex-direction: row;
    padding: 0;
    align-items: stretch;
}

.skeleton-editor .skeleton-sidebar {
    width: 300px;
    background: #f8fafc;
    border-right: 1px solid rgba(0, 0, 0, 0.05);
    padding: 20px;
}

.dark-mode .skeleton-editor .skeleton-sidebar {
    background: #0f172a;
    border-right-color: rgba(255, 255, 255, 0.05);
}

.skeleton-editor .skeleton-main {
    flex: 1;
    padding: 20px;
}

.skeleton-editor .skeleton-title,
.skeleton-editor .skeleton-text {
    align-self: flex-start;
}

/* 3. Dashboard/Grid Layout (Default) */
.skeleton-dashboard .skeleton-body {
    align-items: flex-start;
    padding: 40px;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

.skeleton-dashboard .skeleton-title {
    align-self: flex-start;
    width: 40%;
}

.skeleton-dashboard .skeleton-text {
    align-self: flex-start;
    width: 60%;
}

.skeleton-dashboard .skeleton-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px;
    width: 100%;
    margin-top: 40px;
}

.skeleton-dashboard .skeleton-card {
    height: 180px;
}

/* 5. Home Page Specialized Layout */
.skeleton-home .skeleton-header {
    justify-content: space-between;
    height: 70px;
    padding: 0 40px;
}

.skeleton-home .skeleton-nav {
    display: flex;
    gap: 24px;
    margin: 0 auto;
}

.skeleton-home .skeleton-nav-item {
    width: 60px;
    height: 14px;
    background: #e2e8f0;
    border-radius: 20px;
}

.skeleton-home .skeleton-actions {
    display: flex;
    gap: 16px;
}

.skeleton-home .skeleton-circle {
    width: 24px;
    height: 24px;
    background: #e2e8f0;
    border-radius: 50%;
}

.skeleton-home .skeleton-announcement {
    width: 100%;
    height: 36px;
    background: #f1f5f9;
    margin-bottom: 20px;
}

.skeleton-home .skeleton-body {
    padding: 20px 40px 60px;
}

.skeleton-home .skeleton-hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    margin-bottom: 40px;
    text-align: center;
}

.skeleton-home .skeleton-title {
    width: 400px;
    height: 60px;
    margin-bottom: 16px;
}

.skeleton-home .skeleton-text {
    width: 500px;
    height: 40px;
    margin-bottom: 32px;
}

.skeleton-home .skeleton-stats {
    width: 80%;
    height: 24px;
    background: #f1f5f9;
    margin: 0 auto 40px;
    border-radius: 4px;
}

.skeleton-home .skeleton-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
}

.skeleton-home .skeleton-domain-card {
    height: 140px;
    background: #e2e8f0;
    border-radius: 12px;
}

.dark-mode .skeleton-nav-item,
.dark-mode .skeleton-circle,
.dark-mode .skeleton-domain-card {
    background: #1e293b;
}

.dark-mode .skeleton-announcement,
.dark-mode .skeleton-stats {
    background: #0f172a;
    opacity: 0.5;
}

.dark-mode .skeleton-announcement,
.dark-mode .skeleton-stats {
    background: #0f172a;
    opacity: 0.5;
}

/* 6. Profile Page specialized Layout */
.skeleton-profile .skeleton-header {
    justify-content: space-between;
    height: 70px;
}

.skeleton-profile .skeleton-body {
    padding: 0;
    align-items: stretch;
}

.skeleton-profile-content {
    display: flex;
    flex: 1;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
    padding: 20px 40px;
    gap: 12px;
}

.skeleton-profile .skeleton-sidebar {
    width: 280px;
    height: 500px;
    background: #e2e8f0;
    border-radius: 12px;
}

.skeleton-profile .skeleton-bento-grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-auto-rows: minmax(140px, auto);
    gap: 12px;
}

.skeleton-profile .skeleton-bento-item {
    background: #e2e8f0;
    border-radius: 12px;
}

.skeleton-profile .skeleton-bento-item.large {
    grid-column: span 3;
    height: 200px;
}

.skeleton-profile .skeleton-bento-item.medium {
    grid-column: span 2;
    height: 280px;
}

.skeleton-profile .skeleton-bento-item.small {
    grid-column: span 1;
    height: 280px;
}

.dark-mode .skeleton-profile .skeleton-sidebar,
.dark-mode .skeleton-profile .skeleton-bento-item {
    background: #1e293b;
}

/* 4. Profile Dashboard Specialized Layout (Legacy/Cleanup) */
.skeleton-profile-wrapper {
    display: flex;
    flex: 1;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
    padding: 40px;
    gap: 40px;
}

.skeleton-sidebar {
    width: 300px;
    height: 600px;
    background: #e2e8f0;
    border-radius: 12px;
}

.skeleton-main {
    flex: 1;
}

.skeleton-bento {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: auto;
    gap: 24px;
}

.skeleton-bento-item {
    background: #e2e8f0;
    border-radius: 16px;
    min-height: 180px;
}

.skeleton-bento-item.large {
    grid-column: span 2;
    min-height: 240px;
}

.skeleton-bento-item.medium {
    grid-column: span 1;
}

.skeleton-bento-item.small {
    grid-column: span 1;
}

.dark-mode .skeleton-sidebar,
.dark-mode .skeleton-bento-item {
    background: #1e293b;
}


/* Dark Mode Overrides for new elements */
.dark-mode .skeleton-logo,
.dark-mode .skeleton-title,
.dark-mode .skeleton-text,
.dark-mode .skeleton-card,
.dark-mode .skeleton-btn,
.dark-mode .skeleton-sidebar-item {
    background: #1e293b;
}

.skeleton-sidebar-item {
    height: 32px;
    background: #e2e8f0;
    border-radius: 4px;
    margin-bottom: 12px;
    width: 100%;
}

/* Page Reveal Transition - High Fidelity Snap */
body:not(.page-ready) {
    background-color: #ffffff; /* Default light */
    overflow: hidden;
}

html.dark-mode body:not(.page-ready),
body.dark-mode:not(.page-ready) {
    background-color: #0f172a; /* Premium dark */
}

body:not(.page-ready) main,
body:not(.page-ready) .dashboard-wrapper,
body:not(.page-ready) .container,
body:not(.page-ready) .split-container,
body:not(.page-ready) .main-wrapper {
    opacity: 0; 
    transform: translateY(10px);
    pointer-events: none;
}

/* Fixed/absolute placeholders: opacity-only (no transform — would break position:fixed navbar) */
body:not(.page-ready) #navbar-placeholder,
body:not(.page-ready) #announcement-placeholder,
body:not(.page-ready) #footer-placeholder,
body:not(.page-ready) #sidebar-placeholder,
body:not(.page-ready) #topic-tags-placeholder,
body:not(.page-ready) #editor-header-placeholder,
body:not(.page-ready) .problem-drawer {
    opacity: 0; 
    pointer-events: none;
}



body.page-ready main,
body.page-ready .dashboard-wrapper,
body.page-ready .container,
body.page-ready .split-container,
body.page-ready .main-wrapper {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.4s ease-out, transform 0.4s cubic-bezier(0.1, 0.7, 0.1, 1);
}

body.page-ready #navbar-placeholder,
body.page-ready #announcement-placeholder,
body.page-ready #footer-placeholder,
body.page-ready #sidebar-placeholder,
body.page-ready #topic-tags-placeholder,
body.page-ready #editor-header-placeholder,
body.page-ready .problem-drawer {
    opacity: 1;
}

/* Page Transition Freeze (V3) */
body.hdl-navigating {
    pointer-events: none !important;
}

body.hdl-navigating::after {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: transparent;
    cursor: wait;
    z-index: 2147483640;
}

@keyframes hdlFreezeFade {
    from { opacity: 0; }
    to { opacity: 1; }
}