/*
 * Wedding Budget — Legal Pages
 * Copyright (c) 2026 Amar Micro Inc.
 *
 * Styles for legal/policy/FAQ pages only.
 * Loaded exclusively by: terms.php, privacy.php, faq.php, about.php,
 *                        cookies.php, security.php
 *
 * Depends on: app.css (tokens, reset, layout)
 */

/* ── Alias tokens used throughout this file ─────────────── */
:root {
    --deep: var(--nav-bg);
    --blush: var(--primary);
    --champagne: var(--nav-brand-color);
    --faint: var(--text-muted);
    --muted: var(--text-secondary);
    --border: var(--border-color);
    --border2: var(--primary);
    --rose: var(--primary-hover);
    --card: var(--content-bg);
    --surface: var(--table-stripe-bg);
    --sage: var(--success);
}

/* ── Hero banner ─────────────────────────────────────────── */
.page-hero {
    /* The app logo (when present) is NOT a background layer here — it renders
       as a grid cell via the .has-app-logo rules below, so hero text can never
       run underneath it. */
    background:
        radial-gradient(circle at 12% 18%, rgba(184, 150, 90, 0.24), transparent 36%),
        radial-gradient(circle at 88% 12%, rgba(106, 138, 170, 0.17), transparent 34%),
        linear-gradient(122deg, #1c1612 0%, #2a2119 48%, #1f1914 100%);
    /* Padding as variables so the logo cell (::before below) can bleed through
       it to the hero's true edges with matching negative margins. */
    --hero-pad-top: 1.45rem;
    --hero-pad-right: 1.6rem;
    --hero-pad-bottom: 1.1rem;
    padding: var(--hero-pad-top) var(--hero-pad-right) var(--hero-pad-bottom) 1.6rem;
    border-bottom: 1px solid rgba(240, 232, 220, 0.16);
    position: relative;
    overflow: hidden;
    margin: -0.75rem -1.25rem 0;
    box-shadow: inset 0 -0.8rem 1.5rem rgba(0, 0, 0, 0.16);
    animation: legal-hero-in 0.45s ease-out;
}

/* Logo pages: two-column grid — text cells left, logo cell right. The logo is
   the ::before pseudo repurposed as a real grid item spanning the hero's three
   text rows (label / h1 / meta), so it is always the full hero height (square,
   via aspect-ratio) and the text column stops before it instead of running
   underneath. The var(...,none) fallback keeps logo-less installs unchanged. */
.has-app-logo .page-hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto auto;
    column-gap: 1.1rem;
}

.has-app-logo .page-hero > * {
    grid-column: 1;
}

.has-app-logo .page-hero::before {
    content: '';
    position: static;
    top: auto;
    right: auto;
    grid-column: 2;
    grid-row: 1 / -1;
    /* The cell bleeds through the hero's padding (negative margins mirror it),
       so the square logo contain-fits the hero's FULL edge-to-edge height. The
       fixed width caps it only on unusually tall heroes (heavily wrapped meta)
       — centered, never under the text. */
    width: calc(7.25rem + var(--hero-pad-right));
    height: calc(100% + var(--hero-pad-top) + var(--hero-pad-bottom));
    margin: calc(-1 * var(--hero-pad-top)) calc(-1 * var(--hero-pad-right)) calc(-1 * var(--hero-pad-bottom)) 0;
    border-radius: 0;
    background: var(--app-logo-url, none) right center / contain no-repeat;
    pointer-events: none;
}

.page-hero::before {
    content: '';
    position: absolute;
    top: -8rem;
    right: -6.5rem;
    width: 17rem;
    height: 17rem;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(240, 232, 220, 0.14) 0%, transparent 72%);
    pointer-events: none;
}

.page-hero::after {
    content: '';
    position: absolute;
    left: -5rem;
    bottom: -7rem;
    width: 12rem;
    height: 12rem;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(184, 150, 90, 0.14) 0%, transparent 70%);
    pointer-events: none;
}

.page-hero-label {
    font-size: 0.68rem;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--blush);
    margin-bottom: 0.38rem;
    font-weight: 500;
}

.page-hero h1 {
    font-family: var(--font-serif);
    font-size: clamp(1.45rem, 2.1vw, 2rem);
    font-weight: 600;
    color: var(--champagne);
    line-height: 1.1;
    margin: 0;
}

