/* Mobile-first CSS for WUASCHT */

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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #000000;
    color: #EEEEEE;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    /* Optimize touch handling on iOS */
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    /* Critical: Prevent ALL scrolling to allow canvas touch handling */
    position: fixed;
    touch-action: none;
    overscroll-behavior: none;
}

body {
    position: fixed;
    top: 0;
    left: 0;
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
    /* Allow all touch interactions on canvas for rotation and pinch zoom */
    touch-action: none;
}

/* Phrase Container */
.phrase-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    z-index: 10;
    cursor: pointer;
    pointer-events: auto;
}

.phrase-text {
    font-size: clamp(18px, 5vw, 32px);
    max-width: 90vw;
    line-height: 1.4;
    opacity: 0;
    transition: opacity 0.5s ease-in-out, font-weight 0.2s ease-in-out, filter 0.3s ease-in-out;
    text-shadow: 0 0 20px rgba(0, 0, 0, 0.9), 0 0 40px rgba(0, 0, 0, 0.5);
    font-weight: 400;
    letter-spacing: 0.8px;
}

.phrase-text.active {
    opacity: 0.85;
}

.phrase-container.paused .phrase-text.active {
    opacity: 1;
    font-weight: 900;
    text-shadow: 0 0 20px rgba(238, 238, 238, 0.4), 0 0 40px rgba(238, 238, 238, 0.2), 0 0 60px rgba(238, 238, 238, 0.1);
}

/* Loading Indicator */
.loading {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}

.loading.hidden {
    display: none;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(238, 238, 238, 0.3);
    border-top-color: #EEEEEE;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Easter Egg Overlay */
.easter-egg-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.95);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.5s ease-in-out;
    pointer-events: auto;
}

.easter-egg-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.easter-egg-content {
    width: 90%;
    max-width: 420px;
    text-align: center;
    max-height: 100vh;
    overflow-y: auto;
    padding: 30px 20px;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.easter-egg-content h2 {
    font-size: clamp(20px, 5vw, 28px);
    margin: 0;
    font-weight: bold;
    letter-spacing: 0.5px;
}

.easter-egg-content p {
    font-size: clamp(11px, 2.8vw, 13px);
    line-height: 1.4;
    margin: 0;
    opacity: 0.9;
}

.qr-template {
    width: 100%;
    max-width: 240px;
    height: auto;
    display: block;
    background-color: white;
    padding: 10px;
    border-radius: 6px;
    margin: 4px 0;
}

.download-button {
    width: 100%;
    max-width: 280px;
    padding: 12px 20px;
    background-color: #EEEEEE;
    color: #000000;
    text-decoration: none;
    border-radius: 5px;
    font-weight: bold;
    font-size: clamp(12px, 3.2vw, 14px);
    transition: background-color 0.3s ease;
    border: none;
    cursor: pointer;
    display: block;
    margin: 2px auto;
}

.download-button:hover {
    background-color: #FFFFFF;
}

.download-button:active {
    background-color: #CCCCCC;
}

.amazon-hint {
    width: 100%;
    max-width: 300px;
    padding: 14px 24px;
    border: 2px solid rgba(238, 238, 238, 0.4);
    color: #EEEEEE;
    border-radius: 5px;
    font-size: clamp(12px, 3.2vw, 14px);
    display: block;
    margin: 4px auto;
    opacity: 0.8;
    font-style: italic;
}

.amazon-hint.main-message {
    max-width: 350px;
    padding: 15px 20px;
    border: none;
    font-size: clamp(12px, 3.5vw, 15px);
    opacity: 1;
    font-weight: 600;
    line-height: 1.5;
    background-color: transparent;
    margin: 8px auto;
    text-transform: uppercase;
    letter-spacing: 1.2px;
}

.footer-text {
    margin-top: 12px;
    opacity: 0.6;
    font-size: clamp(11px, 2.5vw, 12px);
    font-style: italic;
}

.close-button {
    position: absolute;
    top: 15px;
    right: 18px;
    background: none;
    border: none;
    color: #EEEEEE;
    font-size: 32px;
    cursor: pointer;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.8;
    transition: opacity 0.3s ease;
    z-index: 1001;
    line-height: 1;
}

.close-button:hover {
    opacity: 1;
}

.close-button:active {
    opacity: 1;
}

/* WebGL Fallback */
.fallback {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    width: 90%;
    max-width: 600px;
    z-index: 10;
}

.fallback.hidden {
    display: none;
}

.fallback p {
    font-size: clamp(16px, 4vw, 20px);
    line-height: 1.6;
    margin-bottom: 20px;
}

/* Tablet adjustments (iPad, etc.) */
@media (min-width: 768px) {
    .phrase-container {
        top: 30px;
    }

    .phrase-text {
        font-size: clamp(28px, 4vw, 48px);
        max-width: 70vw;
    }

    .easter-egg-content {
        padding: 50px 40px;
        max-width: 500px;
    }

    .qr-template {
        max-width: 350px;
    }

    .close-button {
        font-size: 36px;
        top: 20px;
        right: 24px;
    }

    /* Impressum panel - centered card on tablet/desktop */
    .diagnostics-panel {
        bottom: auto !important;
        top: 50% !important;
        left: 50% !important;
        right: auto !important;
        transform: translate(-50%, -50%) !important;
        max-height: 60vh;
        max-width: 400px;
        width: 90%;
        border: 1px solid rgba(238, 238, 238, 0.3);
        border-radius: 12px;
        border-top: none;
    }

    .diagnostics-content {
        padding: 30px;
    }

    #impressum .impressum-title {
        font-size: 16px;
    }

    #impressum p {
        font-size: 13px;
    }

    #impressum .impressum-privacy {
        font-size: 11px;
    }
}

