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

body {
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    cursor: none;
}

.cursor {
    position: fixed;
    top: -15px;
    left: -15px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background-color: rgba(255, 0, 0, 0.35);
    pointer-events: none;
    z-index: 9999;
    transition: opacity 0.3s ease;
    will-change: transform;
}

.portfolio-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
}

.master-grid,
.content-grid {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    grid-template-rows: repeat(4, 1fr);
    gap: 1px;
}

.master-grid {
    background-color: #E0E0E0;
}

.grid-cell {
    background-color: #FFFFFF;
    transition: background-color 0.4s ease;
}

.grid-cell:hover {
    background-color: #FF0000;
}

/* Header */
.header {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    z-index: 10;
}

.header-row {
    display: flex;
    height: calc((100vh - 3px) / 40);
}

.header-cell {
    flex: 1;
    background-color: transparent;
    display: flex;
    align-items: center;
    font-family: 'Instrument Sans', sans-serif;
    color: #FF0000;
    font-weight: 700;
    font-size: 1.6vh;
    letter-spacing: 0.02em;
}

.header-cell-right {
    justify-content: flex-end;
}

.header-cell span {
    transition: color 0.4s ease;
}

.header-cell span.inverted {
    color: #FFFFFF;
}

.content-grid {
    pointer-events: none;
}

.content-item {
    pointer-events: none;
}

/* Grid utility classes */
.col-start-2 {
    grid-column-start: 2;
}

.col-span-2 {
    grid-column-end: span 2;
}

.col-span-3 {
    grid-column-end: span 3;
}

.row-start-2 {
    grid-row-start: 2;
}

.row-start-4 {
    grid-row-start: 4;
}

/* Title Module */
.title-module {
    container-type: inline-size;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    width: 100%;
    height: 100%;
    font-family: 'Instrument Sans', sans-serif;
    line-height: 0.85;
}

.top-row {
    display: flex;
    justify-content: space-between;
    width: 100%;
    font-size: 14cqi;
    overflow: visible;
}

.top-row span,
.bottom-row span {
    white-space: nowrap;
}

.bottom-row {
    display: flex;
    justify-content: flex-end;
    width: 100%;
    font-size: 14cqi;
    overflow: visible;
}

/* Bio Module */
.bio-module {
    container-type: inline-size;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    width: 100%;
    height: 100%;
    font-family: 'Instrument Sans', sans-serif;
    line-height: 1.4;
}

.bio-module p {
    font-size: 3cqi;
    font-weight: 300;
    text-align: justify;
    hyphens: auto;
}


/* Portrait Module */
.portrait-module {
    grid-column: 5 / 7;
    grid-row: 1 / -1;
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
    overflow: hidden;
}

.portrait-module img {
    height: 100%;
    width: auto;
    object-fit: contain;
}

@media (min-width: 431px) and (max-width: 1024px) {
    .bio-module p {
        font-size: 4.5cqi;
    }

    .portrait-module {
        grid-row: 2 / -1;
    }
}

@media (max-width: 430px) {
    body {
        cursor: auto;
    }

    .cursor {
        display: none;
    }

    .header-row {
        height: calc((100vh - 3px) / 40);
    }

    .header-cell {
        display: none;
    }

    /* Row 1: KARL KALN (col1), PORTFOLIO (col4 right) */
    .header-row:nth-child(2) .header-cell:nth-child(1),
    .header-row:nth-child(2) .header-cell:nth-child(6) {
        display: flex;
    }

    /* Row 2: CONTACT (col2), RESUME (col5) */
    .header-row:nth-child(3) .header-cell:nth-child(2),
    .header-row:nth-child(3) .header-cell:nth-child(5) {
        display: flex;
    }

    .header-row {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
    }

    /* Row 1: KARL KALN in col 1 */
    .header-row:nth-child(2) .header-cell:nth-child(1) {
        grid-column: 1;
    }

    /* Row 1: PORTFOLIO in col 4, right-aligned */
    .header-row:nth-child(2) .header-cell:nth-child(6) {
        grid-column: 4;
        justify-content: flex-end;
    }

    /* Row 2: CONTACT in col 2 */
    .header-row:nth-child(3) .header-cell:nth-child(2) {
        grid-column: 2;
    }

    /* Row 2: RESUME in col 3 */
    .header-row:nth-child(3) .header-cell:nth-child(5) {
        grid-column: 3;
    }

    /* Spacer row: just empty */
    .header-spacer {
        display: block;
    }

    .master-grid,
    .content-grid {
        grid-template-columns: repeat(4, 1fr);
        grid-template-rows: repeat(4, 1fr);
    }

    .grid-cell:nth-child(n+17) {
        display: none;
    }

    .title-module {
        grid-column: 1 / -1;
        grid-row: 2 / 3;
        height: 100%;
        justify-content: flex-start;
        gap: 1cqi;
    }

    .top-row {
        width: 100%;
        font-size: 10cqi;
    }

    .bottom-row {
        width: 100%;
        font-size: 10cqi;
        justify-content: flex-start;
    }

    .bio-module {
        grid-column: 1 / 3;
        grid-row: 3 / 5;
        height: 100%;
    }

    .bio-module p {
        font-size: 9cqi;
        text-align: left;
    }

    .portrait-module {
        grid-column: 3 / -1;
        grid-row: 2 / -1;
        justify-content: center;
        align-items: flex-end;
        overflow: visible;
    }

    .portrait-module img {
        width: 100%;
        height: auto;
    }
}
