/**
 * Legal pages — Privacy & Terms
 *
 * @package Bargtunes
 */

.lg-page {
    --lg-accent: #e8ff6a;
    --lg-accent-dim: rgba(232, 255, 106, 0.14);
    --lg-ink: #f5f5f7;
    --lg-muted: rgba(255, 255, 255, 0.62);
    --lg-line: rgba(255, 255, 255, 0.1);
    --lg-panel: rgba(12, 12, 16, 0.82);
    --lg-gutter: clamp(20px, 4vw, 56px);
    --lg-header-offset: clamp(76px, 11vw, 104px);
    --lg-rail-offset: 0px;
    --lg-dock-offset: 0px;
    position: relative;
    min-height: 100vh;
    min-height: 100dvh;
    padding:
        calc(var(--lg-header-offset) + 12px)
        0
        calc(clamp(72px, 10vw, 120px) + var(--lg-dock-offset));
    color: var(--lg-ink);
    overflow: clip;
}

/* Reading progress */
.lg-progress {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    z-index: 10001;
    background: rgba(255, 255, 255, 0.06);
    pointer-events: none;
}

.lg-progress__fill {
    display: block;
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, rgba(232, 255, 106, 0.65), var(--lg-accent));
    box-shadow: 0 0 16px rgba(232, 255, 106, 0.45);
    transition: width 0.12s linear;
}

.lg-bg {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
}

.lg-bg__mesh {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse 80% 50% at 15% -10%, rgba(232, 255, 106, 0.09), transparent 55%),
        radial-gradient(ellipse 60% 40% at 90% 20%, rgba(120, 140, 255, 0.07), transparent 50%),
        linear-gradient(180deg, #050507 0%, #0a0a0f 45%, #060608 100%);
}

.lg-bg__grid {
    position: absolute;
    inset: 0;
    opacity: 0.35;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
    background-size: 48px 48px;
    mask-image: linear-gradient(180deg, #000 0%, transparent 85%);
}

.lg-bg__glow {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.45;
}

.lg-bg__glow--a {
    width: 420px;
    height: 420px;
    top: 8%;
    left: -8%;
    background: rgba(232, 255, 106, 0.12);
}

.lg-bg__glow--b {
    width: 360px;
    height: 360px;
    bottom: 10%;
    right: -6%;
    background: rgba(90, 110, 255, 0.1);
}

.lg-wrap {
    position: relative;
    z-index: 1;
    width: min(1180px, 100% - var(--lg-gutter) * 2);
    margin-inline: auto;
    padding-inline: max(var(--lg-gutter), env(safe-area-inset-left)) max(var(--lg-gutter), env(safe-area-inset-right));
}

/* Mobile / tablet TOC rail — hidden on desktop */
.lg-rail {
    display: none;
    margin-bottom: clamp(18px, 3vw, 28px);
}

.lg-rail__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
    padding-inline: 2px;
}

.lg-rail__label {
    font-size: 0.72rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--lg-muted);
}

.lg-rail__count {
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    color: rgba(232, 255, 106, 0.75);
    font-variant-numeric: tabular-nums;
}

.lg-rail__track {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    scroll-padding-inline: var(--lg-gutter);
    padding: 4px 2px 12px;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x;
    scrollbar-width: none;
    mask-image: linear-gradient(to right, transparent, #000 16px, #000 calc(100% - 16px), transparent);
}

.lg-rail__track::-webkit-scrollbar {
    display: none;
}

.lg-rail__pill {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    max-width: min(78vw, 280px);
    padding: 10px 14px;
    border: 1px solid var(--lg-line);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.03);
    color: var(--lg-muted);
    text-decoration: none;
    scroll-snap-align: start;
    transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.lg-rail__pill.is-active {
    border-color: rgba(232, 255, 106, 0.35);
    background: rgba(232, 255, 106, 0.1);
    color: var(--lg-ink);
    transform: translateY(-1px);
}

.lg-rail__pill-num {
    font-size: 0.68rem;
    letter-spacing: 0.08em;
    color: rgba(232, 255, 106, 0.8);
}

.lg-rail__pill-text {
    font-size: 0.82rem;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Bottom dock — mobile only */
.lg-dock {
    display: none;
}

/* Hero */
.lg-hero {
    margin-bottom: clamp(36px, 5vw, 56px);
}

.lg-back {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 28px;
    padding: 10px 16px 10px 12px;
    border: 1px solid var(--lg-line);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.03);
    color: var(--lg-ink);
    text-decoration: none;
    font-size: 0.82rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    transition: border-color 0.25s ease, background 0.25s ease, transform 0.25s ease;
}

.lg-back:hover {
    border-color: rgba(232, 255, 106, 0.35);
    background: rgba(232, 255, 106, 0.06);
    transform: translateX(-2px);
}

body.lang-persian .lg-back:hover,
body.rtl .lg-back:hover {
    transform: translateX(2px);
}

.lg-back__icon {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
}

.lg-back__icon svg {
    width: 16px;
    height: 16px;
}

body.lang-persian .lg-back__icon svg,
body.rtl .lg-back__icon svg {
    transform: scaleX(-1);
}

.lg-hero__meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 14px;
    margin-bottom: 16px;
}

