/* ============================================================
   mobile.css — Suroît sur téléphone (24/10/2026, js/app/mobile.js)
   Actif seulement avec body.m-on (écran étroit ou téléphone en paysage).
   A : carte plein écran, onglets en bas, feuille à trois hauteurs.
   B : parcours guidé Points › Météo › Calcul › Route.
   C : mode cockpit (gros chiffres, prochaine marque, alertes).
   ============================================================ */

body.m-on {
    --m-tab: calc(56px + env(safe-area-inset-bottom, 0px));
    --m-top: calc(52px + env(safe-area-inset-top, 0px));
    --m-sheet-h: 96px;
    height: 100dvh;
}

/* ---------- mise en page : carte, puis onglets en bas ---------- */
body.m-on .map-container { order: 1; flex: 1; }
body.m-on > .main-bar {
    order: 10; height: var(--m-tab); padding: 0 0 env(safe-area-inset-bottom, 0px); gap: 0;
    border-top: 1px solid var(--rope); border-bottom: 0; box-shadow: none; background: var(--ink);
    z-index: 1400 !important; overflow: hidden; justify-content: space-around;
}
body.m-on .main-btn {
    flex: 1 1 0; min-width: 0; height: 56px; padding: 6px 0 4px !important; margin: 0; border: 0 !important; border-radius: 0;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    background: transparent !important; color: var(--mist); font-size: 11px !important; font-weight: 500; letter-spacing: 0;
}
body.m-on .main-btn span:not(.icon) { display: block !important; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
body.m-on .main-btn .icon { font-size: 18px !important; line-height: 1; }
body.m-on .main-btn .icon .glyph svg { width: 21px !important; height: 21px !important; }
body.m-on .main-btn.active, body.m-on .main-btn.m-cur { color: var(--cardinal); box-shadow: inset 0 2px 0 var(--cardinal) !important; }
body.m-on .main-bar > div[style*="flex: 1"] { display: none; }
body.m-on > .main-bar { display: flex !important; width: 100% !important; flex-wrap: nowrap !important; }
body.m-on > .main-bar .main-btn { flex: 1 1 0 !important; width: auto !important; max-width: none !important; }
body.m-on > .main-bar .main-btn.hidden { display: none !important; }

/* ---------- haut : logo, météo, polaire, compte, posés sur la carte ---------- */
#mTop { display: none; }
body.m-on #mTop {
    display: flex; align-items: center; gap: 6px; position: absolute; z-index: 1300; left: 8px; right: 8px;
    top: calc(8px + env(safe-area-inset-top, 0px)); pointer-events: none;
}
body.m-on #mTop > * { pointer-events: auto; }
body.m-on #mTop .av-logo { padding: 0; flex: 0 0 auto; }
body.m-on #mTop .av-logo img { height: 30px !important; }
body.m-on #mTop .av-logo span { display: none; }
body.m-on #mTop .status-badge {
    display: inline-flex !important; min-width: 0; max-width: 40%; height: 32px; padding: 0 10px; border-radius: 16px;
    background: rgba(16, 28, 36, 0.92); border: 1px solid var(--rope); font-size: 12px;
}
body.m-on #mTop .status-badge span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
body.m-on #mTop .m-spacer { flex: 1; }
body.m-on #mTop .user-btn { height: 34px; min-width: 34px; border-radius: 17px; background: rgba(16, 28, 36, 0.92); }
body.m-on #mTop .user-btn #userName, body.m-on #mTop .user-btn .dropdown-arrow { display: none; }
body.m-on #mTop .user-dropdown-menu { right: 0; left: auto; }

/* ---------- feuille du bas ---------- */
#mSheet { display: none; }
body.m-on #mSheet {
    display: flex; flex-direction: column; position: fixed; left: 0; right: 0; bottom: var(--m-tab); z-index: 1350;
    background: var(--hull); border-top: 1px solid var(--rope); border-radius: 14px 14px 0 0;
    box-shadow: 0 -10px 30px rgba(3, 8, 12, 0.45); height: var(--m-sheet-h); max-height: calc(100dvh - var(--m-tab) - var(--m-top));
    transition: height 0.22s ease; touch-action: none;
}
body.m-on #mSheet.dragging { transition: none; }
#mSheet .m-grab { flex: 0 0 auto; padding: 7px 0 2px; cursor: grab; touch-action: none; }
#mSheet .m-grab i { display: block; width: 36px; height: 4px; border-radius: 2px; background: var(--rope); margin: 0 auto; }
#mSheet .m-peek { flex: 0 0 auto; touch-action: none; }
#mSheet .m-body { flex: 1 1 auto; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; touch-action: pan-y; overscroll-behavior: contain; border-top: 1px solid var(--rope); }
#mSheet[data-state="peek"] .m-body { display: none; }

