:root {
    --primary: #4361ee;
    --primary-light: #4895ef;
    --primary-dark: #3a0ca3;
    --secondary: #7209b7;
    --accent: #f72585;
    --success: #4cc9f0;
    --light: #f8f9fa;
    --dark: #212529;
    --dark-gray: #495057;
    --gray: #adb5bd;
    --light-gray: #e9ecef;
    --transition: all 0.3s ease;
    --shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 15px 30px rgba(0, 0, 0, 0.15);
    --radius: 12px;
    --card-padding: 30px;
    --btn-primary: #4361ee;
    --btn-primary-dark: #3a0ca3;
    --surface-invert: #212529;
    --surface-invert-text: #ffffff;
    --surface-invert-muted: #adb5bd;
}

.dark-mode {
    --primary: #4cc9f0;
    --primary-light: #4895ef;
    --primary-dark: #3a0ca3;
    --light: #121212;
    --dark: #f8f9fa;
    --dark-gray: #b4b4b4;
    --light-gray: #2d2d2d;
    --gray: #6c757d;
    --shadow: 0 10px 20px rgba(0, 0, 0, 0.4);
    --shadow-hover: 0 15px 30px rgba(0, 0, 0, 0.5);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    transition: var(--transition);
}

body {
    font-family: "Poppins", "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: var(--dark);
    background-color: var(--light);
    background: linear-gradient(135deg, #f5f7fa 0%, #e4e8f0 100%);
    min-height: 100vh;
}

.dark-mode body {
    background: linear-gradient(135deg, #0f0f0f 0%, #232323 100%);
}

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 10px 20px;
}

/* Blog Content Styles */
.blog-container {
    max-width: none;
    margin: 60px 0 50px;
    padding: 40px 85px;
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.dark-mode .blog-container {
    background: var(--light-gray);
}

.blog-header {
    text-align: center;
    margin-bottom: 40px;
    margin-top: 20px;
    padding-top: 20px;
}

.blog-title {
    font-size: 2.5rem;
    margin-bottom: 20px;
    color: var(--primary);
    font-weight: 700;
    line-height: 1.2;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.blog-meta {
    color: var(--dark-gray);
    font-size: 0.9rem;
    margin-bottom: 30px;
}

.blog-image-container {
    width: 100%;
    text-align: center;
    margin: 30px 0;
}

.blog-image {
    border-radius: 10px;
    box-shadow: var(--shadow);
    max-width: 100%;
    height: auto;
    display: block;
    margin: 0 auto;
}

.blog-content h2 {
    font-size: 1.8rem;
    margin: 40px 0 20px;
    color: var(--primary);
    padding-bottom: 10px;
    border-bottom: 2px solid var(--light-gray);
}

.dark-mode .blog-content h2 {
    border-bottom-color: var(--dark-gray);
}

.blog-content h3 {
    font-size: 1.4rem;
    margin: 30px 0 15px;
    color: var(--primary-dark);
}

.dark-mode .blog-content h3 {
    color: var(--primary-light);
}

.blog-content p {
    margin-bottom: 20px;
    font-size: 1.1rem;
}

.blog-content ul,
.blog-content ol {
    margin-bottom: 20px;
    padding-left: 30px;
}

.blog-content li {
    margin-bottom: 10px;
}

.formula {
    background: var(--light-gray);
    padding: 20px;
    border-radius: var(--radius);
    margin: 20px 0;
    text-align: center;
    font-style: italic;
}

.dark-mode .formula {
    background: var(--dark-gray);
}

.example {
    background: var(--light-gray);
    padding: 20px;
    border-radius: var(--radius);
    margin: 20px 0;
}

.dark-mode .example {
    background: var(--dark-gray);
}

.feature-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin: 30px 0;
}

.feature-item {
    background: var(--light-gray);
    padding: 20px;
    border-radius: var(--radius);
}

.dark-mode .feature-item {
    background: var(--dark-gray);
}

.feature-item h4 {
    margin-bottom: 15px;
    color: var(--primary);
}

.faq-item {
    margin-bottom: 20px;
    border-bottom: 1px solid var(--light-gray);
    padding-bottom: 20px;
}

.dark-mode .faq-item {
    border-bottom-color: var(--dark-gray);
}

.faq-item h3 {
    color: var(--primary);
    margin-bottom: 10px;
}

/* Floating "On This Page" rail: a small fixed tick-mark toggle on the right
   edge of the viewport that expands into a scrollable panel of jump-links.
   Fixed positioning takes it out of document flow entirely, so where its
   markup sits in the article makes no visual difference - see
   post-template.php for where {$tocHtml} is emitted. */
.toc-widget {
    position: fixed;
    top: 50%;
    right: 16px;
    transform: translateY(-50%);
    z-index: 60;
    display: flex;
    flex-direction: row-reverse;
    align-items: center;
    gap: 12px;
    /* Hints the browser to promote this to its own GPU-composited layer up
       front, so scrolling never has to repaint it from scratch on every
       frame - keeps a fixed-position element buttery smooth even on
       low-end phones/laptops instead of only optimizing once scrolling has
       already started. */
    will-change: transform;
}

.toc-toggle {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    padding: 14px 10px;
    background: none;
    border: none;
    cursor: pointer;
    flex-shrink: 0;
}

.toc-toggle:hover .toc-tick:not(.is-active) {
    background: var(--dark-gray);
}

.dark-mode .toc-toggle:hover .toc-tick:not(.is-active) {
    background: rgba(255, 255, 255, 0.6);
}

.toc-ticks {
    display: flex;
    flex-direction: column;
    /* Right-aligned rather than centered: with center alignment, the active
       tick's extra width (see .toc-tick.is-active below) grew evenly on
       both sides, so every scroll-triggered active-tick change visibly
       shifted the whole rail left AND right - reading as a "shake" while
       scrolling. Anchoring all ticks to a shared right edge means only the
       left edge ever moves, growing toward the content instead of
       wobbling the rail itself. */
    align-items: flex-end;
    gap: 7px;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.25));
}

