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

/* Local font (from ./fonts) */
@font-face {
    font-family: "Neue Haas Grotesk Display Pro";
    src: url("fonts/neue-haas-grotesk-display-pro/NeueHaasDisplayRoman.ttf") format("truetype");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Neue Haas Grotesk Display Pro";
    src: url("fonts/neue-haas-grotesk-display-pro/NeueHaasDisplayRomanItalic.ttf") format("truetype");
    font-weight: 400;
    font-style: italic;
    font-display: swap;
}

@font-face {
    font-family: "Neue Haas Grotesk Display Pro";
    src: url("fonts/neue-haas-grotesk-display-pro/NeueHaasDisplayMediu.ttf") format("truetype");
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Neue Haas Grotesk Display Pro";
    src: url("fonts/neue-haas-grotesk-display-pro/NeueHaasDisplayMediumItalic.ttf") format("truetype");
    font-weight: 500;
    font-style: italic;
    font-display: swap;
}

:root {
    --color-red: #FF3A30;
    --color-blue: #0030AF;
    --ui-black: #000;
    --ui-white: #fff;
    --ui-height: 64px; /* Standardhöhe für alle Elemente */
    
    /* Theme tokens */
    --page-bg: #fff;
    --page-fg: #000;
    --ui-border: #000;
    --hover-bg: rgba(0,0,0,0.04);
    --poster-bg: #fff;

    /* Typography */
    --font-display: "Neue Haas Grotesk Display Pro", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

body {
    min-height: 100vh;
    background: var(--page-bg);
    color: var(--page-fg);
    font-family: var(--font-display);
}

/* --- MOBILE LAYOUT (< 1101px) --- */
@media (max-width: 1100px) {
    body {
        min-height: 0;
        overscroll-behavior: none;
    }

    .app {
        display: grid;
        grid-template-columns: repeat(12, minmax(0, 1fr));
        grid-template-rows: 1fr repeat(5, var(--ui-height));
        height: 100svh;
    }

    .app__poster {
        grid-column: 1 / -1;
        grid-row: 1;
        overflow: hidden;
        background: var(--page-bg);
        border-bottom: 1px solid var(--ui-border);
    }

    .poster-wrap {
        width: 100%;
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        min-height: 0;
    }

    .poster {
        height: 100%;
        width: auto;
        max-width: 100%;
        aspect-ratio: 210 / 297;
    }

    .generator { display: contents; }
    .generator__title { display: none; }
    .generator__inputs { display: contents; }

    .text-input {
        grid-column: 1 / -1;
        padding: 0 24px;
        border-bottom: 1px solid var(--ui-border);
        display: flex;
        align-items: center;
    }

    .text-input--top    { grid-row: 2; }
    .text-input--mid    { grid-row: 3; }
    .text-input--bottom { grid-row: 4; }

    .generator__colors { display: contents; }

    .color-swatch--blue {
        grid-column: 1 / span 3;
        grid-row: 5;
        background: var(--color-blue);
        border-bottom: 1px solid var(--ui-border);
    }

    .generator__colors .icon-button {
        grid-column: 4 / span 2;
        grid-row: 5;
        border-left: 1px solid var(--ui-border);
        border-bottom: 1px solid var(--ui-border);
    }

    .color-swatch--red {
        grid-column: 6 / span 3;
        grid-row: 5;
        background: var(--color-red);
        border-left: 1px solid var(--ui-border);
        border-bottom: 1px solid var(--ui-border);
    }

    #toggleBgBtn {
        grid-column: 9 / span 4;
        grid-row: 5;
        border-left: 1px solid var(--ui-border);
        border-bottom: 1px solid var(--ui-border);
        background: transparent;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    #submitOrderBtn {
        grid-column: 1 / -1;
        grid-row: 6;
        background: var(--ui-black);
        color: var(--ui-white);
        border: none;
        font-weight: 500;
        font-size: 18px;
    }

    .primary-button { display: none; }
}

/* --- SHARED STYLES --- */

/* Poster: position:relative nötig damit grid-layer (position:absolute;inset:0) korrekt enthalten sind */
.poster {
    position: relative;
    isolation: isolate;
    background: var(--poster-bg);
}

/* Text-Input: flex für vertikale Zentrierung auf Desktop UND Mobile */
.text-input {
    display: flex;
    align-items: center;
}

.text-input input[type="text"] {
    width: 100%;
    border: none;
    outline: none;
    background: transparent;
    font-size: 16px;
    font-style: italic;
    color: var(--page-fg);
}

.color-swatch {
    position: relative;
    cursor: pointer;
    border: none;
}

.color-swatch input[type="color"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.icon-button {
    border: none;
    background: transparent;
    color: var(--page-fg);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-button:hover {
    background: var(--hover-bg);
}

#toggleBgBtn {
    position: relative;
    cursor: pointer;
    font-size: 16px;
}

#toggleBgBtn input[type="color"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.submit-button {
    width: 100%;
    cursor: pointer;
    font-size: 16px;
    font-family: var(--font-display);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.15s;
}

