/* legal-viewer — editorial layout
 *
 * Type stack is system-only (no external font requests) so a legal-document
 * viewer makes zero third-party network calls. Charter / Iowan Old Style /
 * Cambria render well across macOS, iOS, and Windows; Linux falls back to
 * Georgia which is acceptable.
 *
 * Color, spacing, and rhythm do the heavy aesthetic lifting; the per-product
 * --lv-brand variable is used sparingly (links, breadcrumb, brand mark).
 */

:root {
    --lv-bg: #fdfdfc;
    --lv-surface: #f7f6f3;
    --lv-ink: #1c1917;
    --lv-ink-soft: #44403c;
    --lv-muted: #78716c;
    --lv-rule: #e7e5e0;
    --lv-rule-strong: #d6d3ce;
    --lv-brand: #1f6feb;
    --lv-radius: 6px;
    --lv-measure: 68ch;
    --lv-content-max: 1180px;
    --lv-font-sans: -apple-system, "Segoe UI Variable Display", "Segoe UI", Inter, Roboto, system-ui, sans-serif;
    --lv-font-serif: Charter, "Iowan Old Style", "Source Serif 4", "Source Serif Pro", "Sitka Text", Cambria, Georgia, serif;
    --lv-font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

[data-product="uptimia"]    { --lv-brand: #0369a1; }
[data-product="datriva"]    { --lv-brand: #4f46e5; }
[data-product="helpcanvas"] { --lv-brand: #0d9488; }
[data-product="productlog"] { --lv-brand: #c2410c; }
[data-product="eubuilt"]    { --lv-brand: #003399; }
[data-product="calcprism"]  { --lv-brand: #2e5d4e; }

* { box-sizing: border-box; }

html { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
html, body {
    margin: 0;
    padding: 0;
    background: var(--lv-bg);
    color: var(--lv-ink);
    font-family: var(--lv-font-sans);
    font-size: 16px;
    line-height: 1.6;
}

a { color: var(--lv-brand); text-decoration: none; }
a:hover { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }

::selection { background: color-mix(in srgb, var(--lv-brand) 18%, transparent); }

/* ---------- Header ---------- */

.lv-header {
    border-bottom: 1px solid var(--lv-rule);
    background: var(--lv-bg);
    position: sticky;
    top: 0;
    z-index: 10;
    backdrop-filter: saturate(180%) blur(6px);
    background: color-mix(in srgb, var(--lv-bg) 92%, transparent);
}
.lv-header__inner {
    max-width: var(--lv-content-max);
    margin: 0 auto;
    padding: 16px 32px;
    display: flex;
    align-items: center;
    gap: 24px;
}
.lv-brand {
    display: inline-flex;
    align-items: center;
    color: var(--lv-ink);
    line-height: 0;
}
.lv-brand img {
    /* Default. Per-product overrides below for logos whose intrinsic glyph
       reads smaller at the same pixel height (Datriva, HelpCanvas). */
    height: 28px;
    width: auto;
    display: block;
}
[data-product="uptimia"]    .lv-brand img { height: 24px; }
[data-product="datriva"]    .lv-brand img { height: 32px; }
[data-product="helpcanvas"] .lv-brand img { height: 32px; }
[data-product="productlog"] .lv-brand img { height: 26px; }
[data-product="eubuilt"]    .lv-brand img { height: 28px; }
[data-product="calcprism"]  .lv-brand img { height: 28px; }
.lv-nav { flex: 1; }
.lv-nav__link {
    color: var(--lv-muted);
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.01em;
}
.lv-nav__link:hover { color: var(--lv-ink); text-decoration: none; }

/* ---------- Language switcher ---------- */

.lv-langswitch { position: relative; }
.lv-langswitch summary {
    cursor: pointer;
    list-style: none;
    padding: 7px 12px 7px 14px;
    border: 1px solid var(--lv-rule);
    border-radius: var(--lv-radius);
    font-size: 13px;
    font-weight: 500;
    color: var(--lv-ink-soft);
    background: var(--lv-bg);
    transition: border-color 0.15s, color 0.15s;
}
.lv-langswitch summary:hover { border-color: var(--lv-rule-strong); color: var(--lv-ink); }
.lv-langswitch summary::-webkit-details-marker { display: none; }
.lv-langswitch summary::after {
    content: "";
    display: inline-block;
    width: 6px;
    height: 6px;
    margin-left: 8px;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: rotate(45deg) translate(-2px, -2px);
    vertical-align: middle;
    opacity: 0.6;
}
.lv-langswitch ul {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    background: var(--lv-bg);
    border: 1px solid var(--lv-rule);
    border-radius: var(--lv-radius);
    padding: 6px 0;
    margin: 0;
    list-style: none;
    min-width: 180px;
    box-shadow: 0 12px 28px -8px rgba(20, 18, 14, 0.16), 0 2px 6px rgba(20, 18, 14, 0.05);
    /* Many products ship 20+ languages — cap the menu height and scroll so it
       never runs off the bottom of the viewport. */
    max-height: min(70vh, 460px);
    overflow-y: auto;
    overscroll-behavior: contain;
}
.lv-langswitch li { padding: 0; }
.lv-langswitch li a,
.lv-langswitch li span {
    display: block;
    padding: 8px 16px;
    color: var(--lv-ink-soft);
    font-size: 13px;
    font-weight: 500;
}
.lv-langswitch li a:hover { background: var(--lv-surface); color: var(--lv-ink); text-decoration: none; }
.lv-langswitch li.is-active a { color: var(--lv-brand); }
.lv-langswitch li.is-active a::before {
    content: "✓";
    display: inline-block;
    width: 14px;
    margin-right: 6px;
    margin-left: -4px;
}
.lv-langswitch li.is-unavailable span { color: var(--lv-muted); cursor: default; }
.lv-langswitch li.is-unavailable span::after {
    content: "translation pending";
    display: block;
    font-size: 11px;
    color: var(--lv-muted);
    font-weight: 400;
    text-transform: lowercase;
}

/* ---------- Main + container ---------- */

.lv-main { padding: 56px 0 96px; }
.lv-container {
    max-width: var(--lv-content-max);
    margin: 0 auto;
    padding: 0 32px;
}
.lv-container--narrow { max-width: 720px; }

/* ---------- Index page ---------- */

.lv-container--narrow h1 {
    font-family: var(--lv-font-serif);
    font-size: 44px;
    line-height: 1.1;
    letter-spacing: -0.01em;
    margin: 0 0 12px;
    font-weight: 600;
}
.lv-lede {
    color: var(--lv-muted);
    font-size: 18px;
    line-height: 1.55;
    margin: 0 0 40px;
    max-width: 52ch;
}
.lv-doclist {
    list-style: none;
    padding: 0;
    margin: 0;
    border-top: 1px solid var(--lv-rule);
}
.lv-doclist li {
    border-bottom: 1px solid var(--lv-rule);
}
.lv-doclist li a {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 4px;
    color: var(--lv-ink);
    transition: padding 0.2s;
}
.lv-doclist li a:hover { padding-left: 8px; text-decoration: none; }
.lv-doclist li a strong {
    font-family: var(--lv-font-serif);
    font-size: 19px;
    font-weight: 600;
    letter-spacing: -0.005em;
}
.lv-doclist__langs { display: flex; gap: 6px; }
.lv-chip {
    font-size: 11px;
    font-weight: 500;
    padding: 3px 9px;
    border-radius: 999px;
    background: var(--lv-surface);
    color: var(--lv-muted);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

/* ---------- Document page ---------- */

.lv-container--doc { max-width: var(--lv-content-max); }

.lv-breadcrumb {
    color: var(--lv-muted);
    font-size: 13px;
    margin: 0 0 20px;
    letter-spacing: 0.01em;
}
.lv-breadcrumb a { color: var(--lv-muted); }
.lv-breadcrumb a:hover { color: var(--lv-ink); }

.lv-doc__header {
    margin-bottom: 48px;
    padding-bottom: 32px;
    border-bottom: 1px solid var(--lv-rule);
}
.lv-doc__header h1 {
    font-family: var(--lv-font-serif);
    font-size: 52px;
    line-height: 1.05;
    letter-spacing: -0.015em;
    font-weight: 600;
    margin: 0 0 16px;
    color: var(--lv-ink);
}
.lv-doc__meta {
    color: var(--lv-muted);
    font-size: 13px;
    margin: 0;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}
.lv-doc__meta span + span { margin-left: 16px; }

.lv-doc__layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 48px;
}
@media (min-width: 980px) {
    .lv-doc__layout {
        grid-template-columns: 240px minmax(0, 1fr);
        gap: 80px;
    }
    .lv-toc {
        position: sticky;
        top: 92px;
        align-self: start;
        max-height: calc(100vh - 120px);
        overflow-y: auto;
        padding-right: 8px;
    }
}

/* ---------- Table of contents ---------- */

.lv-toc { font-size: 13.5px; }
.lv-toc__title {
    font-family: var(--lv-font-sans);
    font-size: 11px;
    font-weight: 600;
    color: var(--lv-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin: 0 0 16px;
}
.lv-toc ul {
    list-style: none;
    padding: 0;
    margin: 0;
}
.lv-toc li {
    padding: 5px 0;
    line-height: 1.4;
}
.lv-toc li.lv-toc__l3 {
    padding-left: 14px;
    font-size: 13px;
}
.lv-toc a {
    color: var(--lv-ink-soft);
    transition: color 0.1s;
    display: block;
}
.lv-toc a:hover { color: var(--lv-brand); text-decoration: none; }

/* ---------- Article body ---------- */

.lv-doc__body {
    font-family: var(--lv-font-serif);
    font-size: 18px;
    line-height: 1.7;
    color: var(--lv-ink);
    max-width: var(--lv-measure);
}

.lv-doc__body p { margin: 18px 0; }

.lv-doc__body h2,
.lv-doc__body h3,
.lv-doc__body h4 {
    font-family: var(--lv-font-serif);
    color: var(--lv-ink);
    letter-spacing: -0.005em;
    font-weight: 600;
}
.lv-doc__body h2 {
    font-size: 28px;
    line-height: 1.2;
    margin: 64px 0 16px;
    padding-top: 32px;
    border-top: 1px solid var(--lv-rule);
}
.lv-doc__body > h2:first-child { border-top: none; padding-top: 0; margin-top: 0; }
.lv-doc__body h3 {
    font-size: 21px;
    line-height: 1.3;
    margin: 40px 0 12px;
}
.lv-doc__body h4 {
    font-size: 17px;
    line-height: 1.4;
    margin: 28px 0 8px;
    font-family: var(--lv-font-sans);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--lv-ink-soft);
}

.lv-doc__body ul,
.lv-doc__body ol { padding-left: 28px; margin: 18px 0; }
.lv-doc__body li { margin: 8px 0; }
.lv-doc__body li::marker { color: var(--lv-muted); }

.lv-doc__body strong { font-weight: 600; color: var(--lv-ink); }
.lv-doc__body em { font-style: italic; }

.lv-doc__body code {
    font-family: var(--lv-font-mono);
    background: var(--lv-surface);
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 0.88em;
    color: var(--lv-ink-soft);
}
.lv-doc__body pre {
    font-family: var(--lv-font-mono);
    background: var(--lv-surface);
    padding: 16px 20px;
    border-radius: var(--lv-radius);
    overflow-x: auto;
    font-size: 14px;
    line-height: 1.55;
    border: 1px solid var(--lv-rule);
    margin: 24px 0;
}

.lv-doc__body blockquote {
    border-left: 3px solid var(--lv-brand);
    padding: 4px 0 4px 24px;
    color: var(--lv-ink-soft);
    margin: 28px 0;
    font-style: italic;
}

.lv-doc__body hr {
    border: none;
    border-top: 1px solid var(--lv-rule);
    margin: 48px 0;
}

/* ---------- Tables ---------- */

.lv-doc__body table {
    border-collapse: collapse;
    margin: 28px 0;
    width: 100%;
    font-family: var(--lv-font-sans);
    font-size: 14.5px;
    line-height: 1.5;
}
.lv-doc__body thead { background: var(--lv-surface); }
.lv-doc__body th,
.lv-doc__body td {
    text-align: left;
    padding: 12px 16px;
    border-bottom: 1px solid var(--lv-rule);
    vertical-align: top;
}
.lv-doc__body th {
    font-weight: 600;
    color: var(--lv-ink);
    border-bottom: 1px solid var(--lv-rule-strong);
    font-size: 12.5px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.lv-doc__body tbody tr:hover { background: color-mix(in srgb, var(--lv-surface) 60%, transparent); }
.lv-doc__body table code { background: transparent; padding: 0; }

/* ---------- Heading permalink anchor ----------
 *
 * The heading-permalink extension prepends an `<a class="heading-permalink">#</a>`
 * inside each H2/H3/H4. Left in normal flow it shifts the heading text rightward
 * (visually indenting it), so we absolute-position it into the left gutter on
 * wide viewports and hide it entirely on narrow screens where no gutter exists.
 */

@media (min-width: 980px) {
    .lv-doc__body h2,
    .lv-doc__body h3,
    .lv-doc__body h4 { position: relative; }

    .lv-doc__body .heading-permalink {
        position: absolute;
        left: -1.4em;
        top: 0;
        line-height: inherit;
        font-size: 0.7em;
        font-weight: 400;
        color: var(--lv-rule-strong);
        text-decoration: none;
        opacity: 0;
        transition: opacity 0.15s;
    }
    .lv-doc__body h2:hover .heading-permalink,
    .lv-doc__body h3:hover .heading-permalink,
    .lv-doc__body h4:hover .heading-permalink { opacity: 1; }
    .lv-doc__body .heading-permalink:hover { color: var(--lv-brand); }
}

@media (max-width: 979px) {
    .lv-doc__body .heading-permalink { display: none; }
}

/* ---------- Footer (page-level) ---------- */

.lv-doc__footer {
    margin-top: 64px;
    padding-top: 24px;
    border-top: 1px solid var(--lv-rule);
}
.lv-source { color: var(--lv-muted); font-size: 12px; font-family: var(--lv-font-mono); margin: 0; }

.lv-footer {
    border-top: 1px solid var(--lv-rule);
    padding: 32px 0;
    color: var(--lv-muted);
    font-size: 13px;
    margin-top: 64px;
}
.lv-footer__inner {
    max-width: var(--lv-content-max);
    margin: 0 auto;
    padding: 0 32px;
    display: flex;
    justify-content: space-between;
    gap: 16px;
}
.lv-footer a { color: var(--lv-muted); }
.lv-footer a:hover { color: var(--lv-ink); }

.lv-empty { color: var(--lv-muted); padding: 32px 0; }

/* ---------- Responsive ---------- */

@media (max-width: 720px) {
    .lv-container, .lv-header__inner, .lv-footer__inner { padding-left: 20px; padding-right: 20px; }
    .lv-doc__header h1 { font-size: 38px; }
    .lv-container--narrow h1 { font-size: 34px; }
    .lv-doc__body { font-size: 17px; }
    .lv-doc__body h2 { font-size: 24px; margin-top: 48px; padding-top: 24px; }
    .lv-doc__body h3 { font-size: 19px; }
    .lv-main { padding: 32px 0 64px; }
}
