/* Responsive Design - Immersive Layout */

/* ─── Large & ultrawide screens ─────────────────────────────────────────── */
@media (min-width: 1800px) {
    .content-wrapper {
        max-width: min(1100px, 70vw);
    }

    .content-area[data-page-type="detail"] .content-wrapper {
        max-width: min(1440px, 76vw);
    }

    .content-area[data-page-type="satellite"] .content-wrapper {
        max-width: min(1340px, 78vw);
    }
}

@media (min-width: 3200px) {
    .content-wrapper {
        max-width: min(1380px, 50vw);
    }

    .content-area[data-page-type="detail"] .content-wrapper {
        max-width: min(1800px, 55vw);
    }

    .content-area[data-page-type="satellite"] .content-wrapper {
        max-width: min(1680px, 56vw);
    }
}

@media (max-width: 1100px) {
    .content-wrapper {
        max-width: min(920px, 82vw);
        padding: 92px 32px 72px;
    }

    .content-area[data-page-type="satellite"] .content-wrapper {
        max-width: min(980px, 86vw);
        padding-left: 36px;
        padding-right: 36px;
    }

    .content-area[data-page-type="detail"] .content-wrapper {
        max-width: min(980px, 82vw);
    }

    .content-area.home-overlay .content-wrapper {
        max-width: min(680px, 64vw);
    }

    .career-head-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .content-area[data-page-key="work-career"].origin-left .content-wrapper {
        max-width: calc(100vw - 24px);
        margin-left: 12px;
        margin-right: 12px;
    }

    .detail-tiles-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    }
}

@media (max-width: 900px) {
    .hud {
        padding: 0 18px;
    }

    .side-panel {
        width: min(360px, 88vw);
    }

    .content-wrapper {
        max-width: min(100%, 88vw);
        padding: 88px 24px 64px;
    }

    .content-area[data-page-type="satellite"] .content-wrapper {
        max-width: min(100%, 90vw);
        padding-left: 24px;
        padding-right: 24px;
    }

    .content-area[data-page-type="detail"] .content-wrapper {
        max-width: min(100%, 90vw);
    }

    .content-area.home-overlay .content-wrapper {
        max-width: min(100%, 78vw);
    }

    .section-title {
        font-size: clamp(1.8rem, 7vw, 2.8rem);
    }

    .feature-grid,
    .cv-grid {
        grid-template-columns: 1fr;
    }

}

@media (max-width: 768px) {
    .hud {
        height: 60px;
        padding: 0 14px;
    }

    .hud-logo {
        gap: 8px;
        font-size: 0.68rem;
        letter-spacing: 0.14em;
    }

    .hud-actions {
        gap: 8px;
    }

    .language-switcher {
        right: 14px;
        bottom: 14px;
        max-width: 88px;
        padding: 0 8px;
    }

    .language-switcher-label {
        display: none;
    }

    .language-switcher select {
        width: 100%;
        font-size: 0.68rem;
        padding-right: 0;
    }

    .menu-btn {
        width: 38px;
        height: 38px;
    }

    .side-panel {
        width: min(320px, 92vw);
    }

    .side-panel-header {
        padding: 18px 18px 16px;
    }

    .side-nav-item {
        padding: 14px 18px;
    }

    .side-panel-footer {
        padding: 0 18px;
    }

    .back-btn {
        top: 72px;
        left: 14px;
        padding: 8px 12px;
        font-size: 0.68rem;
    }

    .content-wrapper {
        max-width: calc(100vw - 24px);
        padding: 92px 12px 44px;
    }

    .content-area.home-overlay {
        background: linear-gradient(
            180deg,
            rgba(5, 5, 7, 0.86) 0%,
            rgba(5, 5, 7, 0.72) 36%,
            rgba(5, 5, 7, 0.28) 76%,
            rgba(5, 5, 7, 0.05) 100%
        );
        overflow-y: auto;
    }

    .content-area.home-overlay .content-wrapper {
        max-width: calc(100vw - 24px);
        margin-left: 12px;
        margin-right: 12px;
        padding-top: 94px;
    }

    .home-scene-note {
        left: 12px;
        right: 12px;
        bottom: 12px;
        width: auto;
        padding: 12px;
    }

    .button-row,
    .button-stack {
        flex-direction: column;
    }

    .button,
    .page-action {
        width: 100%;
        justify-content: center;
    }

    .legal-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .legal-switch-group {
        width: 100%;
    }

    .legal-chip {
        flex: 1 1 auto;
        text-align: center;
    }

    .legal-language-switcher {
        width: 100%;
        justify-content: space-between;
    }

    .legal-content {
        min-height: 160px;
        max-height: 260px;
        font-size: 0.74rem;
    }

    .detail-tiles-grid {
        grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    }

    .section {
        margin-bottom: 44px;
    }

    /* Fade home bio text before the fixed weather note at the bottom */
    .content-area.home-overlay .content-wrapper {
        -webkit-mask-image: linear-gradient(to bottom, black 58%, transparent 86%);
        mask-image: linear-gradient(to bottom, black 58%, transparent 86%);
    }
}

