/* ═══════════════════════════════════════════════════
   CMS Pages — Premium Article & Page Viewer
   ═══════════════════════════════════════════════════ */

/* Variables now centralized in color-palette.css */

/* ─────────────  PROGRESS BAR  ───────────── */
.pg-progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    width: 0%;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    z-index: 9999;
    transition: width 0.15s linear;
    border-radius: 0 3px 3px 0;
    box-shadow: 0 0 8px rgba(108, 96, 254, 0.4);
}

/* ─────────────  LOADING  ───────────── */
.pg-loading {
    text-align: center;
    padding: 120px 0;
}

.pg-loading p {
    color: var(--text-muted);
    margin-top: 20px;
    font-size: 15px;
}

.pg-loader {
    position: relative;
    width: 60px;
    height: 60px;
    margin: 0 auto;
}

.pg-loader-ring {
    position: absolute;
    inset: 0;
    border: 3px solid transparent;
    border-radius: 50%;
}

.pg-loader-ring:nth-child(1) {
    border-top-color: var(--primary);
    animation: pgSpin 1s linear infinite;
}

.pg-loader-ring:nth-child(2) {
    inset: 6px;
    border-right-color: var(--accent);
    animation: pgSpin 1.5s linear infinite reverse;
}

.pg-loader-ring:nth-child(3) {
    inset: 12px;
    border-bottom-color: var(--primary-light);
    animation: pgSpin 2s linear infinite;
}

@keyframes pgSpin {
    to {
        transform: rotate(360deg);
    }
}

/* ─────────────  ERROR  ───────────── */
.pg-error {
    padding: 80px 0;
}

.pg-error-card {
    max-width: 480px;
    margin: 0 auto;
    text-align: center;
    background: var(--surface);
    border-radius: var(--radius);
    padding: 48px 36px;
    box-shadow: var(--shadow);
}

.pg-error-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 24px;
    background: rgba(253, 51, 88, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    color: var(--accent);
}

.pg-error-card h2 {
    color: var(--dark);
    margin-bottom: 8px;
}

.pg-error-card p {
    color: var(--text-muted);
    margin-bottom: 24px;
}

.pg-btn-primary {
    background: var(--primary);
    color: #fff;
    border-radius: 50px;
    padding: 12px 28px;
    font-weight: 700;
    font-size: 14px;
    transition: var(--transition);
    border: none;
}

.pg-btn-primary:hover {
    background: var(--primary-dark);
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(108, 96, 254, 0.3);
}

/* ─────────────  HERO  ───────────── */
.pg-hero {
    position: relative;
    padding: 80px 0 56px;
    overflow: hidden;
    min-height: 300px;
    display: flex;
    align-items: center;
}

.pg-hero-bg {
    position: absolute;
    inset: 0;
}

.pg-hero-gradient {
    position: absolute;
    inset: 0;
    background: var(--gradient-hero);
}

.pg-hero-pattern {
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(circle at 20% 80%, rgba(253, 51, 88, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 80% 30%, rgba(138, 128, 255, 0.1) 0%, transparent 40%);
    pointer-events: none;
}

.pg-hero-orbs {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}

.pg-orb {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.pg-orb-1 {
    width: 350px;
    height: 350px;
    top: -120px;
    right: -60px;
    animation: pgOrbFloat 14s ease-in-out infinite;
}

.pg-orb-2 {
    width: 200px;
    height: 200px;
    bottom: -50px;
    left: -30px;
    animation: pgOrbFloat 10s ease-in-out infinite reverse;
}

.pg-orb-3 {
    width: 120px;
    height: 120px;
    top: 40%;
    left: 55%;
    animation: pgOrbFloat 8s ease-in-out infinite 3s;
}

@keyframes pgOrbFloat {

    0%,
    100% {
        transform: translate(0, 0) scale(1);
    }

    50% {
        transform: translate(15px, -25px) scale(1.06);
    }
}

.pg-hero-title {
    color: #fff;
    font-size: 44px;
    font-weight: 800;
    line-height: 1.2;
    margin-bottom: 18px;
    animation: pgFadeUp 0.6s ease both;
}

.pg-hero-meta {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
    animation: pgFadeUp 0.6s ease 0.15s both;
}

.pg-meta-item {
    color: rgba(255, 255, 255, 0.75);
    font-size: 14px;
}

.pg-meta-item i {
    margin-right: 4px;
    opacity: 0.6;
}

.pg-meta-dot {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
}

@keyframes pgFadeUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ─────────────  BODY  ───────────── */
.pg-body {
    background: var(--bg);
    padding: 48px 0 72px;
}

/* ─────────────  SIDEBAR / TOC  ───────────── */
.pg-sidebar {
    position: sticky;
    top: 100px;
    background: var(--surface);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
    border: 1px solid var(--border-soft);
    max-height: calc(100vh - 140px);
    overflow-y: auto;
}

.pg-sidebar-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--dark);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--border-soft);
}

