/* ═════════════════════════════════════════════════════════════ */

/* ─── PHONE: PORTRAIT ORIENTATION (max-width: 767px) ──────────── */
@media only screen and (max-width: 767px) and (orientation: portrait) {

    :root {
        --banner-h: 17%;
    }

    html,
    body {
        overflow: hidden;
    }

    .content {
        height: calc(100vh - 17vh);
        min-height: 0;
        overflow: hidden;
    }

    /* ─── BANNER ──────────────────────────────────────────────── */
    .banner {
        height: 17vh;
    }

    .banner-logo-wrapper {
        display: none;
    }

    .banner-title {
        font-size: clamp(4rem, 6vw, 5rem);
        line-height: 1.2;
        white-space: normal;
        word-break: break-word;
        max-width: 90vw;
    }

    /* ─── LAYOUT ────────────────────────────────────────────────── */
    .panel-left {
        display: none;
    }

    .panel-right {
        flex: 0 0 100%;
        height: 100%;
        min-height: 0;
        overflow: hidden;
    }

    /* ─── MAP CONTAINER ───────────────────────────────────────── */
    .map-container {
        flex: none;
        height: 112vw;
        min-height: 320px;
        max-height: 46vh;
        padding: 8px 8px 18px;
        margin-bottom: 6px;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
    }

    /* Allow the rendered SVG width to exceed the viewport when the active map needs it. */
    .map-container svg,
    .map-container .dv-map {
        flex: none;
        width: var(--mobile-map-width, 100%);
        min-width: 100%;
        height: 100%;
        max-width: none;
    }

    /* Scrollbar styling for map container */
    .map-container::-webkit-scrollbar {
        height: 12px;
    }

    .map-container::-webkit-scrollbar-track {
        background: rgba(255, 255, 255, 0.08);
        border-radius: 500;
    }

    .map-container::-webkit-scrollbar-thumb {
        background: rgba(59, 140, 207, 0.92);
        border: 2px solid rgba(16, 18, 28, 0.95);
        border-radius: 999px;
    }

    .map-container::-webkit-scrollbar-thumb:hover {
        background: #66b0ec;
    }

    .site-footer {
        position: fixed;
        top: calc(17vh + 8px);
        right: 8px;
    }

    /* Firefox scrollbar */
    .map-container {
        scrollbar-width: auto;
        scrollbar-color: rgba(167, 179, 189, 0.92) rgba(255, 255, 255, 0.08);
    }

    /* ─── CONTROLS BAR ────────────────────────────────────────── */
    .controls-bar {
        flex: 1 1 auto;
        flex-direction: column;
        min-height: 0;
        overflow-y: auto;
        overflow-x: hidden;
        border-top: 5px solid var(--accent);
        gap: 0;
        padding: 0;
    }

    /* Scrollbar styling for controls bar */
    .controls-bar::-webkit-scrollbar {
        width: 12px;
    }

    .controls-bar::-webkit-scrollbar-track {
        background: rgba(255, 255, 255, 0.08);
        border-radius: 999px;
    }

    .controls-bar::-webkit-scrollbar-thumb {
        background: rgba(59, 140, 207, 0.92);
        border: 2px solid rgba(16, 18, 28, 0.95);
        border-radius: 999px;
    }

    .controls-bar::-webkit-scrollbar-thumb:hover {
        background: #66b0ec;
    }

    /* Firefox scrollbar */
    .controls-bar {
        scrollbar-width: auto;
        scrollbar-color: rgba(167, 179, 189, 0.92) rgba(255, 255, 255, 0.08);
    }

    /* ─── TOGGLE BOXES ────────────────────────────────────────── */
    .toggle-boxes {
        flex: none;
        border-right: none;
        border-bottom: 1px solid var(--border-sep);
        font-size: clamp(0.95rem, 1.2vw, 1.1rem);
        gap: 4px;
        padding: 12px;
    }

    .toggle-label {
        gap: 6px;
        line-height: 1.3;
    }

    .toggle-label input[type="checkbox"] {
        width: 12px;
        height: 12px;
        flex-shrink: 0;
    }

    .toggle-label--sm {
        font-size: clamp(0.85rem, 1vw, 0.95rem);
    }

    .toggle-group-separator {
        height: 1px;
        background: var(--border-sep);
        margin: 3px 0;
    }

    /* ─── SLIDER ────────────────────────────────────────────────── */
    .slider-group {
        gap: 1px;
        margin-top: 4px;
    }

    #slider-value {
        font-size: clamp(0.85rem, 1vw, 1rem);
    }

    /* ─── MAP CONTROLS ────────────────────────────────────────── */
    .map-controls {
        flex: none;
        border-left: none;
        border-right: none;
        border-bottom: 1px solid var(--border-sep);
        font-size: clamp(0.95rem, 1.2vw, 1.1rem);
        gap: 4px;
        padding: 12px;
    }

    .map-controls-title {
        font-size: clamp(0.75rem, 0.9vw, 0.9rem);
        margin-bottom: 1px;
    }

    /* ─── RESULTS PANEL ───────────────────────────────────────── */
    .results-panel {
        flex: none;
        display: block;
        min-height: max-content;
        padding: 12px;
        gap: 8px;
        overflow: visible;
        border-left: none;
    }

    .results-layout {
        display: flex;
        flex-direction: column;
        flex: none;
        gap: 8px;
        align-items: stretch;
        min-height: max-content;
    }

    .transfer-row {
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
        gap: 14px;
        align-items: stretch;
    }

    .transfer-block {
        flex: 1 1 0;
        min-width: 0;
        width: auto;
    }

    .result-group {
        gap: 2px;
    }

    .result-row {
        gap: 10px;
    }

    .result-label {
        font-size: clamp(0.8rem, 1vw, 0.95rem);
    }

    .result-display {
        font-size: clamp(1.4rem, 2.5vw, 2rem);
        width: 150px;
    }

    .result-display--angle {
        font-size: clamp(1rem, 1.5vw, 1.1rem);
        width: 90px;
    }

    /* ─── PHASE DIAGRAMS ──────────────────────────────────────── */
    .phase-diagram {
        width: 110px;
        height: auto;
        aspect-ratio: 1;
        max-width: 110px;
    }

    /* ─── HIDDEN/ADJUSTED ELEMENTS ────────────────────────────── */
    #label-toggle8 {
        display: none;
    }

    .banner-img--desktop {
        display: none;
    }

    .banner-img--mobile {
        display: block;
    }

    #version-info {
        font-size: 0.75rem;
    }
}
