/* ==========================================================================
   Bernards Gulbis - Portfolio Website
   Sunset theme | Dark/Light mode | Responsive
   ========================================================================== */

/* --- Reset --- */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    scroll-padding-top: 5rem;
}

/* --- Light Mode (default) --- */
:root {
    --bg-primary: #FFF8F0;
    --bg-secondary: #FFF0E0;
    --text-primary: #2D1B14;
    --text-secondary: #6B4C3B;
    --accent: #BE4928;
    --gradient-start: #C04A2E;
    --gradient-end: #D07540;
    --nav-bg: rgba(255, 248, 240, 0.95);
    --card-bg: #FFFFFF;
    --card-shadow: rgba(45, 27, 20, 0.08);
    --tag-bg: rgba(190, 73, 40, 0.1);
    --tag-text: #993520;
    --border-color: rgba(107, 76, 59, 0.15);
}

/* --- Dark Mode --- */
[data-theme="dark"] {
    --bg-primary: #1A1216;
    --bg-secondary: #2A1E24;
    --text-primary: #F5E6D8;
    --text-secondary: #C4A88E;
    --accent: #F07B5C;
    --accent-hover: #FF9070;
    --gradient-start: #C84E30;
    --gradient-end: #F4845F;
    --nav-bg: rgba(26, 18, 22, 0.95);
    --card-bg: #231A1F;
    --card-shadow: rgba(0, 0, 0, 0.3);
    --tag-bg: rgba(240, 123, 92, 0.15);
    --tag-text: #FF9070;
    --border-color: rgba(196, 168, 142, 0.15);
}

/* --- Color transition for dark/light switch (scoped to toggle only) --- */
html.transitioning,
html.transitioning * {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease !important;
}

/* --- Base Typography --- */
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 1rem;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3 {
    line-height: 1.2;
    font-weight: 700;
}

p {
    margin-bottom: 1rem;
}

a {
    text-decoration: none;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

ul {
    list-style: none;
}

/* --- Utility --- */
.container {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* --- Section shared styles --- */
.section {
    padding: 5rem 0;
}

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

.section__header {
    text-align: center;
    margin-bottom: 3rem;
}

.section__title {
    font-size: 2rem;
    color: var(--text-primary);
    display: inline-block;
    position: relative;
    padding-bottom: 0.75rem;
}

.section__title::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 3px;
    background: linear-gradient(90deg, var(--gradient-start), var(--gradient-end));
    border-radius: 2px;
}

.section__subtitle {
    color: var(--text-secondary);
    margin-top: 1rem;
    font-size: 1.1rem;
}

/* ==========================================================================
   Navigation
   ========================================================================== */

.nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: var(--nav-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    padding: 0.875rem 0;
}

.nav__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav__logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    transition: color 0.3s ease;
}

.nav__logo:hover {
    color: var(--accent);
}

.nav__links {
    display: flex;
    gap: 2rem;
}

.nav__link {
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 500;
    position: relative;
    padding-bottom: 0.25rem;
    transition: color 0.3s ease;
}

.nav__link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--accent);
    transition: width 0.3s ease;
}

.nav__link:hover,
.nav__link.active {
    color: var(--accent);
}

.nav__link:hover::after,
.nav__link.active::after {
    width: 100%;
}

.nav__actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* --- Theme toggle --- */
.theme-toggle {
    background: none;
    border: 2px solid var(--border-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-secondary);
    transition: color 0.3s ease, border-color 0.3s ease, background-color 0.3s ease;
}

.theme-toggle:hover {
    color: var(--accent);
    border-color: var(--accent);
    background-color: var(--tag-bg);
}

/* Light mode: show moon, hide sun */
.theme-toggle__icon--sun {
    display: none;
}

.theme-toggle__icon--moon {
    display: block;
}

/* Dark mode: show sun, hide moon */
[data-theme="dark"] .theme-toggle__icon--sun {
    display: block;
}

[data-theme="dark"] .theme-toggle__icon--moon {
    display: none;
}

/* --- Hamburger (hidden on desktop) --- */
.hamburger {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-primary);
    padding: 0.25rem;
}

.hamburger__icon--close {
    display: none;
}

.hamburger[aria-expanded="true"] .hamburger__icon--open {
    display: none;
}

.hamburger[aria-expanded="true"] .hamburger__icon--close {
    display: block;
}

/* ==========================================================================
   Hero
   ========================================================================== */

.hero {
    min-height: 100vh;
    display: flex;
    align-items: center;
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
    padding-top: 4rem; /* offset for fixed nav */
    position: relative;
}

.hero__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 3rem;
}

.hero__content {
    flex: 1;
    max-width: 600px;
}

.hero__title {
    font-size: 3.5rem;
    color: #FFFFFF;
    margin-bottom: 1rem;
    letter-spacing: -0.02em;
}

.hero__tagline {
    font-size: 1.25rem;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 2rem;
    line-height: 1.5;
}