.lg-hero__badge {
    display: inline-flex;
    padding: 6px 12px;
    border-radius: 999px;
    background: var(--lg-accent-dim);
    border: 1px solid rgba(232, 255, 106, 0.22);
    color: var(--lg-accent);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.lg-hero__dot {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.35);
}

.lg-hero__updated {
    font-size: 0.82rem;
    color: var(--lg-muted);
}

.lg-hero__title {
    margin: 0 0 14px;
    font-family: 'Bebas Neue', 'Vazirmatn', sans-serif;
    font-size: clamp(2.6rem, 7vw, 4.4rem);
    line-height: 0.95;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

body.lang-persian .lg-hero__title,
body.rtl .lg-hero__title {
    font-family: 'Vazirmatn', sans-serif;
    text-transform: none;
    letter-spacing: 0;
    line-height: 1.15;
}

.lg-hero__subtitle {
    max-width: 62ch;
    margin: 0 0 18px;
    font-size: clamp(1rem, 1.6vw, 1.12rem);
    line-height: 1.7;
    color: var(--lg-muted);
}

.lg-hero__brand {
    margin: 0;
    font-size: 0.78rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: rgba(232, 255, 106, 0.75);
}

/* Shell grid */
.lg-shell {
    display: grid;
    grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
    gap: clamp(24px, 4vw, 48px);
    align-items: start;
}

.lg-aside {
    position: sticky;
    top: 96px;
}

.lg-toc {
    padding: 20px;
    border: 1px solid var(--lg-line);
    border-radius: 20px;
    background: var(--lg-panel);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
}

.lg-toc__label {
    margin: 0 0 14px;
    font-size: 0.72rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--lg-muted);
}

.lg-toc__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 6px;
}

.lg-toc__link {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 12px;
    color: var(--lg-muted);
    text-decoration: none;
    font-size: 0.88rem;
    line-height: 1.45;
    transition: background 0.2s ease, color 0.2s ease;
}

.lg-toc__link:hover,
.lg-toc__link:focus-visible,
.lg-toc__link.is-active {
    background: rgba(255, 255, 255, 0.05);
    color: var(--lg-ink);
}

.lg-toc__link.is-active {
    border: 1px solid rgba(232, 255, 106, 0.22);
    background: rgba(232, 255, 106, 0.08);
}

.lg-toc__num {
    flex: 0 0 auto;
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    color: rgba(232, 255, 106, 0.7);
    padding-top: 2px;
}

.lg-aside__card {
    margin-top: 16px;
    padding: 18px;
    border: 1px solid var(--lg-line);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.02);
}

.lg-aside__label {
    margin: 0 0 12px;
    font-size: 0.82rem;
    color: var(--lg-muted);
}

.lg-aside__cta {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    padding: 10px 14px;
    border-radius: 999px;
    background: var(--lg-accent);
    color: #0a0a0c;
    font-size: 0.82rem;
    font-weight: 600;
    text-decoration: none;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.lg-aside__cta:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 24px rgba(232, 255, 106, 0.25);
}

.lg-aside__related {
    display: block;
    font-size: 0.84rem;
    color: var(--lg-accent);
    text-decoration: none;
}

.lg-aside__related:hover {
    text-decoration: underline;
}

/* Content sections */
.lg-content {
    display: grid;
    gap: 18px;
}

