/* Basis - Optimiert für Performance */
html {
    scroll-behavior: smooth;
}

body {
    font-family: Garamond, serif;
    margin: 0;
    padding: 20px;
    background-color: #fff;
    color: #333;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.index-page {
    height: 100dvh;
    overflow: hidden;
    box-sizing: border-box;
    overscroll-behavior: none;
    position: fixed;
    inset: 0;
    width: 100%;
    padding: 0;
}

.kontakt-page {
    height: 100dvh;
    min-height: 100dvh;
    overflow: hidden;
    overflow: clip;
    box-sizing: border-box;
    overscroll-behavior: none;
    position: fixed;
    inset: 0;
    width: 100%;
    padding: 0;
}

.project-page.kontakt-page main {
    min-height: calc(100vh - 80px);
    overflow: hidden;
    position: relative;
    padding-top: 0;
}

.index-page header {
    padding: 20px;
    margin-bottom: 0;
}

.kontakt-page header {
    padding: 20px;
    margin-bottom: 0;
}

html:has(body.index-page) {
    overflow: hidden;
    height: 100%;
}

html:has(body.kontakt-page) {
    overflow: hidden;
    overflow: clip;
    height: 100%;
}

/* Header */
header {
    position: relative;
    z-index: 30;
    text-align: left;
    margin-bottom: 20px;
}

header h1 {
    font-size: 0.8rem;
    margin: 0 0 -10px 0px;
}

header h1 a {
    color: inherit;
    text-decoration: none;
}

header p {
    font-size: 0.8rem;
    color: #000000;
}

.index-contact-link {
    position: absolute;
    top: 20px;
    right: 20px;
    font-size: 0.8rem;
    color: #000000;
    text-decoration: none;
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    line-height: 1;
}

.project-page:not(.kontakt-page) .index-contact-link {
    top: 0;
    right: 0;
}

main {
    position: relative;
    min-height: calc(100vh - 80px);
    overflow: hidden;
}

.project-page main {
    overflow: visible;
    position: static;
    padding-top: clamp(56px, 8vw, 96px);
}

.hownot-page {
    height: 100dvh;
    overflow: hidden;
    box-sizing: border-box;
    overscroll-behavior: none;
    position: fixed;
    inset: 0;
    width: 100%;
    padding: 0;
    background-color: #fff;
}

.hownot-page header {
    padding: 20px;
    margin-bottom: 0;
}

.project-page.hownot-page main {
    min-height: calc(100vh - 80px);
    overflow: hidden;
    position: relative;
    padding-top: clamp(56px, 8vw, 96px);
    background-image: url("images/hownottobeseen/muster_result.webp");
    background-repeat: no-repeat;
    background-position: center 150px;
    background-size: cover;
}

html:has(body.hownot-page) {
    overflow: hidden;
    height: 100%;
}

/* Project Links - GPU Accelerated */
.project-link {
    position: absolute;
    left: 0;
    width: max-content;
    animation: project-loop 12s linear infinite;
    animation-fill-mode: both;
    will-change: transform;
    transform: translate3d(-100%, 0, 0);
    backface-visibility: hidden;
    contain: paint;
}

.project-link:nth-of-type(even) {
    animation-direction: reverse;
}

.project-link img {
    width: 70px;
    height: auto;
    display: block;
}

.project-link + .project-link {
    margin-top: 0;
}

.project-link a {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    font-family: 'Cormorant Garamond', Garamond, serif;
    font-size: clamp(32px, 6.6vw, 64pt);
    font-style: normal;
    font-weight: 300;
    font-variation-settings: "wght" 300;
    font-synthesis: none;
    line-height: 1;
    letter-spacing: 0;
    color: #000000;
    text-decoration: none;
    text-transform: uppercase;
}

/* Final lock: force one identical style for every index project link */
.index-page .project-link > a {
    font-family: 'Cormorant Garamond', Garamond, serif !important;
    font-size: clamp(32px, 6.6vw, 64pt) !important;
    font-style: normal !important;
    font-weight: 300 !important;
    font-variation-settings: "wght" 300 !important;
    font-synthesis: none;
    line-height: 1 !important;
    letter-spacing: 0 !important;
    color: #000000 !important;
    text-decoration: none !important;
    text-transform: uppercase !important;
    text-shadow: none !important;
    -webkit-text-stroke: 0 transparent !important;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: geometricPrecision;
}

/* Rebuilt last line: controlled text layering to match stroke appearance */
.index-page .project-link.rebuilt-last-line > a {
    display: inline-grid;
    grid-auto-flow: column;
    align-items: center;
    column-gap: 8px;
}

