/*
 * Warm pastel palette — zero blue light
 * Inspired by Material Design 2 structure + Figma pastel warmth
 * - Light: parchment surfaces, terracotta accent
 * - Dark: cocoa surfaces, soft apricot accent
 * - All pairs WCAG AA compliant (min 4.75:1)
 */

@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('fonts/inter-400.woff2') format('woff2');
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url('fonts/inter-500.woff2') format('woff2');
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url('fonts/inter-600.woff2') format('woff2');
}
@font-face {
    font-family: 'JetBrains Mono';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('fonts/jetbrains-mono-400.woff2') format('woff2');
}
:root,
[data-theme="light"] {
    --primary: #925a34;
    --primary-hover: #7d4c2a;
    --text: #3b2f24;
    --text-light: #7a6b5a;
    --bg: #faf5ef;
    --bg-alt: #f2ebe2;
    --border: #e3d9cd;
    --shadow: 0 1px 3px 0 rgba(59, 47, 36, 0.06),
              0 1px 2px 0 rgba(59, 47, 36, 0.04);
}

[data-theme="dark"] {
    --primary: #dba06a;
    --primary-hover: #e6b482;
    --text: #ede4d8;
    --text-light: #b5a594;
    --bg: #1e1815;
    --bg-alt: #2a2320;

    --border: #3e3530;
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.25),
              0 1px 2px 0 rgba(0, 0, 0, 0.18);
}

/* Respect OS-level dark mode for initial paint before JS loads */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]):not([data-theme="dark"]) {
        --primary: #dba06a;
        --primary-hover: #e6b482;
        --text: #ede4d8;
        --text-light: #b5a594;
        --bg: #1e1815;
        --bg-alt: #2a2320;
    
        --border: #3e3530;
        --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.25),
                  0 1px 2px 0 rgba(0, 0, 0, 0.18);
    }
}

/* Accessibility: reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', system-ui, sans-serif;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
    transition: background-color 0.4s ease;
}

/* Accessibility */
.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: var(--primary);
    color: #fdf6ee;
    padding: 8px;
    text-decoration: none;
    border-radius: 4px;
    z-index: 1000;
    transition: top 0.3s;
}

.skip-link:focus {
    top: 6px;
}

/* Focus-visible for keyboard navigation accessibility */
:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

:focus:not(:focus-visible) {
    outline: none;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Scroll Progress Bar */
#scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--primary);
    z-index: 100;
    transition: opacity 0.3s ease;
}

/* Reading Time */
.reading-time {
    font-size: 0.8rem;
    font-weight: 400;
    color: var(--text-light);
    margin-left: 0.5rem;
}

/* World Map Background */
#world-map {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.6s ease;
}

#world-map.visible {
    opacity: 1;
}

/* Resting countries tone-matched to the page: the warm --border stroke sits only
   a few shades off --bg, so outlines melt into the parchment. */
#world-map path {
    fill: var(--border);
    fill-opacity: 0;
    stroke: var(--border);
    stroke-opacity: 0.5;
    stroke-width: 0.7;
    transition: stroke 0.4s ease, stroke-opacity 0.4s ease, fill-opacity 0.4s ease;
}

/* Highlighted country keeps a higher-contrast warm --primary outline plus a faint
   fill, so it separates clearly from the softened resting lines. */
#world-map path.focused {
    stroke: var(--primary);
    stroke-opacity: 0.45;
    fill-opacity: 0.18;
}

/* Dark: --border (#3e3530) ≈ --bg (#1e1815), so a --border stroke would vanish.
   Keep the lighter --text-light tone and lower opacity to reach the same
   melted-in resting look. Scoped to :not(.focused) so it never overrides the
   focused rule (equal specificity would otherwise clobber the highlight). */
[data-theme="dark"] #world-map path:not(.focused) {
    stroke: var(--text-light);
    stroke-opacity: 0.12;
}

#world-map .city-marker {
    fill: var(--primary);
    opacity: 0;
    transition: opacity 0.4s ease;
}

#world-map .city-marker.active {
    opacity: 0.5;
}

/* Layout */
.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 1rem 2rem 1rem;
    position: relative;
    z-index: 1;
}

/* Theme Toggle Switch */
.theme-switch-wrapper {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 1rem 0 1rem;
}

.print-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    color: var(--text-light);
    background-color: var(--bg-alt);
    border: 1px solid var(--border);
    border-radius: 50%;
    cursor: pointer;
    transition: color 0.3s ease, border-color 0.3s ease, background-color 0.3s ease, transform 0.15s ease;
}

.print-btn:hover {
    color: var(--primary);
    border-color: var(--primary);
}