/* bande du bas : barre de temps compacte + ligne d'état */
body.m-on #mSheet .timeline {
    height: 40px; padding: 0 12px; gap: 8px; background: transparent; border: 0; box-shadow: none; position: static;
}
body.m-on #mSheet .timeline #instruments, body.m-on #mSheet .timeline #boatStatus, body.m-on #mSheet .timeline #instrumentsBtn,
body.m-on #mSheet .timeline .timeline-date { display: none !important; }
body.m-on #mSheet .timeline-btn { width: 36px; height: 36px; font-size: 14px; }
body.m-on #mSheet .timeline-controls #prevBtn, body.m-on #mSheet .timeline-controls #nextBtn { display: none; }
body.m-on #mSheet .timeline-time { font-size: 15px; min-width: 44px; }
.m-line { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 12px 8px 16px; font-size: 14px; }
.m-line .m-txt { flex: 1; min-width: 0; color: var(--paper); line-height: 1.25; }
.m-line .m-txt small { display: block; color: var(--mist); font-size: 12px; }
.m-line .m-txt b { font-family: var(--font-num); font-weight: 600; font-size: 17px; }

/* boutons de la version téléphone */
.m-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 16px;
    font: 500 15px var(--font-ui); color: var(--paper); background: transparent; border: 1px solid var(--rope); border-radius: 8px; cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.m-btn:active { background: var(--hull-2); }
.m-btn.primary { background: var(--cardinal); border-color: var(--cardinal); color: #1b1406; font-weight: 600; }
.m-btn.primary:disabled { opacity: 0.45; }
.m-btn.wide { width: 100%; }
.m-btn.ghost { border-color: transparent; color: var(--mist); }
.m-btn.small { min-height: 36px; padding: 0 12px; font-size: 14px; }

/* panneaux des onglets rangés dans la feuille */
body.m-on #mSheet .sub-bar { display: none; }
body.m-on #mSheet .sub-bar.open, body.m-on #mSheet #mFlow .sub-bar {
    display: block; height: auto !important; min-height: 0 !important; max-height: none !important; overflow: visible !important;
    padding: 0 !important; background: transparent !important; border: 0 !important;
}
body.m-on #mSheet .sub-section {
    display: grid !important; grid-template-columns: 1fr 1fr; gap: 8px; align-items: center; padding: 12px 16px 14px; margin: 0;
    border-bottom: 1px solid var(--rope); height: auto; flex-wrap: nowrap;
}
body.m-on #mSheet .sub-section:last-child { border-bottom: 0; }
body.m-on #mSheet .sub-section-title {
    grid-column: 1 / -1; position: static; font-size: 13px; color: var(--mist); text-transform: none; letter-spacing: 0; margin: 0 0 2px; padding: 0;
}
body.m-on #mSheet .sub-divider { display: none; }
body.m-on #mSheet .sub-bar > div[style*="flex: 1"] { display: none; }
body.m-on #mSheet .sub-btn, body.m-on #mSheet .sub-select, body.m-on #mSheet .sub-input, body.m-on #mSheet select, body.m-on #mSheet .mini-input {
    width: 100% !important; min-height: 44px; height: auto; font-size: 15px !important; padding: 0 12px; justify-content: flex-start; text-align: left; margin: 0;
}
body.m-on #mSheet .sub-btn.primary { justify-content: center; }
body.m-on #mSheet .checkbox-label { min-height: 44px; font-size: 15px !important; display: flex; align-items: center; gap: 10px; }
body.m-on #mSheet .checkbox-label input { width: 20px !important; height: 20px !important; }
body.m-on #mSheet .tide-info, body.m-on #mSheet .calc-status { display: block !important; grid-column: 1 / -1; max-width: none; font-size: 13px; }
body.m-on #mSheet input[type=range] { grid-column: 1 / -1; width: 100% !important; }
body.m-on #mSheet .value-chip { justify-self: start; }
body.m-on #mSheet .file-dropdown { grid-column: 1 / -1; }
body.m-on #mSheet .file-dropdown-menu { position: static !important; }
body.m-on #mSheet #sailsOnBoard { grid-column: 1 / -1; }
body.m-on #mSheet .m-cockpit-entry { padding: 12px 16px 4px; }

