/* The legal page (legal.html): the Terms and the Privacy Policy.

   Read after src/tokens.css, and on its own: the app's style.css is the
   one-screen studio layout and is not loaded here. Same look as the app
   (docs/LOOK.md): Chop Red tokens, Bitter headings, Overpass body, the
   house pills, 44 px targets, a 3 px focus ring. Light only. One readable
   column of about 68 characters; on a wide screen the contents list stands
   beside it. */

@font-face {
    font-family: 'Bitter';
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url('../../vendor/fonts/Bitter-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: 'Overpass';
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url('../../vendor/fonts/Overpass-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

html {
    scroll-padding-top: 1rem;
}

body.legal {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font-ui);
    font-size: var(--fs-base);
    line-height: 1.65;
    color: var(--text-primary);
    background-color: var(--bg-1);
    background-image:
        radial-gradient(at 0% 0%, rgba(170, 90, 110, 0.10) 0px, transparent 55%),
        radial-gradient(at 100% 0%, rgba(170, 90, 110, 0.08) 0px, transparent 55%),
        radial-gradient(at 50% 100%, rgba(170, 90, 110, 0.06) 0px, transparent 55%);
    background-attachment: fixed;
}

/* ---- Focus and the skip link (as the app) ---- */
:focus-visible {
    outline: 3px solid var(--focus-ring);
    outline-offset: 2px;
    border-radius: var(--radius-inset);
}
.legal-doc:focus {
    outline: none;
}

.skip-link {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 100;
    transform: translateY(-140%);
    padding: 0.7rem 1.2rem;
    background: var(--c-white);
    color: var(--accent-text);
    border: 3px solid var(--focus-ring);
    border-radius: 0 0 var(--radius-card) 0;
    font: 700 var(--fs-base) var(--font-display);
    text-decoration: none;
    transition: transform var(--dur-150) ease;
}
.skip-link:focus {
    transform: translateY(0);
}

/* ---- Header: the lockup, the way back, the two tabs ---- */
.legal-top {
    background: var(--sidebar-bg);
    border-bottom: 1px solid var(--border-card);
    box-shadow: 0 6px 30px var(--shadow-soft);
}
.legal-top-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    max-width: 72rem;
    margin: 0 auto;
    padding: 14px 18px 0.5rem;
}

.legal-brand {
    display: inline-flex;
    flex-direction: column;
    gap: 0.1rem;
    min-height: 44px;
    justify-content: center;
    text-decoration: none;
}
.legal-brand-row {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-family: var(--font-display);
    font-size: var(--fs-mark);
    font-weight: var(--fw-display);
    line-height: var(--lh-tight);
    letter-spacing: var(--tracking-tight);
}
.brand-mark {
    flex: none;
    width: 28px;
    height: 28px;
}
.brand-word {
    background: var(--grad-wordmark);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: var(--accent-text);
}
.brand-line {
    font-size: var(--fs-sm);
    line-height: var(--lh-tight);
    letter-spacing: var(--tracking-caps);
    text-transform: uppercase;
    color: var(--accent-text);
}
.brand-line strong {
    font-weight: var(--fw-display);
}

/* The primary pill (LOOK.md "Buttons"). */
.legal-back {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-chip);
    background: var(--grad-primary);
    color: var(--c-white);
    font-weight: var(--fw-strong);
    font-size: var(--fs-sm);
    text-decoration: none;
    box-shadow: 0 4px 12px var(--shadow-pink);
    transition: transform var(--dur-150) ease, box-shadow var(--dur-150) ease;
}
.legal-back:hover {
    background: var(--grad-primary-hover);
    transform: translateY(-1px);
}
.legal-back:active {
    transform: scale(0.97);
}

/* The two documents as secondary pills; the open one is filled. */
.legal-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    max-width: 72rem;
    margin: 0 auto;
    padding: 0.5rem 18px 0.9rem;
}
.legal-tab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0.5rem 1rem;
    border: 1.5px solid var(--border-card);
    border-radius: var(--radius-chip);
    background: var(--c-white);
    color: var(--text-primary);
    font-weight: var(--fw-strong);
    font-size: var(--fs-sm);
    text-decoration: none;
    transition: border-color var(--dur-150) ease, background var(--dur-150) ease;
}
.legal-tab:hover {
    border-color: var(--border-card-open);
    background: #f6ecea;
}
.legal-tab[aria-current="page"] {
    border-color: transparent;
    background: var(--grad-primary);
    color: var(--c-white);
    box-shadow: 0 4px 12px var(--shadow-pink);
}

/* ---- The column and the contents list ---- */
.legal-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 1rem;
    max-width: calc(68ch + 4rem);
    margin: 0 auto;
    padding: 1.25rem 16px 2rem;
}