.print-btn:active {
    transform: scale(0.94);
}

.theme-switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 30px;
}

.theme-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--bg-alt);
    border: 1px solid var(--border);
    border-radius: 20px;
    transition: all 0.4s ease-in-out;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 5px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 4px;
    top: 50%;
    transform: translateY(-50%);
    background-color: var(--bg);
    border-radius: 50%;
    transition: all 0.4s ease-in-out;
    box-shadow: 0 1px 3px rgba(59, 47, 36, 0.12);
    border: 1px solid var(--border);
}

.sun-icon, .moon-icon {
    width: 16px;
    height: 16px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    transition: all 0.4s ease-in-out;
}

/* Light Mode State — sun active (terracotta), moon muted */
.sun-icon {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%237a6b5a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='5'%3E%3C/circle%3E%3Cline x1='12' y1='1' x2='12' y2='3'%3E%3C/line%3E%3Cline x1='12' y1='21' x2='12' y2='23'%3E%3C/line%3E%3Cline x1='4.22' y1='4.22' x2='5.64' y2='5.64'%3E%3C/line%3E%3Cline x1='18.36' y1='18.36' x2='19.78' y2='19.78'%3E%3C/line%3E%3Cline x1='1' y1='12' x2='3' y2='12'%3E%3C/line%3E%3Cline x1='21' y1='12' x2='23' y2='12'%3E%3C/line%3E%3Cline x1='4.22' y1='19.78' x2='5.64' y2='18.36'%3E%3C/line%3E%3Cline x1='18.36' y1='5.64' x2='19.78' y2='4.22'%3E%3C/line%3E%3C/svg%3E");
}

.moon-icon {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%237a6b5a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z'%3E%3C/path%3E%3C/svg%3E");
}

/* Dark Mode State — moon active (apricot), sun muted */
input:checked + .slider:before {
    transform: translateX(30px) translateY(-50%);
}

input:checked + .slider .sun-icon {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23b5a594' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='5'%3E%3C/circle%3E%3Cline x1='12' y1='1' x2='12' y2='3'%3E%3C/line%3E%3Cline x1='12' y1='21' x2='12' y2='23'%3E%3C/line%3E%3Cline x1='4.22' y1='4.22' x2='5.64' y2='5.64'%3E%3C/line%3E%3Cline x1='18.36' y1='18.36' x2='19.78' y2='19.78'%3E%3C/line%3E%3Cline x1='1' y1='12' x2='3' y2='12'%3E%3C/line%3E%3Cline x1='21' y1='12' x2='23' y2='12'%3E%3C/line%3E%3Cline x1='4.22' y1='19.78' x2='5.64' y2='18.36'%3E%3C/line%3E%3Cline x1='18.36' y1='5.64' x2='19.78' y2='4.22'%3E%3C/line%3E%3C/svg%3E");
}

input:checked + .slider .moon-icon {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23b5a594' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z'%3E%3C/path%3E%3C/svg%3E");
}

/* Header */
header {
    margin-bottom: 3rem;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 2rem;
    align-items: stretch;
    margin-top: 1rem;
}

.profile {
    display: flex;
    gap: 2rem;
    align-items: stretch;
}

.avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    object-fit: cover;
    object-position: center top;
    border: 3px solid var(--border);
    flex-shrink: 0;
    align-self: center;
}

.profile-info {
    display: flex;
    flex-direction: column;
}

.profile-info h1 {
    font-size: 2.5rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: var(--text);
}

.title {
    font-size: 1.25rem;
    color: var(--primary);
    margin-top: auto;
    margin-bottom: 0.15rem;
    font-weight: 500;
}

.summary {
    color: var(--text-light);
    font-size: 1rem;
    max-width: 780px;
    text-align: justify;
}

.contact-print {
    display: none;
}

.contact {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.contact-icon {
    color: var(--primary);
    text-decoration: none;
    transition: transform 0.2s ease, color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
}

.contact-icon svg {
    width: 22px;
    height: 22px;
}

.contact-icon--pin svg {
    width: 28px;
    height: 28px;
}

.contact-icon:hover {
    transform: translateY(-2px);
    color: var(--primary-hover);
}

/* Navigation */
nav {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 3rem;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--bg);
    z-index: 10;
    padding-top: 0.25rem;
}

nav a {
    padding: 0.75rem 1.5rem;
    text-decoration: none;
    color: var(--text-light);
    border-bottom: 2px solid transparent;
    transition: color 0.2s ease, border-bottom-color 0.2s ease;
}

nav a:hover {
    color: var(--primary-hover);
    border-bottom-color: var(--primary-hover);
}

nav a.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* Sections */
section {
    padding-top: 2rem;
    margin-bottom: 2rem;
}

