/* ========== 
   Base (screen + print)
   ========== */

:root {
    --fg: #222;
    --fg-muted: #555; /* improved contrast */
    --bg: #fff;
    --accent: #0f62fe;
    --border: #e8e8e8;
    --maxw: 56.25rem; /* 900px in rem (16px base) */
    --space-1: 0.375rem; /* 6px */
    --space-2: 0.625rem; /* 10px */
    --space-3: 1rem; /* 16px */
    --space-4: 1.5rem; /* 24px */
    --radius: 0.625rem; /* 10px */
    --line: 1.55;
}

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

html, body {
    height: 100%;
    background: var(--bg);
    color: var(--fg);
    font-family: Segoe UI, Roboto, Helvetica, Arial, sans-serif;
    line-height: var(--line);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-wrap: break-word; /* modern replacement for word-wrap */
}

body {
    margin: var(--space-4);
}

/* ========== 
   Controls (screen)
   ========== */

.controls {
    margin: 0 0 var(--space-3);
    padding: 0 0 var(--space-2);
    border-bottom: 1px solid var(--border);
    font-family: inherit; /* ensure consistent font */
}

    .controls label {
        font-weight: 600;
    }

    .controls input[type=file] {
        display: inline-block;
        margin-left: var(--space-2);
    }

    .controls button {
        margin-left: var(--space-2);
        padding: 0.5rem 0.75rem; /* 8px 12px */
        border-radius: var(--radius);
        border: 1px solid var(--border);
        background: #fafafa;
        cursor: pointer;
        transition: background-color 0.3s ease, border-color 0.3s ease;
    }

        .controls button:focus-visible,
        .controls button:hover {
            background-color: var(--accent);
            border-color: var(--accent);
            color: #fff;
            outline-offset: 3px;
            outline: 2px solid var(--accent);
        }

    .controls .muted {
        color: var(--fg-muted);
    }

/* ========== 
   Resume container
   ========== */

.resume {
    max-width: var(--maxw);
    margin: 0 auto;
    padding: 0 var(--space-1);
    overflow-wrap: break-word;
}

/* Header top area */

header {
    display: grid;
    grid-template-columns: 7.5rem 1fr; /* 120px base */
    gap: var(--space-3);
    align-items: center;
    margin-bottom: var(--space-4);
    padding-bottom: var(--space-3);
    border-bottom: 1px solid var(--border);
}

.photo {
    width: 7.5rem; /* 120px */
    height: 7.5rem;
    object-fit: cover;
    border-radius: 0.75rem; /* slightly more consistent rounding with 12px */
    border: 1px solid var(--border);
}

.info h1 {
    font-size: 1.8rem;
    margin: 0 0 0.25rem 0;
}

.muted {
    color: var(--fg-muted);
}

.contact {
    margin-top: 0.25rem;
    font-size: 0.95rem;
}

.profiles {
    margin-top: 0.375rem;
}

    .profiles a {
        color: var(--accent);
        text-decoration: none;
        border-bottom: 1px solid transparent;
        transition: border-color 0.3s ease;
    }

        .profiles a:hover,
        .profiles a:focus-visible {
            border-color: var(--accent);
            outline-offset: 3px;
            outline: 2px solid var(--accent);
        }

/* Summary */

.summary {
    /* retain existing margins (if any from HTML) */
    padding: var(--space-3);
    border: 1px solid var(--border);
    border-left: 0.3125rem solid var(--accent); /* 5px */
    border-radius: var(--radius);
    font-size: 1.06rem; /* slightly larger */
    line-height: var(--line);
    background: rgba(15, 98, 254, 0.06); /* fallback */
    background: color-mix(in oklab, var(--accent) 8%, white);
    box-shadow: 0 1px 0 rgba(0,0,0,0.03);
    transition: background-color 0.3s ease;
}

    .summary > p:first-child {
        margin-top: 0;
        font-weight: 600;
    }

    .summary a {
        border-bottom-color: rgba(15,98,254,0.5);
    }

    .summary strong {
        font-weight: 700;
    }

    .summary em {
        font-style: italic;
        opacity: 0.9;
    }

/* Sections */

.section {
    margin: 0 0 var(--space-4);
    padding: 0 0 var(--space-3);
    border-bottom: 1px solid var(--border);
}

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

    .section > h2 {
        font-size: 1.25rem;
        margin: 0 0 var(--space-2);
        border-left: 0.25rem solid var(--accent); /* 4px */
        padding-left: 0.625rem; /* 10px */
    }

.item {
    margin: 0 0 var(--space-3);
    break-inside: avoid;
    page-break-inside: avoid;
}

    .item h3 {
        margin: 0 0 0.25rem 0;
        font-size: 1.05rem;
    }

    .item .muted {
        margin: 0.125rem 0 0.375rem;
    }

    .item p {
        margin: 0.375rem 0;
    }

    .item ul {
        margin: 0.375rem 0 0 1.2em;
        padding: 0;
    }

        .item ul li {
            margin: 0.1875rem 0;
        }

