/**
 * Custom Mobile Carts: Legal pages
 *
 * Privacy Policy, Terms and Conditions and Return Policy on
 * templates/template-legal.php. A reading column with the table of contents
 * beside it on wide screens and above it on phones. Prose comes from the
 * .entry-content rules in style.css, cards and the page hero are global too.
 * This file only lays the page out and adds the pieces specific to it.
 *
 * @package CustomMobileCarts
 */

/* Layout: contents card beside the reading column
   ========================================================================== */

.legal-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--spacing-2xl);
    align-items: start;
}

.legal-layout__main {
    width: 100%;
    max-width: 72ch;
    min-width: 0;
}

/* No contents list (editor text, or a short policy): the column sits in
   the middle, the way page.php reads */
.legal-layout:not(.legal-layout--toc) .legal-layout__main {
    margin-inline: auto;
}

@media (min-width: 1024px) {
    .legal-layout--toc {
        grid-template-columns: minmax(0, 17rem) minmax(0, 1fr);
        column-gap: var(--spacing-3xl);
    }

    .legal-toc {
        position: sticky;
        top: calc(var(--header-height) + var(--spacing-xl));
        max-height: calc(100vh - var(--header-height) - var(--spacing-2xl));
        overflow-y: auto;
    }
}

/* Table of contents
   ========================================================================== */

.legal-toc {
    padding: var(--spacing-lg);
}

/* A list of links, never a link itself: the card stays still under the pointer */
@media (hover: hover) {
    .legal-toc:hover {
        transform: none;
        box-shadow: var(--shadow-xs);
    }
}

.legal-toc__title {
    margin-bottom: var(--spacing-sm);
    font-family: var(--font-heading);
    font-size: 0.8125rem;
    font-weight: var(--font-weight-bold);
    line-height: 1.3;
    letter-spacing: var(--letter-spacing-eyebrow);
    text-transform: uppercase;
    color: var(--color-eyebrow);
}

.legal-toc__list {
    display: grid;
    gap: 0.125rem;
    counter-reset: legal-toc;
}

.legal-toc__link {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    min-height: 44px;
    margin-inline: calc(-1 * var(--spacing-sm));
    padding: 0.375rem var(--spacing-sm);
    font-size: var(--font-size-sm);
    line-height: 1.45;
    color: var(--color-text-light);
    border-radius: var(--radius-sm);
    transition: color var(--transition-fast), background-color var(--transition-fast);
}

.legal-toc__link::before {
    counter-increment: legal-toc;
    content: counter(legal-toc);
    flex: none;
    min-width: 1.25rem;
    font-variant-numeric: tabular-nums;
    color: var(--color-text-muted);
}

.legal-toc__link:hover {
    color: var(--color-heading);
    background-color: var(--color-surface-hover);
}

/* Reading column
   ========================================================================== */

.legal-updated {
    margin-bottom: var(--spacing-xl);
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
}

.legal-updated time {
    font-weight: var(--font-weight-medium);
    color: var(--color-text-light);
}

/* Sections are separated by a rule. The selector outweighs the
   .entry-content > * + * spacing in style.css on purpose. */
.legal-section + .legal-section {
    margin-top: var(--spacing-2xl);
    padding-top: var(--spacing-2xl);
    border-top: 1px solid var(--color-border);
}

.legal-section > :last-child {
    margin-bottom: 0;
}

.legal-section__title {
    margin-bottom: var(--spacing-md);
    font-size: var(--font-size-2xl);
}

.legal-body ul {
    margin-bottom: var(--spacing-md);
}

/* Short callouts: a soft tint with a gold edge */
.legal-note {
    padding: var(--spacing-md) var(--spacing-lg);
    font-size: 0.9375rem;
    line-height: 1.6;
    color: var(--color-text);
    background-color: var(--color-bg-tint);
    border: 1px solid var(--color-border);
    border-left: 3px solid var(--color-secondary);
    border-radius: var(--radius-md);
}

/* Closing contact card
   ========================================================================== */

.legal-contact {
    margin-top: var(--spacing-3xl);
}

/* Details only, never a link */
@media (hover: hover) {
    .legal-contact:hover {
        transform: none;
        box-shadow: var(--shadow-xs);
    }
}

.legal-contact__title {
    margin-bottom: var(--spacing-xs);
}

.legal-contact__text {
    margin-bottom: var(--spacing-lg);
    font-size: 0.9375rem;
    color: var(--color-text-light);
}

.legal-contact__list {
    display: grid;
    gap: var(--spacing-sm);
}

.legal-contact__item {
    display: flex;
    align-items: baseline;
    gap: var(--spacing-md);
}

.legal-contact__label {
    flex: none;
    min-width: 4.5rem;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text-light);
}

.legal-contact__value {
    min-width: 0;
    font-style: normal;
    font-weight: var(--font-weight-medium);
    color: var(--color-heading);
    overflow-wrap: anywhere;
}

a.legal-contact__value:hover {
    color: var(--color-link);
}

.legal-contact__related {
    margin-top: var(--spacing-lg);
    padding-top: var(--spacing-lg);
    border-top: 1px solid var(--color-border);
}

.legal-contact__related-title {
    margin-bottom: var(--spacing-sm);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text-light);
}

.legal-contact__links {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-sm) var(--spacing-lg);
}

/* Motion and print
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    .legal-toc__link {
        transition: none;
    }
}

@media print {
    .legal-toc,
    .legal-contact__related {
        display: none !important;
    }

    .legal-layout {
        display: block;
    }

    .legal-layout__main {
        max-width: none;
    }

    .legal-section {
        break-inside: auto;
    }

    .legal-section__title {
        break-after: avoid;
    }

    .legal-note,
    .legal-contact {
        break-inside: avoid;
    }
}
