/* ============================================================================
   Fiaschi Studio — shared desktop layout (wide screens used with a mouse)
   Built 21/10/2026 for Koffre first; the other apps opt in later with the same classes.

   Only applies to screens at least 1100px wide that have a mouse (hover + fine pointer), so phones and tablets - even
   a big iPad - keep exactly the layout they have today.

   How an app opts in:
     <body class="dk">
     <nav class="dk-side" id="dk-side">...brand slot (.dk-brand) + .dk-nav-item buttons...</nav>
     elements that only make sense on a touch screen (floating buttons, back arrows):  class="dk-hide"
     elements that only exist on desktop (the "Add" button in the toolbar):             class="dk-only"
     a form popup that should dock to the right instead of floating:        class="modal-backdrop dk-panel"
       (or a shared .reconnect-modal-backdrop popup: give it dk-panel while it holds a form - Jim does this in dlg())
       (or a .modal-overlay + .modal-card popup: Loopr's New tracker / Log forms)
     (toggle  body.dk-panel-open  while that panel is open so the page makes room for it)
   The app's own JS decides what happens on click (see Koffre's index.html for the wiring).

   Sizes (change them here, every app follows):
     --dk-side-w     sidebar          --dk-content-max   widest the page content gets (centred beyond it)
     --dk-panel-w    docked form panel
   ============================================================================ */
:root{ --dk-side-w:232px; --dk-content-max:1560px; --dk-panel-w:440px; }

.dk-side{ display:none; }
.dk-user-text{ display:none; }   /* the name next to the avatar: only in the sidebar */
/* !important: an app's own .btn { display:inline-flex } would otherwise win over this (it comes later in the page) */
.dk-only{ display:none !important; }

