/**
 * MindScape Terminal – Responsive (nur Media Queries)
 * Desktop-UI bleibt; auf Smartphone/Tablet dashboard-ähnliche Anordnung,
 * Proportionen und Größen angepasst.
 */

/* ========== Tablet / großes Smartphone (bis 768px) – minimal kleiner ========== */
@media (max-width: 768px) {
    html {
        font-size: 95%;
    }

    body {
        height: auto;
        min-height: 100vh;
    }

    .container {
        flex-direction: column;
        min-height: 100vh;
        padding-inline: 8px;
        padding-block: 0 8px;
    }

    .column {
        width: 100%;
        height: auto;
        min-height: 0;
        flex-shrink: 0;
        padding-inline: 8px;
        padding-block: 8px;
    }

    .left-column,
    .right-column {
        width: 100%;
        max-height: 38vh;
    }

    .left-column .panel,
    .right-column .panel {
        max-height: 38vh;
        overflow-y: auto;
        padding: 12px;
    }

    .middle-column {
        width: 100%;
        flex: 1 1 auto;
        min-height: 260px;
        display: flex;
        flex-direction: column;
    }

    .middle-column .terminal-panel {
        flex: 1;
        min-height: 220px;
    }

    .media-player {
        margin-top: 8px;
    }

    /* Fetch/ASCII: kein horizontaler Scroll im Terminal */
    .fetch-container {
        flex-wrap: wrap;
        gap: 10px;
    }

    .fetch-logo {
        font-size: 0.72em;
        max-width: 100%;
        overflow-x: auto;
    }

    .identity-modal-content {
        width: min(520px, 94vw);
    }
}

/* ========== Smartphone (bis 480px) – dashboard-ähnlich, insgesamt minimal kleiner ========== */
@media (max-width: 480px) {
    html {
        font-size: 90%;
    }

    body {
        min-height: 100vh;
    }

    /* Waybar: kompakter; symmetrisch zentriert */
    .waybar {
        padding-inline: 8px;
        height: 34px;
        margin-inline: 6px;
        margin-block: 4px 0;
        border-radius: 8px;
    }

    .waybar-center {
        display: none !important;
    }

    .waybar-right {
        display: flex;
    }

    .waybar-right .waybar-icon {
        width: 28px;
        height: 28px;
        min-width: 28px;
        min-height: 28px;
        border-radius: 6px;
        font-size: 0.85rem;
    }

    .waybar-left .waybar-icon-app {
        position: relative;
        width: 32px;
        height: 32px;
        min-width: 32px;
        min-height: 32px;
        border-radius: 6px;
        font-size: 0.9rem;
    }

    .waybar-icon-app.is-active {
        background: transparent;
    }

    .waybar-icon-app.is-active::before {
        content: '';
        position: absolute;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
        width: 20px;
        height: 20px;
        border-radius: 4px;
        background: rgba(224, 175, 255, 0.2);
        z-index: 0;
    }

    .waybar-icon-app i {
        position: relative;
        z-index: 1;
    }

    .waybar-left {
        justify-content: flex-start;
        gap: 4px;
    }

    .waybar-divider {
        height: 12px;
    }

    /* Container: symmetrisches Padding, zentral */
    .container {
        padding-inline: 6px;
        padding-block: 0 6px;
        gap: 0;
    }

    .column {
        padding-inline: 6px;
        padding-block: 5px;
    }

    .left-column {
        max-height: none;
        min-height: 0;
    }

    .left-column .narrative-panel {
        min-height: 160px;
        max-height: 30vh;
        border-radius: 8px;
        padding: 8px 10px;
    }

    .left-column .panel,
    .right-column .panel {
        max-height: none;
    }

    .right-column .status-panel {
        min-height: 180px;
        max-height: 34vh;
        border-radius: 8px;
        padding: 8px 10px;
    }

    .status-panel #objectives,
    .status-panel #skills,
    .status-panel #game-solution {
        padding: 6px 8px;
        margin-bottom: 6px;
    }

    .status-panel #objectives h3,
    .status-panel #skills h3,
    .status-panel #game-solution h3 {
        font-size: 0.88em;
    }

    .game-solution-content {
        max-height: 180px;
        font-size: 0.95em;
    }

    .objectives-completed-wrap:not(.is-collapsed) {
        max-height: min(360px, 48vh);
    }

    .middle-column {
        min-height: 240px;
        flex: 1 1 auto;
        order: 0;
    }

    .middle-column .terminal-panel {
        min-height: 200px;
        border-radius: 8px 8px 0 0; /* nur oben, unten ohne Radius wie Desktop */
        padding: 8px 10px;
    }

    #terminal-output {
        padding: 8px;
        font-size: 0.95em;
    }

    .terminal-loading-text {
        font-size: 0.8rem;
    }

    .terminal-input {
        padding: 6px 8px;
        border-radius: 0 0 8px 8px;
    }

    #terminal-input-line {
        font-size: 16px; /* verhindert Zoom auf iOS */
    }

    .editor-panel {
        min-height: 180px;
        padding: 8px 10px;
    }

    .editor-panel h2 {
        font-size: 0.9em;
    }

    .editor-panel .CodeMirror {
        min-height: 160px;
    }

    .media-player {
        margin-top: 6px;
        padding: 8px 10px;
        border-radius: 8px;
    }

    .media-player-cover-wrap {
        max-width: 120px;
        margin-bottom: 8px;
    }

    .media-player-info {
        font-size: 0.9em;
        margin-bottom: 8px;
    }

    .media-title {
        font-size: 0.9rem;
    }

    .media-artist {
        font-size: 0.75rem;
    }

    .media-player-progress {
        gap: 6px;
        margin-bottom: 8px;
    }

    .media-time-current,
    .media-time-total {
        font-size: 0.7rem;
    }

    .media-player-controls {
        gap: 6px;
        margin-bottom: 8px;
    }

    .media-btn {
        width: 40px;
        height: 40px;
        min-width: 40px;
        min-height: 40px;
        font-size: 0.85rem;
    }

    .media-btn-play {
        width: 44px;
        height: 44px;
        min-width: 44px;
        min-height: 44px;
        font-size: 1rem;
    }

    .media-progress-slider::-webkit-slider-thumb {
        width: 18px;
        height: 18px;
    }

    .media-progress-slider::-moz-range-thumb {
        width: 18px;
        height: 18px;
    }

    .messenger-chat-item {
        padding: 6px 8px;
    }

    .messenger-chat-avatar {
        width: 24px;
        height: 24px;
    }

    .messenger-chat-name {
        font-size: 0.85em;
    }

    .messenger-chat-preview {
        font-size: 0.65rem;
    }

    .messenger-bubble {
        font-size: 0.72rem;
        padding: 3px 6px;
    }

    .messenger-input-field {
        font-size: 0.9em;
        padding: 3px 5px;
    }

    .messenger-input-send {
        width: 40px;
        height: 40px;
        min-width: 40px;
        min-height: 40px;
    }

    .objectives-completed-header {
        padding: 8px 0;
        min-height: 40px;
        font-size: 0.9em;
        align-items: center;
    }

    #objectives .objective-active,
    #objectives .objective-completed {
        font-size: 0.88em;
    }

    .skill-row {
        font-size: 0.85em;
    }

    .mission-notification {
        left: 6px;
        right: 6px;
        bottom: auto;
        max-width: none;
        width: auto;
        padding: 10px 40px 10px 12px;
        font-size: 0.85rem;
        border-radius: 10px;
    }

    .mission-notification-close {
        width: 40px;
        height: 40px;
        min-width: 40px;
        min-height: 40px;
        top: 5px;
        right: 5px;
    }

    .notification-container {
        left: 6px;
        right: 6px;
        bottom: 6px;
        max-width: none;
        align-items: stretch;
    }

    .scan-progress-wrap {
        max-width: 100%;
    }

    .fetch-container {
        gap: 8px;
        margin: 10px 0;
    }

    .fetch-logo {
        font-size: 0.68em;
    }

    .fetch-info {
        font-size: 0.85em;
    }

    .identity-modal-content {
        width: 96vw;
        border-radius: 10px;
    }

    .identity-modal-header {
        padding: 12px 14px;
    }

    .identity-form {
        padding: 12px 14px 14px;
        gap: 6px;
    }

    .identity-input {
        padding: 9px 10px;
    }
}

