/*
  Kit Show · postazione del prototipo (Mac, Windows, iPhone con scrivania vera)
  Da COPIARE nella cartella della presentazione, accanto a postazione.js.
  Va caricato DOPO dispositivi.css: riusa finestre, barra di Windows e iPhone del kit e li completa.

  La radice (l'elemento passato a ShowStation.create) deve avere un'altezza sua (flex/grid o height):
  il dispositivo scelto ci sta dentro in larghezza e altezza (data-fit="contain").

  Variabili: si impostano su .st o su un antenato (es. :root della presentazione); tra parentesi il default.
    --st-font              carattere della postazione e del selettore (system-ui)
    --st-accent            selezione, icona di ripiego dell'app, cartella attiva (#2f6fde)
    --st-focus             contorno del focus da tastiera (--st-accent)
    --st-pick-bg / --st-pick-fg / --st-pick-border     pulsanti del selettore (bianco / #1d2733 / #c9d2db)
    --st-pick-on-bg / --st-pick-on-fg                   pulsante scelto (#1d2733 / #fff)
    --st-bezel             cornice di Mac e monitor (#0d1015)
    --st-mac-wallpaper     sfondo della scrivania Mac (qualsiasi background)
    --st-win-wallpaper     sfondo del desktop di Windows
    --st-phone-wallpaper   sfondo della Home dell'iPhone
    --st-menubar-bg / --st-menubar-fg                   barra dei menu del Mac (vetro chiaro / #111)
    --st-dock-bg           Dock del Mac (vetro chiaro)
    --st-taskbar-bg        barra delle applicazioni di Windows (#eef2f6)
    --st-window-bg         contenuto di Finder ed Esplora file (#fff)
    --st-sidebar-bg        barra laterale di Finder ed Esplora file (#f3f5f7)
*/