@media (min-width:1100px) and (hover:hover) and (pointer:fine){
  .dk-hide{ display:none !important; }
  .dk-only{ display:inline-flex !important; }

  body.dk{ padding-left:var(--dk-side-w); padding-bottom:32px; transition:padding-right .2s ease; }
  body.dk.dk-panel-open{ padding-right:var(--dk-panel-w); }
  body.dk main{ max-width:var(--dk-content-max); padding:20px 32px; }
  body.dk .appbar-inner{ max-width:var(--dk-content-max); padding:0 32px; }

  /* ---- sidebar ---- */
  .dk-side{
    display:flex; flex-direction:column; gap:4px;
    position:fixed; left:0; top:0; bottom:0; width:var(--dk-side-w); z-index:30;
    background:var(--surface); border-right:1px solid var(--border);
    padding:18px 12px;
  }
  .dk-brand{ display:flex; align-items:center; padding:2px 8px 18px; }
  .dk-brand .appbar-title{ gap:10px; }
  .dk-brand .appbar-title .logo{ width:36px; height:36px; }
  .dk-brand .appbar-title h1{ font-size:20px; }
  .dk-nav-item{
    display:flex; align-items:center; gap:12px; width:100%;
    padding:10px 12px; border-radius:10px; border:1px solid transparent;
    background:none; color:var(--text-muted);
    font:inherit; font-size:14px; font-weight:600; text-align:left; cursor:pointer;
    transition:background .15s, color .15s;
  }
  .dk-nav-item svg{ width:20px; height:20px; stroke:currentColor; fill:none; stroke-width:2; stroke-linecap:round; stroke-linejoin:round; flex-shrink:0; }
  .dk-nav-item:hover{ background:var(--surface-2); color:var(--text); }
  .dk-nav-item:focus-visible{ outline:2px solid var(--accent); outline-offset:1px; }
  .dk-nav-item.active{ background:var(--accent-soft); color:var(--accent); }
  .dk-nav-spacer{ flex:1; }
  .dk-keys{ font-size:11.5px; line-height:1.6; color:var(--text-dim); padding:8px 10px; }

  /* ---- the user at the bottom of the sidebar (shared/shortcuts.js moves the page's avatar here) ---- */
  .dk-user{ position:relative; margin-top:6px; padding-top:8px; border-top:1px solid var(--border); }
  .dk-user .user-avatar-wrap{ position:static; width:100%; }
  .dk-user .user-avatar-btn{ width:100%; height:auto; border-radius:10px; border:1px solid transparent; background:none; padding:7px 8px;
    justify-content:flex-start; gap:10px; overflow:visible; color:var(--text-muted); text-align:left; font:inherit; }
  .dk-user .user-avatar-btn:hover, .dk-user .user-avatar-wrap.open .user-avatar-btn{ background:var(--surface-2); border-color:transparent; }
  .dk-user .user-avatar-btn:focus-visible{ outline:2px solid var(--accent); outline-offset:1px; }
  .dk-user .user-avatar-img{ width:34px; height:34px; border-radius:50%; flex:none; }
  .dk-user .user-avatar-placeholder{ width:34px; height:34px; padding:7px; border-radius:50%; flex:none; box-sizing:border-box;
    background:var(--surface-2); border:1px solid var(--border); }
  .dk-user .user-avatar-img:not([hidden]) + .user-avatar-placeholder{ display:none; }
  .dk-user .dk-user-text{ display:flex; flex-direction:column; min-width:0; gap:1px; }
  .dk-user .dk-user-name{ font-size:14px; font-weight:600; color:var(--text); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
  .dk-user .dk-user-mail{ font-size:11.5px; color:var(--text-muted); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
  .dk-user .dk-user-mail[hidden]{ display:none; }
  .dk-user .user-avatar-menu{ top:auto; bottom:calc(100% + 6px); left:0; right:0; min-width:0; }

  /* ---- docked form panel (a .modal-backdrop / .reconnect-modal-backdrop that becomes a right-hand side panel) ---- */
  /* !important: shared/motion.js sets inline size/position on popups for the phone keyboard */
  .modal-backdrop.dk-panel, .reconnect-modal-backdrop.dk-panel, .modal-overlay.dk-panel{
    position:fixed !important; top:0 !important; right:0 !important; bottom:0 !important; left:auto !important;
    width:var(--dk-panel-w) !important; height:100% !important;
    background:var(--surface); border-left:1px solid var(--border);
    align-items:stretch; justify-content:stretch; z-index:40;
    box-shadow:-12px 0 32px rgba(0,0,0,0.28);
  }
  .reconnect-modal-backdrop.dk-panel, .modal-overlay.dk-panel{ padding:0; }
  .modal-backdrop.dk-panel .modal, .reconnect-modal-backdrop.dk-panel .reconnect-modal, .modal-overlay.dk-panel .modal-card{
    max-width:none; width:100%; max-height:none; height:100%;
    border-radius:0; border:0; background:transparent;
    padding:22px 24px 0; animation:none;
    display:flex; flex-direction:column;
  }
  .reconnect-modal-backdrop.dk-panel .reconnect-modal, .modal-overlay.dk-panel .modal-card{ overflow-y:auto; box-shadow:none; }
  .modal-backdrop.dk-panel .modal-footer, .reconnect-modal-backdrop.dk-panel .reconnect-modal > .reconnect-modal-actions:last-child{
    position:sticky; bottom:0; margin-top:auto;
    padding:14px 0 22px; background:var(--surface);
  }
  html .modal-backdrop.dk-panel.pop-in, html .reconnect-modal-backdrop.dk-panel.pop-in, html .modal-overlay.dk-panel.pop-in{ animation:dkPanelIn .2s cubic-bezier(.2,.9,.3,1) both; }
  html .modal-backdrop.dk-panel.pop-out, html .reconnect-modal-backdrop.dk-panel.pop-out, html .modal-overlay.dk-panel.pop-out{ animation:dkPanelOut .16s ease-in both; }
  html .modal-backdrop.dk-panel.pop-in .fs-pop-card, html .reconnect-modal-backdrop.dk-panel.pop-in .fs-pop-card, html .modal-overlay.dk-panel.pop-in .fs-pop-card,
  html .modal-backdrop.dk-panel.pop-out .fs-pop-card, html .reconnect-modal-backdrop.dk-panel.pop-out .fs-pop-card, html .modal-overlay.dk-panel.pop-out .fs-pop-card{ animation:none; }

  /* ---- two-column screens (dashboard, settings): only where there is room for two readable columns ---- */
  @media (min-width:1500px){
    body.dk .dk-cols.active{ display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); column-gap:20px; align-items:start; }
    body.dk .dk-cols > .dk-span{ grid-column:1 / -1; }
  }
}
@keyframes dkPanelIn{ from{ opacity:0; transform:translateX(36px); } to{ opacity:1; transform:none; } }
@keyframes dkPanelOut{ from{ opacity:1; transform:none; } to{ opacity:0; transform:translateX(36px); } }
@media (prefers-reduced-motion:reduce){
  html .modal-backdrop.dk-panel.pop-in, html .modal-backdrop.dk-panel.pop-out,
  html .reconnect-modal-backdrop.dk-panel.pop-in, html .reconnect-modal-backdrop.dk-panel.pop-out,
  html .modal-overlay.dk-panel.pop-in, html .modal-overlay.dk-panel.pop-out{ animation-duration:.01s !important; }
}