.hero__cta {
    display: inline-block;
    padding: 0.875rem 2rem;
    background: #FFFFFF;
    color: var(--gradient-start);
    font-weight: 600;
    font-size: 1rem;
    border-radius: 8px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.hero__cta:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.hero__image-wrapper {
    flex-shrink: 0;
    width: 280px;
    height: 280px;
    border-radius: 50%;
    overflow: hidden;
    border: 4px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 0 40px rgba(255, 255, 255, 0.2);
}

.hero__image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center top;
}

/* ==========================================================================
   About Me
   ========================================================================== */

.about {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3rem;
    align-items: start;
}

.about__text p {
    color: var(--text-secondary);
    margin-bottom: 1.25rem;
}

.about__text p:first-child {
    color: var(--text-primary);
    font-size: 1.1rem;
    font-weight: 500;
}

.about__stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.25rem;
}

.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    text-align: center;
    box-shadow: 0 2px 8px var(--card-shadow);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px var(--card-shadow);
}

.stat-card__number {
    display: block;
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent);
    line-height: 1;
    margin-bottom: 0.5rem;
}

.stat-card__label {
    display: block;
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ==========================================================================
   Skills
   ========================================================================== */

.skills {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.skill-category {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.75rem;
    box-shadow: 0 2px 8px var(--card-shadow);
}

.skill-category__header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.skill-category__icon {
    color: var(--accent);
    flex-shrink: 0;
}

.skill-category__title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

.skill-category__tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tag {
    display: inline-block;
    padding: 0.375rem 0.875rem;
    background: var(--tag-bg);
    color: var(--tag-text);
    font-size: 0.85rem;
    font-weight: 500;
    border-radius: 20px;
    white-space: nowrap;
}

.tag small {
    font-weight: 400;
    opacity: 0.8;
}

/* ==========================================================================
   Portfolio / Projects
   ========================================================================== */

.projects {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.project-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 2px 8px var(--card-shadow);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
}

.project-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px var(--card-shadow);
}

.project-card__title {
    font-size: 1.2rem;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
}

.project-card__link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin-top: 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--accent);
    text-decoration: none;
    transition: gap 0.2s ease;
}

.project-card__link:hover {
    gap: 0.6rem;
    text-decoration: underline;
}

.project-card__link svg {
    flex-shrink: 0;
}

.project-card__description {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 1rem;
    flex-grow: 1;
}

.project-card__impact {
    margin-bottom: 1rem;
}

.project-card__metric {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
    color: #FFFFFF;
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: 20px;
}

.project-card__tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: auto;
}

/* ==========================================================================
   Experience Timeline
   ========================================================================== */

.timeline {
    position: relative;
    padding-left: 2.5rem;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 0.5rem;
    top: 0.5rem;
    bottom: 0.5rem;
    width: 2px;
    background: linear-gradient(180deg, var(--gradient-start), var(--gradient-end));
}

.timeline__item {
    position: relative;
    padding-bottom: 2.5rem;
}

.timeline__item:last-child {
    padding-bottom: 0;
}

.timeline__dot {
    position: absolute;
    left: -2.5rem;
    top: 0.25rem;
    width: 1.125rem;
    height: 1.125rem;
    background: var(--accent);
    border: 3px solid var(--bg-secondary);
    border-radius: 50%;
    z-index: 1;
}

.timeline__dot--education {
    width: 1.75rem;
    height: 1.75rem;
    background: var(--card-bg);
    border: 2px solid var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    left: calc(-2.5rem - 0.3125rem);
    top: 0;
}

.timeline__content {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px var(--card-shadow);
}

.timeline__date {
    display: inline-block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent);
    background: var(--tag-bg);
    padding: 0.2rem 0.75rem;
    border-radius: 20px;
    margin-bottom: 0.5rem;
}

.timeline__title {
    font-size: 1.2rem;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.timeline__company {
    display: block;
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

.timeline__highlights li {
    position: relative;
    padding-left: 1.25rem;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.925rem;
    line-height: 1.5;
}

.timeline__highlights li:last-child {
    margin-bottom: 0;
}

.timeline__highlights li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0.625rem;
    width: 6px;
    height: 6px;
    background: var(--accent);
    border-radius: 50%;
}

.timeline__item--education .timeline__content {
    background: transparent;
    border: 1px dashed var(--border-color);
    box-shadow: none;
}

.timeline__item--education .timeline__company {
    margin-bottom: 0;
}

/* ==========================================================================
   Certifications & Publications
   ========================================================================== */

.credentials {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3rem;
}

.credentials__heading {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1.25rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border-color);
}

.credentials__list li {
    display: flex;
    gap: 1rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-color);
    align-items: baseline;
}

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

.credentials__year {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent);
    background: var(--tag-bg);
    padding: 0.15rem 0.6rem;
    border-radius: 12px;
    white-space: nowrap;
    flex-shrink: 0;
}

.credentials__name {
    color: var(--text-secondary);
    font-size: 0.925rem;
    line-height: 1.4;
}

