/* Citywide legal & policy pages — shared layout + formatting polish.
   Applies to: refund-policy, shipping-policy, terms-of-service, cancellation-policy
   Scoped to the body class .cw-policy-page added by the enqueue module. */

.cw-policy-page {
    --cw-pol-accent: #0b6dd8;
    --cw-pol-accent-dark: #084e9c;
    --cw-pol-accent-soft: rgba(11, 109, 216, 0.10);
    --cw-pol-accent-line: rgba(11, 109, 216, 0.22);
    --cw-pol-text: #1f2a37;
    --cw-pol-body: #3a4658;
    --cw-pol-muted: #5f6f85;
    --cw-pol-border: #e6ecf4;
    --cw-pol-card-border: #dfe7f2;
    --cw-pol-bg: #f4f4f5;
    --cw-pol-sheet-shadow: 0 30px 60px -42px rgba(23, 59, 102, 0.45);
    --cw-pol-card-shadow: 0 18px 40px -34px rgba(23, 59, 102, 0.40);
    --cw-pol-radius: 20px;
    --cw-pol-offset: 96px; /* sticky offset / anchor landing below the header */
}

/* ─────────────────────────  Canvas  ───────────────────────── */
.cw-policy-page {
    background: var(--cw-pol-bg);
}

.cw-policy-page .content-area,
.cw-policy-page #primary {
    background: var(--cw-pol-bg);
}

.cw-policy-page .site-main {
    background: transparent;
    padding-block: clamp(28px, 5vw, 64px);
}

.cw-policy-page article,
.cw-policy-page article.hentry {
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
}

/* Neutralize WPBakery wrapper spacing so both builder and plain-editor pages match. */
.cw-policy-page .entry-content .vc_row,
.cw-policy-page .entry-content .wpb_column,
.cw-policy-page .entry-content .vc_column-inner,
.cw-policy-page .entry-content .wpb_wrapper,
.cw-policy-page .entry-content .wpb_text_column {
    margin: 0 !important;
    padding: 0 !important;
}

