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

html {
    scroll-behavior: smooth;
}

/* Font Faces */
@font-face {
    font-family: 'PP Kyoto';
    src: url('assets/font/PPKyoto-Medium.otf') format('opentype');
    font-weight: 500;
    font-style: normal;
}

@font-face {
    font-family: 'PP Kyoto';
    src: url('assets/font/PPKyoto-Light.otf') format('opentype');
    font-weight: 300;
    font-style: normal;
}

/* Theme Variables */
:root {
    /* Base colors - only these change per theme */
    --fg: #FFFFFF;
    --bg: #090909;
    --icon-invert: 1; /* 1 for dark themes, 0 for light themes */
    
    /* Derived colors using color-mix */
    --text-color: var(--fg);
    --bg-color: var(--bg);
    --text-75: color-mix(in srgb, var(--fg) 75%, transparent);
    --text-65: color-mix(in srgb, var(--fg) 65%, transparent);
    --text-50: color-mix(in srgb, var(--fg) 50%, transparent);
    --text-40: color-mix(in srgb, var(--fg) 40%, transparent);
    --text-10: color-mix(in srgb, var(--fg) 10%, transparent);
    --border-color: color-mix(in srgb, var(--fg) 6%, var(--bg));
    --hover-bg: color-mix(in srgb, var(--fg) 3%, var(--bg));
    
    /* Grid */
    --grid-columns: 12;
    --grid-gutter: 10px;
    --grid-margin: 40px;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: 'PP Kyoto', sans-serif;
    font-weight: 300;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
    font-size: 18px;
    line-height: 1.1;
}

body.preload .grid-container {
    opacity: 0;
}

/* Grid Layout */
.grid-container {
    display: grid;
    grid-template-columns: repeat(var(--grid-columns), 1fr);
    column-gap: var(--grid-gutter);
    padding: 0 var(--grid-margin);
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
    position: relative;
    opacity: 1;
    transition: opacity 0.2s ease;
}

/* Hero Wrapper - vertical centering */
.hero-wrapper {
    grid-column: 1 / -1;
    min-height: calc(100vh - 20px);
    display: flex;
    flex-direction: column;
    padding: 40px 0 0;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    color: var(--text-65);
}

.top-block {
    display: grid;
    grid-template-columns: repeat(var(--grid-columns), 1fr);
    column-gap: var(--grid-gutter);
    margin: auto 0;
}

.top-block .hero {
    grid-row: 1;
    margin-bottom: 20px;
}

.top-block .intro {
    grid-row: 2;
}

.name {
    grid-column: 1 / span 4;
    font-size: inherit;
    font-weight: inherit;
    margin: 0;
}

.email {
    grid-column: 9 / span 4;
    text-align: right;
    color: var(--text-50);
    text-decoration: none;
    transition: color 0.2s ease;
}

@media (hover: hover) {
    .email:hover {
        color: var(--text-color);
    }
}

/* Footer */
.footer {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(var(--grid-columns), 1fr);
    column-gap: var(--grid-gutter);
    margin-top: 80px;
    padding-bottom: 32px;
}

.footer .linkedin {
    grid-column: 1 / span 4;
    color: var(--text-50);
    text-decoration: none;
    transition: color 0.2s ease;
}

@media (hover: hover) {
    .footer .linkedin:hover {
        color: var(--text-color);
    }
}

.footer .email {
    grid-column: 9 / span 4;
}

/* Hero Section */
.hero {
    grid-column: 1 / span 6;
}

.hero h1 {
    font-weight: 300;
    font-size: 56px;
    line-height: 0.96;
    letter-spacing: 1.12px;
    white-space: pre-wrap;
    width: 600px;
}