.lg-section {
    padding: clamp(22px, 3vw, 30px);
    border: 1px solid var(--lg-line);
    border-radius: 22px;
    background: linear-gradient(165deg, rgba(255, 255, 255, 0.04) 0%, rgba(255, 255, 255, 0.01) 100%);
    scroll-margin-top: calc(var(--lg-header-offset) + var(--lg-rail-offset) + 24px);
    content-visibility: auto;
    contain-intrinsic-size: auto 280px;
}

.lg-section.is-active {
    border-color: rgba(232, 255, 106, 0.18);
    box-shadow: 0 0 0 1px rgba(232, 255, 106, 0.06) inset;
}

.lg-section__head {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.lg-section__index {
    display: grid;
    place-items: center;
    min-width: 42px;
    height: 42px;
    border-radius: 12px;
    background: var(--lg-accent-dim);
    border: 1px solid rgba(232, 255, 106, 0.18);
    color: var(--lg-accent);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.06em;
}

.lg-section__title {
    margin: 0;
    font-size: clamp(1.15rem, 2vw, 1.45rem);
    line-height: 1.25;
}

.lg-section__body {
    color: rgba(255, 255, 255, 0.78);
    font-size: 0.96rem;
    line-height: 1.75;
}

.lg-section__body p {
    margin: 0 0 14px;
}

.lg-section__body p:last-child {
    margin-bottom: 0;
}

.lg-section__body ul {
    margin: 0 0 14px;
    padding-inline-start: 1.2em;
}

.lg-section__body li {
    margin-bottom: 8px;
}

.lg-section__body a {
    color: var(--lg-accent);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.lg-section__body code {
    padding: 2px 6px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.08);
    font-size: 0.88em;
}

.lg-section__body strong {
    color: var(--lg-ink);
    font-weight: 600;
}

.lg-foot {
    padding-top: 8px;
}

.lg-foot__related {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    border: 1px solid rgba(232, 255, 106, 0.22);
    border-radius: 16px;
    background: rgba(232, 255, 106, 0.05);
    color: var(--lg-accent);
    text-decoration: none;
    font-size: 0.92rem;
    transition: background 0.2s ease, transform 0.2s ease;
}

.lg-foot__related:hover {
    background: rgba(232, 255, 106, 0.1);
    transform: translateY(-1px);
}

body.lang-persian .lg-foot__related svg,
body.rtl .lg-foot__related svg {
    transform: scaleX(-1);
}

/* ==========================================================
   RESPONSIVE — advanced breakpoints
   ========================================================== */

/* Large tablet */
@media (max-width: 1100px) {
    .lg-shell {
        grid-template-columns: minmax(200px, 240px) minmax(0, 1fr);
        gap: clamp(20px, 3vw, 32px);
    }

    .lg-aside {
        top: calc(var(--lg-header-offset) + 8px);
    }
}

/* Tablet stack + sticky rail */
@media (max-width: 900px) {
    .lg-page {
        --lg-rail-offset: 72px;
    }

    .lg-shell {
        grid-template-columns: 1fr;
    }

    .lg-aside {
        position: static;
        display: none;
    }

    .lg-rail {
        display: block;
        position: sticky;
        top: calc(var(--lg-header-offset) - 4px);
        z-index: 50;
        margin-inline: calc(var(--lg-gutter) * -1);
        padding: 10px max(var(--lg-gutter), env(safe-area-inset-left)) 8px max(var(--lg-gutter), env(safe-area-inset-right));
        background: linear-gradient(180deg, rgba(5, 5, 7, 0.94) 0%, rgba(5, 5, 7, 0.88) 70%, transparent 100%);
        backdrop-filter: none;
    }

    .lg-rail__track {
        padding-inline: 0;
        mask-image: linear-gradient(to right, transparent, #000 8px, #000 calc(100% - 8px), transparent);
    }

    .lg-hero {
        margin-bottom: clamp(24px, 4vw, 36px);
    }

    .lg-section {
        border-radius: 20px;
    }
}

/* Mobile */
@media (max-width: 720px) {
    .lg-page {
        --lg-gutter: clamp(18px, 5vw, 24px);
        --lg-dock-offset: 76px;
    }

    .lg-hero__title {
        font-size: clamp(2.2rem, 11vw, 3rem);
    }

    .lg-hero__subtitle {
        font-size: clamp(0.94rem, 3.8vw, 1.05rem);
        line-height: 1.65;
    }

    .lg-back {
        width: 100%;
        justify-content: center;
    }

    .lg-content {
        gap: 14px;
    }

    .lg-section {
        padding: clamp(18px, 4.5vw, 22px);
        border-radius: 18px;
        contain-intrinsic-size: auto 240px;
    }

    .lg-section__body {
        font-size: 0.92rem;
        line-height: 1.72;
        overflow-wrap: anywhere;
        word-break: break-word;
    }

    .lg-section__body ul {
        padding-inline-start: 1em;
    }

    .lg-foot__related {
        width: 100%;
        justify-content: center;
    }

    .lg-dock {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 9998;
        padding: 12px max(var(--lg-gutter), env(safe-area-inset-left)) calc(12px + env(safe-area-inset-bottom)) max(var(--lg-gutter), env(safe-area-inset-right));
        border-top: 1px solid rgba(255, 255, 255, 0.08);
        background: rgba(6, 6, 8, 0.94);
        box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.45);
    }

    .lg-dock__btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-height: 48px;
        padding: 12px 14px;
        border-radius: 14px;
        font-size: 0.78rem;
        font-weight: 600;
        line-height: 1.25;
        text-align: center;
        text-decoration: none;
        transition: transform 0.2s ease, background 0.2s ease;
    }

    .lg-dock__btn--ghost {
        border: 1px solid var(--lg-line);
        color: var(--lg-ink);
        background: rgba(255, 255, 255, 0.04);
    }

    .lg-dock__btn--accent {
        border: 1px solid rgba(232, 255, 106, 0.35);
        background: var(--lg-accent);
        color: #0a0a0c;
    }

    .lg-dock__btn:active {
        transform: scale(0.98);
    }

    body:has(.lg-page) .fn-dock {
        display: none !important;
    }

    .lg-bg__glow--a,
    .lg-bg__glow--b {
        opacity: 0.28;
    }
}

