:root {
    --cv-brand-ink: #0b1728;
    --cv-brand-blue: #2f66b3;
    --cv-brand-sky: #4aa9e9;
    --cv-brand-warm: #f1c75b;
    --cv-paper: #fbfdff;
    --cv-paper-soft: #eef3fb;
    --cv-text: #1a2940;
    --cv-text-muted: #5f738f;
    --cv-line: rgba(25, 62, 116, 0.16);
}

.cv-lock-scroll {
    overflow: hidden;
}

.cv-lightbox {
    position: fixed;
    inset: 0;
    z-index: 120;
    display: none;
}

.cv-lightbox--open {
    display: block;
}

.cv-lightbox__backdrop {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 14% 18%, rgba(74, 169, 233, 0.24), transparent 38%),
        radial-gradient(circle at 86% 9%, rgba(47, 102, 179, 0.27), transparent 34%),
        rgba(2, 6, 20, 0.76);
    backdrop-filter: blur(8px);
}

.cv-lightbox__panel {
    position: relative;
    margin: 2vh auto;
    width: min(1160px, 96vw);
    height: min(96vh, 1100px);
    border-radius: 20px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, #071325 0%, #0b1728 100%);
    border: 1px solid rgba(148, 178, 216, 0.4);
    box-shadow: 0 24px 60px rgba(2, 10, 26, 0.62);
}

.cv-lightbox__toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid rgba(140, 170, 210, 0.32);
    background: rgba(5, 13, 26, 0.72);
    color: #edf5ff;
}

.cv-lightbox__toolbar h2 {
    margin: 0;
    font-size: 1.02rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    font-weight: 700;
}

.cv-lightbox__actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.cv-lightbox__action {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 0;
    border-radius: 11px;
    font-size: 0.86rem;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    transition: transform 0.16s ease, opacity 0.16s ease, box-shadow 0.2s ease;
}

.cv-lightbox__action:hover {
    transform: translateY(-1px);
}

.cv-lightbox__action:focus-visible {
    outline: 2px solid var(--cv-brand-warm);
    outline-offset: 2px;
}

.cv-lightbox__action--download {
    padding: 10px 13px;
    color: #f4f8ff;
    background: linear-gradient(115deg, #275494 0%, #3d8fd2 100%);
    box-shadow: 0 8px 20px rgba(61, 143, 210, 0.34);
}

.cv-lightbox__action--download[disabled] {
    cursor: wait;
    opacity: 0.72;
    transform: none;
}

.cv-lightbox__action--download svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.cv-lightbox__action--close {
    width: 36px;
    height: 36px;
    justify-content: center;
    font-size: 1.35rem;
    color: #d8e7fb;
    border: 1px solid rgba(165, 190, 223, 0.4);
    background: rgba(9, 20, 38, 0.72);
}

.cv-lightbox__scroll {
    overflow: auto;
    padding: 20px;
}

.cv-document {
    width: min(1000px, 100%);
    margin: 0 auto;
    padding: 2.1rem;
    color: var(--cv-text);
    border-radius: 17px;
    background: #ffffff 100%;
    font-family: "Segoe UI", "Trebuchet MS", "Helvetica Neue", sans-serif;
}

.cv-document a {
    color: var(--cv-brand-blue);
    text-decoration: none;
}

.cv-document a:hover {
    text-decoration: underline;
}

.cv-links-list a,
.cv-role a {
    overflow-wrap: anywhere;
    word-break: break-word;
}

.cv-document__header {
    display: grid;
    gap: 18px;
    border-bottom: 1px solid var(--cv-line);
    padding-bottom: 20px;
    margin-bottom: 24px;
}

.cv-document__top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
}

.cv-document__brand {
    display: grid;
    gap: 10px;
}

.cv-document__logo {
    width: min(260px, 58vw);
    height: auto;
    display: block;
}

.cv-document__brandline {
    margin: 0;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--cv-text-muted);
}

.cv-profile-placeholder {
    width: 126px;
    min-height: 154px;
    border: 2px dashed rgba(67, 108, 167, 0.52);
    border-radius: 14px;
    background:
        linear-gradient(170deg, rgba(249, 252, 255, 0.95), rgba(235, 243, 255, 0.95)),
        repeating-linear-gradient(
            -45deg,
            rgba(58, 111, 180, 0.06),
            rgba(58, 111, 180, 0.06) 10px,
            transparent 10px,
            transparent 20px
        );
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 10px;
    color: var(--cv-text-muted);
}

