/* =====================================================
   Legal Pages Styles + shared subpage chrome
   Originally for privatlivspolitik/handelsbetingelser/databehandleraftale,
   but .header-solid, .legal-breadcrumb and the .legal-section typography are
   deliberately reused by nearly every subpage (videnscenter guides, audience
   pages, om-os, kundehistorier), so this file loads site-wide by design.
   ===================================================== */

/* Header Solid Style (non-transparent for legal pages) */
.header-solid {
    background: var(--color-white);
    box-shadow: var(--shadow-sm);
}

/* Legal Page Layout */
.legal-page {
    padding: 170px 0 80px;
    min-height: 100vh;
    background: var(--color-bg);
}

.legal-header {
    margin-bottom: 40px;
}

.legal-breadcrumb {
    display: flex;
    align-items: center;
    /* long trails (Forside > Losninger > Infoskaerm til idraetscentre...)
       must wrap tidily on narrow phones instead of overflowing */
    flex-wrap: wrap;
    gap: 6px 12px;
    font-size: 0.9rem;
    color: var(--color-text-muted);
    margin-bottom: 16px;
}

@media (max-width: 480px) {
    .legal-breadcrumb {
        gap: 4px 8px;
        font-size: 0.85rem;
    }
}

.legal-breadcrumb a {
    color: var(--color-text-muted);
    text-decoration: none;
    transition: color var(--transition-fast);
}

.legal-breadcrumb a:hover {
    color: var(--color-blue);
}

.legal-breadcrumb i.fa-chevron-right {
    font-size: 0.7rem;
}

.legal-header h1 {
    font-size: 2.5rem;
    margin-bottom: 8px;
}

/* Balance the guide/blog post title so long headlines wrap into even lines
   instead of leaving an orphaned word on the last line. */
.legal-page:has(.vc-byline) .legal-header h1 {
    text-wrap: balance;
}

.legal-updated {
    color: var(--color-text-muted);
    font-size: 0.95rem;
    margin: 0;
}

/* Legal Content */
.legal-content {
    background: var(--color-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 48px;
    /* Cap the reading measure and centre the column so long legal/guide prose
       doesn't run to unreadable line-lengths on tablet/desktop. Wide enough
       that the 2-col grids and tables inside still breathe. */
    max-width: 940px;
    margin-left: auto;
    margin-right: auto;
}

/* On guide/blog posts the header (breadcrumb + title + byline) is constrained
   to the same 940px measure as the content column below and centred as a block,
   so it sits neatly above the container. Text inside stays left-aligned so its
   left edge lines up with the content column. */
.legal-page:has(.vc-byline) .legal-header {
    max-width: 940px;
    margin-left: auto;
    margin-right: auto;
}

/* Long unbreakable tokens (email addresses, URLs, inline code) must wrap
   rather than force horizontal scroll on the narrowest phones. */
.legal-section p,
.legal-section li,
.legal-info-box p,
.legal-highlight p,
.contact-method a,
.contact-method span {
    overflow-wrap: break-word;
    word-break: break-word;
}

/* Table of Contents */
.legal-toc {
    background: var(--color-bg);
    border-radius: var(--radius-md);
    padding: 24px 32px;
    margin-bottom: 40px;
    border-left: 4px solid var(--color-blue);
}

.legal-toc h2 {
    font-size: 1.1rem;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--color-text-primary);
}

.legal-toc h2 i {
    color: var(--color-blue);
}

.legal-toc ol {
    columns: 2;
    column-gap: 40px;
    padding-left: 20px;
    margin: 0;
}

.legal-toc li {
    margin-bottom: 8px;
    break-inside: avoid;
}

/* Un-numbered TOC entry: for a section that carries an icon instead of a step
   number (e.g. a deep-dive between the numbered steps). Hides the <ol> marker so
   the TOC numbering stays in sync with the section headings. */
.legal-toc li.legal-toc-nonum {
    list-style: none;
    margin-left: -20px;
}
.legal-toc li.legal-toc-nonum > a > i {
    margin-right: 4px;
    color: var(--color-blue);
}

.legal-toc a {
    color: var(--color-text-secondary);
    text-decoration: none;
    font-size: 0.95rem;
    transition: color var(--transition-fast);
}

.legal-toc a:hover {
    color: var(--color-blue);
}

/* Legal Sections */
.legal-section {
    margin-bottom: 48px;
    padding-bottom: 27px;
    border-bottom: 1px solid var(--color-border-light);
}