.st {
  --_font: var(--st-font, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);
  --_accent: var(--st-accent, #2f6fde);
  --_focus: var(--st-focus, var(--_accent));
  --_pick-bg: var(--st-pick-bg, #fff);
  --_pick-fg: var(--st-pick-fg, #1d2733);
  --_pick-border: var(--st-pick-border, #c9d2db);
  --_pick-on-bg: var(--st-pick-on-bg, #1d2733);
  --_pick-on-fg: var(--st-pick-on-fg, #fff);
  --_bezel: var(--st-bezel, #0d1015);
  --_mac-wall: var(--st-mac-wallpaper, radial-gradient(120% 90% at 15% 0%, #f6d3c4 0%, transparent 55%), radial-gradient(90% 80% at 100% 100%, #5b6fd8 0%, transparent 60%), linear-gradient(160deg, #a9b8e8 0%, #7f8fd8 50%, #4f5fb8 100%));
  --_win-wall: var(--st-win-wallpaper, radial-gradient(70% 90% at 50% 110%, #2f7de1 0%, transparent 70%), radial-gradient(60% 60% at 50% 70%, #9cc6ff 0%, transparent 70%), linear-gradient(180deg, #dfe9f6 0%, #a8c4ea 55%, #5e8fd6 100%));
  --_phone-wall: var(--st-phone-wallpaper, radial-gradient(100% 60% at 0% 0%, #ffb88c 0%, transparent 60%), radial-gradient(100% 70% at 100% 100%, #5a4fcf 0%, transparent 65%), linear-gradient(170deg, #f38b7a 0%, #b45da8 50%, #4b3fa8 100%));
  --_menubar-bg: var(--st-menubar-bg, rgba(255, 255, 255, .5));
  --_menubar-fg: var(--st-menubar-fg, #111);
  --_dock-bg: var(--st-dock-bg, rgba(255, 255, 255, .38));
  --_taskbar-bg: var(--st-taskbar-bg, #eef2f6);
  --_window-bg: var(--st-window-bg, #fff);
  --_sidebar-bg: var(--st-sidebar-bg, #f3f5f7);
  display: flex; flex-direction: column; gap: 10px; height: 100%; min-height: 0; min-width: 0; font-family: var(--_font);
}
.st, .st * { box-sizing: border-box; }
/* Focus visibile su tutti i comandi della postazione (non tocca quelli dell'app). */
.st-ctl:focus { outline: none; }
.st-ctl:focus-visible { outline: 2px solid var(--_focus); outline-offset: 2px; }

/* =========================================================================
   Selettore Mac · Windows · iPhone: va a capo, non scorre mai di lato
   ========================================================================= */
.st-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 0; }
.st-pick { display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 5px 14px 5px 11px; border: 1px solid var(--_pick-border); border-radius: 999px;
  background: var(--_pick-bg); color: var(--_pick-fg); font: 600 13px/1.2 var(--_font); white-space: nowrap; cursor: pointer; }
.st-pick:hover { border-color: var(--_pick-fg); }
.st-pick[aria-pressed="true"] { background: var(--_pick-on-bg); color: var(--_pick-on-fg); border-color: var(--_pick-on-bg); }
.st-pick.is-only { cursor: default; border-style: dashed; }
.st-pick-ico { display: inline-grid; width: 16px; height: 16px; }
.st-pick-ico svg { width: 100%; height: 100%; }

/* =========================================================================
   Palco: un solo dispositivo visibile, a misura fissa e scalato
   ========================================================================= */
.st-stage { position: relative; flex: 1 1 auto; display: flex; min-height: 220px; min-width: 0; }
.st-slot { flex: 1 1 auto; min-width: 0; }
.st-slot[hidden] { display: none !important; }
.st-device svg { display: block; }

/* Cornice di Mac e monitor: lo schermo (1280×800 / 1280×720) è dentro, a 12px dal bordo. */
.st-device-mac, .st-device-windows { background: var(--_bezel); border-radius: 24px; box-shadow: 0 0 0 1.5px #3d434c, 0 40px 80px -30px rgba(0, 0, 0, .5); }
.st-device-windows { border-radius: 14px; }
.st-screen.st-mac, .st-screen.st-windows { position: absolute; left: 12px; top: 12px; right: auto; bottom: auto; width: 1280px; overflow: hidden; isolation: isolate; border-radius: 8px; }
.st-screen.st-mac { height: 800px; background: var(--_mac-wall); color: #111; font: 13px/1.3 -apple-system, "SF Pro Text", system-ui, "Helvetica Neue", Arial, sans-serif; }
.st-screen.st-windows { height: 720px; background: var(--_win-wall); border-radius: 3px; }
.st-screen.is-dragging, .st-screen.is-dragging *, .st-screen.is-resizing, .st-screen.is-resizing * { -webkit-user-select: none; user-select: none; }

/* Scrivania delle finestre: sotto la barra dei menu (Mac) o sopra la barra delle applicazioni (Windows). */
.st-desktop { position: absolute; left: 0; right: 0; z-index: 1; overflow: hidden; isolation: isolate; }
.st-mac .st-desktop { top: 28px; bottom: 0; }
.st-windows .st-desktop { top: 0; bottom: 44px; }

/* =========================================================================
   Finestre (comuni a Mac e Windows)
   ========================================================================= */
.st-win { position: absolute; min-width: 0; transform-origin: 50% 100%;
  transition: opacity .2s ease, transform .24s cubic-bezier(.2, .7, .2, 1), visibility 0s; }
.st-win.is-min, .st-win.is-closed { visibility: hidden; opacity: 0; pointer-events: none;
  transition: opacity .18s ease, transform .22s ease, visibility 0s .22s; }
.st-win.is-min { transform: translateY(45%) scale(.25); }
.st-win.is-closed { transform: scale(.94); }
.st-win.is-max { border-radius: 0; }
/* touch-action: none SOLO su barre del titolo e maniglie: altrove il dito fa scorrere come sempre. */
.st-drag { touch-action: none; -webkit-user-select: none; user-select: none; cursor: default; }
.st-grip { position: absolute; z-index: 5; touch-action: none; }
.st-grip-n { top: 0; left: 12px; right: 12px; height: 5px; cursor: ns-resize; }
.st-grip-s { bottom: 0; left: 12px; right: 12px; height: 6px; cursor: ns-resize; }
.st-grip-e { right: 0; top: 12px; bottom: 12px; width: 6px; cursor: ew-resize; }
.st-grip-w { left: 0; top: 12px; bottom: 12px; width: 6px; cursor: ew-resize; }
.st-grip-ne { top: 0; right: 0; width: 12px; height: 12px; cursor: nesw-resize; }
.st-grip-nw { top: 0; left: 0; width: 12px; height: 12px; cursor: nwse-resize; }
.st-grip-se { bottom: 0; right: 0; width: 16px; height: 16px; cursor: nwse-resize; }
.st-grip-sw { bottom: 0; left: 0; width: 12px; height: 12px; cursor: nesw-resize; }
.st-win.is-max .st-grip { display: none; }
.st-body { position: relative; flex: 1 1 auto; min-height: 0; overflow: hidden; background: var(--_window-bg); }

/* Host dell'app: misura del disegno, scorre in verticale, mai di lato. Container query: @container st-app (…) */
.st-app { position: absolute; inset: 0; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; container: st-app / inline-size; background: #fff; }

/* Barra dell'indirizzo */
.st-addr-pill { display: flex; align-items: center; gap: 6px; min-width: 0; overflow: hidden; white-space: nowrap; }
.st-addr-text, .st-crumb-text, .st-search-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.st-addr-lock, .st-crumb-ico { flex: none; display: inline-grid; width: 12px; height: 12px; color: #7a8491; }
.st-addr-lock svg, .st-crumb-ico svg { width: 100%; height: 100%; }

/* =========================================================================
   Mac: barra dei menu, Dock, finestre con semafori
   ========================================================================= */
.st-menubar { position: absolute; top: 0; left: 0; right: 0; height: 28px; z-index: 3; display: flex; align-items: center; gap: 18px; padding: 0 16px;
  background: var(--_menubar-bg); color: var(--_menubar-fg); -webkit-backdrop-filter: blur(24px) saturate(1.6); backdrop-filter: blur(24px) saturate(1.6); font-size: 13px; white-space: nowrap; }
.st-menu-logo { display: inline-grid; width: 15px; height: 15px; }
.st-menu-logo svg, .st-menu-ico svg { width: 100%; height: 100%; }
.st-menu-app { font-weight: 700; }
.st-menu-items { display: flex; gap: 18px; }
.st-menu-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.st-menu-ico { display: inline-grid; width: 17px; height: 17px; }

.st-dock { position: absolute; left: 50%; bottom: 6px; z-index: 3; transform: translateX(-50%); display: flex; align-items: flex-end; gap: 8px; height: 66px; padding: 6px 10px;
  border-radius: 22px; background: var(--_dock-bg); border: 1px solid rgba(255, 255, 255, .45); box-shadow: 0 10px 30px rgba(0, 0, 0, .18);
  -webkit-backdrop-filter: blur(24px) saturate(1.5); backdrop-filter: blur(24px) saturate(1.5); }
.st-dock-item { position: relative; width: 52px; height: 52px; padding: 0; border: 0; border-radius: 12px; background: transparent; cursor: pointer; transition: transform .15s ease; }
.st-dock-item.is-static { cursor: default; }
.st-dock-ico { display: block; width: 52px; height: 52px; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .18)); }
.st-dock-ico svg, .st-dock-ico img { width: 100%; height: 100%; border-radius: 12px; }
button.st-dock-item:hover { transform: translateY(-4px); }
.st-dock-item.is-running::after { content: ""; position: absolute; left: 50%; bottom: -5px; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: rgba(0, 0, 0, .65); }
/* Nome sopra l'icona al passaggio o al focus */
.st-dock-item::before { content: attr(data-label); position: absolute; left: 50%; bottom: calc(100% + 12px); transform: translateX(-50%); padding: 3px 10px; border-radius: 6px;
  background: rgba(240, 240, 240, .95); color: #111; font-size: 12px; white-space: nowrap; box-shadow: 0 2px 8px rgba(0, 0, 0, .2); opacity: 0; pointer-events: none; }
button.st-dock-item:hover::before, .st-dock-item:focus-visible::before { opacity: 1; }
.st-dock-sep { align-self: stretch; width: 1px; margin: 6px 2px; background: rgba(0, 0, 0, .2); }

.st-mac .mac-win { border-radius: 12px; box-shadow: 0 24px 60px rgba(0, 0, 0, .3), 0 0 0 .5px rgba(0, 0, 0, .25); }
.st-mac .mac-win.is-front { box-shadow: 0 34px 80px rgba(0, 0, 0, .38), 0 0 0 .5px rgba(0, 0, 0, .3); }
.st-mac .mac-win.is-max { border-radius: 0; }
.st-mac .mac-title { position: relative; flex: 0 0 44px; gap: 14px; padding: 0 14px; background: #eceff2; border-bottom: 1px solid #d3d8dd; }
.st-mac .mac-win.is-inactive .mac-title { background: #f5f6f7; }
.st-lights { display: flex; gap: 8px; flex: none; }
.st-l { position: relative; width: 12px; height: 12px; padding: 0; border: 0; border-radius: 50%; background: #ff5f57; box-shadow: inset 0 0 0 .5px rgba(0, 0, 0, .2); cursor: pointer; }
.st-l-min { background: #febc2e; }
.st-l-max { background: #28c840; }
.mac-win.is-inactive .st-l { background: #d5d8dc; }
.st-lights:hover .st-l::after, .st-l:focus-visible::after { position: absolute; inset: 0; display: grid; place-items: center; font: 700 10px/12px system-ui, sans-serif; color: rgba(0, 0, 0, .55); }
.st-lights:hover .st-l-close::after, .st-l-close:focus-visible::after { content: "×"; }
.st-lights:hover .st-l-min::after, .st-l-min:focus-visible::after { content: "−"; }
.st-lights:hover .st-l-max::after, .st-l-max:focus-visible::after { content: "+"; }
.st-mac .mac-win.is-inactive .st-lights:hover .st-l-close { background: #ff5f57; }
.st-mac .mac-win.is-inactive .st-lights:hover .st-l-min { background: #febc2e; }
.st-mac .mac-win.is-inactive .st-lights:hover .st-l-max { background: #28c840; }
.st-nav { flex: none; display: inline-grid; width: 30px; height: 16px; color: #8a939d; }
.st-nav svg { width: 100%; height: 100%; }
.st-mac .mac-ttext { flex: 1; text-align: left; font-size: 13px; color: #2b333d; }
.st-mac .mac-address { flex: 0 1 520px; margin: 0 auto; padding: 6px 14px; background: #fff; border: 1px solid #dde1e5; color: #4a5566; font-size: 12.5px; }
.st-mac .mac-address::after { content: ""; flex: none; width: 50px; }
.st-mac .mac-body { background: var(--_window-bg); }

/* =========================================================================
   Windows: barra delle applicazioni, finestre, barra dell'indirizzo
   ========================================================================= */
.st-windows.desk { background: var(--_win-wall); }
.st-windows .taskbar { height: 44px; background: var(--_taskbar-bg); border-top: 1px solid rgba(255, 255, 255, .7); }
.st-tb-ico { display: grid; width: 24px; height: 24px; }
.st-tb-ico svg, .st-tb-ico img { width: 100%; height: 100%; border-radius: 4px; }
.st-tb-app { cursor: pointer; }
.st-windows .tb-clock { line-height: 1.3; }
.st-windows .wf-win { border-radius: 8px; border-color: #8a97a5; }
.st-windows .wf-win.is-max { border-radius: 0; border-width: 0; }
.st-windows .wf-title { flex: 0 0 31px; }
.st-windows .wf-tbtn { cursor: default; }
.st-windows button.wf-tbtn:hover { background: rgba(0, 0, 0, .06); }
.st-windows button.wf-close:hover { background: #c42b1c; }
.st-windows .wf-tico svg, .st-windows .wf-tico img { border-radius: 3px; }
/* Ripristina: due quadrati al posto di uno */
.st-win.is-max .g-max::before { width: 8px; height: 8px; margin: -3px 0 0 -5px; }
.st-win.is-max .g-max::after { width: 8px; height: 8px; margin: -5px 0 0 -3px; border-top: 1px solid #222; border-right: 1px solid #222; border-radius: 0 2px 0 0; }
.st-addr { flex: 0 0 36px; display: flex; align-items: center; gap: 10px; padding: 0 10px; background: #f7f8f9; border-bottom: 1px solid #e3e6e9; color: #3b4450; font-size: 12px; }
.st-nav-win { flex: none; display: inline-grid; width: 60px; height: 22px; color: #5b6570; }
.st-nav-win svg { width: 100%; height: 100%; }
.st-addr .st-addr-pill { flex: 1 1 auto; height: 26px; padding: 0 12px; border-radius: 13px; background: #fff; border: 1px solid #dfe3e7; }
.st-addr .st-search { flex: 0 1 200px; color: #6b7480; }
.st-windows .wf-body { background: var(--_window-bg); }

/* =========================================================================
   Finder ed Esplora file: barra laterale + elenco (va a capo, mai di lato)
   ========================================================================= */
.st-files-body { container-type: inline-size; }
.st-files { position: absolute; inset: 0; display: grid; grid-template-columns: 172px minmax(0, 1fr); background: var(--_window-bg); color: #1f2730; font-size: 12.5px; }
.st-side { min-width: 0; overflow: hidden auto; padding: 10px 8px; background: var(--_sidebar-bg); border-right: 1px solid #e3e6e9; }
.st-side-head { margin: 4px 8px 6px; font-size: 11px; font-weight: 600; color: #8a919a; }
.st-side-item { display: flex; align-items: center; gap: 8px; width: 100%; min-width: 0; padding: 5px 8px; border: 0; border-radius: 6px; background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.st-side-item:hover { background: rgba(0, 0, 0, .05); }
.st-side-item[aria-current="true"] { background: color-mix(in srgb, var(--_accent) 16%, transparent); }
.st-side-ico { flex: none; display: inline-grid; width: 16px; height: 16px; }
.st-side-ico svg { width: 100%; height: 100%; }
.st-side-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st-list { min-width: 0; overflow: hidden auto; }
.st-table { width: 100%; table-layout: fixed; border-collapse: collapse; }
.st-table th { position: sticky; top: 0; z-index: 1; padding: 6px 10px; background: var(--_window-bg); border-bottom: 1px solid #e3e6e9; color: #6b7480; font-weight: 500; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.st-table td { padding: 5px 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #4b5560; }
.st-mac .st-table tbody tr:nth-child(even) td { background: #f5f6f8; }
.st-table .st-c-name { color: #1f2730; }
.st-c-date { width: 150px; }
.st-c-type { width: 150px; }
.st-c-size { width: 90px; }
.st-table td.st-c-size { text-align: right; }
.st-fname { display: flex; align-items: center; gap: 8px; min-width: 0; }
.st-fico { flex: none; display: inline-grid; width: 18px; height: 18px; }
.st-fico svg { width: 100%; height: 100%; }
.st-fname-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.st-empty { padding: 28px 10px !important; text-align: center; color: #8a919a !important; }
@container (max-width: 640px) { .st-c-type { display: none; } }
@container (max-width: 520px) { .st-c-date { display: none; } .st-files { grid-template-columns: 132px minmax(0, 1fr); } }
@container (max-width: 360px) { .st-files { grid-template-columns: minmax(0, 1fr); } .st-side { display: none; } }

/* =========================================================================
   iPhone: Home (sfondo, icone, dock) e app a tutto schermo
   ========================================================================= */
.st-phone { background: var(--_phone-wall); }
.iphone.is-proto .st-phone .st-phone-view { overflow: hidden; }
.st-phone.is-home .ios-status, .st-phone.is-home .ios-home { background: transparent; color: #fff; }
.st-phone.is-home .ios-home i { background: #fff; }
.st-homebar { position: relative; width: 100%; padding: 0; border: 0; border-radius: 0 0 40px 40px; cursor: pointer; }
.st-homebar::before { content: ""; position: absolute; left: 25%; right: 25%; top: -16px; bottom: 0; } /* area di tocco più alta della barretta */
.st-phone.is-home .st-homebar { cursor: default; }

.st-home { position: absolute; inset: 0; display: flex; flex-direction: column; padding: 22px 18px 12px;
  transition: opacity .25s ease, transform .3s cubic-bezier(.2, .7, .2, 1), visibility 0s; }
.st-phone.is-app .st-home { visibility: hidden; opacity: 0; transform: scale(1.08); transition: opacity .2s ease, transform .3s ease, visibility 0s .3s; }
.st-home-grid { flex: 1 1 auto; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 24px 8px; align-content: start; }
.st-hicon { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; padding: 0; border: 0; background: transparent; color: #fff;
  font: 500 11px/1.2 -apple-system, "SF Pro Text", system-ui, sans-serif; text-shadow: 0 1px 3px rgba(0, 0, 0, .35); }
button.st-hicon { cursor: pointer; }
.st-hicon-img { display: block; width: 60px; height: 60px; overflow: hidden; border-radius: 14px; box-shadow: 0 2px 6px rgba(0, 0, 0, .18); }
.st-hicon-img svg, .st-hicon-img img { width: 100%; height: 100%; }
.st-hicon-label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
button.st-hicon:active .st-hicon-img { filter: brightness(.85); }
.st-home-dock { display: flex; justify-content: space-around; padding: 14px 10px; border-radius: 30px; background: rgba(255, 255, 255, .28);
  -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px); }
.st-home-dock .st-hicon-label { display: none; }

.st-phone-app { position: absolute; inset: 0; background: #fff; transform-origin: 30px 40px;
  transition: opacity .2s ease, transform .3s cubic-bezier(.2, .7, .2, 1), visibility 0s; }
.st-phone.is-home .st-phone-app { visibility: hidden; opacity: 0; transform: scale(.2); pointer-events: none;
  transition: opacity .2s ease, transform .26s ease, visibility 0s .26s; }

/* =========================================================================
   Movimento ridotto: aperture, riduzioni e cambi immediati
   ========================================================================= */
@media (prefers-reduced-motion: reduce) {
  .st-win, .st-win.is-min, .st-win.is-closed, .st-home, .st-phone.is-app .st-home, .st-phone-app, .st-phone.is-home .st-phone-app, .st-dock-item, .st .ios-status, .st .ios-home {
    transition: none !important; animation: none !important;
  }
  .st-win.is-min, .st-win.is-closed, .st-phone.is-app .st-home, .st-phone.is-home .st-phone-app { transform: none; }
  button.st-dock-item:hover { transform: none; }
}
