:root {
    --bg: #0f172a;
    --bg-alt: #111c34;
    --text: #e2e8f0;
    --muted: #94a3b8;
    --accent: #38bdf8;
    --accent-dark: #0ea5e9;
    --card-bg: #1e2a46;
    --border: rgba(148, 163, 184, 0.3);
    --max-width: 1100px;
    --radius: 14px;
    font-family: "Segoe UI", Arial, sans-serif;
}

/* Light theme overrides - applied when `theme-light` is added to the body */
body.theme-light {
    --bg: #f8fafc;
    --bg-alt: #ffffff;
    --text: #0f172a;
    --muted: #475569;
    --accent: #0ea5e9;
    --accent-dark: #0284c7;
    --card-bg: #ffffff;
    --border: rgba(15, 23, 42, 0.06);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    /* smooth fade for theme changes */
    transition: background-color 240ms ease, color 240ms ease, border-color 240ms ease, box-shadow 240ms ease;
}

html {
    scroll-behavior: smooth;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: "Segoe UI", Arial, sans-serif;
    line-height: 1.6;
    min-height: 100vh;
    padding: 3rem;
}

/* Smooth scroll offset for anchor links */
section {
    scroll-margin-top: 2rem;
}

/* Enhanced keyboard navigation */
*:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
    border-radius: 4px;
}

button:focus-visible,
a:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover,
a:focus {
    color: var(--accent-dark);
    text-decoration: underline;
}

.container {
    margin: 0 auto;
    max-width: var(--max-width);
    padding: 0 1.5rem;
}

.hero {
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.08), rgba(14, 165, 233, 0.15));
    border-bottom: 1px solid var(--border);
    padding: 4rem 0 3rem;
}

.hero__content {
    display: grid;
    gap: 2.5rem;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    align-items: flex-start;
}

.hero__eyebrow {
    color: var(--accent);
    font-size: 0.95rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    margin-bottom: 0.75rem;
    font-weight: 600;
}

.hero h1 {
    font-size: clamp(2.5rem, 5vw, 3.5rem);
    margin-bottom: 1.2rem;
    /* slight padding to the name for better spacing from the left/top */
    padding-left: 0.5rem;
    padding-top: 0.25rem;
}

.hero__summary {
    color: var(--muted);
    font-size: 1.05rem;
    max-width: 36ch;
}

.hero__cta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 2rem;
}

.hero__details {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
}

.hero__details ul {
    list-style: none;
}

.hero__details-header {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 1.5rem;
}

.hero__details-divider {
    height: 1px;
    background: rgba(148, 163, 184, 0.35);
    margin: 0 -1.5rem 1.5rem;
}

.profile-image {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
    margin: 0;
    /* enhanced clarity with better border and shadow */
    padding: 4px;
    border: 3px solid var(--accent);
    box-shadow: 0 6px 20px rgba(56, 189, 248, 0.35);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    /* improve image quality */
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    background: var(--card-bg);
}

.profile-image:hover {
    transform: scale(1.05);
    box-shadow: 0 10px 30px rgba(56, 189, 248, 0.5);
}

.hero__details li + li {
    margin-top: 0.75rem;
}

.contact-list li {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.contact-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 50%;
    background: rgba(56, 189, 248, 0.18);
    color: var(--accent);
}

.contact-icon svg {
    width: 1rem;
    height: 1rem;
}

.contact-list a {
    color: var(--text);
    font-weight: 500;
}

.contact-list a:hover,
.contact-list a:focus {
    color: var(--accent);
}

.button {
    background: var(--accent);
    border-radius: 999px;
    color: #0f172a;
    font-weight: 600;
    padding: 0.75rem 1.6rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.button:hover,
.button:focus {
    box-shadow: 0 12px 30px rgba(56, 189, 248, 0.25);
    transform: translateY(-2px);
    text-decoration: none;
}

.button--ghost {
    background: transparent;
    border: 1px solid var(--accent);
    color: var(--accent);
}

/* Theme toggle button specific styling */
.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 999px;
}

.theme-toggle svg {
    color: var(--accent);
}

.theme-toggle[aria-pressed="true"] svg {
    color: var(--text);
}

.section {
    padding: 3.5rem 0;
}

.section--alt {
    background: var(--bg-alt);
}

.section h2 {
    font-size: 2rem;
    margin-bottom: 1.5rem;
    position: relative;
    padding-bottom: 0.75rem;
    text-align: center;
}

.section h2::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 3px;
    background: var(--accent);
    border-radius: 2px;
}

.grid {
    display: grid;
    gap: 1.75rem;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.grid--skills {
    gap: 1.5rem;
}

.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.75rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    /* subtle entrance animation */
    animation: fadeInUp 0.6s ease-out backwards;
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(56, 189, 248, 0.15);
}