.legal-section:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.legal-section h2 {
    font-size: 1.5rem;
    margin-bottom: 20px;
    color: var(--color-text-primary);
    display: flex;
    align-items: center;
    gap: 12px;
}

.legal-section h2 .section-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    /* accessible variant: white on bright brand blue is only 2.46:1 */
    background: var(--color-blue-accessible);
    color: white;
    border-radius: 50%;
    font-size: 0.95rem;
    flex-shrink: 0;
}

.legal-section h3 {
    font-size: 1.15rem;
    margin: 28px 0 12px;
    color: var(--color-text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.legal-section h3 i {
    color: var(--color-blue);
    font-size: 1rem;
}

.legal-section h4 {
    font-size: 1.05rem;
    margin: 20px 0 10px;
    color: var(--color-text-primary);
}

.legal-section p {
    margin-bottom: 16px;
    line-height: 1.7;
}

.legal-section ul,
.legal-section ol {
    margin-bottom: 20px;
    padding-left: 24px;
}

.legal-section li {
    margin-bottom: 10px;
    line-height: 1.6;
    color: var(--color-text-secondary);
}

.legal-section li strong {
    color: var(--color-text-primary);
}

/* Info Box */
.legal-info-box {
    background: var(--color-bg);
    border-radius: var(--radius-md);
    padding: 20px 24px;
    margin: 20px 0;
    border: 1px solid var(--color-border);
}

.legal-info-box p {
    margin-bottom: 8px;
}

.legal-info-box p:last-child {
    margin-bottom: 0;
}

.legal-info-box i {
    color: var(--color-blue);
    margin-right: 8px;
}

/* Highlight Box */
.legal-highlight {
    background: var(--color-blue-light);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    margin: 20px 0;
    display: flex;
    align-items: flex-start;
    gap: 14px;
    border-left: 4px solid var(--color-blue);
}

.legal-highlight i {
    color: var(--color-blue);
    font-size: 1.2rem;
    margin-top: 2px;
}

.legal-highlight p {
    margin: 0;
    flex: 1;
    /* Explicit color: contexts like .section-header set muted gray on p,
       which is only 4.4:1 on the highlight tints - secondary passes on all. */
    color: var(--color-text-secondary);
}

/* Secondary note that sits underneath the highlight's main text, aligned with
   it (inside the same p) and at the same font size as the surrounding copy. */
.legal-highlight-note {
    display: block;
    margin-top: 6px;
    color: var(--color-text-muted);
}

.legal-highlight.green {
    background: var(--color-green-light);
    border-left-color: var(--color-green);
}

.legal-highlight.green i {
    color: var(--color-green);
}

.legal-highlight.yellow {
    background: var(--color-yellow-light);
    border-left-color: var(--color-yellow);
}

.legal-highlight.yellow i {
    color: var(--color-yellow);
}

/* Legal Tables */
.legal-table-wrapper {
    overflow-x: auto;
    margin: 20px 0;
    /* Anchor for the mobile right-edge scroll fade (::after) below. */
    position: relative;
}

.legal-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

/* On narrow screens the 100%-wide table would squeeze into unreadable
   slivers; a minimum width makes the wrapper scroll horizontally instead. */
.legal-table-wrapper .legal-table {
    min-width: 560px;
}

.legal-table thead {
    background: var(--color-text-primary);
    color: white;
}

.legal-table th {
    padding: 14px 16px;
    text-align: left;
    font-weight: 600;
}

.legal-table thead th:first-child {
    border-radius: var(--radius-md) 0 0 0;
}

.legal-table thead th:last-child {
    border-radius: 0 var(--radius-md) 0 0;
}

.legal-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--color-border-light);
    color: var(--color-text-secondary);
}

/* Row headers (th scope="row") look like body cells, just emphasised */
.legal-table tbody th {
    border-bottom: 1px solid var(--color-border-light);
    color: var(--color-text-primary);
}

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

.legal-table tr:nth-child(even) {
    background: var(--color-bg);
}

.legal-table code {
    background: rgba(0,0,0,0.06);
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.85em;
}

/* Purpose Grid */
.legal-purpose-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin: 24px 0;
}

.legal-purpose-card {
    background: var(--color-bg);
    border-radius: var(--radius-md);
    padding: 24px;
    text-align: center;
    border: 1px solid var(--color-border-light);
    transition: all var(--transition-normal);
}

.legal-purpose-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}

.purpose-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    color: white;
    margin: 0 auto 16px;
}