.index-page .project-link.rebuilt-last-line .project-link-label {
    position: relative;
    display: inline-block;
    font: inherit;
    font-weight: 300 !important;
    font-variation-settings: "wght" 300 !important;
    line-height: 1 !important;
    letter-spacing: 0 !important;
    color: #000000;
    text-transform: uppercase;
    transform: translateZ(0);
}

.index-page .project-link.rebuilt-last-line .project-link-label::after {
    content: attr(data-text);
    position: absolute;
    inset: 0;
    pointer-events: none;
    color: #000000;
    opacity: 0.08;
    transform: translateX(0.02px);
}

.project-link a + a {
    margin-left: 0;
}

.project-link.split-row {
    width: max-content;
}

.project-link.split-row a + a {
    margin-left: 72vw;
}

.back-link {
    font-family: 'Cormorant Garamond', Garamond, serif;
    font-size: 34pt;
    color: #000000;
    text-decoration: none;
    text-transform: none;
    white-space: nowrap;
}

.project-footer {
    position: static;
    margin-top: 48px;
    padding: 0 0 24px;
    text-align: center;
}

.project-page .thumb-grid.mascha-grid {
    margin: 16px auto 0;
}

.mascha-footer {
    margin-top: -24px;
}

.project-link:nth-of-type(1) {
    top: 40%;
}

.project-link:nth-of-type(2) {
    top: 54%;
}

.project-link:nth-of-type(3) {
    top: 68%;
}

.project-link:nth-of-type(4) {
    top: 82%;
}

@keyframes project-loop {
    0% {
        transform: translate3d(-100%, 0, 0);
    }
    100% {
        transform: translate3d(100vw, 0, 0);
    }
}

@media (prefers-reduced-motion: reduce) {
    .project-link {
        animation: none;
        transform: none;
    }

    .abstrakt-images img,
    .thumb-grid img,
    .image-lightbox,
    .image-lightbox img {
        transition: none;
    }
}

/* Project Detail */
.project-detail {
    text-align: center;
    margin-top: 0;
    position: relative;
    z-index: 200;
}

.kontakt-section {
    width: min(480px, 92%);
    margin: 24px auto 80px;
}

.kontakt-page .kontakt-section {
    margin: 24px auto 0;
}

.kontakt-image {
    width: min(150px, 36vw);
    height: auto;
    display: block;
    margin: 0 0 20px;
}

.project-page .project-detail {
    margin-top: 0;
    position: absolute;
    top: clamp(12px, 2vw, 20px);
    left: 50%;
    transform: translateX(-50%);
    width: max-content;
}

.project-detail h2 {
    font-family: 'Cormorant Garamond', Garamond, serif;
    font-size: clamp(32px, 6.6vw, 64pt);
    color: #000000;
    text-transform: uppercase;
    font-weight: 300;
    font-variation-settings: "wght" 300;
    letter-spacing: 0;
    margin: 0;
    line-height: 1;
    position: relative;
    z-index: 300;
    transform: none;
    pointer-events: none;
}