/* ─────────────────  Base typography (both modes)  ───────────────── */
.cw-policy-page .entry-content {
    color: var(--cw-pol-body);
    font-size: clamp(1rem, 0.97rem + 0.18vw, 1.06rem);
    line-height: 1.75;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

/* JS-OFF fallback: the content itself becomes the centered sheet. */
.cw-policy-page .entry-content {
    max-width: 880px;
    margin-inline: auto;
    padding: clamp(24px, 4.5vw, 56px);
    background: #fff;
    border: 1px solid var(--cw-pol-card-border);
    border-radius: var(--cw-pol-radius);
    box-shadow: var(--cw-pol-sheet-shadow);
}

/* JS-ON: enhanced into a TOC + document grid; the bare host goes full width. */
.cw-policy-page .entry-content.cw-pol-on {
    max-width: 1180px;
    padding: 0;
    background: transparent;
    border: 0;
    box-shadow: none;
}

/* ─────────────────────────  Headings  ───────────────────────── */
.cw-policy-page .entry-content h1 {
    margin: 0 0 0.5rem;
    color: var(--cw-pol-text);
    font-size: clamp(1.9rem, 1.4rem + 2.2vw, 2.7rem);
    line-height: 1.12;
    letter-spacing: -0.025em;
    font-weight: 800;
}

/* "Last updated:" caption — the first paragraph after the title. */
.cw-policy-page .entry-content h1 + p {
    margin: 0 0 1.5rem;
    color: var(--cw-pol-muted);
    font-size: 0.9rem;
    font-weight: 500;
    letter-spacing: 0.01em;
}

.cw-policy-page .entry-content h1 + p strong {
    color: var(--cw-pol-accent);
    font-weight: 700;
}

/* Lead/intro paragraph (refund & terms pages have one; others harmlessly skip). */
.cw-policy-page .entry-content h1 + p + p {
    margin: 0 0 0.5rem;
    color: #34435a;
    font-size: clamp(1.05rem, 1rem + 0.35vw, 1.2rem);
    line-height: 1.6;
}

/* Section headings — number-agnostic so numbered and unnumbered pages both work. */
.cw-policy-page .entry-content h2 {
    position: relative;
    margin: 2.4rem 0 0.8rem;
    padding-top: 1.7rem;
    border-top: 1px solid var(--cw-pol-border);
    color: var(--cw-pol-text);
    font-size: clamp(1.2rem, 1.05rem + 0.6vw, 1.5rem);
    line-height: 1.3;
    letter-spacing: -0.015em;
    font-weight: 800;
    scroll-margin-top: var(--cw-pol-offset);
}

/* Accent "tab" sitting on the section divider. */
.cw-policy-page .entry-content h2::before {
    content: "";
    position: absolute;
    top: -1px;
    left: 0;
    width: 56px;
    height: 3px;
    border-radius: 3px;
    background: var(--cw-pol-accent);
}

.cw-policy-page .entry-content h3 {
    margin: 1.8rem 0 0.6rem;
    color: var(--cw-pol-text);
    font-size: clamp(1.05rem, 1rem + 0.3vw, 1.2rem);
    font-weight: 700;
    letter-spacing: -0.01em;
    scroll-margin-top: var(--cw-pol-offset);
}

/* ─────────────────────────  Body copy  ───────────────────────── */
.cw-policy-page .entry-content p {
    margin: 0 0 1.05rem;
}

.cw-policy-page .entry-content strong {
    color: var(--cw-pol-text);
    font-weight: 700;
}

.cw-policy-page .entry-content a {
    color: var(--cw-pol-accent);
    font-weight: 600;
    text-decoration: none;
    border-bottom: 1px solid var(--cw-pol-accent-line);
    transition: color 0.15s ease, border-color 0.15s ease;
}

.cw-policy-page .entry-content a:hover {
    color: var(--cw-pol-accent-dark);
    border-bottom-color: currentColor;
}

/* Lists with accent diamond markers. */
.cw-policy-page .entry-content ul {
    list-style: none;
    margin: 0 0 1.2rem;
    padding: 0;
}

.cw-policy-page .entry-content ul li {
    position: relative;
    margin-bottom: 0.6rem;
    padding-left: 1.7rem;
    /* Defeat the inline ".entry-content li { list-style-type: disc }" rule that
       WP custom-CSS sets directly on the <li> — only the diamond ::before should show. */
    list-style: none !important;
}

.cw-policy-page .entry-content ul li::before {
    content: "";
    position: absolute;
    left: 0.15rem;
    top: 0.62em;
    width: 8px;
    height: 8px;
    border-radius: 2px;
    background: var(--cw-pol-accent);
    transform: translateY(-50%) rotate(45deg);
}

.cw-policy-page .entry-content ol {
    margin: 0 0 1.2rem;
    padding-left: 1.3rem;
}

.cw-policy-page .entry-content ol li {
    margin-bottom: 0.6rem;
    padding-left: 0.3rem;
}

.cw-policy-page .entry-content ol li::marker {
    color: var(--cw-pol-accent);
    font-weight: 700;
}

.cw-policy-page .entry-content hr {
    margin: 2.2rem 0;
    border: 0;
    border-top: 1px solid var(--cw-pol-border);
}

/* ───────────────  Enhanced layout: TOC + document grid  ─────────────── */
.cw-policy-page .cw-pol {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: clamp(20px, 3vw, 40px);
    align-items: start;
}

.cw-policy-page .cw-pol__doc {
    min-width: 0;
    padding: clamp(26px, 4vw, 60px);
    background: #fff;
    border: 1px solid var(--cw-pol-card-border);
    border-radius: var(--cw-pol-radius);
    box-shadow: var(--cw-pol-sheet-shadow);
}

/* Table of contents (a <details> element so it collapses on small screens). */
.cw-policy-page .cw-pol__toc {
    padding: 1.1rem 1.2rem;
    background: #fff;
    border: 1px solid var(--cw-pol-card-border);
    border-radius: 16px;
    box-shadow: var(--cw-pol-card-shadow);
}

.cw-policy-page .cw-pol__toc > summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    list-style: none;
    cursor: pointer;
    color: var(--cw-pol-muted);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.cw-policy-page .cw-pol__toc > summary::-webkit-details-marker {
    display: none;
}

.cw-policy-page .cw-pol__toc > summary::after {
    content: "";
    width: 8px;
    height: 8px;
    margin-left: 0.6rem;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg);
    transition: transform 0.2s ease;
}