section:first-child {
    padding-top: 0;
}

section h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 2rem;
    color: var(--text);
    position: relative;
}

section h2::after {
    content: '';
    position: absolute;
    bottom: -0.5rem;
    left: 0;
    width: 3rem;
    height: 2px;
    background: var(--primary);
}

.scroll-top {
    text-decoration: none;
    color: var(--text-light);
    font-size: 1.2rem;
    margin-left: 0.5rem;
    opacity: 0.6;
    transition: opacity 0.2s ease;
}

.scroll-top:hover {
    opacity: 1;
    color: var(--primary);
}

/* Experience */
.job {
    margin-bottom: 1rem;
    padding-bottom: 1rem;
}

.job:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
}

.job-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 0.5rem;
    gap: 1rem;
}

.job h3,
.degree h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
}

.duration {
    font-size: 0.9rem;
    color: var(--text-light);
    white-space: nowrap;
}

.company,
.school {
    font-weight: 500;
    color: var(--primary);
    font-size: 0.95rem;
}

.company {
    margin-bottom: 1rem;
}

.job ul {
    list-style: none;
    margin-bottom: 1rem;
}

.job li {
    position: relative;
    padding-left: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--text);
}

.job li::before {
    content: '•';
    position: absolute;
    left: 0;
    color: var(--primary);
    font-weight: bold;
}

.tech {
    font-size: 0.85rem;
    color: var(--text-light);
    font-family: 'JetBrains Mono', monospace;
}

/* Skills */

/* Professional Ethos */
.ethos-list {
    list-style: none;
    display: grid;
    gap: 0.75rem;
}

.ethos-list li {
    padding: 0.75rem 1rem;
    background: var(--bg-alt);
    border-left: 3px solid var(--primary);
    border-radius: 0 0.25rem 0.25rem 0;
    color: var(--text);
    line-height: 1.5;
}

.ethos-list strong {
    color: var(--primary);
}

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

.skill-group h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--primary);
}

.skill-group ul {
    list-style: none;
}

.skill-group li {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}

.skill-group li:last-child {
    border-bottom: none;
}

.skill-group a,
.degree a {
    color: var(--primary);
    text-decoration: none;
    transition: color 0.2s ease;
}

.skill-group a:visited,
.degree a:visited {
    color: var(--primary);
}

.skill-group a:hover,
.degree a:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

/* Education */
.degree {
    margin-bottom: 2rem;
}

.school {
    margin-bottom: 0.5rem;
}

.degree p {
    color: var(--text-light);
    font-size: 0.9rem;
}


/* Responsive Design */
@media (max-width: 1160px) {
    .theme-switch-wrapper {
        padding: 1rem;
    }
}