.cv-profile-placeholder span {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.cv-profile-placeholder small {
    margin-top: 4px;
    font-size: 0.72rem;
}

.cv-document__identity h1 {
    margin: 0;
    color: var(--cv-brand-ink);
    font-size: clamp(1.85rem, 3.2vw, 2.6rem);
    line-height: 1.08;
}

.cv-document__subtitle {
    margin: 8px 0 0;
    color: var(--cv-brand-blue);
    font-weight: 700;
    font-size: 1.1rem;
}

.cv-document__location {
    margin: 6px 0 0;
    color: var(--cv-text-muted);
    font-size: 0.93rem;
}

.cv-links-list,
.cv-contact-list {
    margin: 0;
    padding: 0;
    list-style: none;
    display: grid;
    gap: 7px 16px;
    font-size: 0.70rem;
}

.cv-document__grid {
    display: grid;
    grid-template-columns: minmax(240px, 0.92fr) minmax(0, 1.86fr);
    gap: 24px;
}

.cv-side {
    display: grid;
    align-content: start;
    gap: 4px;
}

.cv-section {
    margin-bottom: 20px;
    break-inside: avoid;
}

.cv-section h3 {
    margin: 0 0 11px;
    color: var(--cv-brand-ink);
    font-size: 0.92rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    display: inline-block;
    padding-bottom: 6px;
    border-bottom: 2px solid rgba(47, 102, 179, 0.35);
}

.cv-section p {
    margin: 0 0 10px;
    line-height: 1.52;
    color: var(--cv-text);
}

.cv-simple-list,
.cv-role ul,
.cv-main ul {
    margin: 0;
    padding-left: 18px;
}

.cv-links-list li,
.cv-simple-list li,
.cv-role li,
.cv-main li {
    margin-bottom: 6px;
    color: var(--cv-text);
    line-height: 1.45;
}

.cv-skill-list {
    margin: 0;
    padding: 0;
    list-style: none;
    display: grid;
    gap: 9px;
}

.cv-skill-item {
    display: grid;
    gap: 5px;
}

.cv-skill-item__heading {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 10px;
}

.cv-skill-item__name {
    font-size: 0.79rem;
    color: var(--cv-text);
    font-weight: 600;
    line-height: 1.35;
}

.cv-skill-item__value {
    color: var(--cv-text-muted);
    font-size: 0.74rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.cv-skill-item__bar {
    width: 100%;
    height: 7px;
    border-radius: 999px;
    overflow: hidden;
    background: #dbe5f4;
}

.cv-skill-item__bar span {
    display: block;
    height: 100%;
    width: calc((var(--cv-skill-level, 0) / 5) * 100%);
    border-radius: 999px;
    background: linear-gradient(90deg, #21467f 0%, #3f88cf 100%);
}

.cv-role {
    margin-bottom: 20px;
}

.cv-role header h4 {
    margin: 0;
    font-size: 1rem;
    color: var(--cv-brand-ink);
}

.cv-role header p {
    margin: 4px 0;
    font-size: 0.9rem;
    color: var(--cv-text-muted);
}

.cv-note {
    margin-top: 12px;
    margin-bottom: 6px;
}

.cv-document--export {
    width: 202mm;
    max-width: 202mm;
    margin: 0;
    box-sizing: border-box;
    padding: 5mm 6mm 5mm;
}

.cv-document--export .cv-profile-placeholder {
    display: none !important;
}

.cv-document--export .cv-contact-list {
    gap: 2mm 6mm;
}

.cv-document--export .cv-role {
    margin-bottom: 4mm;
}

.cv-document--export p,
.cv-document--export li,
.cv-document--export a,
.cv-document--export span {
    overflow-wrap: anywhere;
    word-break: break-word;
}

.cv-document--export .cv-document__grid {
    grid-template-columns: minmax(56mm, 0.9fr) minmax(0, 1.9fr);
    gap: 5.5mm;
}

.cv-document--export .cv-document__logo {
    width: 62mm;
}

.cv-document--export .cv-section,
.cv-document--export .cv-role {
    break-inside: auto;
    page-break-inside: auto;
}

.cv-document--export h3 {
    break-after: avoid-page;
    page-break-after: avoid;
}


.cv-pdf-footer {
    margin-top: 8mm;
    padding-top: 3mm;
    border-top: 1px solid #d4deec;
    text-align: right;
    font-size: 10px;
    color: #607690;
    letter-spacing: 0.02em;
}

@media (max-width: 960px) {
    .cv-lightbox__panel {
        width: min(1100px, 97vw);
    }

    .cv-lightbox__action--download span {
        display: none;
    }

    .cv-lightbox__scroll {
        padding: 12px;
    }

    .cv-document {
        padding: 1.45rem;
    }

    .cv-contact-list {
        grid-template-columns: 1fr;
    }

    .cv-document__grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .cv-skill-item__name {
        font-size: 0.82rem;
    }
}

@media (max-width: 640px) {
    .cv-lightbox__panel {
        width: 100vw;
        height: 100vh;
        margin: 0;
        border-radius: 0;
    }

    .cv-lightbox__toolbar {
        padding: 12px 14px;
    }

    .cv-lightbox__toolbar h2 {
        font-size: 0.94rem;
    }

    .cv-document {
        padding: 1.2rem;
    }

    .cv-document__top {
        flex-direction: column;
        align-items: flex-start;
    }

    .cv-profile-placeholder {
        width: 100%;
        min-height: 100px;
        border-style: solid;
    }
}

@page {
    size: A4 portrait;
    margin: 6mm 6mm 10mm 6mm;
}

@media print {
    body {
        background: #ffffff !important;
        color: #111827 !important;
    }

    body * {
        visibility: hidden;
    }

    #cvLightbox,
    #cvLightbox * {
        visibility: visible;
    }

    #cvLightbox {
        position: static !important;
        display: block !important;
        inset: auto !important;
    }

    .cv-lightbox__backdrop,
    .cv-lightbox__toolbar,
    .cv-lightbox__actions {
        display: none !important;
    }

    .cv-lightbox__panel,
    .cv-lightbox__scroll {
        width: auto !important;
        height: auto !important;
        margin: 0 !important;
        padding: 0 !important;
        overflow: visible !important;
        border: 0 !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        background: #ffffff !important;
    }

    #cvDocument {
        width: auto !important;
        max-width: none !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    #cvDocument .cv-document__grid {
        gap: 4mm !important;
    }

    #cvDocument .cv-profile-placeholder {
        display: none !important;
    }

    #cvDocument .cv-section,
    #cvDocument .cv-role {
        break-inside: auto;
        page-break-inside: auto;
    }

    #cvDocument h3 {
        break-after: avoid-page;
        page-break-after: avoid;
    }

}

