/* ============================================================================
   HYPERTEXT++ THEME STYLESHEET
   ============================================================================

   Table of Contents:
   ------------------
   1. FONTS
   2. CSS CUSTOM PROPERTIES (Variables)
   3. BASE STYLES (html, body)
   4. TYPOGRAPHY (p, a, strong)
   5. TABLES
   6. LAYOUT (main, article)
   7. HEADER & LOGO
   8. DECORATIVE ELEMENTS
   9. NAVIGATION - Base Styles
   10. NAVIGATION - Nav Items
   11. NAVIGATION - Homepage Scrambled Layout
   12. SNIPPETS GRID
   13. SNIPPET COMPONENT
   14. IMAGE GALLERY
   15. ARTICLE SECTIONS (credits, shows)
   16. MOBILE STYLES (max-width: 768px)

   ============================================================================ */

/* ============================================================================
   1. FONTS
   ============================================================================
   DM Mono font family with various weights and styles.
   Source: ../fonts/TTF/
   ============================================================================ */

@font-face {
    font-family: "DM Mono Light";
    src: url("../fonts/TTF/DMMono-Light.ttf") format("truetype");
}

@font-face {
    font-family: "DM Mono Light Italic";
    src: url("../fonts/TTF/DMMono-LightItalic.ttf") format("truetype");
}

@font-face {
    font-family: "DM Mono Regular";
    src: url("../fonts/TTF/DMMono-Regular.ttf") format("truetype");
}

@font-face {
    font-family: "DM Mono Italic";
    src: url("../fonts/TTF/DMMono-Italic.ttf") format("truetype");
}

@font-face {
    font-family: "DM Mono Medium";
    src: url("../fonts/TTF/DMMono-Medium.ttf") format("truetype");
}

@font-face {
    font-family: "DM Mono Medium Italic";
    src: url("../fonts/TTF/DMMono-MediumItalic.ttf") format("truetype");
}

/* ============================================================================
   2. CSS CUSTOM PROPERTIES
   ============================================================================
   Central place for all configurable values.

   Spacing System:
   - Desktop uses fixed sidebar layout with content offset
   - Mobile uses full-width layout with consistent padding
   ============================================================================ */

:root {
    /* ----- Colors ----- */
    --color-background: #fff;
    --color-text: #000;
    --color-accent: #f13a3a;

    /* ----- Typography ----- */
    --font-primary: "DM Mono Light", monospace;
    --font-medium: "DM Mono Medium", monospace;

    /* ----- Layout: Desktop ----- */
    --desktop-body-margin-left: 260px; /* Space for fixed sidebar */
    --desktop-main-margin-left: 200px; /* Additional content indent */
    --desktop-main-margin-top: 100px; /* Space below header */
    --desktop-article-margin-left: 100px; /* Article indent from main */
    --desktop-content-max-width: 8000px;
    --desktop-article-text-width: 900px;

    /* ----- Layout: Homepage ----- */
    --homepage-nav-left: 600px; /* Nav grid starts after logo area */

    /* ----- Layout: Mobile ----- */
    --mobile-padding: 15px; /* Consistent page padding */
    --mobile-content-gap: 20px; /* Space between major sections */

    /* ----- Navigation ----- */
    --nav-icon-size: 80px;
    --nav-icon-size-homepage: 120px;
    --nav-icon-size-mobile: 64px;
    --nav-gap: 20px;
    --nav-gap-mobile: 15px;

    /* ----- Cursors ----- */
    --cursor-default:
        url("../assets/dither_it_hexe_markus_scaled_bw.gif"), auto;
    --cursor-hover: url("../assets/dither_it_hexe_markus_scaled.gif"), auto;
}

/* ============================================================================
   3. BASE STYLES
   ============================================================================
   Root element and body configuration.
   ============================================================================ */

html {
    cursor: var(--cursor-default);
    background-color: var(--color-background);
    min-height: 100vh;
}