/* Desktop adjustments */
@media (min-width: 1024px) {
    .phrase-container {
        top: 40px;
    }

    .phrase-text {
        font-size: clamp(32px, 3.5vw, 56px);
        max-width: 65vw;
    }

    .diagnostics-panel {
        max-width: 450px;
    }

    .diagnostics-content {
        padding: 40px;
    }

    #impressum .impressum-title {
        font-size: 18px;
    }

    #impressum p {
        font-size: 14px;
    }
}

/* Landscape mode adjustments */
@media (max-height: 600px) {
    .phrase-container {
        top: 45%;
    }

    .easter-egg-content {
        max-height: 95vh;
        padding: 20px 15px;
    }

    .phrase-text {
        font-size: clamp(14px, 4vw, 24px);
    }
}

/* Diagnostics Panel - On-page debugging for mobile */
.diagnostics-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 50vh;
    background-color: rgba(0, 0, 0, 0.98);
    border-top: 2px solid #EEEEEE;
    z-index: 999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: transform 0.3s ease;
}

.diagnostics-panel.hidden {
    display: none;
}

.diagnostics-content {
    padding: 20px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 13px;
    color: #EEEEEE;
    overflow-y: auto;
    flex: 1;
    position: relative;
}

#impressum {
    text-align: center;
}

#impressum .impressum-title {
    font-size: 14px;
    font-weight: bold;
    letter-spacing: 2px;
    margin-bottom: 16px;
    opacity: 0.9;
}

#impressum p {
    margin: 0 0 14px 0;
    line-height: 1.6;
    font-size: 12px;
    opacity: 0.8;
}

#impressum .impressum-privacy {
    margin-top: 20px;
    font-size: 10px;
    opacity: 0.4;
    letter-spacing: 0.3px;
}

.diagnostics-close {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    color: #EEEEEE;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.8;
    transition: opacity 0.3s ease;
}

.diagnostics-close:hover {
    opacity: 1;
}

/* Floating Poop Button - Easter Egg Trigger */
.poop-button {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background-color: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1001;
    opacity: 0;
    transform: translateX(120px) translateY(120px);
    transition: none;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    padding: 0;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

.poop-button-image {
    width: 50px;
    height: 50px;
    object-fit: contain;
    pointer-events: none;
    filter: invert(1) brightness(1.2);
}

.poop-button.visible {
    pointer-events: auto;
    animation: slideInPoop 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) forwards,
              floatPoop 3s ease-in-out 0.8s infinite;
}

@keyframes slideInPoop {
    0% {
        opacity: 0;
        transform: translateX(120px) translateY(120px);
    }
    100% {
        opacity: 1;
        transform: translateX(0) translateY(0);
    }
}

@keyframes floatPoop {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-8px);
    }
}

.poop-button:hover {
    background-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 6px 16px rgba(255, 255, 255, 0.3), 0 0 20px rgba(255, 255, 255, 0.1);
    transform: scale(1.15);
    transition: all 0.3s ease;
}

.poop-button:active {
    background-color: rgba(255, 255, 255, 0.15);
    box-shadow: 0 2px 8px rgba(255, 255, 255, 0.2);
    transform: scale(0.98);
    transition: all 0.15s ease;
}

/* Mobile adjustments for poop button */
@media (max-width: 480px) {
    .poop-button {
        width: 60px;
        height: 60px;
        font-size: 36px;
        bottom: 16px;
        right: 16px;
    }
}

/* Tablet adjustments for poop button */
@media (min-width: 768px) {
    .poop-button {
        width: 80px;
        height: 80px;
        font-size: 44px;
        bottom: 24px;
        right: 24px;
    }

    .poop-button:hover {
        transform: scale(1.2);
    }
}

/* Accessibility: Prefers reduced motion */
@media (prefers-reduced-motion: reduce) {
    .phrase-text,
    .easter-egg-overlay,
    .loading-spinner,
    .poop-button {
        animation: none;
        transition: none;
    }

    .loading-spinner {
        border-top-color: #EEEEEE;
    }

    .poop-button.visible {
        opacity: 1;
        transform: translateX(0) translateY(0);
    }
}