.submit-button:hover {
    opacity: 0.85;
}

.grid-layer {
    position: absolute;
    inset: 0;
    display: flex;
    mix-blend-mode: hard-light;
}

.grid-column {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.tile {
    flex: 1;
    width: 100%;
}

.tile.red { background-color: var(--color-red); }
.tile.blue { background-color: var(--color-blue); }

/* --- DESKTOP LAYOUT (> 1100px) --- */
@media (min-width: 1101px) {
    .app {
        display: grid;
        grid-template-columns: repeat(12, minmax(0, 1fr));
        grid-template-rows: repeat(12, minmax(0, 1fr));
        height: 100vh;
        overflow: hidden;
        padding: clamp(20px, 4vw, 40px);
    }

    .app__poster {
        grid-area: 2 / 2 / span 10 / span 4;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .poster-wrap {
        height: 100%;
        max-width: 100%;
        aspect-ratio: 210 / 297; /* Safari: aspect-ratio auf Wrap statt auf .poster */
    }

    .poster {
        width: 100%;
        height: 100%;
    }

    .color-swatch--blue { background: var(--color-blue); }
    .color-swatch--red  { background: var(--color-red); }

    .generator { display: contents; }
    
    .generator__title {
        grid-area: 2 / 9 / span 2 / span 3;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .generator__title h1 {
        font-size: 32px;
        font-weight: 700;
        text-align: center;
    }

    .generator__inputs { display: contents; }

    .text-input {
        padding: 0 24px;
        border-left: 1px solid var(--ui-border);
        border-right: 1px solid var(--ui-border);
    }

    .text-input--top { grid-area: 4 / 9; border-top: 1px solid var(--ui-border); grid-column: 9 / span 3; }
    .text-input--mid { grid-area: 5 / 9; border-top: 1px solid var(--ui-border); grid-column: 9 / span 3; }
    .text-input--bottom { grid-area: 6 / 9; border-top: 1px solid var(--ui-border); border-bottom: 1px solid var(--ui-border); grid-column: 9 / span 3; }

    .generator__colors { display: contents; }
    .color-swatch--blue { grid-area: 7 / 9; }
    .generator__colors .icon-button { grid-area: 7 / 10; border-left: 1px solid var(--ui-border); border-bottom: 1px solid var(--ui-border); }
    .color-swatch--red { grid-area: 7 / 11; }
    
    #toggleBgBtn {
        grid-area: 8 / 9;
        grid-column: 9 / span 3;
        border-left: 1px solid var(--ui-border);
        border-right: 1px solid var(--ui-border);
        border-bottom: 1px solid var(--ui-border);
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .primary-button {
        display: none;
    }

    #submitOrderBtn {
        grid-area: 10 / 9;
        grid-column: 9 / span 3;
        background: var(--page-fg);
        color: var(--page-bg);
        border: none;
    }
}

/* Overlays & Print */
.confirm-overlay {
    position: fixed;
    inset: 0;
    background: var(--page-bg);
    display: flex;
    flex-direction: column;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
}

.confirm-overlay--visible { opacity: 1; pointer-events: auto; }

.confirm-overlay__content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    padding: 40px 24px;
    text-align: center;
}

.confirm-overlay__icon {
    width: 80px;
    height: 80px;
    border: 1px solid var(--ui-border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
}

.confirm-overlay__title {
    font-size: 22px;
    font-weight: 500;
}

.confirm-overlay__sub {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    opacity: 0.5;
    margin-bottom: -8px; /* Abstand zur Zahl reduzieren */
}

.confirm-overlay__number {
    font-size: 56px;
    font-weight: 400;
    font-style: italic;
}

.confirm-overlay__close {
    width: 100%;
    height: 80px;
    flex-shrink: 0;
    background: var(--page-fg);
    color: var(--page-bg);
    border: none;
    font-size: 18px;
    font-weight: 400;
    font-family: var(--font-display);
    cursor: pointer;
    transition: opacity 0.15s;
}

.confirm-overlay__close:hover {
    opacity: 0.85;
}

/* --- KLEINE SCREENS (< 600px / iPhone SE) --- */
/* Input-Rows sind fix (var(--ui-height)), kein Override nötig */

/* --- DESKTOP: Overlay als zentriertes Modal --- */
@media (min-width: 1101px) {
    .confirm-overlay {
        inset: auto;
        width: 360px;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        border: 1px solid var(--ui-border);
        box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.4);
    }
}

@media print {
    @page { size: A6 portrait; margin: 0; }
    body * { visibility: hidden !important; }
    .app__poster, .poster, .poster * { visibility: visible !important; }
    * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
