/* ==========================================================================
   dotvoid — responsive & touch adjustments
   Desktop: free-floating icons and windows.
   Compact (phones / small landscape): icons flow in a CSS grid, apps go full
   screen, the taskbar becomes icon-only and menus get bigger touch targets.
   ========================================================================== */

/* bigger targets whenever the primary pointer is a finger */
@media (pointer: coarse) {
  .menu-item { min-height: 36px; }
  .menubar { height: 34px; }
  .menubar-item { height: 30px; padding: 0 12px; }
  .row-item,
  .nav-link { min-height: 36px; }
  .btn { height: 32px; }
  .input { height: 32px; }
  .cap-btn { height: 24px; width: 32px; }
  .cap-close { width: 48px; }
  .win-titlebar { height: 34px; }
  .sm-item.small { min-height: 38px; }
  .sm-link { height: 36px; }
  .ex-item.selected .ex-label { max-height: 2.5em; }
}

/* medium screens: tighten the chrome a bit */
@media (max-width: 1024px) {
  .ex-side { flex-basis: 150px; }
  .st-nav { flex-basis: 150px; }
  .pz-side { flex-basis: 180px; }
}

@media (max-width: 700px), (max-height: 480px) {
  :root { --taskbar-h: 50px; }

  /* ----- icons: flow layout instead of free positioning */
  #icons {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(calc(var(--icon-size) + 36px), 1fr));
    grid-auto-rows: min-content;
    align-content: start;
    gap: 8px 4px;
    padding: 14px 10px 24px;
    overflow-y: auto;
    touch-action: pan-y;
  }
  .d-icon {
    position: relative; left: auto !important; top: auto !important;
    width: auto;
  }
  .d-icon .d-label { font-size: 12.5px; }

  /* ----- windows fill the screen above the taskbar */
  .window {
    left: 0 !important; top: 0 !important; width: 100% !important; height: 100% !important;
    padding: 0; border: 0; border-radius: 0; --frame: 0px;
  }
  .window .win-resize { display: none; }
  .win-titlebar { height: 42px; padding: 0 128px 0 10px; }
  .win-titlebar .win-icon { width: 20px; height: 20px; }
  .win-title { font-size: 15px; }
  .win-caption { top: 0; right: 0; }
  .cap-btn { width: 44px; height: 36px; }
  .cap-btn svg { width: 16px; height: 14px; }
  .cap-max { display: none; }
  .cap-close { width: 54px; }
  .cap-btn:last-child { border-bottom-right-radius: 0; }
  .win-body { border-left: 0; border-right: 0; border-bottom: 0; box-shadow: none; }
  .win-body.glass { padding: 0 6px 0; }

  /* dialogs stay as centred cards */
  .window.dialog {
    left: 0 !important; right: 0; top: 0 !important; bottom: 0; margin: auto;
    width: min(94%, 440px) !important; height: fit-content !important; max-height: 94%;
    padding: 0 6px 6px; border: 1px solid rgba(0, 0, 0, .6); border-radius: 8px;
  }
  .window.dialog:has(.filedlg) { width: 96% !important; height: min(94%, 520px) !important; }
  .window.dialog .win-titlebar { height: 36px; padding-right: 64px; }
  .window.dialog .cap-btn { height: 30px; }
  .window.dialog .win-body { border: 1px solid rgba(0, 0, 0, .5); }
  .filedlg-nav { flex-basis: 120px; }

  /* ----- taskbar: icon-only buttons */
  #taskbar { padding-left: 64px; }
  #start-orb { width: 52px; height: 52px; bottom: 2px; left: 5px; }
  #quick-launch,
  #peek,
  #tray .tray-icon,
  #clock .clock-date { display: none; }
  #tray { border-left: 0; box-shadow: none; padding-right: 8px; }
  #task-buttons { overflow-x: auto; scrollbar-width: none; }
  #task-buttons::-webkit-scrollbar { display: none; }
  .task-btn { flex: 0 0 46px; height: 40px; padding: 0; justify-content: center; }
  .task-btn img { width: 24px; height: 24px; }
  .task-btn span { display: none; }

  /* ----- start menu becomes a bottom sheet */
  #start-menu {
    left: 0; right: 0; width: auto; bottom: var(--taskbar-h);
    height: min(600px, calc(100% - var(--taskbar-h)));
    flex-direction: column; gap: 8px;
    border-radius: 12px 12px 0 0; border-bottom: 0;
  }
  .sm-left { flex: 1 1 auto; width: auto; }
  .sm-right { flex: none; padding: 0; }
  .sm-pic { display: none; }
  .sm-links { flex-direction: row; flex-wrap: wrap; gap: 2px; overflow: visible; }
  .sm-link { width: auto; flex: 1 1 30%; height: 34px; justify-content: center; padding: 0 6px; font-size: 12.5px; }
  .sm-link.user,
  .sm-link-sep { display: none; }
  .sm-power { justify-content: flex-end; padding-top: 6px; }
  .sm-pbtn { width: 52px; height: 36px; }

  .flyout { left: 6px; right: 6px !important; }
  .cal-body { flex-direction: column; align-items: center; }

  /* ----- apps */
  .ex-side,
  .ex-details { display: none; }
  .ex-nav { gap: 6px; padding-top: 4px; }
  .ex-search { flex-basis: 110px; }
  .ex-panel { border-left: 0; border-right: 0; }
  .ex-grid { grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); }
  .c-date,
  .c-type { display: none; }

  .st-header { flex-wrap: wrap; gap: 8px; padding: 8px 10px; }
  .st-logo > div { display: none; }
  .st-search { order: 5; flex: 1 1 100%; max-width: none; margin: 0; }
  .st-balance { margin-left: auto; }
  .st-body { flex-direction: column; }
  .st-nav {
    flex: none; display: flex; gap: 4px; padding: 6px 8px; overflow-x: auto; overflow-y: hidden;
    border-right: 0; border-bottom: 1px solid #b9d0e8; scrollbar-width: none;
  }
  .st-nav::-webkit-scrollbar { display: none; }
  .st-nav-btn { width: auto; flex: none; height: 34px; margin: 0; }
  .st-nav-sep { display: none; }
  .st-main { padding: 12px 12px 22px; }
  .st-hero { padding: 18px; }
  .st-hero-art { display: none; }
  .st-grid { grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 10px; }
  .st-thumb.big { width: 100%; height: 170px; }
  .st-cart-row { flex-wrap: wrap; }
  .st-cart-row .st-cart-info { flex-basis: calc(100% - 110px); }
  .st-summary { max-width: none; }

  .personalize { flex-direction: column; }
  .pz-side {
    flex: none; display: flex; gap: 4px; padding: 6px 8px; overflow-x: auto; overflow-y: hidden;
    border-right: 0; border-bottom: 1px solid #a9c5e3; scrollbar-width: none;
  }
  .pz-side::-webkit-scrollbar { display: none; }
  .pz-side-title { display: none; }
  .pz-link { width: auto; flex: none; white-space: nowrap; padding: 6px 10px; }
  .pz-main { padding: 14px 14px 22px; }
  .pz-row > label { min-width: 0; flex-basis: 100%; }

  .wc-head { padding: 14px; }
  .wc-pic { width: 60px; height: 60px; }
  .wc-headtext h2 { font-size: 21px; }
  .wc-specs { display: none; }
  .wc-body { padding: 12px 14px; }

  .calc { display: flex; flex-direction: column; }
  .calc-pad { flex: 1; grid-auto-rows: 1fr; }
  .calc-key,
  .calc-key.mem { height: auto; min-height: 44px; font-size: 16px; }

  .pt-paper { width: 100%; }
  .pt-canvas { width: 100%; height: auto; }
  .pt-stage { padding: 6px; }

  .balloon { width: calc(100vw - 20px); }
  #balloons { right: 10px; left: 10px; align-items: stretch; }
}

/* very short landscape phones: keep the start menu scrollable */
@media (max-height: 480px) {
  #start-menu { height: calc(100% - var(--taskbar-h)); }
  .sm-links { display: none; }
}