.toc-tick {
    display: block;
    width: 22px;
    height: 3px;
    border-radius: 2px;
    background: var(--gray);
    transition: width 0.2s ease, height 0.2s ease, background-color 0.2s ease;
}

.dark-mode .toc-tick {
    background: rgba(255, 255, 255, 0.35);
}

/* The tick for whichever section is currently on screen (see the
   scroll-spy logic in post-template.php's inline script) grows wider as
   well as changing color, so the "you are here" marker reads clearly at a
   glance rather than just being a subtle color change. */
.toc-tick.is-active {
    width: 28px;
    height: 4px;
    background: var(--primary);
}

.toc-panel {
    width: min(320px, calc(100vw - 88px));
    max-height: min(70vh, 520px);
    background: white;
    border-radius: 16px;
    box-shadow: var(--shadow-hover);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.toc-panel[hidden] {
    display: none;
}

/* Desktop/mouse: hovering anywhere over the rail or the open panel shows
   it, for as long as the pointer stays within the widget - this CSS rule
   alone handles that (it outranks the [hidden] rule above on specificity,
   so it shows the panel even while its hidden attribute is still true).
   Touch/keyboard users, who have no hover, still get the click-to-toggle
   behavior wired up in the inline script instead. */
.toc-widget:hover .toc-panel {
    display: flex;
}

.dark-mode .toc-panel {
    background: var(--dark-gray);
}

.toc-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px 14px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    flex-shrink: 0;
}

.dark-mode .toc-panel-head {
    border-bottom-color: rgba(255, 255, 255, 0.12);
}

.toc-panel-label {
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--dark-gray);
}

.dark-mode .toc-panel-label {
    color: var(--light);
}

.toc-panel-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    border: none;
    border-radius: 50%;
    background: var(--light-gray);
    color: var(--dark-gray);
    cursor: pointer;
}

.toc-panel-close:hover {
    background: var(--gray);
    color: white;
}

.toc-panel-close svg {
    width: 14px;
    height: 14px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
}

.toc-panel-list {
    list-style: none;
    overflow-y: auto;
    padding: 10px 14px 16px;
    scrollbar-width: thin;
    scrollbar-color: var(--gray) transparent;
}