/* Stagger card animations */
.card:nth-child(1) { animation-delay: 0.1s; }
.card:nth-child(2) { animation-delay: 0.2s; }
.card:nth-child(3) { animation-delay: 0.3s; }
.card:nth-child(4) { animation-delay: 0.4s; }
.card:nth-child(5) { animation-delay: 0.5s; }

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.card h3 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    color: var(--accent);
}

.card__meta {
    color: var(--muted);
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
}

.card ul {
    list-style: disc inside;
}

.card ul li + li {
    margin-top: 0.4rem;
}

.card__link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-weight: 600;
    margin-top: 1.2rem;
}

.card__link::after {
    content: "\2192";
    font-size: 1rem;
    transition: transform 0.2s ease;
}

.card__link:hover::after {
    transform: translateX(4px);
}

.note {
    color: var(--muted);
    font-size: 0.9rem;
    margin-top: 1.5rem;
}

.tag {
    color: var(--accent);
    font-size: 0.85rem;
    font-weight: 600;
}

.timeline {
    display: grid;
    gap: 2.5rem;
}

.timeline__item {
    border-left: 2px solid var(--accent);
    padding-left: 1.5rem;
    position: relative;
}

.timeline__item::before {
    background: var(--accent);
    border-radius: 50%;
    content: "";
    height: 12px;
    width: 12px;
    position: absolute;
    left: -7px;
    top: 0.35rem;
}

.timeline__meta {
    color: var(--muted);
    font-size: 0.95rem;
    margin: 0.35rem 0 1rem;
}

.footer {
    border-top: 1px solid var(--border);
    padding: 2rem 0;
}

.footer__content {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
    justify-content: space-between;
}

.footer__link {
    font-weight: 600;
}

@media (max-width: 640px) {
    body {
        padding: 1.5rem;
    }

    .hero__content {
        grid-template-columns: 1fr;
    }

    .hero h1 {
        font-size: 2rem;
    }

    .section {
        padding: 2.5rem 0;
    }

    .timeline__item {
        border-left: none;
        padding-left: 0;
    }

    .timeline__item::before {
        display: none;
    }

    .hero__details-header {
        justify-content: center;
    }

    .profile-image {
        width: 96px;
        height: 96px;
        margin: 0 auto 1.5rem;
    }
}

/* Print styles for clean CV printing */
@media print {
    body {
        background: white;
        color: black;
        padding: 0;
        font-size: 11pt;
    }

    .hero {
        background: white;
        border: none;
        page-break-after: avoid;
    }

    .theme-toggle,
    .hero__cta,
    .footer__link {
        display: none;
    }

    .card,
    .section {
        page-break-inside: avoid;
    }

    .card {
        border: 1px solid #ccc;
        box-shadow: none;
        animation: none;
    }

    a {
        color: black;
        text-decoration: underline;
    }

    .profile-image {
        border-color: #ccc;
        box-shadow: none;
    }

    h1, h2, h3 {
        color: black;
    }

    .section h2::after {
        background: black;
    }
}

/* In-page PDF viewer overlay */
.pdf-viewer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(2,6,23,0.75);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1200;
    padding: 2rem;
}
.pdf-viewer-overlay[aria-hidden="false"] {
    display: flex;
}
.pdf-viewer {
    width: 100%;
    max-width: 1100px;
    height: 86vh;
    background: var(--card-bg);
    border-radius: 10px;
    box-shadow: 0 20px 60px rgba(2,6,23,0.6);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.pdf-viewer__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 1rem;
    background: linear-gradient(90deg, rgba(56,189,248,0.06), transparent);
    border-bottom: 1px solid var(--border);
}
.pdf-viewer__title {
    color: var(--text);
    font-weight: 700;
}
.pdf-viewer__controls {
    display: flex;
    gap: 0.5rem;
}
.pdf-viewer iframe {
    width: 100%;
    height: 100%;
    border: 0;
    background: #fff;
}
.button--back {
    background: #fff;
    color: var(--accent);
    border: 2px solid var(--accent);
    padding: 0.45rem 0.9rem;
    border-radius: 999px;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(2,6,23,0.08);
}
.viewer-close {
    background: transparent;
    border: none;
    color: var(--muted);
    font-size: 1.25rem;
    cursor: pointer;
}

/* Floating overlay controls (top-right) */
.overlay-controls {
    position: absolute;
    top: 18px;
    right: 18px;
    display: flex;
    gap: 0.6rem;
    align-items: center;
    z-index: 1250;
}
.overlay-controls .viewer-close {
    background: rgba(255,255,255,0.06);
    color: var(--text);
    width: 36px;
    height: 36px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    border: 1px solid rgba(148,163,184,0.08);
}

@media (max-width: 640px) {
    .pdf-viewer {
        height: 92vh;
        border-radius: 8px;
    }
}

/* Make certificate list items appear clickable when they open the viewer */
.cert-item {
    cursor: pointer;
}
.cert-item:hover {
    background: rgba(148,163,184,0.02);
}