/* Intro Text */
.intro {
    grid-column: 9 / span 4;
    text-align: right;
    color: var(--text-50);
    font-size: 18px;
    line-height: 1.2;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.intro p {
    margin-bottom: 20px;
    width: 400px;
}

.intro .location {
    width: 400px;
}

.intro .toggle-text {
    cursor: pointer;
    text-decoration: underline;
    text-decoration-style: dashed;
    text-decoration-color: var(--text-40);
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
    text-decoration-skip-ink: auto;
    transition: color 0.2s ease, text-decoration-color 0.2s ease;
}

@media (hover: hover) {
    .intro .toggle-text:hover {
        color: var(--text-color);
        text-decoration-color: var(--text-50);
    }
}

.intro .toggle-text.animating {
    text-decoration-color: transparent;
    transition: none;
}

.intro .intro-text.intro-expanded,
.intro .intro-text.intro-awards-expanded,
.intro .intro-text.intro-expanded.intro-awards-expanded,
.intro .location.location-expanded {
    max-width: none;
}

.intro .intro-text.intro-expanded {
    width: min(640px, 85vw);
}

.intro .intro-text.intro-awards-expanded {
    width: min(580px, 85vw);
}

.intro .intro-text.intro-expanded.intro-awards-expanded {
    width: min(800px, 85vw);
}

.intro .location.location-expanded {
    width: min(820px, 85vw);
}

/* CV Wrapper */
.cv-wrapper {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(var(--grid-columns), 1fr);
    column-gap: var(--grid-gutter);
}

/* Testimonials Section */
.testimonials-section {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(var(--grid-columns), 1fr);
    column-gap: var(--grid-gutter);
    margin-top: 100px;
}

.testimonials-header {
    grid-column: 1 / -1;
    margin-bottom: 40px;
}

.testimonials-title {
    font-weight: 500;
    font-size: 40px;
    line-height: 1;
    margin: 0;
}

.testimonial-item {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(var(--grid-columns), 1fr);
    column-gap: var(--grid-gutter);
    padding: 24px 0;
    border-top: 1px solid var(--border-color);
}

.testimonial-item:last-child {
    border-bottom: 1px solid var(--border-color);
}

.testimonial-author {
    grid-column: 1 / span 4;
}

.author-name {
    font-weight: 300;
    font-size: 18px;
    line-height: 1.2;
    margin: 0 0 4px 0;
    color: var(--text-color);
}

.author-title {
    font-weight: 300;
    font-size: 18px;
    line-height: 1.2;
    margin: 0;
    color: var(--text-40);
}

.testimonial-quote {
    grid-column: 6 / span 7;
    font-weight: 300;
    font-size: 18px;
    line-height: 1.2;
    color: var(--text-75);
    letter-spacing: 0.2px;
}

.testimonial-quote p {
    margin: 0 0 14px 0;
}

.testimonial-quote p:last-child {
    margin-bottom: 0;
}

/* Hero Typewriter */
.hero-typewriter {
    display: inline;
}

.hero-typewriter::after {
    content: '';
    display: inline-block;
    width: 2px;
    height: 0.9em;
    background: var(--text-10);
    margin-left: 3px;
    vertical-align: baseline;
    animation: blink 1000ms step-end infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* CV Sections */
.company-section {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(var(--grid-columns), 1fr);
    column-gap: var(--grid-gutter);
    margin-bottom: 100px;
}

.company-header {
    grid-column: 1 / -1;
    margin-bottom: 40px;
}

.company-name {
    font-weight: 500;
    font-size: 40px;
    line-height: 1;
    margin-bottom: 4px;
    color: inherit;
    text-decoration: none;
}

.company-role {
    font-weight: 300;
    font-size: 40px;
    line-height: 1;
}

/* Project Lists */
.year-group {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: subgrid;
}

.year-label {
    grid-column: 5;
    color: var(--text-75);
    display: flex;
    align-items: center;
}

.project-item {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: subgrid;
    padding: 10px 0;
    border-top: 1px solid var(--border-color);
}

@media (hover: hover) {
    .project-item:hover {
        background-color: var(--hover-bg);
    }
}

.company-section .year-group:last-child .project-item:last-child {
    border-bottom: 1px solid var(--border-color);
}

.project-client {
    grid-column: 6 / span 3;
    color: var(--text-75);
    display: flex;
    align-items: center;
    gap: 8px;
}

.project-link-icon {
    width: 16px;
    height: 16px;
    filter: brightness(0) invert(var(--icon-invert)) opacity(0.3);
    pointer-events: none;
    transition: left 0.2s ease-out, top 0.2s ease-out, filter 0.2s ease-out, width 0.2s ease-out, height 0.2s ease-out;
    z-index: 1000;
}

.project-link-icon.hovering {
    width: 24px;
    height: 24px;
    filter: brightness(0) invert(var(--icon-invert));
}

.project-desc {
    grid-column: 10 / span 3;
    text-align: right;
    color: var(--text-40);
    white-space: nowrap;
    text-overflow: ellipsis;
    line-height: 1.4;
}

/* Responsive Design */

/* Large screens - up to 1440px */
@media (max-width: 1440px) {
    :root {
        --grid-margin: 32px;
    }
}

/* Tables - medium layout up to 1280px */
@media (max-width: 1280px) {
    .year-label {
        grid-column: 1 / span 2;
    }

    .project-client {
        grid-column: 3 / span 5;
    }

    .project-desc {
        grid-column: 8 / -1;
    }
}

/* Medium screens - up to 1024px */
@media (max-width: 1024px) {
    :root {
        --grid-margin: 24px;
        --grid-gutter: 8px;
    }
    
    .hero {
        grid-column: 1 / -1;
    }
    
    .company-header {
        grid-column: 1 / -1;
    }
}

/* Short viewports - disable centering */
@media (max-height: 600px) {
    .hero-wrapper {
        min-height: auto;
        padding: 40px 0 60px;
    }

    .top-block {
        margin: 100px 0 0;
    }
}

/* Tall viewports - cap centering at 1000px */
@media (min-height: 1000px) {
    .hero-wrapper {
        min-height: 980px;
    }
}

/* Mobile - up to 768px */
@media (max-width: 768px) {
    :root {
        --grid-margin: 16px;
    }

    body {
        font-size: 16px;
    }

    .hero-wrapper {
        min-height: auto;
        padding: 16px 0 120px;
    }

    .top-block {
        margin: 140px 0 0;
    }

    .hero h1 {
        font-size: 36px;
        width: auto;
    }

    .top-block .hero {
        margin-bottom: 40px;
    }
    
    .intro {
        grid-column: 1 / -1;
        text-align: right;
        font-size: 16px;
        margin-bottom: 0;
        width: auto;
        margin-left: auto;
    }

    .intro p {
        width: auto;
        max-width: min(320px, 85vw);
    }

    .intro .intro-text.intro-expanded,
    .intro .intro-text.intro-awards-expanded,
    .intro .intro-text.intro-expanded.intro-awards-expanded,
    .intro .location.location-expanded {
        max-width: 85vw;
    }

    .intro p br {
        display: none;
    }

    .company-name,
    .company-role {
        font-size: 22px;
    }

    .company-header {
        margin-bottom: 24px;
    }
    
    .company-section {
        margin-bottom: 48px;
    }

    /* CV tables: 2-column layout - year left, client+desc stacked right */
    .project-item {
        display: grid;
        grid-template-columns: 70px 1fr;
        grid-template-rows: auto auto;
        gap: 2px 12px;
        padding: 10px 0;
    }

    .year-label {
        grid-column: 1;
        grid-row: 1;
        text-align: left;
        align-self: start;
    }

    .year-label:empty {
        display: block;
    }

    .project-client {
        grid-column: 2;
        grid-row: 1;
        text-align: left;
    }

    .project-desc {
        grid-column: 2;
        grid-row: 2;
        text-align: left;
        white-space: nowrap;
        text-overflow: ellipsis;
    }

    /* Testimonials mobile layout */
    .testimonials-section {
        margin-top: 48px;
    }

    .testimonials-header {
        margin-bottom: 24px;
    }

    .testimonials-title {
        font-size: 22px;
    }

    .testimonial-item {
        display: flex;
        flex-direction: column;
        gap: 12px;
        padding: 16px 0;
    }

    .testimonial-author {
        grid-column: auto;
    }

    .author-name,
    .author-title {
        font-size: 16px;
    }

    .testimonial-quote {
        grid-column: auto;
        font-size: 16px;
    }

    .testimonial-quote p {
        margin: 0 0 12px 0;
    }
}