.toc-panel-list::-webkit-scrollbar {
    width: 6px;
}

.toc-panel-list::-webkit-scrollbar-thumb {
    background: var(--gray);
    border-radius: 999px;
}

.toc-panel-list::-webkit-scrollbar-track {
    background: transparent;
}

.toc-item a {
    display: block;
    padding: 10px 12px;
    border-radius: 8px;
    color: var(--dark);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.92rem;
    border-left: 3px solid transparent;
}

.dark-mode .toc-item a {
    color: var(--light);
}

.toc-item--sub a {
    margin-left: 16px;
    font-weight: 400;
    font-size: 0.86rem;
    color: var(--dark-gray);
}

.dark-mode .toc-item--sub a {
    color: var(--gray);
}

.toc-item a:hover,
.toc-item a:focus-visible {
    background: var(--light-gray);
    color: var(--primary);
}

.dark-mode .toc-item a:hover,
.dark-mode .toc-item a:focus-visible {
    background: rgba(255, 255, 255, 0.08);
}

.toc-item.is-active > a {
    background: var(--light-gray);
    border-left-color: var(--primary);
    color: var(--primary-dark);
}

.dark-mode .toc-item.is-active > a {
    background: rgba(255, 255, 255, 0.1);
    color: var(--primary);
}

.data-t-sec {
    overflow-x: auto;
    width: 100%;
}