body {
    /* Typography */
    color: var(--color-text);
    font-family: var(--font-primary);
    font-size: large;
    text-align: left;

    /* Layout */
    margin: 40px auto;
    margin-left: var(--desktop-body-margin-left);
    padding: 0 0 10px;
    max-width: var(--desktop-content-max-width) !important;

    /* Appearance */
    cursor: var(--cursor-default);
    background-color: var(--color-background);
}

/* Prevent scrolling when modal/overlay is open */
body:has(.no-scroll) {
    overflow: hidden;
}

/* Homepage: Center body, transparent background */
body.home {
    margin-left: auto;
    background-color: transparent;
}

ol {
    margin-left: 0;
    padding-left: 0;
}

.li_no_numbering {
    list-style-type: none;
    margin: 0;
    padding: 0;
}

/* Ensure paragraphs outside verteiler-content have line-height 1.5 */
p {
    line-height: 0;
}
p:not(.media-row p) {
    line-height: 1.5;
}

/* ----- Verteiler Top Image ----- */
.verteiler-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1;
    max-width: 200px;
    max-height: 200px;
    pointer-events: all;

    .verteiler-top-image {
        position: relative;
        width: 100%;
        height: 100%;

        img {
            width: 100%;
            height: 100%;
            object-fit: cover;
            display: block;
        }
    }
}

.verteiler-form {
    position: absolute;
    bottom: 20px;
    left: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: all;
    padding: 15px;

    input[type="email"],
    button[type="submit"] {
        background: rgba(255, 255, 255, 0.3);
        border: none;
        border-bottom: 1px solid rgba(0, 0, 0, 0.7);
        padding: 8px 0;
        font-family: var(--font-primary);
        font-size: 0.9rem;
        color: rgba(0, 0, 0, 0.9);
        outline: none;
        transition: border-color 0.2s ease;

        &::placeholder {
            color: rgba(0, 0, 0, 0.5);
        }

        &:focus {
            border-bottom-color: rgba(0, 0, 0, 1);
        }
    }

    button[type="submit"] {
        text-align: left;
        cursor: pointer;
        color: red;
        font-weight: bold;

        &:hover {
            border-bottom-color: rgba(0, 0, 0, 1);
            cursor: var(--cursor-hover);
        }
    }
}

.verteiler-content {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 3rem;

    .media-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;

        p {
            display: contents;
        }
        figure {
            width: 100%;
            height: auto;
            grid-column: span 2;
            margin: 0;
        }

        figcaption {
            position: relative;
            top: -40px;
            z-index: 100;
            left: 10px;
            background-color: rgba(255, 255, 255, 0.5);
            width: 30px;
            height: 30px;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        figure.width-1-2 {
            grid-column: span 1;
        }

        figure.width-1-3 {
            grid-column: span 1;
        }

        figure.width-1-1 {
            grid-column: span 2;
        }
    }

    .text {
        width: 90%;
    }
}
            height: 30px;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        figure.width-1-2 {
            grid-column: span 1;
        }

        figure.width-1-3 {
            grid-column: span 1;
        }

        figure.width-1-1 {
            grid-column: span 2;
        }
    }

    .text {
        width: 90%;
    }
}

/* ============================================================================
   4. TYPOGRAPHY
   ============================================================================
   Basic text elements styling.
   ============================================================================ */

a {
    color: var(--color-accent);
    text-decoration: none;
}

a:hover {
    cursor: var(--cursor-hover);
}

a:hover > title {
    text-decoration: underline;
}

/* ============================================================================
   5. TABLES
   ============================================================================
   Default table styling.
   ============================================================================ */

table {
    border-spacing: 0;
    width: 100%;
}

td,
th {
    border: 0;
    padding: 20px 24px;
}

/* ============================================================================
   6. LAYOUT
   ============================================================================
   Main content containers and article styling.
   ============================================================================ */

main {
    margin-left: var(--desktop-main-margin-left);
    margin-top: var(--desktop-main-margin-top);
    padding: 0 0 20px;
}