/* Small mobile */
@media (max-width: 540px) {
    .lg-page {
        --lg-header-offset: 72px;
        --lg-rail-offset: 64px;
    }

    .lg-hero__meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .lg-hero__dot {
        display: none;
    }

    .lg-section__head {
        align-items: flex-start;
        flex-direction: row;
        flex-wrap: wrap;
    }

    .lg-section__index {
        min-width: 38px;
        height: 38px;
        font-size: 0.72rem;
    }

    .lg-rail__pill {
        max-width: 82vw;
        padding: 9px 12px;
    }

    .lg-dock {
        grid-template-columns: 1fr;
    }

    .lg-dock__btn--ghost {
        display: none;
    }
}

/* Extra small */
@media (max-width: 400px) {
    .lg-wrap {
        padding-inline: max(16px, env(safe-area-inset-left)) max(16px, env(safe-area-inset-right));
    }

    .lg-hero__brand {
        letter-spacing: 0.14em;
    }

    .lg-rail__head {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* Landscape phones */
@media (max-width: 900px) and (max-height: 520px) and (orientation: landscape) {
    .lg-page {
        --lg-rail-offset: 56px;
        --lg-dock-offset: 64px;
        padding-top: calc(var(--lg-header-offset) + 4px);
    }

    .lg-hero {
        margin-bottom: 16px;
    }

    .lg-hero__subtitle {
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .lg-rail {
        position: static;
        margin-inline: 0;
        padding-inline: 0;
        background: transparent;
    }

    .lg-dock {
        grid-template-columns: 1fr 1fr;
        padding-block: 8px;
    }

    .lg-dock__btn--ghost {
        display: inline-flex;
    }
}

/* Touch — larger tap targets */
@media (hover: none), (pointer: coarse) {
    .lg-toc__link,
    .lg-rail__pill,
    .lg-back,
    .lg-foot__related,
    .lg-dock__btn {
        min-height: 44px;
    }

    .lg-rail__pill:hover,
    .lg-foot__related:hover,
    .lg-back:hover {
        transform: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .lg-back,
    .lg-aside__cta,
    .lg-foot__related,
    .lg-rail__pill,
    .lg-dock__btn {
        transition: none;
    }

    .lg-progress__fill {
        transition: none;
    }

    .lg-section {
        content-visibility: visible;
    }
}