.page-hero-meta {
    margin-top: 0.58rem;
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.page-hero-meta span {
    font-size: 0.73rem;
    color: #d8ccbb;
    letter-spacing: 0.02em;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 2rem;
    padding: 0.22rem 0.58rem;
}

.page-hero-meta span strong {
    color: var(--champagne);
    font-weight: 600;
}

.page-hero-meta a {
    color: var(--blush);
    text-decoration: none;
}

.page-hero-meta a:hover {
    text-decoration: underline;
}

/* ── Two-column layout: TOC + content ────────────────────── */
.legal-layout {
    display: grid;
    grid-template-columns: 15.5rem 1fr;
    gap: 1.6rem;
    width: 100%;
    padding: 1.2rem 0.8rem 3.4rem;
    align-items: start;
}

/* ── Sticky table-of-contents sidebar ───────────────────── */
.toc-sidebar {
    position: sticky;
    top: 5.25rem;
    padding: 1rem;
    border: 1px solid rgba(184, 150, 90, 0.3);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.94) 0%, rgba(250, 246, 240, 0.96) 100%);
    border-radius: 0.75rem;
    box-shadow: 0 0.45rem 1rem rgba(30, 20, 10, 0.08);
}

.toc-label {
    font-size: 0.65rem;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--faint);
    margin-bottom: 1rem;
    font-weight: 500;
}

.toc-nav {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.24rem;
    margin: 0;
    padding: 0;
}

.toc-nav a {
    display: block;
    padding: 0.38rem 0.54rem;
    font-size: 0.82rem;
    color: var(--muted);
    text-decoration: none;
    border-left: 0.14rem solid transparent;
    border-radius: 0.34rem;
    transition: all 0.18s;
    line-height: 1.4;
}

.toc-nav a:hover {
    color: #6f4f2b;
    background: rgba(184, 150, 90, 0.14);
    border-left-color: var(--rose);
}

.toc-nav a.active {
    color: #4f3318;
    background: rgba(184, 150, 90, 0.2);
    border-left-color: #7f5930;
    font-weight: 700;
}

/* ── Content area ────────────────────────────────────────── */
.legal-content {
    padding: 0.45rem 0;
    position: relative;
}

.legal-content :is(h2, h3, h4, [id]) {
    scroll-margin-top: 5.8rem;
}

/* ── Section cards ───────────────────────────────────────── */
.legal-section {
    margin-bottom: 1.15rem;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid #ebe1d5;
    border-radius: 0.72rem;
    box-shadow: 0 0.2rem 0.6rem rgba(30, 20, 10, 0.04);
    padding: 1.1rem 1.15rem 1rem;
    animation: legal-card-in 0.35s ease-out;
}

.section-number {
    font-family: var(--font-sans);
    font-size: 0.68rem;
    color: var(--blush);
    letter-spacing: 0.1em;
    margin-bottom: 0.5rem;
}

.legal-section h2 {
    font-family: var(--font-serif);
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0.2rem 0 0.8rem;
    padding-bottom: 0.55rem;
    border-bottom: 1px solid var(--border);
}

.legal-section h3 {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 1.25rem 0 0.5rem;
    letter-spacing: 0.02em;
}

.legal-section p {
    font-size: 0.9rem;
    color: var(--text-primary);
    line-height: 1.72;
    margin-bottom: 0.68rem;
}

.legal-section ul,
.legal-section ol {
    margin: 0.62rem 0 0.88rem 1.25rem;
}

.legal-section li {
    font-size: 0.9rem;
    color: var(--text-primary);
    line-height: 1.75;
    margin-bottom: 0.25rem;
}

/* Honest/transparency section variant */
.legal-section-honest {
    border-color: rgba(106, 138, 170, 0.42);
    background:
        linear-gradient(180deg, rgba(106, 138, 170, 0.1) 0%, rgba(106, 138, 170, 0.04) 100%),
        rgba(255, 255, 255, 0.94);
}

.legal-section-honest .section-number {
    color: #2f5e88;
}

.legal-section-honest h2 {
    border-bottom-color: rgba(106, 138, 170, 0.35);
}

/* ── Inline highlights ───────────────────────────────────── */
.legal-highlight {
    display: inline;
    font-weight: 700;
    border-radius: 0.26rem;
    padding: 0.02rem 0.26rem;
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
}

.legal-highlight-product {
    background: linear-gradient(180deg, rgba(184, 150, 90, 0.28) 0%, rgba(184, 150, 90, 0.16) 100%);
    color: #4f3318;
}