article {
    font-size: 16px;
    margin-left: var(--desktop-article-margin-left);
}

/* Article paragraphs: fixed width for readability (excludes gallery/snippets) */
article p:not(.image-gallery p):not(.snippets-grid p) {
    max-width: var(--desktop-article-text-width);
    width: 95%;
    text-align: justify;
}

article strong {
    font-family: var(--font-medium);
}

/* ----- Article Headings ----- */

article h1 {
    text-transform: uppercase;
    font-size: 2.2rem;
}

/* Reduce gap when h2 directly follows h1 */
article h1 + h2 {
    margin-top: -1rem;
}

article h2 {
    margin-top: 4rem;
    margin-bottom: 2rem;
    font-family: var(--font-medium);
    text-transform: uppercase;
    font-size: 1.2rem;
    font-weight: 100;
    opacity: 0.7;
}

/* ============================================================================
   7. HEADER & LOGO
   ============================================================================
   Fixed position header image and subtitle.
   ============================================================================ */

#header-image {
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 10;
    width: 300px;
    max-width: 300px;
    color: var(--color-accent);
}

.header-image-sub {
    position: fixed;
    top: 3rem;
    left: 1.2rem;
    z-index: 10;
    font-size: 1rem;
    color: var(--color-accent);
}

/* ============================================================================
   8. DECORATIVE ELEMENTS
   ============================================================================
   Background decorative images.
   ============================================================================ */

.hand {
    position: absolute;
    top: -20px;
    left: 0;
    z-index: -10;
    width: 500px;
    opacity: 95%;
    transform: rotate(140deg);
}

/* ============================================================================
   9. NAVIGATION - Base Styles
   ============================================================================
   Default navigation: vertical sidebar layout (non-homepage).
   Homepage navigation: scrambled grid layout.
   ============================================================================ */

/* ----- Default: Vertical Sidebar Navigation ----- */
nav.nav-grid,
.nav.nav-grid {
    position: fixed;
    left: 1rem;
    top: 100px;
    z-index: 5;
    display: flex;
    flex-direction: column;
    gap: var(--nav-gap);
    height: auto;
    pointer-events: none;
}

/* ----- Homepage: Scrambled Grid Navigation ----- */
body.home nav.nav-grid,
body.home .nav.nav-grid {
    position: fixed;
    left: var(--homepage-nav-left);
    top: 20%;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    grid-template-rows: repeat(4, 1fr);
    width: calc(100vw - var(--homepage-nav-left) - 40px);
    height: 60vh;
}

/* ============================================================================
   10. NAVIGATION - Nav Items
   ============================================================================
   Individual navigation item styling and hover states.
   ============================================================================ */

.nav-grid .nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: all;
}

/* ----- Nav Item Links ----- */
.nav-grid .nav-item a {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: inherit;
}

.nav-grid .nav-item a.current {
    filter: none;
}

.nav-grid .nav-item:has(a.current) {
    filter: none;
}

/* ----- Nav Item Images ----- */
.nav-grid .nav-item img {
    width: var(--nav-icon-size);
    height: var(--nav-icon-size);
    object-fit: contain;
    margin-bottom: 8px;
}

/* Homepage: Larger icons */
body.home .nav-grid .nav-item img {
    width: var(--nav-icon-size-homepage);
    height: var(--nav-icon-size-homepage);
}

/* ----- Nav Item Text ----- */
.nav-grid .nav-item span {
    font-size: 1rem;
    text-align: center;
    white-space: nowrap;
    opacity: 0;
}

/* Show text on current page or hover */
.nav-grid .nav-item:has(a.current) span,
.nav-grid .nav-item:hover span {
    opacity: 1;
}

/* ----- Nav Item Hover States (Image Swaps) ----- */
.nav-grid .nav-item:hover img {
    content: url("../assets/dither_it_arbeit02.png");
}

#arbeit:hover img {
    content: url("../assets/dither_it_arbeit02.png");
}