a.credentials__name {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--accent);
    text-decoration: none;
    transition: color 0.2s ease;
}

a.credentials__name:hover {
    text-decoration: underline;
}

a.credentials__name .credentials__link-icon {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

a.credentials__name:hover .credentials__link-icon {
    opacity: 1;
}

/* ==========================================================================
   Contact
   ========================================================================== */

.contact {
    display: flex;
    justify-content: center;
    gap: 2rem;
    flex-wrap: wrap;
}

.contact__link {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 2rem 2.5rem;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 2px 8px var(--card-shadow);
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
    min-width: 200px;
}

.contact__link:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px var(--card-shadow);
    border-color: var(--accent);
}

.contact__icon {
    color: var(--accent);
    width: 32px;
    height: 32px;
}

.contact__label {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 1rem;
}

.contact__value {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* ==========================================================================
   Footer
   ========================================================================== */

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

.footer__text {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
}

.footer__note {
    color: var(--text-secondary);
    font-size: 0.8rem;
    opacity: 0.7;
    margin-bottom: 0;
}

/* --- Screen reader only utility --- */
.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;
}

/* ==========================================================================
   Accessibility: Focus Styles
   ========================================================================== */

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

/* Skip-to-content link (keyboard users only) */
.skip-link {
    position: absolute;
    top: -100%;
    left: 1rem;
    padding: 0.75rem 1.5rem;
    background: var(--accent);
    color: #FFFFFF;
    font-weight: 600;
    border-radius: 0 0 8px 8px;
    z-index: 10000;
    transition: top 0.3s ease;
}

.skip-link:focus {
    top: 0;
}

/* ==========================================================================
   Scroll Reveal Animations
   ========================================================================== */

.reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.reveal.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Stagger children (skill categories, project cards, stat cards, contact links) */
.stagger > * {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.stagger.visible > *:nth-child(1) { transition-delay: 0ms; }
.stagger.visible > *:nth-child(2) { transition-delay: 50ms; }
.stagger.visible > *:nth-child(3) { transition-delay: 100ms; }
.stagger.visible > *:nth-child(4) { transition-delay: 150ms; }
.stagger.visible > *:nth-child(5) { transition-delay: 200ms; }
.stagger.visible > *:nth-child(6) { transition-delay: 250ms; }

.stagger.visible > * {
    opacity: 1;
    transform: translateY(0);
}

/* ==========================================================================
   Responsive: Tablet (max-width: 1024px)
   ========================================================================== */

@media (max-width: 1024px) {
    .hero__inner {
        flex-direction: column;
        text-align: center;
    }

    .hero__content {
        max-width: 100%;
    }

    .hero__image-wrapper {
        width: 220px;
        height: 220px;
        order: -1;
    }

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

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

    .credentials {
        grid-template-columns: 1fr;
        gap: 2rem;
    }
}

/* ==========================================================================
   Responsive: Mobile (max-width: 768px)
   ========================================================================== */

@media (max-width: 768px) {
    .section {
        padding: 3.5rem 0;
    }

    .section__title {
        font-size: 1.625rem;
    }

    /* --- Mobile Nav --- */
    .hamburger {
        display: block;
    }

    .nav__links {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--nav-bg);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        flex-direction: column;
        padding: 1rem 1.5rem 1.5rem;
        gap: 0;
        border-bottom: 1px solid var(--border-color);
    }

    .nav__links.open {
        display: flex;
    }

    .nav__link {
        display: block;
        padding: 0.75rem 0;
        font-size: 1.1rem;
        border-bottom: 1px solid var(--border-color);
    }

    .nav__link::after {
        display: none;
    }

    .nav__links li:last-child .nav__link {
        border-bottom: none;
    }

    /* --- Mobile Hero --- */
    .hero__title {
        font-size: 2rem;
    }

    .hero__tagline {
        font-size: 1rem;
    }

    .hero__image-wrapper {
        width: 180px;
        height: 180px;
    }

    /* --- Mobile Skills --- */
    .skills {
        grid-template-columns: 1fr;
    }

    /* --- Mobile Contact --- */
    .contact {
        flex-direction: column;
        align-items: center;
    }

    .contact__link {
        width: 100%;
        max-width: 320px;
    }

    /* --- Mobile Timeline --- */
    .timeline {
        padding-left: 2rem;
    }

    .timeline__dot {
        left: -2rem;
    }

    .timeline__dot--education {
        left: calc(-2rem - 0.3125rem);
    }

    .timeline__content {
        padding: 1.25rem;
    }
}

/* ==========================================================================
   Responsive: Small Mobile (max-width: 480px)
   ========================================================================== */

@media (max-width: 480px) {
    .about__stats {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .stat-card {
        padding: 1rem;
    }

    .stat-card__number {
        font-size: 1.5rem;
    }
}

/* ==========================================================================
   Reduced Motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }

    html {
        scroll-behavior: auto;
    }

    .reveal,
    .stagger > * {
        opacity: 1;
        transform: none;
        transition: none;
    }
}