.legal-highlight-company {
    background: linear-gradient(180deg, rgba(106, 138, 170, 0.25) 0%, rgba(106, 138, 170, 0.14) 100%);
    color: #26425f;
}

.contact-block .legal-highlight {
    font-weight: 700;
    border: 1px solid rgba(240, 232, 220, 0.28);
}

.contact-block .legal-highlight-product {
    background: linear-gradient(180deg, rgba(184, 150, 90, 0.38) 0%, rgba(184, 150, 90, 0.2) 100%);
    color: #fff4df;
}

.contact-block .legal-highlight-company {
    background: linear-gradient(180deg, rgba(106, 138, 170, 0.4) 0%, rgba(106, 138, 170, 0.24) 100%);
    color: #e9f3ff;
}

/* ── Callout boxes ───────────────────────────────────────── */
.callout {
    border-left: 3px solid var(--blush);
    background: linear-gradient(90deg, rgba(184, 150, 90, 0.16) 0%, rgba(184, 150, 90, 0.07) 70%, rgba(184, 150, 90, 0) 100%);
    padding: 0.88rem 1rem;
    border-radius: 0 0.44rem 0.44rem 0;
    margin: 1rem 0;
}

.callout.warning {
    border-left-color: #c97f4a;
    background: rgba(201, 127, 74, 0.06);
}

.callout.sage {
    border-left-color: var(--sage);
    background: rgba(138, 158, 138, 0.08);
}

.callout p {
    margin: 0;
    font-size: 0.87rem;
    line-height: 1.7;
}

/* ── Data table inside legal content ─────────────────────── */
.legal-table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    font-size: 0.86rem;
    background: #fff;
    border: 1px solid #e8dece;
    border-radius: 0.44rem;
    overflow: hidden;
}

.legal-table th {
    background: var(--champagne);
    color: var(--deep);
    font-weight: 700;
    font-size: 0.72rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    padding: 0.62rem 0.88rem;
    text-align: left;
    border-bottom: 2px solid var(--border2);
}

.legal-table td {
    padding: 0.62rem 0.88rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
    vertical-align: top;
}

.legal-table tr:last-child td {
    border-bottom: none;
}

.legal-table tr:hover td {
    background: rgba(245, 237, 224, 0.5);
}

/* ── Contact block ───────────────────────────────────────── */
.contact-block {
    background: var(--deep);
    color: var(--champagne);
    padding: 1.75rem 2rem;
    border-radius: 0.5rem;
    margin-top: 1rem;
}

.contact-block p {
    color: var(--champagne) !important;
    font-size: 0.88rem !important;
    margin-bottom: 0.5rem;
}

.contact-block a {
    color: var(--blush);
    text-decoration: none;
}

.contact-block a:hover {
    text-decoration: underline;
}

/* ── FAQ accordion ───────────────────────────────────────── */
.faq-group {
    margin-bottom: 1.6rem;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid #ebe1d5;
    border-radius: 0.72rem;
    box-shadow: 0 0.2rem 0.6rem rgba(30, 20, 10, 0.04);
    padding: 1rem 1rem 0.5rem;
}

.faq-group-title {
    font-size: 0.65rem;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--blush);
    font-weight: 500;
    margin-bottom: 1.25rem;
    padding-bottom: 0.62rem;
    border-bottom: 1px solid var(--border);
}

.faq-item {
    border: 1px solid var(--border);
    border-radius: 0.56rem;
    margin-bottom: 0.62rem;
    overflow: hidden;
    transition: border-color 0.2s, transform 0.2s;
    background: #fff;
}

.faq-item:hover {
    border-color: var(--border2);
    transform: translateY(-0.06rem);
}

.faq-question {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    cursor: pointer;
    background: linear-gradient(180deg, #ffffff 0%, #fdfaf6 100%);
    user-select: none;
    gap: 1rem;
}

.faq-question span {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.5;
}

.faq-icon {
    flex-shrink: 0;
    width: 1.4rem;
    height: 1.4rem;
    border-radius: 50%;
    background: var(--champagne);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--rose);
    font-size: 1rem;
    line-height: 1;
    transition: transform 0.25s, background 0.2s;
}

.faq-item.open .faq-icon {
    transform: rotate(45deg);
    background: var(--rose);
    color: #fff;
}

.faq-answer {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s ease;
    background: var(--surface);
}