/* ---- REFACTOR OVERRIDES ---- */
.cv-document {
    padding: 3rem;
    color: #1a2940;
}

.cv-document__grid {
    display: grid;
    grid-template-columns: 215px 1fr;
    gap: 0;
}

.cv-side {
    border-right: 1px solid #1a2940;
    padding-right: 24px;
    padding-top: 0;
}

.cv-main {
    padding-left: 24px;
    padding-top: 0;
}

.cv-side__top {
    display: flex;
    gap: 16px;
    margin-bottom: 32px;
    align-items: stretch;
}

.cv-profile-placeholder {
    width: 140px !important;
    height: 140px;
    min-height: 140px !important;
    border: 0;
    background: #e1e5eb;
    border-radius: 0; /* Square! */
}

.cv-side__badge {
    border: 1px solid #1a2940;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cv-side__badge span {
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.1em;
    color: #1a2940;
}

.cv-main__header {
    margin-bottom: 32px;
}

.cv-main__header h1 {
    font-size: 2.8rem;
    line-height: 1.1;
    color: #0b1728;
    margin: 0 0 8px 0;
    letter-spacing: 0.05em;
    font-weight: 800;
}

.cv-main__header .cv-document__subtitle {
    font-size: 1rem;
    font-weight: 300;
    letter-spacing: 0.15em;
    color: #5f738f;
    text-transform: uppercase;
    margin: 0;
}

/* Headings */
.cv-section h3 {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 0 !important;
}

.cv-section h3 {
    border-top: 1px solid #1a2940;
    border-bottom: 1px solid #1a2940 !important;
    padding: 10px 0 !important;
    margin-bottom: 20px !important;
    width: 100%;
}

.cv-icon {
    width: 22px;
    height: 22px;
    fill: #1a2940;
}

.cv-contact-list--side {
    display: flex !important;
    flex-direction: column;
    gap: 12px;
}

.cv-contact-list--side li {
    display: flex;
    gap: 8px;
    word-break: break-all;
    color: #1a2940;
}

.cv-contact-list--side strong {
    display: none; /* Hide labels like phone, email to match image */
}

.cv-personal-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 12px;
}

.cv-personal-details__item {
    display: flex;
    flex-direction: column;
}

.cv-personal-details__item strong {
    color: #1a2940;
    margin-bottom: 4px;
}