/* ---------- carte : commandes au-dessus de la feuille ---------- */
body.m-on .layers-btn { bottom: min(calc(var(--m-sheet-h) + 64px), calc(100% - var(--m-top) - 104px)) !important; right: 10px; width: 44px; height: 44px; }
body.m-on .zoom-controls { bottom: min(calc(var(--m-sheet-h) + 12px), calc(100% - var(--m-top) - 52px)) !important; right: 10px; }
body.m-on #zoomInBtn, body.m-on #zoomOutBtn { display: none; }
body.m-on .zoom-btn { width: 44px; height: 44px; }
body.m-on .leaflet-bottom { bottom: var(--m-sheet-h); }
body.m-on .cursor-info, body.m-on #resultPanel.result-float:not(.m-in) { display: none !important; }
body.m-on .map-instructions {
    top: calc(var(--m-top) + 4px) !important; left: 12px; right: 12px; transform: none; max-width: none; text-align: center; font-size: 14px; padding: 10px 12px;
}
body.m-on .layers-panel { left: 8px; right: 8px; width: auto; bottom: calc(var(--m-sheet-h) + 12px); max-height: calc(100dvh - var(--m-tab) - var(--m-sheet-h) - var(--m-top) - 24px); overflow-y: auto; top: auto; }
body.m-on .calc-progress { bottom: calc(var(--m-sheet-h) + 14px); top: auto; }
body.m-on #statusMsg { left: 10px !important; right: 10px !important; transform: none !important; max-width: none !important; top: calc(var(--m-top) + 4px) !important; bottom: auto !important; z-index: 2500; }
body.m-on .nav-panel, body.m-on .sk-panel, body.m-on .fleet-panel { z-index: 1360; left: 8px; right: 8px; width: auto; bottom: calc(var(--m-tab) + var(--m-sheet-h) + 8px) !important; top: auto !important; }
body.m-on .inst-col { display: none !important; }
body.m-on .update-banner { bottom: calc(var(--m-tab) + var(--m-sheet-h) + 8px); left: 10px; right: 10px; transform: none; }
body.m-on .arr-layer { display: none; }

/* fenêtres : plein écran ou presque */
body.m-on .modal-overlay { align-items: flex-end; }
body.m-on .modal { width: 100% !important; max-width: 100% !important; max-height: 92dvh; border-radius: 14px 14px 0 0; margin: 0; padding-bottom: env(safe-area-inset-bottom, 0px); }
body.m-on .modal-close { min-width: 44px; min-height: 44px; }
body.m-on .regate-timer { left: 8px !important; right: 8px !important; width: auto !important; max-width: none !important; top: calc(var(--m-top) + 4px) !important; transform: none !important; }
body.m-on .regate-timer-display { font-size: clamp(3.4rem, 20vw, 5rem) !important; }
body.m-on .regate-timer-btn { min-height: 48px; font-size: 1rem; }
body.m-on .regate-info-panel { left: 8px !important; right: 8px !important; max-width: none; bottom: calc(var(--m-tab) + var(--m-sheet-h) + 8px) !important; }

