/* =============================================
   SPARSH — Mattress Buying Guide
   Chapter-paged layout: only the active chapter is
   visible. Sidebar shows the full chapter list (no
   internal scroll). Each chapter ends with a
   "next chapter" link.
   ============================================= */

/* ---------- Two-column layout (desktop) ---------- */
.guide-page .page-body {
    max-width: 1180px;
    padding: 60px 24px 140px;
}

.guide-page .guide-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 64px;
    align-items: flex-start;
}

/* ---------- Sticky chapter sidebar (no internal scroll) ---------- */
.guide-toc-sticky {
    position: sticky;
    top: 130px;
    align-self: start;
    padding: 28px 22px 28px 26px;
    background:
        linear-gradient(160deg, rgba(255, 255, 255, 0.04) 0%, rgba(255, 255, 255, 0.01) 100%);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 18px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    /* No max-height + no overflow — the chapter list fits naturally
       and never produces an internal scrollbar. */
    overflow: visible;
}

.guide-toc-sticky h4 {
    font-family: 'Inter', sans-serif;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    font-weight: 600;
    color: var(--accent-gold, #61B564);
    margin: 0 0 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.guide-toc-sticky ol {
    list-style: none;
    padding: 0;
    margin: 0;
    counter-reset: tocnum;
}

.guide-toc-sticky li {
    counter-increment: tocnum;
    margin: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.guide-toc-sticky li:last-child {
    border-bottom: none;
}

.guide-toc-sticky a {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 0 10px 14px;
    margin-left: -16px;
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    line-height: 1.4;
    color: rgba(255, 255, 255, 0.6);
    text-decoration: none;
    border-left: 2px solid transparent;
    border-bottom: none !important;
    transition: color 0.25s ease, border-color 0.25s ease, background 0.25s ease;
    cursor: pointer;
}

.guide-toc-sticky a::before {
    content: counter(tocnum, decimal-leading-zero);
    font-size: 0.68rem;
    color: rgba(255, 255, 255, 0.32);
    letter-spacing: 0.08em;
    margin-top: 1px;
    flex-shrink: 0;
    transition: color 0.25s ease;
}

.guide-toc-sticky a:hover {
    color: rgba(255, 255, 255, 0.95);
    background: rgba(255, 255, 255, 0.025);
}

.guide-toc-sticky a.is-active {
    color: #fff;
    border-color: var(--accent-gold, #61B564);
    background: rgba(97, 181, 100, 0.07);
}

.guide-toc-sticky a.is-active::before {
    color: var(--accent-gold, #61B564);
}

/* ---------- Chapter progress badge above the article ---------- */
.guide-chapter-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin: 0 0 22px;
    padding-bottom: 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    font-family: 'Inter', sans-serif;
    font-size: 0.75rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.55);
}

.guide-chapter-meta .chapter-progress {
    color: var(--accent-gold, #61B564);
    font-weight: 600;
}

/* ---------- Article column ---------- */
.guide-page .guide-article {
    min-width: 0;
}

/* ---- Chapter visibility ----
   Each top-level <section> in the article is a chapter.
   Only the .is-active chapter is rendered. */
.guide-page .guide-article > section {
    display: none;
    animation: chapterFadeIn 0.45s ease both;
}

.guide-page .guide-article > section.is-active {
    display: block;
}

@keyframes chapterFadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.guide-page .guide-article > section h2 {
    margin-top: 0;
}

.guide-page .guide-article > section {
    scroll-margin-top: 110px;
    margin-bottom: 0;
}

/* ---------- Chapter prev/next navigation ---------- */
.chapter-nav {
    margin-top: 64px;
    padding-top: 32px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    justify-content: space-between;
    align-items: stretch;
    gap: 18px;
}

.chapter-nav-link {
    flex: 1;
    display: flex;
    flex-direction: column;
    text-decoration: none;
    padding: 18px 24px;
    border-radius: 16px;
    background:
        linear-gradient(160deg, rgba(255, 255, 255, 0.04) 0%, rgba(255, 255, 255, 0.01) 100%);
    border: 1px solid rgba(255, 255, 255, 0.08);
    transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1),
        border-color 0.3s ease, background 0.3s ease;
    color: rgba(255, 255, 255, 0.85) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
}

.chapter-nav-link:hover {
    transform: translateY(-4px);
    border-color: rgba(97, 181, 100, 0.45);
    background:
        linear-gradient(160deg, rgba(97, 181, 100, 0.08) 0%, rgba(97, 181, 100, 0.02) 100%);
}

.chapter-nav-link .chapter-nav-direction {
    font-family: 'Inter', sans-serif;
    font-size: 0.68rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--accent-gold, #61B564);
    font-weight: 600;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.chapter-nav-link .chapter-nav-title {
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    color: #fff;
    line-height: 1.3;
}

.chapter-nav-link.chapter-prev {
    text-align: left;
}

.chapter-nav-link.chapter-next {
    text-align: right;
    margin-left: auto;
}

.chapter-nav-link.chapter-prev .chapter-nav-direction {
    justify-content: flex-start;
}

.chapter-nav-link.chapter-next .chapter-nav-direction {
    justify-content: flex-end;
}

/* When only a "next" exists (first chapter) push it to the right edge.
   When only a "prev" exists (last chapter) keep it on the left. */
.chapter-nav.only-next .chapter-nav-link {
    flex: 0 0 auto;
    margin-left: auto;
    min-width: 280px;
}

.chapter-nav.only-prev .chapter-nav-link {
    flex: 0 0 auto;
    min-width: 280px;
}

/* ---------- Callout boxes for key takeaways ---------- */
.guide-callout {
    margin: 28px 0;
    padding: 20px 24px 20px 56px;
    border-radius: 14px;
    border: 1px solid rgba(97, 181, 100, 0.22);
    background:
        linear-gradient(160deg, rgba(97, 181, 100, 0.06) 0%, rgba(97, 181, 100, 0.015) 100%);
    position: relative;
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.96rem;
    line-height: 1.65;
}

.guide-callout::before {
    content: '\f0eb'; /* Font Awesome lightbulb */
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    left: 22px;
    top: 22px;
    color: var(--accent-gold, #61B564);
    font-size: 18px;
}

.guide-callout strong {
    color: #fff;
}

/* ---------- Budget tier card grid ---------- */
.tier-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 22px;
    margin: 28px 0 12px;
}

.tier-card {
    position: relative;
    padding: 28px 26px 24px;
    border-radius: 18px;
    background:
        linear-gradient(165deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0.015) 100%);
    border: 1px solid rgba(255, 255, 255, 0.08);
    transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1), border-color 0.3s ease, background 0.3s ease;
}

.tier-card:hover {
    transform: translateY(-4px);
    border-color: rgba(97, 181, 100, 0.3);
    background:
        linear-gradient(165deg, rgba(255, 255, 255, 0.07) 0%, rgba(255, 255, 255, 0.02) 100%);
}

.tier-card .tier-label {
    display: inline-block;
    font-family: 'Inter', sans-serif;
    font-size: 0.68rem;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--accent-gold, #61B564);
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(97, 181, 100, 0.1);
    border: 1px solid rgba(97, 181, 100, 0.3);
    margin-bottom: 14px;
}

.tier-card h3 {
    font-family: 'Inter', sans-serif;
    font-size: 1.2rem !important;
    font-weight: 700;
    color: #fff;
    margin: 0 0 18px !important;
    line-height: 1.25;
}

.tier-card ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.tier-card ul li {
    padding-left: 18px;
    position: relative;
    font-size: 0.92rem;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.72);
}

.tier-card ul li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 9px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-gold, #61B564);
    box-shadow: 0 0 8px rgba(97, 181, 100, 0.5);
}