.cv-personal-details__item span {
    color: #1a2940;
}

/* Skills slider style */
.cv-skill-item__bar {
    position: relative;
    height: 1px !important;
    background: #1a2940 !important;
    margin-top: 10px;
    border-radius: 0 !important;
    overflow: visible !important;
}
.cv-skill-item__bar span {
    position: absolute;
    width: 12px !important;
    height: 12px !important;
    background: #fff !important;
    border: 1px solid #1a2940 !important;
    border-radius: 50% !important;
    top: 50%;
    transform: translate(-50%, -50%);
    left: calc((var(--cv-skill-level, 0) / 5) * 100%) !important;
}

/* Adjust roles */
.cv-role {
    margin-bottom: 24px;
    display: grid;
    grid-template-columns: 100px 1fr;
    gap: 16px;
    align-items: baseline;
}
.cv-role header {
    grid-column: 1 / -1;
    display: contents; /* Let children flow into grid */
}
.cv-role header p:last-of-type {
    /* 2008 - Present */
    grid-column: 1;
    font-size: 0.8rem;
    text-transform: uppercase;
    margin: 0;
}
.cv-role header h4 {
    grid-column: 2;
    margin: 0;
    font-weight: 700;
}
.cv-role header p:first-of-type {
    /* Freelancer | Lisbon */
    grid-column: 2;
    margin: 4px 0 12px 0;
    font-style: italic;
}
.cv-role ul, .cv-role .cv-note {
    grid-column: 2;
}

@media (max-width: 768px) {
    .cv-document__grid {
        grid-template-columns: 1fr;
    }
    .cv-side {
        border-right: none;
        border-bottom: 1px solid #1a2940;
        padding-right: 0;
        padding-bottom: 24px;
        margin-bottom: 24px;
    }
    .cv-main {
        padding-left: 0;
    }
    .cv-role {
        grid-template-columns: 1fr;
    }
    .cv-role header p:last-of-type {
        grid-column: 1;
        margin-bottom: 8px;
    }
    .cv-role header h4, .cv-role header p:first-of-type, .cv-role ul, .cv-role .cv-note {
        grid-column: 1;
    }
}

/* Roles new layout */
.cv-role--new {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 16px;
    margin-bottom: 24px;
    align-items: baseline;
}
.cv-role--new .cv-role__date {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    color: #1a2940;
    line-height: 1.4;
}
.cv-role--new .cv-role__content h4 {
    margin: 0;
    font-size: 1rem;
    color: #1a2940;
    font-weight: 700;
}
.cv-role--new .cv-role__content .cv-role__subtitle {
    margin: 4px 0 12px 0;
    font-style: italic;
    color: #5f738f;
    font-size: 0.9rem;
}






.cv-links-list li {
    font-size: 0.70rem;
    color: #1a2940;
}

.cv-simple-list li, .cv-main li {
    font-size: 0.88rem;
    color: #1a2940;
}
.cv-section p {
    font-size: 0.88rem;
    color: #1a2940;
}

/* ---- ROLE REFACTOR UPDATES ---- */
.cv-role--new {
    display: block; /* Removed previous grid */
    margin-bottom: 24px;
}
.cv-role__header-grid {
    display: grid;
    grid-template-columns: 100px 1fr;
    gap: 16px;
    align-items: baseline;
    margin-bottom: 12px;
}
.cv-role__date {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    color: #1a2940;
    line-height: 1.4;
}
.cv-role__title h4 {
    margin: 0;
    font-size: 1rem;
    color: #1a2940;
    font-weight: 700;
}
.cv-role__title .cv-role__subtitle {
    margin: 4px 0 0 0;
    font-style: italic;
    color: #5f738f;
    font-size: 0.9rem;
}
.cv-role__body {
    padding-left: 0; /* Fully align left */
}
.cv-role__body ul {
    margin-left: 0;
    padding-left: 18px; /* Give bullets room to exist but the block itself is left-aligned */
}

.cv-contact-icon { width: 16px; min-width: 16px; height: 16px; fill: currentColor; }
.cv-contact-list--side li svg, .cv-links-list li svg { margin-top: 2px; }
.cv-profile-placeholder { background:url('/assets/img/profile.jpg') center/cover !important; border:0; }

/* Hobbies list should not have left margin */
.cv-side .cv-simple-list { padding-left: 0; list-style-position: inside; }

/* Pull up the first page content to reduce its perceived top margin */
.cv-document--export {
    margin-top: -17mm;
}
