/* Reset and base styles */
:root {
    --primary-color: #2c3e50;
    --accent-color: #2573a7;
    --highlight-color: #ff4f4f;
    --focus-color: #ff9f43;
    --text-color: #333;
    --background-color: #b6b5b5;
    --surface-color: #ffffff;
    --border-color: #e0e0e0;
    color-scheme: light;
}

/* Dark mode is opt-in via .dark class or OS preference, but default is light */
html.dark,
html.dark body {
    color-scheme: dark;
}

html.dark {
    --primary-color: #e0e6ed;
    --accent-color: #5dade2;
    --highlight-color: #ff6b6b;
    --focus-color: #feca57;
    --text-color: #e8e8e8;
    --background-color: #1a1a1a;
    --surface-color: #242424;
    --border-color: #444444;
}

@media screen and (prefers-color-scheme: dark) {
    :root {
        --primary-color: #2c3e50;
        --accent-color: #2573a7;
        --highlight-color: #ff4f4f;
        --focus-color: #ff9f43;
        --text-color: #333;
        --background-color: #b6b5b5;
        --surface-color: #ffffff;
        --border-color: #e0e0e0;
        color-scheme: light;
    }
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

body {
    font-family: 'Ubuntu', sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background: var(--background-color);
}

/* Skip link */
.skip-link {
    position: absolute;
    top: -100%;
    left: 0.5rem;
    z-index: 1000;
    padding: 0.5rem 1rem;
    background: var(--surface-color);
    color: var(--text-color);
    border: 2px solid var(--focus-color);
    border-radius: 4px;
    text-decoration: none;
    font-weight: 500;
}

.skip-link:focus {
    top: 0.5rem;
}

/* CV Container */
.cv-container {
    max-width: 1100px;
    margin: 1rem auto;
    padding: 1rem;
    background: var(--surface-color);
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    position: relative;
}

/* Section Headers */
.section-header {
    font-size: clamp(1.1rem, 2vw, 1.25rem);
    font-weight: 700;
    color: var(--text-color);
    margin-bottom: 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

/* Permission Section */
.permission-box {
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 1.5rem;
    margin-top: 1rem;
    background-color: var(--surface-color);
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--text-color);
}

/* Background Decorations */
.bg-decoration-top,
.bg-decoration-bottom {
    top: 0;
    background-position: left top;
    position: absolute;
    width: 100%;
    height: 50%;
    left: 0;
    pointer-events: none;
    background-size: cover;
}

.bg-decoration-top {
    background-image: url('../images/bg-top.svg');
}


/* Focus states */
a:focus-visible,
button:focus-visible,
[tabindex]:focus-visible {
    outline: 3px solid var(--focus-color);
    outline-offset: 2px;
    border-radius: 2px;
}

/* Header Section */
.cv-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 2rem;
    position: relative;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.profile-photo {
    width: clamp(100px, 25vw, 200px);
    height: auto;
    aspect-ratio: 1 / 1;
    border-radius: 50%;
    object-fit: cover;
}

.header-info {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.header-name {
    font-size: clamp(1.75rem, 5vw, 2.5rem);
    font-weight: 700;
    color: var(--primary-color);
    margin: 0;
}

.header-title {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.header-title-text {
    font-size: clamp(1rem, 2.5vw, 1.1rem);
    color: var(--highlight-color);
    margin: 0;
    font-weight: 500;
}

.contact-list {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0;
    text-align: right;
    position: relative;
    list-style: none;
    padding: 0;
    margin: 0;
}

.contact-list li {
    list-style: none;
    margin: 0;
    padding: 0;
    line-height: 1.3;
}

.contact-item {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 28px;
    min-width: 28px;
    color: var(--text-color);
    text-decoration: none;
    font-size: clamp(0.85rem, 1.8vw, 0.9rem);
    font-weight: 500;
    padding: 0.1rem 0.25rem;
    border-radius: 4px;
}

.contact-item.hidden {
    display: none;
}

.contact-item:hover,
.contact-item:focus-visible {
    color: var(--accent-color);
    text-decoration: underline;
}

.contact-item img {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* Sections */
.cv-section {
    margin-bottom: 2rem;
    position: relative;
    z-index: 1;
}

/* Add more space before PERSONAL PROJECTS section */
.two-column-grid .cv-section.personal-projects {
    margin-top: 1rem !important;
}

/* Two-column layout */
.two-column-grid {
    display: grid;
    grid-template-columns: 60% 40%;
    gap: 0%;
    margin-bottom: 3rem;
}

@media (max-width: 768px) {
    .two-column-grid {
        grid-template-columns: 1fr;
        gap: 0;
    }
}

/* Adjust section margins in grid */
.two-column-grid .cv-section {
    margin: 0;
}

/* Make timeline line stay within its column */
.two-column-grid .timeline {
    margin-right: 2rem;
}

/* Right column layout */
.right-column {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.right-column .cv-section {
    margin: 0;
}

/* Adjust timeline in right column */
.right-column .timeline {
    padding-left: 30px;
}

/* Adjust education section spacing */
.right-column .education-timeline {
    margin-top: 2rem;
}

/* Work Experience */
.work-items {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.work-item {
    margin-bottom: 1rem;
}

.work-item h3 {
    color: var(--primary-color);
    margin-bottom: 0.3rem;
}

.company {
    color: var(--accent-color);
    font-weight: 500;
    margin-bottom: 0.3rem;
}

.date {
    color: var(--text-color);
    opacity: 0.7;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.achievements {
    list-style-position: inside;
    padding-left: 1rem;
    margin-top: 0.5rem;
}

.achievements-title {
    color: var(--text-color);
    opacity: 0.7;
    font-style: italic;
    margin-bottom: 0.5rem;
}

.achievements ul {
    list-style: none;
    padding-left: 1rem;
}

.achievements li {
    position: relative;
    margin-bottom: 0.25rem;
}

.achievements li::before {
    content: '–';
    position: absolute;
    left: -1rem;
}

.contact {
    margin-top: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-color);
    opacity: 0.7;
}

.timeline {
    position: relative;
    padding-left: 30px;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 7px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--highlight-color);
}

.timeline-item {
    position: relative;
    margin-bottom: 2rem;
}

.timeline-marker {
    position: absolute;
    left: -30px;
    width: 16px;
    height: 16px;
    border: 2px solid var(--highlight-color);
    border-radius: 50%;
    background: var(--surface-color);
}

.timeline-marker.filled {
    background: var(--highlight-color);
}

.timeline-content {
    padding-bottom: 1rem;
}

.timeline-content h3 {
    font-size: clamp(1rem, 2.2vw, 1.1rem);
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 0.25rem;
}

.timeline-content .company,
.timeline-content .institution {
    font-size: 1rem;
    color: var(--text-color);
    margin-bottom: 0.25rem;
}

.timeline-content .date {
    font-size: 0.9rem;
    color: var(--text-color);
    opacity: 0.7;
    margin-bottom: 0.5rem;
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.timeline-content .location {
    color: var(--highlight-color);
}

/* Education Section */
.courses {
    margin-top: 0.5rem;
}

.courses-title {
    color: var(--text-color);
    opacity: 0.7;
    font-style: italic;
    margin-bottom: 0.5rem;
}

.courses ul {
    list-style: none;
    padding-left: 1rem;
}

.courses li {
    position: relative;
    margin-bottom: 0.25rem;
}

.courses li::before {
    content: '–';
    position: absolute;
    left: -1rem;
}

.course-label {
    font-weight: 500;
}

.institution {
    color: var(--accent-color);
    font-weight: 500;
    font-size: 1rem;
    margin-bottom: 0.25rem;
}

/* Certificates Section */
.certificates-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.certificate-item {
    position: relative;
    padding-left: 1rem;
    page-break-inside: avoid;
}

.certificate-item::before {
    content: '✓';
    position: absolute;
    left: 0;
    color: var(--highlight-color);
    font-weight: bold;
}

.certificate-item p {
    margin: 0;
    font-size: 1rem;
    color: var(--text-color);
}

.certificate-note {
    font-style: italic;
    color: var(--text-color);
    opacity: 0.7;
    font-size: 0.9rem;
    margin-top: 0.25rem !important;
}

/* Skills Section */
.skills-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding-left: 1rem;
}

.skill-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.25rem 0;
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
}

.skill-name {
    font-size: 1rem;
    color: var(--text-color);
    flex: 1;
    font-weight: 500;
    margin-bottom: 0.3rem;
}

.skill-dots {
    display: flex;
    gap: 0.25rem;
    flex-shrink: 0;
}

.dot {
    width: clamp(12px, 3vw, 18px);
    height: clamp(12px, 3vw, 18px);
    border-radius: 50%;
    border: 1px solid var(--highlight-color);
}

.dot.filled {
    background-color: var(--highlight-color);
}

/* Languages Section */
.languages-list {
    margin-top: 0.5rem;
}

.language-item {
    position: relative;
    margin-bottom: 0.5rem;
    padding-left: 1rem;
}

.language-item::before {
    content: '–';
    position: absolute;
    left: 0;
}

.language-name {
    font-weight: 500;
    color: var(--primary-color);
    margin-right: 0.5rem;
}

.language-proficiency {
    color: var(--text-color);
    opacity: 0.8;
    font-style: italic;
    font-size: 0.9rem;
}

/* Personal Projects Section */
.projects-list {
    margin-top: 0.5rem;
}

.project-item {
    position: relative;
    margin-bottom: 1rem;
    padding-left: 1rem;
}

.project-item::before {
    content: '–';
    position: absolute;
    left: 0;
}

.project-title {
    font-weight: 500;
    color: var(--primary-color);
    text-decoration: none;
}

.project-meta {
    margin-top: 0.25rem;
    padding-left: 1rem;
    color: var(--text-color);
    font-size: 0.9rem;
}

.project-meta p {
    margin: 0.1rem 0;
    position: relative;
    padding-left: 1rem;
}

.project-meta p::before {
    content: '–';
    position: absolute;
    left: 0;
}

/* Print styles */
@media print {
    /* Set page size and margins */
    @page {
        size: A4;
        margin: 10mm;
    }

    body {
        background: #ffffff;
        color: #000000;
        font-size: 12pt;
    }

    .skip-link,
    .bg-decoration-top,
    .bg-decoration-bottom {
        display: none !important;
    }

    .cv-container {
        max-width: 100%;
        width: 190mm;
        margin: 0 auto;
        padding: 0;
        background: #ffffff;
        box-shadow: none;
        color: #000000;
    }

    .cv-header {
        display: flex;
        margin-bottom: 1.5rem;
        gap: 1rem;
    }

    .header-name,
    .header-title-text,
    .section-header,
    .timeline-content h3,
    .company,
    .institution,
    .project-title,
    .language-name,
    .certificate-item::before {
        color: #000000 !important;
    }

    .header-title-text {
        font-weight: 700;
    }

    .two-column-grid {
        display: grid;
        grid-template-columns: 52% 43%;
        gap: 5%;
    }

    .header-name {
        font-size: 2rem;
    }

    .header-title-text {
        font-size: 1rem;
    }

    .section-header {
        font-size: 1.1rem;
    }

    .contact-item {
        font-size: 0.85rem;
        color: #000000;
    }

    .profile-photo {
        width: 150px;
        height: 150px;
    }

    .contact-list {
        gap: 0.25rem;
    }

    /* Prevent unwanted page breaks */
    .cv-section,
    .certificate-item,
    .project-item,
    .skill-item,
    .language-item,
    .timeline-item {
        page-break-inside: avoid;
    }

    /* Ensure all images print properly */
    img {
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }

    /* Preserve list styles */
    ul, ol {
        padding-left: inherit;
        margin-left: inherit;
    }

    .achievements ul, .courses ul {
        padding-left: inherit;
    }
}

/* Responsive adjustments */
@media (max-width: 1024px) {
    .cv-container {
        max-width: 90%;
        padding: 1.5rem;
    }
}

@media (max-width: 768px) {
    .cv-container {
        max-width: 100%;
        margin: 0;
        padding: 1rem;
    }

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

    .header-left {
        width: 100%;
    }

    .contact-list {
        align-items: flex-start;
        text-align: left;
        width: 100%;
        padding-left: 0.5rem;
    }

    .timeline {
        padding-left: 24px;
    }

    .timeline::before {
        left: 5px;
    }

    .timeline-marker {
        left: -24px;
        width: 14px;
        height: 14px;
    }

    .two-column-grid .timeline {
        margin-right: 0;
    }

    .right-column .timeline {
        padding-left: 24px;
    }
}

@media (max-width: 480px) {
    .cv-container {
        padding: 0.75rem;
    }

    .header-left {
        gap: 0.75rem;
    }

    .header-info {
        gap: 0.25rem;
    }

    .contact-list {
        gap: 0.1rem;
    }

    .contact-item {
        min-height: 40px;
    }

    .skill-item {
        gap: 0.25rem;
    }

    .timeline-content .date {
        flex-direction: column;
        gap: 0.25rem;
    }
}
