/* Responsive layout: adapt to viewport and display size. */

@media (max-width: 960px) {
    body { padding: 12px; }
    .container { padding: 14px; }
    /* Stretch to the viewport width, or .canvas-section grows to a zoomed canvas's pixel width and the
       page overflows sideways. */
    .main-content { flex-direction: column; align-items: stretch; }
    .canvas-section { width: 100%; min-width: 0; max-width: 100%; }
    .canvas-viewport { max-width: 100%; }
    .coordinates-panel {
        min-width: 0;
        max-width: none;
        width: 100%;
        margin-top: 14px;
    }
    .panel-resizer { display: none; }
    .coordinates-panel.coord-collapsed {
        width: 100%;
        padding: 10px 12px;
    }
    /* Folded under the canvas, the tabs stay and the list alone goes (layout/coord/panel.css hides it),
       its height run by panel/coordFold.js foldHeight while .coord-folding keeps it displayed and clipped. */
    .coordinates-panel.coord-collapsed .coord-tabs { display: inline-flex; }
    .coordinates-panel.coord-folding #coord-body { display: block; overflow: hidden; }
    .coord-panel-header { transition: margin-bottom var(--panel-slide-ms) var(--fold-ease); }
    .coordinates-panel.coord-collapsed #toggle-coord-panel {
        writing-mode: horizontal-tb;
        transform: none;
        border: 1px solid var(--border-main) !important;
    }
    /* A CAP, not a width: only a modal that would not fit is squeezed (user report). */
    #settings-modal, .app-modal { max-width: calc(100vw - 28px); }
}

@media (max-width: 680px) {
    body { padding: 8px; }
    .container { padding: 10px; border-radius: 6px; }
    .controls { gap: 4px 4px; padding: 8px 10px; }
    .ctrl-section { padding: 4px; }
    .ctrl-section + .ctrl-section::before { content: none; }
    #settings-modal, .app-modal { max-height: 88vh; }
    .settings-header, .settings-footer { padding: 10px 12px; }
    .settings-body { padding: 10px 12px; }
    .info-key { flex: 0 0 130px; }
    /* --coord-panel-width is the user's resized width, clamped to the screen. */
    #fs-points-panel { width: clamp(240px, var(--coord-panel-width, var(--coord-panel-default)), 86vw); }
}

@media (max-width: 460px) {
    body { padding: 6px; }
    .container { padding: 8px; }
    button, input, select { font-size: 13px; }
    .controls button { padding: 7px 9px; }
    .coordinates-table { font-size: 11px; }
    .coordinates-table th, .coordinates-table td { padding: 4px 4px; }
    /* A gutter on both sides (user report): edge to edge, a window read as a page of its own. */
    #settings-modal, .app-modal {
        width: calc(100vw - 24px);
        max-width: calc(100vw - 24px);
        max-height: 92vh;
    }
    .shortcut-hint, .ctx-hotkey { display: none; }
    .info-key { flex: 0 0 110px; font-size: 11px; }
}

@media (hover: none) and (pointer: coarse) {
    /* No pointer to drag with and no keyboard to paste from: the hint has nothing to say here. */
    .drop-hint { display: none; }
    .ctx-item { padding-top: 10px; padding-bottom: 10px; }
    .ctx-checkbox-item, .ctx-radio-item { padding-top: 9px; padding-bottom: 9px; }
    .del-pt-btn { opacity: 0.85; font-size: 16px; }
    button:not(:disabled):not(.active):hover { transform: none; box-shadow: none; }
}

@media print {
    .controls-wrapper, #notify-balloon, #ctx-menu,
    .tooltip, #theme-toggle, .drop-hint { display: none !important; }
    body { padding: 0; background: #fff; }
    .container { box-shadow: none; max-width: none; animation: none; }
}