/* Links */

a {
    color: var(--accent);
    text-decoration: none;
    border-bottom: 1px solid rgba(15,98,254,0.35);
    transition: border-color 0.3s ease;
}

    a:hover,
    a:focus-visible {
        border-bottom-color: var(--accent);
        outline-offset: 3px;
        outline: 2px solid var(--accent);
    }

/* ========== 
   Responsive tweaks
   ========== */

@media (max-width: 40rem) { /* 640px */
    header {
        grid-template-columns: 1fr;
        text-align: left;
    }

    .photo {
        width: 6rem; /* 96px */
        height: 6rem;
    }

    body {
        margin: var(--space-3);
    }
}

/* ========== 
   Print styles
   ========== */

/* A4 portrait with narrow margins */
@page {
    size: A4 portrait;
    margin: 12mm;
}

/* Preserve colors in PDF/print */
html, body {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
}

/* Ingen vannmerke på skjerm */
@media screen {
    body.trial::before {
        content: none;
    }
}

/* Hide UI controls on print */

@media print {

    body.trial::before {
        content: "CVSmia Trial";
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%) rotate(-45deg); /* 45 grader */
        font-size: 60pt; /* store bokstaver – juster ved behov */
        font-weight: 700;
        color: rgba(180, 180, 180, 0.18); /* lys grå og gjennomsiktig */
        z-index: 9999;
        pointer-events: none;
        white-space: nowrap;
    }

    .controls {
        display: none !important;
    }

    body {
        margin: 0; /* Use @page margins */
        background: #fff;
    }

    .resume {
        max-width: none;
        padding: 0;
    }

    /* Avoid awkward page breaks */
    header,
    .section,
    .item {
        break-inside: auto !important;
        page-break-inside: auto !important;
    }

        /* Avoid section header alone at bottom */
        .section > h2 {
            break-after: avoid;
            page-break-after: avoid;
        }

    /* Slightly tighter typography for print */
    .info h1 {
        font-size: 1.6rem;
    }

    .section > h2 {
        font-size: 1.15rem;
    }

    .section {
        margin-top: 6mm;
    }

    .item h3 {
        font-size: 1rem;
    }

    /* Remove underline from links, keep color */
    a {
        border-bottom: none;
    }

    /* Allow natural page break after summary */
    .summary {
        margin-bottom: 10mm;
        page-break-after: auto;
        break-after: auto;
        box-shadow: none;
        background: #fff;
    }

    .summary--compact {
        padding: var(--space-2);
        border-left-width: 4px;
        font-size: 1.02rem;
        background: rgba(15, 98, 254, 0.04);
    }

    /* Optional: show URLs after links in print (uncomment to enable)
    a[href]::after {
      content: " (" attr(href) ")";
      font-size: 0.9em;
      color: var(--fg-muted);
    }
    */
}

/* ========== 
   Future: Dark mode support
   ========== */

@media (prefers-color-scheme: dark) {
    :root {
        --fg: #ddd;
        --fg-muted: #aaa;
        --bg: #121212;
        --border: #333;
        --accent: #58a6ff;
    }

    html, body {
        background: var(--bg);
        color: var(--fg);
    }

    .controls button {
        background: #222;
        border-color: var(--border);
        color: var(--fg);
    }

        .controls button:hover,
        .controls button:focus-visible {
            background-color: var(--accent);
            border-color: var(--accent);
            color: #fff;
        }

    .summary {
        background: color-mix(in oklab, var(--accent) 12%, var(--bg));
        border-left-color: var(--accent);
        box-shadow: 0 1px 4px rgba(0,0,0,0.5);
    }

    a, .profiles a {
        color: var(--accent);
        border-bottom-color: rgba(88,166,255,0.5);
    }

        a:hover,
        a:focus-visible,
        .profiles a:hover,
        .profiles a:focus-visible {
            border-bottom-color: var(--accent);
            outline-offset: 3px;
            outline: 2px solid var(--accent);
        }
}

/* --- Photo: skjul helt når mangler --- */
header.no-photo {
    grid-template-columns: 1fr; /* én kolonne */
}

    header.no-photo .photo {
        display: none;
    }

/* --- Initial-avatar fallback --- */
.avatar {
    width: 7.5rem;
    height: 7.5rem;
    display: grid;
    place-items: center;
    border-radius: 0.75rem;
    border: 1px solid var(--border);
    background: color-mix(in oklab, var(--accent) 10%, #fff);
    font-weight: 700;
    font-size: 2rem;
    color: var(--accent);
}

@media (max-width: 40rem) {
    .avatar {
        width: 6rem;
        height: 6rem;
        font-size: 1.6rem;
    }
}