/* ========== Sehr kleines Smartphone (bis 360px) – noch etwas kleiner ========== */
@media (max-width: 360px) {
    html {
        font-size: 85%;
    }

    .waybar {
        height: 30px;
        margin-inline: 4px;
        margin-block: 3px 0;
        padding-inline: 6px;
        border-radius: 6px;
    }

    .waybar-left .waybar-icon-app {
        position: relative;
        width: 28px;
        height: 28px;
        min-width: 28px;
        min-height: 28px;
        border-radius: 5px;
        font-size: 0.85rem;
    }

    .waybar-icon-app.is-active {
        background: transparent;
    }

    .waybar-icon-app.is-active::before {
        content: '';
        position: absolute;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
        width: 16px;
        height: 16px;
        border-radius: 3px;
        background: rgba(224, 175, 255, 0.22);
        z-index: 0;
    }

    .waybar-divider {
        height: 10px;
    }

    .waybar-right {
        display: flex;
    }

    .waybar-right .waybar-icon {
        width: 24px;
        height: 24px;
        min-width: 24px;
        min-height: 24px;
        border-radius: 5px;
        font-size: 0.8rem;
    }

    .container {
        padding-inline: 4px;
        padding-block: 0 4px;
    }

    .column {
        padding-inline: 5px;
        padding-block: 4px;
    }

    .left-column .narrative-panel {
        min-height: 140px;
        max-height: 26vh;
        padding: 6px 8px;
    }

    .right-column .status-panel {
        min-height: 160px;
        max-height: 30vh;
        padding: 6px 8px;
    }

    .status-panel #objectives,
    .status-panel #skills,
    .status-panel #game-solution {
        padding: 5px 6px;
        margin-bottom: 5px;
    }

    .game-solution-content {
        max-height: 160px;
    }

    .middle-column {
        min-height: 220px;
    }

    .middle-column .terminal-panel {
        min-height: 180px;
        border-radius: 6px 6px 0 0; /* nur oben, unten ohne Radius wie Desktop */
        padding: 6px 8px;
    }

    #terminal-output {
        padding: 6px;
    }

    .terminal-input {
        padding: 5px 6px;
        border-radius: 0 0 6px 6px;
    }

    .editor-panel {
        min-height: 160px;
    }

    .editor-panel .CodeMirror {
        min-height: 140px;
    }

    .media-player {
        padding: 6px 8px;
        margin-top: 4px;
    }

    .media-player-cover-wrap {
        max-width: 100px;
        margin-bottom: 6px;
    }

    .media-btn {
        width: 36px;
        height: 36px;
        min-width: 36px;
        min-height: 36px;
    }

    .media-btn-play {
        width: 40px;
        height: 40px;
        min-width: 40px;
        min-height: 40px;
    }

    .media-progress-slider::-webkit-slider-thumb,
    .media-progress-slider::-moz-range-thumb {
        width: 16px;
        height: 16px;
    }

    .messenger-chat-avatar {
        width: 22px;
        height: 22px;
    }

    .mission-notification {
        left: 4px;
        right: 4px;
        padding: 8px 36px 8px 10px;
        font-size: 0.8rem;
    }

    .notification-container {
        left: 4px;
        right: 4px;
        bottom: 4px;
    }
}