@media (max-width: 480px) {
    :root {
        --spacing-3xl: 2rem;
        --spacing-2xl: 1.5rem;
        --font-size-3xl: 1.9rem;
        --font-size-2xl: 1.5rem;
    }

    .hud {
        padding: 0 10px;
    }

    .hud-logo span {
        display: none;
    }

    .language-switcher {
        right: 10px;
        bottom: 10px;
        min-width: 62px;
        height: 36px;
        border-radius: 7px;
    }

    .menu-btn {
        width: 36px;
        height: 36px;
        padding: 0 9px;
    }

    .side-panel {
        width: 100vw;
        border-left: 0;
    }

    .section-subtitle {
        font-size: 0.74rem;
        margin-bottom: 32px;
    }

    .content-wrapper {
        padding: 88px 10px 36px;
    }

    .info-tile,
    .feature-card,
    .cv-block {
        padding: 18px;
    }

    .hero-badge {
        width: 62px;
        height: 62px;
        border-radius: 16px;
        font-size: 1.05rem;
    }

    .page-icon {
        width: 48px;
        height: 48px;
        border-radius: 12px;
        font-size: 0.82rem;
    }

    .back-btn {
        top: 68px;
        left: 10px;
    }

    .home-scene-note {
        left: 10px;
        right: 10px;
        bottom: 10px;
    }

    .section {
        margin-bottom: 32px;
    }

}

/* ─── Portrait mobile: flex layout — note always below text, never overlapping ── */
@media (max-width: 768px) and (orientation: portrait) {
    /* Make the home overlay a flex column so note sits in flow at the bottom */
    .content-area.home-overlay {
        display: flex;
        flex-direction: column;
        overflow-y: hidden;
    }

    /* Content wrapper takes all remaining height and scrolls internally */
    .content-area.home-overlay .content-wrapper {
        min-height: 0;
        flex: 1;
        overflow-y: auto;
        pointer-events: auto; /* allow touch scroll on the text area */
    }

    /* Note exits absolute positioning, sits as a static flex item at the bottom */
    .home-scene-note {
        position: static;
        flex-shrink: 0;
        left: auto;
        right: auto;
        bottom: auto;
        margin: 0 12px calc(12px + env(safe-area-inset-bottom, 0px));
    }

    /* Fade the scrollable text toward the bottom edge (aesthetic transition) */
    .content-area.home-overlay .content-wrapper {
        -webkit-mask-image: linear-gradient(to bottom, black 60%, transparent 94%);
        mask-image: linear-gradient(to bottom, black 60%, transparent 94%);
    }
}

@media (max-height: 640px) and (orientation: landscape) {
    .hud {
        height: 52px;
    }

    .content-wrapper {
        padding-top: 76px;
        padding-bottom: 28px;
    }

    .back-btn {
        top: 58px;
    }

    .legal-content {
        max-height: 180px;
    }
}

@media (hover: none) and (pointer: coarse) {
    .button,
    .menu-btn,
    .side-nav-item,
    .legal-chip,
    .legal-language-switcher,
    button,
    a {
        min-height: 44px;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