.pg-sidebar-title i {
    color: var(--primary);
    margin-right: 6px;
}

.pg-toc a {
    display: block;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 13px;
    color: var(--text-muted);
    text-decoration: none;
    transition: var(--transition);
    border-left: 3px solid transparent;
    margin-bottom: 2px;
    line-height: 1.4;
}

.pg-toc a:hover {
    color: var(--primary);
    background: var(--bg);
    border-left-color: var(--primary-light);
}

.pg-toc a.active {
    color: var(--primary);
    background: rgba(108, 96, 254, 0.08);
    border-left-color: var(--primary);
    font-weight: 600;
}

.pg-toc a.toc-h3 {
    padding-left: 24px;
    font-size: 12px;
}

/* ─────────────  SHARE BAR  ───────────── */
.pg-share-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 28px;
    padding: 14px 20px;
    background: var(--surface);
    border-radius: 50px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
    border: 1px solid var(--border-soft);
}

.pg-share-label {
    font-size: 13px;
    font-weight: 700;
    color: var(--dark);
    white-space: nowrap;
}

.pg-share-btns {
    display: flex;
    gap: 8px;
}

.pg-share-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1px solid var(--border-soft);
    background: var(--surface);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    font-size: 13px;
    padding: 0;
}

.pg-share-btn:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(108, 96, 254, 0.25);
}

.pg-share-copy:hover {
    background: var(--accent);
    border-color: var(--accent);
}

/* ─────────────  ARTICLE  ───────────── */
.pg-article {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 44px 48px;
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.04);
    border: 1px solid var(--border-soft);
    font-size: 16px;
    line-height: 1.9;
    color: var(--text-secondary);
    animation: pgFadeUp 0.4s ease 0.2s both;
}

.pg-article h1,
.pg-article h2,
.pg-article h3,
.pg-article h4 {
    color: var(--dark);
    margin-top: 32px;
    margin-bottom: 14px;
    scroll-margin-top: 100px;
}

.pg-article h2 {
    font-size: 26px;
    font-weight: 800;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--border-soft);
}

.pg-article h3 {
    font-size: 20px;
    font-weight: 700;
}

.pg-article p {
    margin-bottom: 18px;
}

.pg-article img {
    max-width: 100%;
    border-radius: 12px;
    margin: 16px 0;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.pg-article blockquote {
    border-left: 4px solid var(--primary);
    padding: 20px 28px;
    margin: 28px 0;
    background: var(--bg);
    border-radius: 0 14px 14px 0;
    font-style: italic;
    color: #555;
    position: relative;
}

.pg-article blockquote::before {
    content: '\201C';
    position: absolute;
    top: -8px;
    left: 12px;
    font-size: 48px;
    color: rgba(108, 96, 254, 0.15);
    font-family: Georgia, serif;
    line-height: 1;
}

.pg-article ul,
.pg-article ol {
    padding-left: 24px;
    margin-bottom: 18px;
}

.pg-article li {
    margin-bottom: 8px;
    padding-left: 4px;
}

.pg-article a {
    color: var(--primary);
    text-decoration: underline;
    text-underline-offset: 3px;
    transition: color 0.2s;
}

.pg-article a:hover {
    color: var(--accent);
}

.pg-article table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.pg-article table th {
    background: var(--dark);
    color: #fff;
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 14px;
}

.pg-article table td {
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-soft);
    font-size: 14px;
}

.pg-article table tr:nth-child(even) td {
    background: var(--bg);
}

.pg-article hr {
    border: none;
    height: 2px;
    background: var(--border-soft);
    margin: 28px 0;
}

/* ─────────────  ARTICLE FOOTER  ───────────── */
.pg-article-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 32px;
    flex-wrap: wrap;
    gap: 16px;
}

.pg-footer-meta {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
    color: var(--text-muted);
}

.pg-footer-meta i {
    color: var(--primary);
    margin-right: 4px;
}

.pg-footer-meta strong {
    color: var(--dark);
}

/* ─────────────  RESPONSIVE  ───────────── */
@media (max-width: 991px) {
    .pg-hero {
        padding: 64px 0 44px;
        min-height: auto;
    }

    .pg-hero-title {
        font-size: 34px;
    }

    .pg-article {
        padding: 28px 24px;
    }
}

@media (max-width: 767px) {
    .pg-hero {
        padding: 52px 0 36px;
    }

    .pg-hero-title {
        font-size: 26px;
    }

    .pg-hero-meta {
        flex-direction: column;
        gap: 6px;
    }

    .pg-meta-dot {
        display: none;
    }

    .pg-article {
        padding: 24px 18px;
        font-size: 15px;
    }

    .pg-share-bar {
        flex-direction: column;
        border-radius: 14px;
        text-align: center;
    }

    .pg-article-footer {
        flex-direction: column;
        align-items: flex-start;
    }
}
