/*
 * Layout and typography for the text pages: privacy policy (DE/EN),
 * Impressum and account deletion. Needs site-chrome.css for the tokens.
 *
 * Reading comfort comes first: 17px body text, line height 1.65 and a text
 * column of 35rem. Measured on the privacy pages that is a median of 63
 * (German) and 66 (English) characters per line, 71 at the 90th percentile.
 */

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

@media (prefers-reduced-motion: no-preference) {
    html {
        scroll-behavior: smooth;
    }
}

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-family: var(--pw-font-sans);
    font-size: 1.0625rem;
    line-height: 1.65;
    color: var(--pw-text);
    background-color: var(--pw-bg);
    background-image:
        linear-gradient(var(--pw-grid) 1px, transparent 1px),
        linear-gradient(90deg, var(--pw-grid) 1px, transparent 1px);
    background-size: 40px 40px;
}

main {
    flex: 1 0 auto;
}

/* --- Page frame --- */
.doc {
    width: 100%;
    margin: 0 auto;
}

.doc-panel {
    background: var(--pw-panel);
    border-top: 4px solid var(--pw-orange);
    padding: 1.75rem var(--pw-gutter) 2.5rem;
}

@media (min-width: 40em) {
    .doc {
        max-width: 43.5rem;
        padding: 0 1.5rem;
    }

    .doc-panel {
        border: 1px solid var(--pw-line);
        border-top: 4px solid var(--pw-orange);
        border-radius: 4px;
        padding: 2.5rem 2.75rem 3rem;
    }
}

/* Wide screens: table of contents as a sticky column left of the text. */
@media (min-width: 68rem) {
    .doc {
        max-width: 72rem;
    }

    .doc-panel {
        display: grid;
        grid-template-columns: 15rem minmax(0, 35rem);
        grid-template-areas:
            "head head"
            "toc  lead"
            "toc  body";
        column-gap: 3.5rem;
        justify-content: center;
        align-items: start;
    }

    .doc-head { grid-area: head; }
    .doc-lead { grid-area: lead; }
    .doc-body { grid-area: body; }

    .toc {
        grid-area: toc;
        position: sticky;
        top: 1.5rem;
        max-height: calc(100vh - 3rem);
        overflow-y: auto;
        margin-top: 0;
    }
}

/* Pages without a table of contents (Impressum, account deletion). */
@media (min-width: 68rem) {
    .doc--single {
        max-width: 43.5rem;
    }

    .doc--single .doc-panel {
        display: block;
    }
}

.doc-panel + .doc-panel {
    margin-top: 2rem;
}

/* --- Title block --- */
.doc-head {
    margin-bottom: 1.5rem;
}

h1 {
    margin: 0;
    line-height: 1.35;
    font-weight: 400;
}

.h1-main {
    display: block;
    font-family: var(--pw-font-pixel);
    /* Press Start 2P is 1em per glyph: 4vw keeps a 20-letter word inside 375px. */
    font-size: clamp(0.95rem, 4vw, 1.75rem);
    line-height: 1.45;
    text-transform: uppercase;
    color: var(--pw-orange);
    overflow-wrap: break-word;
}

.h1-sub {
    display: block;
    margin-top: 0.6rem;
    font-family: var(--pw-font-sans);
    font-size: 1.25rem;
    font-weight: 600;
    line-height: 1.35;
    color: var(--pw-text);
}

.doc-meta {
    margin: 1rem 0 0;
    font-size: 0.95rem;
    color: var(--pw-text-muted);
}

.doc-meta a {
    white-space: nowrap;
}

/* --- Running text --- */
.doc-lead,
.doc-body {
    max-width: 35rem;
}

p,
ul,
ol,
dl,
address,
table {
    margin: 0 0 1rem;
}

address {
    font-style: normal;
}

ul,
ol {
    padding-left: 1.25rem;
}

ul {
    list-style-type: square;
}

li {
    margin: 0.35rem 0;
}

li::marker {
    color: var(--pw-orange);
}

a {
    color: var(--pw-blue-light);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.18em;
    overflow-wrap: anywhere;
}

/* Mail addresses and phone numbers stay on one line; they are short enough. */
a[href^="mailto:"],
a[href^="tel:"] {
    white-space: nowrap;
    overflow-wrap: normal;
}

a:hover {
    color: var(--pw-orange);
}

a:focus-visible {
    outline: 2px solid var(--pw-orange);
    outline-offset: 2px;
    border-radius: 1px;
}

strong {
    font-weight: 700;
}

.small {
    font-size: 0.95rem;
    color: var(--pw-text-muted);
}

h2,
h3 {
    scroll-margin-top: 1.25rem;
    line-height: 1.3;
    text-wrap: balance;
}

h2 {
    margin: 2.75rem 0 1rem;
    padding-top: 1.25rem;
    border-top: 2px solid var(--pw-line);
    font-size: 1.375rem;
    font-weight: 700;
    color: var(--pw-text);
}

h3 {
    margin: 2.25rem 0 0.75rem;
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--pw-blue-light);
}

h2 .num,
h3 .num {
    font-family: var(--pw-font-pixel);
    font-weight: 400;
    color: var(--pw-orange);
    margin-right: 0.45em;
}

h2 .num {
    font-size: 0.8em;
}