.data-table {
    width: auto;
    height: auto;
    border-collapse: collapse;
    margin: 25px 0;
    font-size: 0.9em;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.data-table thead tr {
    background-color: var(--btn-primary);
    color: white;
    text-align: left;
}

.data-table th,
.data-table td {
    padding: 12px 15px;
    border: 1px solid #ddd;
}

.data-table tbody tr {
    border-bottom: 1px solid #dddddd;
}

.data-table tbody tr:nth-of-type(even) {
    background-color: #f3f3f3;
}

.dark-mode .data-table tbody tr:nth-of-type(even) {
    background-color: #2a2a2a;
}

.data-table tbody tr:last-of-type {
    border-bottom: 2px solid var(--primary);
}

.data-table tbody tr.active-row {
    font-weight: bold;
    color: var(--primary);
}

.chart-container {
    background: white;
    padding: 15px;
    border-radius: var(--radius);
    margin: 20px 0;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

.dark-mode .chart-container {
    background: var(--dark-gray);
}

.chart-bar {
    height: 30px;
    background: linear-gradient(90deg, var(--primary-light), var(--primary-dark));
    margin: 10px 0;
    border-radius: 5px;
    position: relative;
    transition: width 1s ease-in-out;
}

.chart-label {
    position: absolute;
    right: 26px;
    top: 2px;
    color: white;
    font-weight: bold;
}

.reading-time-comparison {
    display: flex;
    justify-content: space-between;
    margin: 30px 0;
    flex-wrap: wrap;
}

.comparison-card {
    flex: 1;
    min-width: 250px;
    background: var(--light-gray);
    padding: 20px;
    border-radius: var(--radius);
    margin: 10px;
    text-align: center;
}

.dark-mode .comparison-card {
    background: var(--dark-gray);
}

.comparison-card h4 {
    color: var(--primary);
    margin-bottom: 15px;
}

.comparison-value {
    font-size: 2rem;
    font-weight: bold;
    color: var(--primary-dark);
}

.dark-mode .comparison-value {
    color: var(--primary-light);
}

.unique-insight {
    border-left: 4px solid var(--primary);
    padding: 15px 20px;
    margin: 25px 0;
    background-color: rgba(67, 97, 238, 0.05);
}

.dark-mode .unique-insight {
    background-color: rgba(76, 201, 240, 0.1);
}

/* Responsive image styling */
.responsive-image {
    width: 100%;
    height: auto;
    display: block;
    margin: auto;
    border-radius: 25px;
}

/* Dark Mode Toggle */
.dark-mode-toggle {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: linear-gradient(135deg, var(--btn-primary), var(--btn-primary-dark));
    color: white;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow);
    z-index: 100;
    transition: var(--transition);
}

.dark-mode-toggle:hover {
    transform: rotate(15deg) scale(1.1);
}

/* Responsive styles */
@media (max-width: 1024px) {
    .blog-title {
        font-size: 2.2rem;
    }

    /* .blog-container's own side padding keeps shrinking at every
       breakpoint below this one (30px, then 20px/15px, then less) - nowhere
       near enough clearance for a fixed side rail at any width down here.
       Hidden rather than continuing to shrink it: the floating TOC is a
       desktop/tablet convenience, not something worth cramming in at the
       cost of overlapping the article text - visitors on these narrower
       screens still have the normal in-article heading structure to
       scroll through. */
    .toc-widget {
        display: none;
    }
}

@media (max-width: 768px) {
    .blog-title {
        font-size: 2rem;
    }

    .blog-content h2 {
        font-size: 1.6rem;
    }

    .blog-content h3 {
        font-size: 1.3rem;
    }

    .feature-list {
        grid-template-columns: 1fr;
    }

    .blog-container {
        padding: 30px;
        margin: 40px auto;
    }

    .reading-time-comparison {
        flex-direction: column;
    }
}

@media (max-width: 576px) {
    .blog-title {
        font-size: 1.8rem;
        line-height: 1.3;
    }

    .blog-content h2 {
        font-size: 1.4rem;
    }

    .blog-content h3 {
        font-size: 1.2rem;
    }

    .blog-container {
        padding: 20px 15px;
        margin: 30px auto;
    }

    .data-table {
        font-size: 0.8em;
    }

    .data-table th,
    .data-table td {
        padding: 8px 10px;
    }
}

@media (max-width: 480px) {
    .blog-title {
        font-size: 1.6rem;
    }

    .blog-container {
        margin: 25px auto;
    }
}

@media (max-width: 360px) {
    .blog-title {
        font-size: 1.4rem;
        margin-bottom: 15px;
        line-height: 1.3;
        padding: 0 10px;
        text-align: center;
        width: 100%;
        display: block;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: normal;
    }

    .blog-content h2 {
        font-size: 1.3rem;
    }

    .blog-content h3 {
        font-size: 1.1rem;
    }

    .blog-header {
        margin-bottom: 30px;
    }

    .blog-container {
        margin: 10px 0;
        padding: 0;
    }

    .data-t-sec {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 100%;
        height: fit-content;
        overflow-x: auto;
        padding: 0;
        margin: 0%;
        text-align: center;
    }

    .data-t-sec thead,
    tbody {
        padding: 0%;
        margin: 0%;
        width: 100%;
    }

    .data-table th,
    .data-table td {
        padding: 8px 5px;
    }
}

@media (max-width: 320px) {
    .data-table th,
    .data-table td {
        padding: 5px 2px;
    }
}

@media (max-width: 240px) {
    .blog-title {
        font-size: 1.2rem;
        padding: 0 5px;
    }

    .blog-content h2 {
        font-size: 1.1rem;
    }

    .blog-content h3 {
        font-size: 1rem;
    }

    .blog-container {
        padding: 15px 10px;
        margin: 15px auto;
    }

    .toc-toggle {
        padding: 14px 16px;
    }

    .toc-panel-list {
        padding: 4px 16px 16px;
    }

    .toc-item--sub {
        margin-left: 16px;
    }
}

/* CMS-generated post additions */
.blog-excerpt-meta {
    color: var(--dark-gray);
    font-size: 0.9rem;
}

.blog-content a {
    color: var(--primary);
}

.blog-content blockquote {
    border-left: 4px solid var(--primary);
    padding: 10px 20px;
    margin: 20px 0;
    background: var(--light-gray);
    border-radius: 0 var(--radius) var(--radius) 0;
    font-style: italic;
}

.dark-mode .blog-content blockquote {
    background: var(--dark-gray);
}

.blog-content pre,
.blog-content code {
    background: var(--light-gray);
    border-radius: 6px;
    font-family: "Consolas", "Monaco", monospace;
}

.dark-mode .blog-content pre,
.dark-mode .blog-content code {
    background: var(--dark-gray);
}

.blog-content code {
    padding: 2px 6px;
    font-size: 0.9em;
}

.blog-content pre {
    padding: 16px;
    overflow-x: auto;
    margin-bottom: 20px;
}

.blog-content pre code {
    padding: 0;
    background: none;
}

.blog-content hr {
    border: none;
    border-top: 1px solid var(--light-gray);
    margin: 30px 0;
}

.dark-mode .blog-content hr {
    border-top-color: var(--dark-gray);
}

.blog-content img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 25px auto;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.author-box {
    display: flex;
    gap: 18px;
    align-items: flex-start;
    background: var(--light-gray);
    padding: 25px 30px;
    border-radius: var(--radius);
    margin: 30px 0;
}

.dark-mode .author-box {
    background: var(--dark-gray);
}

.author-box img {
    border-radius: 50%;
    flex-shrink: 0;
    width: 80px;
    height: 80px;
    object-fit: cover;
}

.author-box h2 {
    margin: 0 0 6px;
    font-size: 1.1rem;
    color: var(--primary);
}

.author-box-name a {
    color: var(--primary);
    text-decoration: none;
}

.author-box-name a:hover {
    text-decoration: underline;
}

.author-credentials {
    color: var(--dark-gray);
    font-size: 0.88rem;
    margin: 4px 0 10px;
}

/* CMS Phase 1 additions: breadcrumbs, key takeaways, steps, key facts,
   sources, CTA, related posts. Definitions/FAQ/Related-Posts reuse the
   existing .feature-list/.feature-item and .faq-item rules above. */

.breadcrumb-nav {
    font-size: 0.85rem;
    color: var(--dark-gray);
    margin-bottom: 16px;
}

.breadcrumb-nav a {
    color: var(--dark-gray);
    text-decoration: none;
}

.breadcrumb-nav a:hover {
    color: var(--primary);
    text-decoration: underline;
}

.key-takeaways,
.steps-list,
.key-facts-list,
.sources-list,
.other-links-list {
    background: var(--light-gray);
    padding: 25px 30px;
    border-radius: var(--radius);
    margin: 30px 0;
}

.dark-mode .key-takeaways,
.dark-mode .steps-list,
.dark-mode .key-facts-list,
.dark-mode .sources-list,
.dark-mode .other-links-list {
    background: var(--dark-gray);
}

.key-takeaways h2,
.steps-list h2,
.key-facts-list h2,
.sources-list h2,
.other-links-list h2 {
    margin-top: 0;
    margin-bottom: 15px;
    color: var(--primary);
}

.other-links-list ul {
    padding-left: 22px;
}

.other-links-list li {
    margin-bottom: 10px;
}

.other-links-list a {
    color: var(--primary);
}

.key-takeaways ul,
.key-facts-list ul {
    padding-left: 22px;
}

.key-takeaways li,
.key-facts-list li {
    margin-bottom: 10px;
}

.steps-list ol {
    padding-left: 22px;
    counter-reset: none;
}

.steps-list li {
    margin-bottom: 20px;
}

.steps-list li h3 {
    color: var(--primary);
    margin-bottom: 6px;
}

.key-fact-note {
    display: block;
    font-size: 0.85rem;
    color: var(--dark-gray);
    margin-top: 2px;
}

.sources-list ol {
    padding-left: 22px;
}

.sources-list li {
    margin-bottom: 12px;
}

.sources-list a {
    color: var(--primary);
}

.source-meta {
    display: block;
    font-size: 0.85rem;
    color: var(--dark-gray);
}

.post-cta {
    background: linear-gradient(135deg, var(--btn-primary), var(--btn-primary-dark));
    color: #fff;
    padding: 30px;
    border-radius: var(--radius);
    margin: 30px 0;
    text-align: center;
}

.post-cta h2 {
    color: #fff;
    margin-bottom: 10px;
}

.post-cta p {
    margin-bottom: 18px;
    opacity: 0.95;
}

.post-cta-button {
    display: inline-block;
    background: #fff;
    color: var(--btn-primary);
    padding: 12px 28px;
    border-radius: 8px;
    font-weight: 600;
    text-decoration: none;
}

.post-cta-button:hover {
    opacity: 0.9;
}