.faq-answer-inner {
    padding: 0 1.25rem 1.12rem;
    font-size: 0.88rem;
    color: var(--text-primary);
    line-height: 1.8;
}

.faq-answer-inner p {
    margin-bottom: 0.62rem;
}

.faq-answer-inner p:last-child {
    margin-bottom: 0;
}

.faq-answer-inner ul {
    margin: 0.5rem 0 0.62rem 1.12rem;
}

.faq-answer-inner li {
    margin-bottom: 0.25rem;
}

.faq-answer-inner a {
    color: var(--rose);
    text-decoration: none;
}

.faq-answer-inner a:hover {
    text-decoration: underline;
}

.faq-item.open .faq-answer {
    max-height: 37.5rem;
}

.faq-item.open .faq-question {
    border-bottom: 1px solid var(--border);
}

/* ── Animations ──────────────────────────────────────────── */
@keyframes legal-hero-in {
    from { opacity: 0; transform: translateY(-0.5rem); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes legal-card-in {
    from { opacity: 0; transform: translateY(0.4rem); }
    to   { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
    .page-hero,
    .legal-section,
    .faq-item {
        animation: none;
        transition: none;
    }
}

/* ── Language-specific typography ───────────────────────── */
html[lang^="fr"] .legal-section p,
html[lang^="fr"] .legal-section li,
html[lang^="es"] .legal-section p,
html[lang^="es"] .legal-section li {
    line-height: 1.82;
    word-break: normal;
    overflow-wrap: anywhere;
    hyphens: auto;
}

html[lang^="fr"] .toc-nav a,
html[lang^="es"] .toc-nav a {
    font-size: 0.8rem;
    line-height: 1.48;
}

/* ── Print ───────────────────────────────────────────────── */
@media print {
    body {
        background: #fff;
        color: #000;
        overflow: visible;
        font-size: 0.72rem;
    }

    .main-nav,
    .page-footer,
    .impersonation-banner,
    .toc-sidebar {
        display: none !important;
    }

    .page-content {
        padding: 0;
        overflow: visible;
    }

    .page-hero {
        margin: 0;
        padding: 0.9rem 0 0.5rem;
        background: #fff;
        box-shadow: none;
        border-bottom: 0.02rem solid #ccc;
    }

    .page-hero::before,
    .page-hero::after {
        display: none;
    }

    .page-hero-label,
    .page-hero-meta span,
    .page-hero h1,
    .page-hero-meta span strong {
        color: #000 !important;
        background: transparent;
        border: 0;
        padding: 0;
    }

    .legal-layout {
        display: block;
        padding: 0;
    }

    .legal-content {
        padding: 0;
    }

    .legal-section,
    .faq-group {
        border: 0;
        box-shadow: none;
        border-radius: 0;
        background: #fff;
        padding: 0;
        margin-bottom: 0.95rem;
        break-inside: avoid;
    }

    .faq-item {
        border: 0;
        margin-bottom: 0.52rem;
        break-inside: avoid;
    }

    .faq-question {
        padding: 0.2rem 0;
        background: transparent;
    }

    .faq-icon {
        display: none;
    }

    .faq-answer {
        max-height: none !important;
        overflow: visible;
        background: transparent;
    }

    .faq-answer-inner {
        padding: 0.2rem 0 0.45rem;
    }

    a {
        color: #000;
        text-decoration: underline;
    }
}

/* ── Narrow screen ───────────────────────────────────────── */
@media (max-width: 48rem) {
    .page-hero {
        --hero-pad-top: 1rem;
        --hero-pad-right: 0.82rem;
        --hero-pad-bottom: 0.84rem;
        padding: var(--hero-pad-top) var(--hero-pad-right) var(--hero-pad-bottom) 0.82rem;
    }

    .has-app-logo .page-hero {
        column-gap: 0.7rem;
    }

    .has-app-logo .page-hero::before {
        width: calc(5rem + var(--hero-pad-right));
    }

    .legal-layout {
        grid-template-columns: 1fr;
        padding: 0 0.5rem 3rem;
        gap: 0.95rem;
    }

    .toc-sidebar {
        position: static;
        border-right: 1px solid rgba(184, 150, 90, 0.3);
        border-bottom: 1px solid rgba(184, 150, 90, 0.3);
        padding: 0.85rem;
    }

    .legal-content {
        padding: 0;
    }
}