.tier-card ul li strong {
    color: #fff;
    font-weight: 600;
}

/* ---------- Back-to-top floating button ---------- */
.guide-back-top {
    position: fixed;
    right: 28px;
    bottom: 28px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(10, 14, 26, 0.85);
    border: 1px solid rgba(97, 181, 100, 0.4);
    color: var(--accent-gold, #61B564);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    box-shadow: 0 14px 40px rgba(0, 0, 0, 0.5);
    opacity: 0;
    transform: translateY(12px);
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease, background 0.3s ease, color 0.3s ease;
    z-index: 1050;
    font-size: 16px;
}

.guide-back-top.is-visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.guide-back-top:hover {
    background: rgba(97, 181, 100, 0.15);
    color: #fff;
}

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
    .guide-page .guide-layout {
        grid-template-columns: 220px 1fr;
        gap: 40px;
    }
}

@media (max-width: 900px) {
    .guide-page .guide-layout {
        display: block;
    }
    .guide-toc-sticky {
        position: static;
        margin-bottom: 36px;
    }
    .tier-grid {
        grid-template-columns: 1fr;
    }
    .chapter-nav {
        flex-direction: column;
    }
    .chapter-nav.only-next .chapter-nav-link,
    .chapter-nav.only-prev .chapter-nav-link {
        margin-left: 0;
        min-width: 0;
    }
}

/* ---------- Buying Guide inline figures ---------- */
.guide-article figure {
    margin: 40px auto;
    max-width: 100%;
    text-align: center;
}

.guide-article figure img {
    width: 100%;
    max-width: 100%;
    height: auto;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
    transition: transform 0.4s ease, border-color 0.4s ease;
    display: block;
    margin: 0 auto 12px;
}

body.light-mode .guide-article figure img {
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.1);
}

.guide-article figure img:hover {
    transform: translateY(-2px);
    border-color: rgba(97, 181, 100, 0.4);
}

.guide-article figcaption {
    font-size: 0.88rem;
    color: var(--text-muted);
    font-style: italic;
    margin-top: 8px;
    letter-spacing: 0.2px;
}

/* ---------- Lightbox Modal ---------- */
.lightbox-modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(10, 14, 26, 0.9);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    align-items: center;
    justify-content: center;
    flex-direction: column;
    opacity: 0;
    transition: opacity 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.lightbox-modal.is-active {
    display: flex;
    opacity: 1;
}

.lightbox-content {
    margin: auto;
    display: block;
    max-width: 90%;
    max-height: 80%;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6);
    transform: scale(0.95);
    transition: transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.lightbox-modal.is-active .lightbox-content {
    transform: scale(1);
}

.lightbox-close {
    position: absolute;
    top: 24px;
    right: 24px;
    width: 48px;
    height: 48px;
    background-color: rgba(20, 26, 46, 0.75);
    border: 2px solid rgba(255, 255, 255, 0.6);
    border-radius: 50%;
    color: #ffffff;
    font-size: 32px;
    font-weight: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 2002;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    padding-bottom: 4px; /* visually center the times character */
    line-height: 1;
}

.lightbox-close:hover,
.lightbox-close:focus {
    background-color: #61B564;
    border-color: #61B564;
    color: #ffffff;
    transform: scale(1.1) rotate(90deg);
    box-shadow: 0 0 20px rgba(97, 181, 100, 0.8);
}

/* Add hand pointer cursor on hover for expandable images */
.guide-article figure img {
    cursor: zoom-in;
}