.legal-toc-box {
    background: var(--card-bg);
    border: 1.5px solid var(--border-card);
    border-radius: var(--radius-card);
    padding: 0 0.75rem;
}
.legal-toc-title {
    display: flex;
    align-items: center;
    min-height: 44px;
    cursor: pointer;
    font-family: var(--font-heading);
    font-weight: var(--fw-strong);
    color: var(--text-primary);
    list-style: none;
}
.legal-toc-title::-webkit-details-marker {
    display: none;
}
/* The fold marker: a chevron that points down when the list is open. */
.legal-toc-title::after {
    content: '';
    width: 0.5rem;
    height: 0.5rem;
    margin: 0 0.4rem 0 auto;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(-45deg);
    transition: transform var(--dur-150) ease;
}
.legal-toc-box[open] .legal-toc-title::after {
    transform: rotate(45deg);
}
.legal-toc-list {
    margin: 0 0 0.6rem;
    padding: 0;
    list-style: none;
    font-size: var(--fs-sm);
    line-height: var(--lh-tight);
}
.legal-toc-list a {
    display: flex;
    align-items: center;
    min-height: 44px;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-inset);
    color: var(--text-secondary);
    text-decoration: none;
}
.legal-toc-list a:hover {
    background: #f6ecea;
    color: var(--accent-text);
    text-decoration: underline;
}

.legal-doc {
    min-width: 0;
    background: var(--card-bg);
    border: 1.5px solid var(--border-card);
    border-radius: var(--radius-card);
    padding: 1.25rem 1rem 1.5rem;
    overflow-wrap: break-word;
}

@media (min-width: 600px) {
    .legal-doc {
        padding: 2rem 2.25rem 2.5rem;
    }
}

@media (min-width: 1024px) {
    .legal-layout {
        grid-template-columns: 16rem minmax(0, calc(68ch + 4.5rem));
        justify-content: center;
        align-items: start;
        gap: 2rem;
        max-width: none;
        padding-top: 2rem;
    }
    .legal-toc {
        position: sticky;
        top: 1rem;
        max-height: calc(100vh - 2rem);
        overflow-y: auto;
    }
}

/* ---- The document ---- */
.legal-doc h1,
.legal-doc h2,
.legal-doc h3 {
    font-family: var(--font-heading);
    color: var(--text-primary);
    letter-spacing: var(--tracking-title);
    line-height: 1.25;
}
.legal-doc h1 {
    margin: 0 0 0.75rem;
    font-size: 2rem;
    font-weight: var(--fw-display);
}
.legal-doc h2 {
    margin: 2.25rem 0 0.6rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-soft);
    font-size: 1.3rem;
    font-weight: var(--fw-strong);
}
.legal-doc h3 {
    margin: 1.5rem 0 0.4rem;
    font-size: 1.1rem;
    font-weight: var(--fw-strong);
}
.legal-doc p,
.legal-doc ul,
.legal-doc ol {
    margin: 0.75rem 0;
}
.legal-doc ul,
.legal-doc ol {
    padding-left: 1.25rem;
}
.legal-doc li {
    margin: 0.3rem 0;
}
.legal-doc strong {
    font-weight: var(--fw-display);
}
.legal-doc a {
    color: var(--accent-text);
    text-decoration: underline;
    text-underline-offset: 0.15em;
}
.legal-doc a:hover {
    text-decoration-thickness: 2px;
}
.legal-doc code {
    padding: 0.05em 0.35em;
    border: 1px solid var(--border-card);
    border-radius: 5px;
    background: #fbefec;
    font-size: 0.9em;
}
.legal-doc hr {
    margin: 2rem 0;
    border: none;
    border-top: 1px solid var(--border-soft);
}
.legal-doc blockquote {
    margin: 1.25rem 0;
    padding: 0.9rem 1.1rem;
    border-left: 4px solid var(--accent-color);
    border-radius: 0 var(--radius-inset) var(--radius-inset) 0;
    background: #fbefec;
    color: var(--text-secondary);
}

/* A wide table scrolls inside itself, never the page. */
.table-wrap {
    margin: 1rem 0;
    overflow-x: auto;
    border-radius: var(--radius-inset);
}
.legal-doc table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
    line-height: 1.5;
}
.legal-doc th,
.legal-doc td {
    padding: 0.5rem 0.65rem;
    border: 1px solid var(--border-card);
    text-align: left;
    vertical-align: top;
}
.legal-doc th {
    background: #fbefec;
    font-weight: var(--fw-display);
}

.legal-loading {
    color: var(--text-secondary);
}
.load-error {
    padding: 1rem;
    border: 2px solid var(--fail-text);
    border-radius: var(--radius-inset);
}

/* ---- Footer ---- */
.legal-foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    padding: 0 16px 2rem;
    font-size: var(--fs-sm);
    color: var(--text-secondary);
}
.legal-foot a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    color: inherit;
    text-decoration: none;
}
.legal-foot a:hover {
    color: var(--accent-text);
    text-decoration: underline;
}

@media (prefers-reduced-motion: reduce) {
    .skip-link,
    .legal-back,
    .legal-tab {
        transition: none;
    }
}