#ueber-mich:hover img {
    content: url("../assets/dither_it_ueber-mich02.png");
}

#kontakt:hover img {
    content: url("../assets/dither_it_kontakt02.png");
}

#verteiler:hover img {
    content: url("../assets/dither_it_verteiler02.png");
}

#werkstatt:hover img {
    content: url("../assets/dither_it_werkstatt02.png");
}

/* ----- Default Nav Item Positions (Sidebar) ----- */
#arbeit,
#ueber-mich,
#kontakt,
#verteiler,
#werkstatt {
    transform: none;
    align-self: center;
}

/* Homepage: Remove filter */
body.home .nav-grid .nav-item {
    filter: none;
}

/* ============================================================================
   11. NAVIGATION - Homepage Scrambled Layout
   ============================================================================
   Specific grid positions and rotations for homepage nav items.
   ============================================================================ */

body.home #arbeit {
    grid-column: 1;
    grid-row: 2;
    transform: rotate(-20deg);
    justify-self: start;
    align-self: start;
}

body.home #ueber-mich {
    grid-column: 4;
    grid-row: 4;
    transform: rotate(45deg);
    justify-self: end;
    align-self: end;
}

body.home #kontakt {
    grid-column: 2;
    grid-row: 4;
    transform: rotate(-10deg);
    justify-self: center;
    align-self: end;
}

body.home #verteiler {
    grid-column: 4;
    grid-row: 2;
    transform: rotate(30deg);
    justify-self: end;
    align-self: center;
}

body.home #werkstatt {
    grid-column: 3;
    grid-row: 3;
    transform: rotate(15deg);
    justify-self: end;
    align-self: center;
}

/* ============================================================================
   12. SNIPPETS GRID
   ============================================================================
   Grid layout for snippet cards.
   ============================================================================ */

.snippets-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(450px, 1fr));
    gap: 25px;
    margin-right: 40px;
}

/* Hide hr elements around snippets */
.snippets-grid + hr,
hr:has(+ .snippet) {
    display: none;
}

/* ============================================================================
   13. SNIPPET COMPONENT
   ============================================================================
   Individual snippet card with image and hover overlay.
   ============================================================================ */