.purpose-icon.blue { background: var(--color-blue); }
.purpose-icon.green { background: var(--color-green); }
.purpose-icon.yellow { background: var(--color-yellow); }
.purpose-icon.red { background: var(--color-red); }

.legal-purpose-card h3,
.legal-purpose-card h4 {
    margin: 0 0 8px;
    font-size: 1.05rem;
}

.legal-purpose-card p {
    margin: 0;
    font-size: 0.9rem;
    color: var(--color-text-muted);
}

/* Legal Basis List */
.legal-basis-list {
    margin: 24px 0;
}

.legal-basis-item {
    background: var(--color-bg);
    border-radius: var(--radius-md);
    padding: 20px 24px;
    margin-bottom: 16px;
    border: 1px solid var(--color-border-light);
}

.legal-basis-item:last-child {
    margin-bottom: 0;
}

.basis-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 10px;
}

.basis-article {
    /* accessible variant: white on bright brand blue is only 2.46:1 */
    background: var(--color-blue-accessible);
    color: white;
    padding: 4px 12px;
    border-radius: var(--radius-pill);
    font-size: 0.8rem;
    font-weight: 600;
}

.basis-header h3,
.basis-header h4 {
    margin: 0;
    font-size: 1.05rem;
}

.legal-basis-item p {
    margin: 0;
    color: var(--color-text-secondary);
}

/* Security Grid */
.legal-security-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin: 24px 0;
}

.security-item {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 16px 20px;
    background: var(--color-bg);
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border-light);
}

.security-item i {
    font-size: 1.3rem;
    color: var(--color-green);
    margin-top: 2px;
}

.security-item strong {
    display: block;
    margin-bottom: 4px;
    color: var(--color-text-primary);
}

.security-item p {
    margin: 0;
    font-size: 0.9rem;
    color: var(--color-text-muted);
}

/* Rights List */
.legal-rights-list {
    margin: 24px 0;
}

.right-item {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 20px 0;
    border-bottom: 1px solid var(--color-border-light);
}

.right-item:first-child {
    padding-top: 0;
}

.right-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.right-icon {
    width: 48px;
    height: 48px;
    min-width: 48px;
    background: var(--color-blue-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-blue);
    font-size: 1.1rem;
}

.right-content h3,
.right-content h4 {
    margin: 0 0 6px;
    font-size: 1.05rem;
}

.right-content p {
    margin: 0;
    color: var(--color-text-secondary);
}

/* Contact Box */
.legal-contact-box {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-top: 24px;
}

.contact-method {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 20px;
    background: var(--color-bg);
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border-light);
}

.contact-method i {
    font-size: 1.3rem;
    color: var(--color-blue);
    margin-top: 2px;
}

.contact-method strong {
    display: block;
    margin-bottom: 4px;
    color: var(--color-text-primary);
}

.contact-method a,
.contact-method span {
    color: var(--color-text-secondary);
    font-size: 0.95rem;
}

.contact-method a:hover {
    color: var(--color-blue);
}