@media (max-width: 768px) {
    .theme-switch-wrapper {
        padding: 1rem 0.75rem 0 0.75rem;
    }

    .container {
        padding: 0 0.75rem 1rem 0.75rem;
    }

    header {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .profile {
        flex-direction: column;
        text-align: center;
        align-items: center;
    }

    .profile-info h1 {
        font-size: 2rem;
    }

    .contact {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        gap: 1rem;
    }

    .job-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    nav {
        flex-wrap: wrap;
        justify-content: center;
    }
}

/* Footer */
footer {
    text-align: center;
    padding: 2rem 0 1rem;
    color: var(--text-light);
    font-size: 0.85rem;
    border-top: 1px solid var(--border);
    margin-top: 2rem;
}

/* QR code — hidden on screen, shown in print */
.print-qr {
    display: none;
}

/* Print Styles — always dark text on white, A4 optimized */
/* NOTE: Print with Chrome Margins set to "Default" */
@media print {
    @page {
        size: A4;
        margin: 1.5cm;
    }

    /* Override all theme variables to print-friendly values */
    :root,
    [data-theme="light"],
    [data-theme="dark"] {
        --primary: #333 !important;
        --primary-hover: #333 !important;
        --text: #000 !important;
        --text-light: #444 !important;
        --bg: transparent !important;
        --bg-alt: transparent !important;
        --border: #ccc !important;
        --shadow: none !important;
    }

    *,
    *::before,
    *::after {
        box-shadow: none !important;
        background-color: transparent !important;
    }

    /* Hide non-printable elements */
    .theme-switch-wrapper,
    nav,
    .scroll-top,
    .skip-link,
    .reading-time,
    footer,
    #world-map,
    #scroll-progress {
        display: none !important;
    }

    body {
        font-size: 10.5px;
        line-height: 1.35;
        color: #000 !important;
        background: none !important;
    }

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

    /* Stack header vertically — profile on top, contact below */
    header {
        margin-top: 0;
        margin-bottom: 1.5rem;
        grid-template-columns: 1fr !important;
        gap: 0.5rem;
    }

    .profile {
        flex-direction: row !important;
        text-align: left !important;
        align-items: stretch !important;
        gap: 1rem;
    }

    .avatar {
        width: 70px;
        height: 70px;
        border-color: #ccc;
    }

    .profile-info h1 {
        font-size: 1.6rem;
        color: #000;
    }

    .title {
        color: #333;
        margin-top: 0;
        font-size: 1.1rem;
    }

    .summary {
        color: #333;
        max-width: none;
        font-size: 0.9rem;
    }

    /* Show plain-text contact for ATS, hide icon contact */
    .contact {
        display: none !important;
    }

    .contact-print {
        display: flex !important;
        flex-direction: row;
        justify-content: center;
        gap: 0.4rem;
        font-size: 0.8rem;
        color: #333;
        white-space: nowrap;
        padding-top: 0.4rem;
        border-top: 1px solid #ccc;
    }

    .contact-print span + span::before {
        content: "•";
        margin-right: 0.4rem;
        color: #999;
    }

    a {
        color: #000 !important;
        text-decoration: none !important;
    }

    /* Sections */
    section {
        padding-top: 1rem;
        margin-bottom: 1rem;
    }

    section:first-child {
        padding-top: 0;
    }

    section h2 {
        font-size: 1.1rem;
        color: #000;
        margin-bottom: 1rem;
        break-after: avoid;
        page-break-after: avoid;
    }

    section h2::after {
        /* !important needed: the blanket "*::after { background-color: transparent
           !important }" print reset above would otherwise hide this accent underline */
        background-color: #333 !important;
        height: 1.5px;
        bottom: -0.2rem;
    }

    /* Individual jobs & degrees — never split across pages */
    .job,
    .degree {
        break-inside: avoid;
        page-break-inside: avoid;
    }

    /* Keep the whole Education section on one page — it is short enough to fit,
       so move it to the next page rather than splitting the heading from a
       degree or the two degrees across a page boundary */
    #education {
        break-inside: avoid;
        page-break-inside: avoid;
    }

    .job {
        margin-bottom: 0.6rem;
        padding-bottom: 0.4rem;
    }

    .job-header {
        flex-direction: row !important;
        align-items: baseline !important;
        margin-bottom: 0.15rem;
        gap: 1rem;
    }

    .job h3,
    .degree h3 {
        color: #000;
        font-size: 1rem;
    }

    .company,
    .school {
        color: #333;
        margin-bottom: 0.2rem;
        font-size: 0.85rem;
    }

    .duration {
        color: #444;
        font-size: 0.8rem;
    }

    .tech {
        color: #555;
        font-size: 0.8rem;
    }

    .job ul {
        list-style: disc;
        padding-left: 1.2rem;
        margin-bottom: 0.2rem;
    }

    .job li {
        color: #000;
        margin-bottom: 0.15rem;
        font-size: 0.9rem;
        padding-left: 0;
    }

    .job li::before {
        display: none;
    }

    .skills-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 0.75rem;
    }

    .skill-group {
        break-inside: avoid;
        page-break-inside: avoid;
    }

    .skill-group h3 {
        color: #333;
        font-size: 0.9rem;
        margin-bottom: 0.2rem;
    }

    .skill-group li {
        color: #000;
        border-bottom-color: #ddd;
        padding: 0.2rem 0;
        font-size: 0.85rem;
    }

    .degree {
        margin-bottom: 0.6rem;
    }

    .degree p {
        color: #444;
        font-size: 0.85rem;
    }

    /* Ethos */
    .ethos-list {
        break-inside: avoid;
        page-break-inside: avoid;
    }

    .ethos-list li {
        background: none;
        border-left: 2px solid #999;
        padding: 0.2rem 0.5rem;
        font-size: 0.85rem;
        color: #000;
    }

    .ethos-list strong {
        color: #333;
    }

    /* Hide emoji flags — some ATS parsers can't handle Unicode emoji */
    .emoji {
        display: none !important;
    }

    /* Hide local-file links in print — they resolve to localhost */
    .local-link {
        pointer-events: none;
        color: #000 !important;
        text-decoration: none !important;
    }

    /* QR code linking to live site */
    .print-qr {
        display: flex !important;
        align-items: center;
        justify-content: center;
        gap: 0.5rem;
        margin-top: 1rem;
        padding-top: 0.5rem;
        border-top: 1px solid #ccc;
    }

    .print-qr img {
        width: 60px;
        height: 60px;
    }

    .print-qr span {
        font-size: 0.75rem;
        color: #666;
    }
}