.snippet {
    position: relative;
    overflow: hidden;
    aspect-ratio: 4 / 3;
    border: 4px solid var(--color-text);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.snippet:hover .snippet-image-container img {
    filter: brightness(0.7);
}

.snippet:hover .snippet-content {
    opacity: 0.9;
}

/* ----- Snippet Image Container ----- */
.snippet-image-container {
    position: relative;
    width: 100%;
    height: 100%;
}

.snippet-image-container img {
    width: 100%;
    height: 100%;
    max-width: 100% !important;
    object-fit: cover;
    display: block;
}

/* Fallback for snippets without images */
.snippet-image-container:not(:has(img)) {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(
        135deg,
        var(--color-accent) 0%,
        var(--color-text) 100%
    );
}

.snippet-image-container:not(:has(img))::before {
    content: "?";
    font-size: 80px;
    font-weight: bold;
    color: rgba(255, 255, 255, 0.3);
}

/* ----- Snippet Content Overlay ----- */
.snippet-content {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
    background: rgba(222, 242, 247, 0.97);
    color: var(--color-text);
    text-align: center;
    text-transform: lowercase;
    overflow-y: auto;
    opacity: 0;
}

.snippet-content h3 {
    margin: 0 0 10px 0;
    font-size: 2em;
    line-height: 1.3;
}

.snippet-content h3 a {
    color: var(--color-accent);
    text-decoration: none;
}

.snippet-content h3 a:hover {
    text-decoration: underline;
}

.snippet-content p {
    margin: 8px 0;
    font-size: 1.2em;
    line-height: 1.5;
    text-transform: lowercase;
}

.snippet-content .nested-children {
    font-size: 0.8em;
    margin: 10px 0;
    padding-left: 20px;
}

.snippet-content .nested-children li {
    margin: 5px 0;
}

.snippet-content small,
.snippet-content sub {
    font-size: 0.75em;
    margin-top: -5px;
}

/* Hide the separate image link in overlay mode */
.snippet-content > p > a:has(img) {
    display: none;
}

/* ============================================================================
   14. IMAGE GALLERY
   ============================================================================
   Horizontal scrolling image gallery.
   ============================================================================ */

.image-gallery {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    cursor: grab;
}

.image-gallery:active {
    cursor: grabbing;
}

.image-gallery img {
    display: inline-block;
    flex-shrink: 0;
    height: 70vh;
    width: auto;
    max-height: none;
    object-fit: contain;
}

.gallery-captions {
    position: absolute;
    right: 0;
    bottom: 0px;
    font-size: 0.9rem;
    visibility: hidden;
}

/* ============================================================================
   15. ARTICLE SECTIONS
   ============================================================================
   Specific styling for credits and shows sections within articles.
   ============================================================================ */

/* ----- Credits Section ----- */
article .credits {
    margin-top: 1rem;
}

article .credits p {
    margin: 0;
    line-height: 2;
}

article .credits a {
    color: var(--color-text);
    text-decoration: underline;
}

/* Förderungen: extra spacing when em is only child */
article .credits p:has(em:only-child) {
    margin-top: 2rem;
}

/* ----- Shows Section (Performance Dates) ----- */
article .shows {
    margin-top: 1rem;
}

article .shows table {
    width: initial;
    border-spacing: 0 5px;
}

article .shows td,
article .shows th {
    border-bottom: none;
    padding: 0 10px 0 0;
}

article .shows td:first-child,
article .shows th:first-child {
    padding-left: 0;
}

/* ============================================================================
   16. MOBILE STYLES
   ============================================================================
   Responsive overrides for screens 768px and below.

   Key changes:
   - Remove fixed sidebar layout
   - Full-width content with consistent padding
   - Static navigation in 2-column grid
   - Simplified snippets grid (single column)
   ============================================================================ */

@media screen and (max-width: 768px) {
    /* -------------------------------------------------------------------------
       16.1 Base Layout Reset
       ------------------------------------------------------------------------- */

    body {
        /* Remove desktop sidebar margin */
        margin: 0;
        margin-top: var(--mobile-content-gap);
        padding: 0 var(--mobile-padding);
        max-width: 100% !important;
    }

    /* Homepage body: same as regular pages on mobile */
    body.home {
        margin: 0;
        margin-top: var(--mobile-content-gap);
        padding: 0 var(--mobile-padding);
    }

    main {
        /* Remove desktop offsets */
        margin-left: 0;
        margin-top: var(--mobile-content-gap);
        padding: var(--mobile-padding) 0;
    }

    article {
        /* Remove desktop indent */
        margin-left: 0;
    }

    /* Article text: full width on mobile */
    article p:not(.image-gallery p):not(.snippets-grid p) {
        width: 100%;
        text-align: left;
    }

    /* -------------------------------------------------------------------------
       16.2 Header & Logo
       ------------------------------------------------------------------------- */

    #header-image {
        /* Keep fixed but smaller */
        position: fixed;
        top: 0.5rem;
        left: 0.5rem;
        width: 150px;
        max-width: 150px;
    }

    .header-image-sub {
        position: fixed;
        top: 1.5rem;
        left: 0.7rem;
        font-size: 0.8rem;
    }

    /* -------------------------------------------------------------------------
       16.3 Navigation - Mobile Grid
       ------------------------------------------------------------------------- */

    /* Reset navigation to static 2-column grid */
    nav.nav-grid,
    .nav.nav-grid,
    body.home nav.nav-grid,
    body.home .nav.nav-grid {
        position: static;
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: repeat(3, auto);
        gap: var(--nav-gap-mobile);
        width: 100%;
        height: auto;
        margin-top: 80px; /* Space for fixed header */
        margin-bottom: var(--mobile-content-gap);
        pointer-events: all;
    }

    /* Nav items: reset all transforms and filters */
    .nav-grid .nav-item,
    body.home .nav-grid .nav-item {
        transform: none;
        filter: none;
        justify-self: center;
        align-self: center;
        text-align: center;
    }

    /* Smaller icons on mobile */
    .nav-grid .nav-item img,
    body.home .nav-grid .nav-item img {
        width: var(--nav-icon-size-mobile);
        height: var(--nav-icon-size-mobile);
    }

    /* Always show labels on mobile */
    .nav-grid .nav-item span {
        opacity: 1;
        font-size: 12px;
    }

    /* -------------------------------------------------------------------------
       16.4 Navigation - Mobile Grid Positions
       ------------------------------------------------------------------------- */

    /* Reset all homepage-specific grid positions */
    #arbeit,
    body.home #arbeit {
        grid-column: 1;
        grid-row: 1;
        transform: none;
        justify-self: center;
        align-self: center;
    }

    #ueber-mich,
    body.home #ueber-mich {
        grid-column: 2;
        grid-row: 1;
        transform: none;
        justify-self: center;
        align-self: center;
    }

    #kontakt,
    body.home #kontakt {
        grid-column: 1;
        grid-row: 2;
        transform: none;
        justify-self: center;
        align-self: center;
    }

    #verteiler,
    body.home #verteiler {
        grid-column: 2;
        grid-row: 2;
        transform: none;
        justify-self: center;
        align-self: center;
    }

    #werkstatt,
    body.home #werkstatt {
        grid-column: 1 / -1; /* Span full width */
        grid-row: 3;
        transform: none;
        justify-self: center;
        align-self: center;
    }

    /* -------------------------------------------------------------------------
       16.5 Images
       ------------------------------------------------------------------------- */

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

    article p img {
        max-width: 100%;
        height: auto;
    }

    /* -------------------------------------------------------------------------
       16.6 Tables
       ------------------------------------------------------------------------- */

    td,
    th {
        padding: 10px 12px;
    }

    /* -------------------------------------------------------------------------
       16.7 Snippets Grid
       ------------------------------------------------------------------------- */

    .snippets-grid {
        grid-template-columns: 1fr;
        gap: var(--nav-gap-mobile);
        margin-right: 0;
    }

    .snippet-content {
        padding: var(--mobile-padding);
    }

    /* -------------------------------------------------------------------------
       16.8 Image Gallery
       ------------------------------------------------------------------------- */

    .image-gallery img {
        height: 30vh;
        max-width: unset;
    }

    .image-gallery-overlay {
        width: 50px;
    }

    /* -------------------------------------------------------------------------
       16.9 Decorative Elements
       ------------------------------------------------------------------------- */

    .hand {
        display: none; /* Hide on mobile to avoid overlap */
    }
}

/* ============================================================================
   17. HIGH DENSITY DISPLAYS (Retina)
   ============================================================================ */

@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    /* Keep dithered/pixelated images sharp on high-res screens */
    img,
    .nav-grid .nav-item img,
    .snippet-image-container img {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: pixelated;
    }

    /*
       If you have high-resolution versions (e.g., @2x) of your assets,
       uncomment and update the paths below to swap them.
    */

    /*
    :root {
        --cursor-default: url("../assets/dither_it_hexe_markus_scaled_bw@2x.gif"), auto;
        --cursor-hover: url("../assets/dither_it_hexe_markus_scaled@2x.gif"), auto;
    }

    #arbeit:hover img { content: url("../assets/dither_it_arbeit02@2x.png"); }
    #ueber-mich:hover img { content: url("../assets/dither_it_ueber-mich02@2x.png"); }
    #kontakt:hover img { content: url("../assets/dither_it_kontakt02@2x.png"); }
    #verteiler:hover img { content: url("../assets/dither_it_verteiler02@2x.png"); }
    #werkstatt:hover img { content: url("../assets/dither_it_werkstatt02@2x.png"); }
    */
}