/* Responsive Styles */
@media (max-width: 768px) {
    .legal-page {
        padding: 120px 0 60px;
    }
    
    .legal-content {
        padding: 32px 24px;
    }
    
    .legal-header h1 {
        font-size: 2rem;
    }
    
    .legal-toc ol {
        columns: 1;
    }
    
    .legal-contact-box {
        grid-template-columns: 1fr;
    }

    .legal-section h2 {
        font-size: 1.3rem;
    }

    /* Tables scroll horizontally on phones anyway, so a slightly larger font
       costs no layout and keeps comparison/price values above the 14px
       primary-content threshold (0.9rem = 14.4px). */
    .legal-table {
        font-size: 0.9rem;
    }

    .legal-table th,
    .legal-table td {
        padding: 10px 12px;
    }

    /* -----------------------------------------------------------------
       Mobile wide-table handling (shared by legal pages, videnscenter
       guides and integration/audience data tables — all use the same
       .legal-table-wrapper > .legal-table markup).

       Problem: min-width:560px made 3/4-col tables clip their right
       columns at the viewport edge with NO scroll cue, so prices,
       comparison answers and link columns were silently unreachable.

       Fix (one coherent solution):
       1. Lower min-width 560->460px so 2-col tables fit the ~342px
          content area (or nearly so) instead of hard-clipping, and
          wide tables don't cut headers mid-word as aggressively.
       2. Make the first column (the row label) sticky so it stays
          visible while the value columns scroll — the biggest win.
       3. Add a persistent thin scrollbar + a right-edge fade so users
          can SEE that more columns exist to the right.
       ----------------------------------------------------------------- */

    /* 1. Narrower minimum: lets short 2-col tables reflow to the
       viewport; wide tables still scroll but clip less. */
    .legal-table-wrapper .legal-table {
        min-width: 460px;
    }

    /* 3a. Persistent thin scrollbar as an affordance (Firefox + WebKit). */
    .legal-table-wrapper {
        scrollbar-width: thin;
        scrollbar-color: var(--color-border) transparent;
        -webkit-overflow-scrolling: touch;
    }
    .legal-table-wrapper::-webkit-scrollbar {
        height: 6px;
    }
    .legal-table-wrapper::-webkit-scrollbar-thumb {
        background: var(--color-border);
        border-radius: 3px;
    }
    .legal-table-wrapper::-webkit-scrollbar-track {
        background: transparent;
    }

    /* 3b. Right-edge fade signalling "more content to the right". Done with
       mask-image like the front-page comparison table: a mask pins to the
       element's VISIBLE box, whereas an absolutely-positioned ::after is
       anchored to the scrolled content and rides along while you swipe. */
    .legal-table-wrapper {
        -webkit-mask-image: linear-gradient(to right, #000 90%, transparent 100%);
                mask-image: linear-gradient(to right, #000 90%, transparent 100%);
    }

    /* 2. Sticky first column so the row label stays put while the
       value/comparison columns scroll. First-column markup is
       inconsistent across tables — guides use th[scope=row], some
       legal tables use td:first-child, others plain th — so cover all. */
    .legal-table tbody th,
    .legal-table tbody td:first-child,
    .legal-table thead th:first-child {
        position: sticky;
        left: 0;
        z-index: 1;
    }
    /* Body first-cell needs an opaque bg or scrolling text shows through.
       Match the zebra striping: default rows sit on white, even rows on
       --color-bg, so even-row first cells get the same tint. */
    .legal-table tbody th,
    .legal-table tbody td:first-child {
        background: var(--color-white);
    }
    .legal-table tr:nth-child(even) th,
    .legal-table tr:nth-child(even) td:first-child {
        background: var(--color-bg);
    }
    /* The thead first cell has the dark header background — keep it dark
       when sticky so it doesn't flash white over the scrolling headers. */
    .legal-table thead th:first-child {
        background: var(--color-text-primary);
        z-index: 2;
    }

    /* Roomier reading on phones/tablet: slightly taller lines and clearer
       paragraph separation for long legal copy. */
    .legal-section p,
    .legal-section li {
        line-height: 1.75;
    }

    .legal-section p {
        margin-bottom: 18px;
    }

    /* TOC anchors become comfortable tap targets when the list is single
       column on mobile. */
    .legal-toc a {
        display: block;
        padding: 8px 0;
        min-height: 44px;
    }

    .legal-toc li {
        margin-bottom: 0;
    }
}

/* Purpose/security cards stay 2-up on tablet (down to ~600px) so a single
   short card doesn't stretch full-width with a detached centred icon; they
   only collapse to one column on true phones. .legal-contact-box keeps its
   768px collapse (handled above). */
@media (max-width: 600px) {
    .legal-purpose-grid,
    .legal-security-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .legal-content {
        padding: 24px 20px;
    }

    /* Give the guide byline a little right breathing room so the wrapped
       credential line ("...udvikler af KlubKlar") isn't flush to the frame. */
    .vc-byline {
        padding-right: 8px;
    }

    /* Tighten the mobile min-width further on the smallest phones so 2-col
       legal/guide tables (Ydelse/Pris, Afstand/Størrelse, Post/Beløb) reflow
       to the viewport instead of scrolling; wide 3/4-col tables still scroll
       with the sticky column + fade + scrollbar cue from the 768px block. */
    .legal-table-wrapper .legal-table {
        min-width: 420px;
    }
    
    .legal-toc {
        padding: 20px;
    }
    
    .right-item {
        flex-direction: column;
        gap: 12px;
    }
    
    .right-icon {
        width: 44px;
        height: 44px;
        min-width: 44px;
    }
    
    .basis-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    /* Numbered section headings: the number circle centers against the
       heading (top-aligning it looked off on one-line headings; centered
       reads fine on wrapped two-liners too). */
    .legal-section h2 {
        align-items: center;
        gap: 10px;
    }

    .legal-section h2 .section-number {
        width: 32px;
        height: 32px;
        font-size: 0.9rem;
    }
}

/* =====================================================
   Print Styles - Prevent page break issues in PDFs
   ===================================================== */
@media print {
    /* Hide non-essential elements */
    .header,
    .footer,
    .legal-breadcrumb,
    .mobile-menu-toggle,
    .nav-cta {
        display: none !important;
    }

    /* Reset page layout */
    .legal-page {
        padding: 0;
        min-height: auto;
        background: white;
    }

    .legal-content {
        box-shadow: none;
        padding: 20px;
        max-width: 100%;
    }

    /* Prevent sections from being cut */
    .legal-section {
        page-break-inside: avoid;
        break-inside: avoid;
    }

    /* For longer sections, allow break but keep headers with content */
    .legal-section h2,
    .legal-section h3,
    .legal-section h4 {
        page-break-after: avoid;
        break-after: avoid;
    }

    /* Keep info boxes together */
    .legal-info-box,
    .legal-highlight,
    .legal-contact-box,
    .legal-basis-item,
    .right-item,
    .security-item,
    .legal-purpose-card {
        page-break-inside: avoid;
        break-inside: avoid;
    }

    /* Keep tables together when possible */
    .legal-table-wrapper {
        page-break-inside: avoid;
        break-inside: avoid;
    }

    /* Keep table rows together */
    .legal-table tr {
        page-break-inside: avoid;
        break-inside: avoid;
    }

    /* Add some spacing before new sections for cleaner breaks */
    .legal-section {
        padding-top: 15px;
    }

    /* Ensure grids don't break awkwardly */
    .legal-security-grid,
    .legal-purpose-grid,
    .legal-rights-list,
    .legal-basis-list {
        page-break-inside: avoid;
        break-inside: avoid;
    }

    /* Force page break before TOC and first section if needed */
    .legal-toc {
        page-break-after: avoid;
        break-after: avoid;
    }

    /* Link styling for print */
    a {
        text-decoration: none;
        color: inherit;
    }

    /* Ensure proper sizing */
    body {
        font-size: 11pt;
        line-height: 1.5;
    }

    .legal-header h1 {
        font-size: 24pt;
    }

    .legal-section h2 {
        font-size: 14pt;
    }

    .legal-section h3 {
        font-size: 12pt;
    }
}

/* Links inside legal/guide prose must not rely on color alone to be
   distinguishable (WCAG 1.4.1 / Lighthouse link-in-text-block). .legal-section
   is included because the guide subpages reuse it without a .legal-content
   wrapper. The TOC keeps its own muted non-underlined style (more specific
   .legal-toc a rule wins on color; restore its no-underline explicitly). */
.legal-content p a,
.legal-content li a,
.legal-section p a,
.legal-section li a {
    text-decoration: underline;
    text-underline-offset: 2px;
}

.legal-toc li a {
    text-decoration: none;
}

/* Highlights inside centered section headers (e.g. priser hero): the row
   layout leaves the icon floating left of centered text — stack it on top */
@media (max-width: 900px) {
    .section-header .legal-highlight {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 10px;
    }
}

/* Breadcrumbs center on mobile AND tablet on the landing pages — scoped to
   <=900 to MATCH where the two-column heroes stack and center (at 901-1024
   they are still side-by-side and left-aligned, and a centered breadcrumb
   over a left hero reads as a glitch). Pages whose hero centers wider carry
   their own rule (om-os). Article headers (.legal-header on guides + legal
   docs) stay left-aligned to match their left-aligned h1/byline. */
@media (max-width: 900px) {
    .legal-breadcrumb {
        justify-content: center;
    }

    .legal-header .legal-breadcrumb {
        justify-content: flex-start;
    }
}

/* Same explicit swipe hint as the front-page comparison table: the fade +
   thin scrollbar alone proved too subtle. CSS-generated so every guide/legal
   table gets it without markup edits; <=600 is where the 560px-min tables
   always overflow. (Contexts whose tables don't scroll disable it.) */
@media (max-width: 768px) {
    /* With the scroll + swipe-hint in place the table may be wide: cells that
       are purely a link ("ForeningLet + infoskaerm ->") keep one line instead
       of wrapping word-per-line; prose cells still wrap normally */
    .legal-table td > a:only-child {
        white-space: nowrap;
    }
}

@media (max-width: 600px) {
    .legal-table-wrapper::before {
        content: "Stryg til siden for at se hele skemaet →";
        display: block;
        text-align: center;
        font-size: 0.85rem;
        font-weight: 600;
        color: var(--color-text-muted);
        margin-bottom: 10px;
    }
}