/* How Not To Be Seen layout: 3 images side by side */
.hownot-layout {
    width: min(1080px, 90%);
    margin: 34px auto 80px;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.hownot-layout img {
    width: 100%;
    height: auto;
    display: block;
    cursor: zoom-in;
    transition: transform 0.2s ease;
    will-change: transform;
}

.hownot-layout img:hover {
    transform: scale(1.01);
}

.hownot-page .hownot-layout {
    width: min(1100px, 94%);
    margin: 10px auto 0;
    gap: 12px;
}

.hownot-page .hownot-top-image {
    width: auto;
    max-width: min(900px, 100%);
    max-height: min(62dvh, 620px);
    object-fit: contain;
}

.hownot-page .hownot-bottom-row {
    width: min(900px, 100%);
}

.hownot-page .hownot-bottom-row img {
    max-height: min(22dvh, 220px);
    object-fit: cover;
}

.hownot-page .project-footer {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    margin-top: 0;
    padding: 0 0 12px;
}

/* Abstrakt - Optimiert */
.abstrakt-page main {
    min-height: auto;
    overflow: visible;
    padding-bottom: 24px;
}

.abstrakt-images {
    width: min(1200px, 96%);
    margin: 24px auto 0;
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 18px;
}

.abstrakt-images img {
    width: 100%;
    height: auto;
    display: block;
    cursor: zoom-in;
    transition: transform 0.2s ease;
    will-change: transform;
}

.abstrakt-images img:hover {
    transform: scale(1.02);
}

.abstrakt-images img:nth-child(1) { grid-column: 1 / span 4; grid-row: 1; }
.abstrakt-images img:nth-child(2) { grid-column: 5 / span 4; grid-row: 1; }
.abstrakt-images img:nth-child(3) { grid-column: 9 / span 4; grid-row: 1; }
.abstrakt-images img:nth-child(5) { grid-column: 1 / span 5; grid-row: 2; }
.abstrakt-images img:nth-child(6) { grid-column: 8 / span 5; grid-row: 2; }
.abstrakt-images img:nth-child(4) { grid-column: 1 / span 4; grid-row: 3; }
.abstrakt-images img:nth-child(7) { grid-column: 5 / span 4; grid-row: 3; }
.abstrakt-images img:nth-child(8) { grid-column: 9 / span 4; grid-row: 3; }
.abstrakt-images img:nth-child(9) { grid-column: 1 / span 6; grid-row: 4; }
.abstrakt-images img:nth-child(10) { grid-column: 7 / span 6; grid-row: 4; }
.abstrakt-images img:nth-child(11) { grid-column: 1 / span 6; grid-row: 5; }
.abstrakt-images img:nth-child(12) { grid-column: 7 / span 6; grid-row: 5; }

.abstrakt-images img:nth-child(-n+3) {
    aspect-ratio: 4 / 5;
    object-fit: cover;
}

.abstrakt-images img:nth-child(5),
.abstrakt-images img:nth-child(6) {
    aspect-ratio: 4 / 3;
    object-fit: cover;
}

.abstrakt-images img:nth-child(9),
.abstrakt-images img:nth-child(10),
.abstrakt-images img:nth-child(11),
.abstrakt-images img:nth-child(12) {
    aspect-ratio: 3 / 4;
    object-fit: contain;
}

/* Thumb Grid */
.thumb-grid {
    width: min(1400px, 96%);
    margin: 16px auto 80px;
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 10px;
    align-items: start;
}

.thumb-grid img {
    width: 100%;
    height: auto;
    display: block;
    cursor: zoom-in;
    transition: transform 0.2s ease;
    will-change: transform;
}

.thumb-grid img:hover {
    transform: scale(1.02);
}

.thumb-grid img:nth-child(n + 7):nth-child(-n + 12) {
    align-self: end;
}

/* Lightbox - Optimiert */
.image-lightbox {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.9);
    z-index: 9998;
    padding: 24px;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.24s ease, visibility 0.24s ease;
}

.image-lightbox.open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.image-lightbox img {
    max-width: min(92vw, 1400px);
    max-height: 92vh;
    width: auto;
    height: auto;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    transform: scale(0.92);
    transition: transform 0.28s ease;
    object-fit: contain;
}

.image-lightbox.open img {
    transform: scale(1);
}

.image-lightbox-close {
    position: absolute;
    top: 16px;
    right: 24px;
    border: 0;
    background: transparent;
    color: #fff;
    font-size: 42px;
    line-height: 1;
    cursor: pointer;
    transition: opacity 0.2s ease;
    padding: 8px 16px;
    font-weight: 300;
}

.image-lightbox-close:hover {
    opacity: 0.7;
}

/* Responsive Design */
@media (max-width: 900px) {
    .abstrakt-images {
        grid-template-columns: repeat(2, minmax(140px, 1fr));
        gap: 12px;
    }

    .abstrakt-images img:nth-child(n) {
        grid-column: auto;
        grid-row: auto;
    }

    .thumb-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (max-width: 700px) {
    body {
        padding: 16px;
    }

    header {
        margin-bottom: 16px;
    }

    .project-page .project-detail {
        top: 16px;
    }


    .back-link {
        font-size: 34pt;
    }

    .project-detail h2 {
        font-size: clamp(24px, 6vw, 50px);
    }

    .thumb-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
        margin: 12px auto 60px;
    }

    .abstrakt-images {
        grid-template-columns: repeat(2, minmax(100px, 1fr));
        gap: 10px;
    }

    .hownot-bottom-row {
        width: 100%;
        grid-template-columns: 1fr;
    }

    .hownot-top-image {
        width: 100%;
    }

    .index-page .project-link > a {
        font-size: clamp(24px, 6vw, 50px);
        gap: 12px;
    }

    .project-link img {
        width: 50px;
    }

    .image-lightbox {
        padding: 16px;
    }

    .image-lightbox img {
        max-width: 95vw;
        max-height: 95vh;
    }

    .image-lightbox-close {
        top: 12px;
        right: 16px;
        font-size: 32px;
    }
}

@media (max-width: 480px) {
    body {
        padding: 12px;
    }

    .project-page .project-detail {
        top: 12px;
    }


    header h1 {
        font-size: 0.7rem;
    }

    header p {
        font-size: 0.65rem;
    }

    .index-page .project-link > a {
        font-size: 18px;
    }

    .project-detail h2 {
        font-size: 18px;
    }
}