/* ========== Background Wallpaper Modal – Responsive ========== */

/* Tablet / großes Smartphone (bis 768px) */
@media (max-width: 768px) {
    .background-modal-content {
        max-width: 95vw;
        max-height: 90vh;
        width: auto;
    }

    .background-modal-header {
        padding: 14px 16px;
    }

    .background-modal-header h3 {
        font-size: 1em;
    }

    .background-modal-close {
        font-size: 1.3em;
        padding: 6px 10px;
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .background-modal-grid {
        padding: 16px;
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 14px;
        max-height: calc(90vh - 70px);
    }

    .background-thumbnail-label {
        font-size: 0.72em;
        padding: 6px 5px 3px;
    }
}

/* Smartphone (bis 480px) */
@media (max-width: 480px) {
    .background-modal-content {
        max-width: 96vw;
        max-height: 92vh;
        border-radius: 10px;
    }

    .background-modal-header {
        padding: 12px 14px;
    }

    .background-modal-header h3 {
        font-size: 0.95em;
    }

    .background-modal-close {
        font-size: 1.4em;
        padding: 8px;
        min-width: 44px;
        min-height: 44px;
        margin: -4px -6px -4px 0;
    }

    .background-modal-grid {
        padding: 12px;
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 12px;
        max-height: calc(92vh - 60px);
    }

    .background-thumbnail {
        border-radius: 6px;
        border-width: 2px;
    }

    .background-thumbnail:hover {
        transform: scale(1.02);
    }

    .background-thumbnail-label {
        font-size: 0.7em;
        padding: 6px 4px 3px;
    }
}

/* Sehr kleines Smartphone (bis 360px) */
@media (max-width: 360px) {
    .background-modal-content {
        max-width: 98vw;
        max-height: 94vh;
        border-radius: 8px;
    }

    .background-modal-header {
        padding: 10px 12px;
    }

    .background-modal-header h3 {
        font-size: 0.9em;
    }

    .background-modal-close {
        font-size: 1.3em;
        min-width: 42px;
        min-height: 42px;
        margin: -3px -4px -3px 0;
    }

    .background-modal-grid {
        padding: 10px;
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
        max-height: calc(94vh - 54px);
    }

    .background-thumbnail {
        border-radius: 5px;
    }

    .background-thumbnail:hover {
        transform: scale(1.01);
    }

    .background-thumbnail-label {
        font-size: 0.68em;
        padding: 5px 4px 2px;
    }
}

/* ========== Theme Modal – Responsive ========== */

@media (max-width: 768px) {
    .theme-modal-content {
        max-width: 95vw;
        width: auto;
    }

    .theme-modal-header {
        padding: 14px 16px;
    }

    .theme-modal-header h3 {
        font-size: 1em;
    }

    .theme-modal-close {
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .theme-modal-grid {
        padding: 16px;
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 12px;
    }

    .theme-thumbnail-label {
        font-size: 0.75em;
    }
}

@media (max-width: 480px) {
    .theme-modal-content {
        max-width: 96vw;
        border-radius: 10px;
    }

    .theme-modal-grid {
        padding: 12px;
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .theme-thumbnail-swatch {
        height: 32px;
    }

    .theme-thumbnail-label {
        font-size: 0.72em;
    }
}

@media (max-width: 360px) {
    .theme-modal-content {
        max-width: 98vw;
        border-radius: 8px;
    }

    .theme-modal-grid {
        padding: 10px;
        gap: 8px;
    }

    .theme-thumbnail-label {
        font-size: 0.68em;
    }
}