/* ---------- B : parcours guidé ---------- */
body.m-on .m-empty, body.m-on #selectModeBtn { display: none !important; }
#mFlow { display: none; }
body.m-on #mSheet[data-tab="route"] #mFlow { display: block; }
.m-steps { display: flex; padding: 10px 12px 0; gap: 4px; position: sticky; top: 0; background: var(--hull); z-index: 2; }
.m-step {
    flex: 1; min-height: 44px; padding: 0 2px 8px; border: 0; border-bottom: 2px solid var(--rope); background: transparent; color: var(--mist);
    font: 500 13px var(--font-ui); display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 2px; cursor: pointer;
}
.m-step i { font-style: normal; font-family: var(--font-num); width: 20px; height: 20px; line-height: 18px; border-radius: 10px; border: 1px solid var(--rope); font-size: 12px; }
.m-step.done { color: var(--paper); }
.m-step.done i { background: var(--starboard); border-color: var(--starboard); color: #0b1a12; }
.m-step.on { color: var(--cardinal); border-bottom-color: var(--cardinal); }
.m-step.on i { border-color: var(--cardinal); }
.m-pane { display: none; padding: 14px 16px 18px; }
.m-pane.on { display: block; }
.m-pane h3 { margin: 0 0 4px; font-size: 17px; font-weight: 600; color: var(--paper); }
.m-pane p.m-hint { margin: 0 0 14px; color: var(--mist); font-size: 14px; line-height: 1.4; }
.m-rows { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.m-row { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 12px; border: 1px solid var(--rope); border-radius: 8px; font-size: 15px; }
.m-row > .m-k { color: var(--mist); width: 70px; flex: 0 0 auto; font-size: 13px; }
.m-row > .m-v { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--font-num); }
.m-row.choice { cursor: pointer; }
.m-row.choice small { color: var(--mist); margin-left: auto; font-size: 13px; }
.m-row.choice.sel { border-color: var(--cardinal); }
.m-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.m-actions .m-btn { width: 100%; }
.m-field { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; margin-bottom: 10px; }
body.m-on .m-field input, body.m-on .m-field select, body.m-on .m-pane .m-full {
    width: 100% !important; min-height: 44px; font-size: 16px !important; padding: 0 10px; box-sizing: border-box;
}
body.m-on .m-pane .grib-pick { width: 100% !important; min-height: 44px; font-size: 15px !important; text-align: left; margin-bottom: 10px; }
.m-pane details { margin: 4px 0 14px; border: 1px solid var(--rope); border-radius: 8px; }
.m-pane details summary { min-height: 44px; display: flex; align-items: center; padding: 0 12px; color: var(--mist); font-size: 14px; cursor: pointer; list-style: none; }
.m-pane details summary::after { content: '›'; margin-left: auto; transition: transform 0.15s; }
.m-pane details[open] summary::after { transform: rotate(90deg); }
body.m-on .m-pane details .sub-section { padding: 8px 12px 12px !important; }
body.m-on #mFlow #resultPanel { position: static !important; width: auto !important; max-height: none !important; min-width: 0; margin: 0 0 12px; display: block !important; box-shadow: none; border: 1px solid var(--rope); }
body.m-on #mFlow #resultPanel #closeResultBtn, body.m-on #mFlow #resultPanel #collapseResultBtn { display: none; }
body.m-on #mFlow #resultPanel #routeGraph { width: 100%; }

/* ---------- C : mode cockpit ---------- */
#mCockpit { display: none; }
body.m-on.m-cockpit #mCockpit {
    display: flex; flex-direction: column; position: absolute; z-index: 1320; left: 0; right: 0; top: 0; height: 60%;
    background: var(--ink); border-bottom: 1px solid var(--rope); padding: calc(10px + env(safe-area-inset-top, 0px)) 14px 10px; box-sizing: border-box;
}
body.m-on.m-cockpit #mSheet, body.m-on.m-cockpit #mTop { display: none; }
body.m-on.m-cockpit { --m-sheet-h: 0px; }
.ck-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.ck-src { flex: 1; min-width: 0; color: var(--mist); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ck-src.live { color: var(--starboard); }
.ck-grid { display: grid; grid-template-columns: 1fr 1fr; grid-auto-rows: min-content; align-content: space-evenly; gap: 12px 14px; flex: 1 1 auto; min-height: 0; }
.ck-cell { min-width: 0; border-top: 1px solid var(--rope); padding-top: 6px; }
.ck-lab { color: var(--mist); font-size: 13px; }
.ck-val { font-family: var(--font-num); font-weight: 600; font-size: clamp(34px, 11vw, 56px); line-height: 1.05; color: var(--paper); letter-spacing: -0.5px; }
.ck-val.acc { color: var(--cardinal); }
.ck-val small { font-size: 0.4em; font-weight: 500; color: var(--mist); margin-left: 3px; letter-spacing: 0; }
.ck-sub { color: var(--mist); font-size: 13px; font-family: var(--font-num); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ck-mark { display: flex; align-items: baseline; gap: 10px; border: 1px solid var(--rope); border-radius: 10px; padding: 8px 12px; margin-top: 10px; }
.ck-mark .ck-mk { color: var(--mist); font-size: 13px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ck-mark b { font-family: var(--font-num); font-size: 22px; font-weight: 600; }
.ck-mark span:last-child { color: var(--mist); font-size: 13px; font-family: var(--font-num); }
.ck-alert { margin-top: 8px; border-left: 3px solid var(--port); padding: 6px 10px; font-size: 14px; background: rgba(217, 87, 76, 0.12); }
.ck-alert.hidden { display: none; }
@media (orientation: landscape) {
    body.m-on.m-cockpit > .main-bar { display: none !important; }
    body.m-on.m-cockpit { --m-tab: 0px; }
    body.m-on.m-cockpit #mCockpit { width: 56%; height: 100%; right: auto; border-bottom: 0; border-right: 1px solid var(--rope); }
    body.m-on.m-cockpit .ck-val { font-size: clamp(30px, 6.5vw, 54px); }
}

/* mode nuit : le filtre rouge de html.night s'applique aussi à la version téléphone */