.cw-policy-page .cw-pol__toc[open] > summary::after {
    transform: rotate(-135deg);
}

.cw-policy-page .cw-pol__toc nav {
    margin-top: 0.8rem;
}

.cw-policy-page .cw-pol__toc ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

.cw-policy-page .cw-pol__toc li {
    margin: 0;
    padding-left: 0;
}

/* The content-list diamond marker must never leak into the TOC items. */
.cw-policy-page .cw-pol__toc li::before {
    content: none;
}

.cw-policy-page .cw-pol__toc a {
    display: block;
    padding: 0.4rem 0.65rem;
    border-left: 2px solid transparent;
    border-bottom: 0; /* cancel the .entry-content link underline that leaks in here */
    border-radius: 8px;
    color: var(--cw-pol-muted);
    font-size: 0.85rem;
    line-height: 1.4;
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.cw-policy-page .cw-pol__toc a:hover {
    background: var(--cw-pol-accent-soft);
    color: var(--cw-pol-accent);
}

.cw-policy-page .cw-pol__toc a.is-active {
    background: var(--cw-pol-accent-soft);
    border-left-color: var(--cw-pol-accent);
    color: var(--cw-pol-accent);
    font-weight: 700;
}

/* Reading-progress bar. */
.cw-pol-progress {
    position: fixed;
    inset: 0 0 auto 0;
    height: 3px;
    background: transparent;
    z-index: 9999;
    pointer-events: none;
}

.cw-pol-progress > span {
    display: block;
    width: 0;
    height: 100%;
    background: linear-gradient(90deg, var(--cw-pol-accent), #36a0ff);
    transition: width 0.1s linear;
}

/* ─────────────────────────  Desktop  ───────────────────────── */
@media (min-width: 1024px) {
    .cw-policy-page .cw-pol {
        grid-template-columns: 250px minmax(0, 1fr);
    }

    .cw-policy-page .cw-pol__toc {
        position: sticky;
        top: var(--cw-pol-offset);
        max-height: calc(100vh - var(--cw-pol-offset) - 24px);
        overflow: auto;
    }

    /* On desktop the summary is just the panel title, not an interactive toggle. */
    .cw-policy-page .cw-pol__toc > summary {
        cursor: default;
        pointer-events: none;
    }

    .cw-policy-page .cw-pol__toc > summary::after {
        display: none;
    }
}

/* ─────────────────────────  Small screens  ───────────────────────── */
@media (max-width: 600px) {
    .cw-policy-page .entry-content {
        border-radius: 14px;
    }

    .cw-policy-page .cw-pol__doc {
        border-radius: 14px;
    }

    .cw-policy-page .entry-content h2 {
        margin-top: 2rem;
    }
}

/* ─────────────────────────  Preferences  ───────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .cw-policy-page .entry-content a,
    .cw-policy-page .cw-pol__toc a,
    .cw-policy-page .cw-pol__toc > summary::after,
    .cw-pol-progress > span {
        transition: none !important;
    }
}

@media print {
    .cw-policy-page,
    .cw-policy-page .content-area,
    .cw-policy-page #primary {
        background: #fff !important;
    }

    .cw-pol__toc,
    .cw-pol-progress {
        display: none !important;
    }

    .cw-policy-page .cw-pol {
        display: block !important;
    }

    .cw-policy-page .entry-content,
    .cw-policy-page .cw-pol__doc {
        max-width: none !important;
        padding: 0 !important;
        border: 0 !important;
        box-shadow: none !important;
    }
}