h3 .num {
    font-size: 0.7em;
}

/* --- Summary card ("Das Wichtigste in Kürze") --- */
.summary {
    margin: 0 0 2rem;
    padding: 1.1rem 1.25rem 0.4rem;
    background: var(--pw-panel-raised);
    border: 1px solid var(--pw-line);
    border-top: 4px solid var(--pw-blue);
    border-radius: 4px;
}

.summary h2 {
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
}

/* --- Table of contents --- */
.toc {
    margin: 0 0 2rem;
    padding: 1rem 1.25rem;
    background: var(--pw-panel-raised);
    border: 1px solid var(--pw-line);
    border-radius: 4px;
    font-size: 0.95rem;
    line-height: 1.4;
}

.toc h2 {
    margin: 0 0 0.75rem;
    padding: 0;
    border: 0;
    font-family: var(--pw-font-pixel);
    font-size: 0.75rem;
    font-weight: 400;
    line-height: 1.5;
    text-transform: uppercase;
    color: var(--pw-orange);
}

.toc ol {
    margin: 0;
    padding: 0;
    list-style: none;
}

.toc li {
    margin: 0;
}

.toc ol ol {
    margin: 0.1rem 0 0.35rem 0.35rem;
    padding-left: 0.75rem;
    border-left: 1px solid var(--pw-line);
    font-size: 0.9rem;
}

.toc a {
    display: inline-block;
    padding: 0.2rem 0;
    color: var(--pw-text-muted);
    text-decoration: none;
}

.toc a:hover {
    color: var(--pw-blue-light);
    text-decoration: underline;
}

/* --- Facts per processing purpose (data, purpose, legal basis, ...) --- */
.facts {
    margin: 1rem 0 1.25rem;
    padding-left: 1rem;
    border-left: 2px solid rgba(255, 149, 0, 0.5);
}

.facts > div + div {
    margin-top: 0.9rem;
}

.facts dt {
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1.4;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--pw-orange);
}

.facts dd {
    margin: 0.15rem 0 0;
}

.facts dd > p,
.facts dd > ul {
    margin-bottom: 0.6rem;
}

.facts dd > :last-child {
    margin-bottom: 0;
}

/* --- Boxed notice (right to object, key actions) --- */
.callout {
    margin: 1.5rem 0;
    padding: 1rem 1.25rem 0.25rem;
    background: rgba(214, 40, 40, 0.08);
    border: 2px solid var(--pw-red);
    border-radius: 4px;
}

.callout h3 {
    margin-top: 0;
    color: var(--pw-text);
}

.callout--info {
    background: rgba(102, 178, 255, 0.07);
    border-color: var(--pw-blue-light);
}

/* --- Tables: a normal table on wide screens, stacked cards on phones --- */
.stack-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
    line-height: 1.5;
}

.stack-table th,
.stack-table td {
    padding: 0.6rem 0.7rem;
    border: 1px solid var(--pw-line);
    text-align: left;
    vertical-align: top;
}

.stack-table thead th {
    background: var(--pw-panel-raised);
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--pw-orange);
}

.stack-table tbody th {
    font-weight: 700;
}

/* Long German compounds ("Auftragsverarbeitungsbedingungen") must not push the
   table wider than the text column. */
@media (min-width: 48em) {
    .stack-table {
        table-layout: fixed;
    }

    .stack-table th,
    .stack-table td {
        -webkit-hyphens: auto;
        hyphens: auto;
        overflow-wrap: anywhere;
    }

    .stack-table thead th:nth-child(1) { width: 24%; }
    .stack-table thead th:nth-child(2) { width: 22%; }
    .stack-table thead th:nth-child(3) { width: 17%; }
    .stack-table thead th:nth-child(4) { width: 37%; }
}

@media (max-width: 47.99em) {
    .stack-table thead {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        clip-path: inset(50%);
        white-space: nowrap;
    }

    .stack-table,
    .stack-table tbody,
    .stack-table tr,
    .stack-table th,
    .stack-table td {
        display: block;
        width: 100%;
    }

    .stack-table tr {
        margin-bottom: 0.75rem;
        padding: 0.5rem 0.85rem;
        border: 1px solid var(--pw-line);
        border-radius: 4px;
    }

    .stack-table tbody th,
    .stack-table td {
        padding: 0.3rem 0;
        border: 0;
    }

    .stack-table [data-label]::before {
        content: attr(data-label);
        display: block;
        font-size: 0.7rem;
        font-weight: 700;
        letter-spacing: 0.08em;
        text-transform: uppercase;
        color: var(--pw-orange);
    }
}

/* --- Print: black on white, no navigation --- */
@media print {
    body {
        background: #FFFFFF;
        color: #000000;
        font-size: 10.5pt;
    }

    .toc {
        display: none;
    }

    .doc-panel {
        display: block;
        padding: 0;
        border: 0;
        background: none;
    }

    .doc-lead,
    .doc-body {
        max-width: none;
    }

    .h1-main,
    .h1-sub,
    h2,
    h3,
    h2 .num,
    h3 .num,
    .facts dt,
    .stack-table thead th,
    a {
        color: #000000;
    }

    .summary,
    .callout,
    .stack-table thead th {
        background: none;
    }
}
