/* כפתור הסגירה של וידג׳ט על שולחן העבודה */
:root .desk-root .board {
  --widget-close-size: 25px;
  --widget-close-icon-size: 13px;
  --widget-close-radius: 999px;
  --widget-close-padding: 7px;
}

:root .desk-root .board > .item[data-item][data-widget] > .lights.widget-tile-controls {
  position: absolute !important;
  inset: var(--widget-close-top, 0px) var(--widget-close-right, 0px) auto auto !important;
  width: auto !important;
  height: auto !important;
  margin: 0 !important;
  padding: 0 !important;
  z-index: 9 !important;
  display: grid !important;
  background: transparent !important;
  box-shadow: none !important;
  opacity: 0 !important;
  visibility: visible !important;
  pointer-events: none;
  transform: none !important;
  transform-origin: top right !important;
  scale: calc(1 / var(--widget-tile-scale, 1));
  transition: opacity .18s var(--ui-ease-out) !important;
}

:root .desk-root .board > .item[data-item][data-widget] > .widget-tile-controls > .widget-tile-close {
  position: relative !important;
  inset: auto !important;
  display: grid !important;
  place-content: center;
  box-sizing: border-box;
  width: var(--widget-close-size) !important;
  height: var(--widget-close-size) !important;
  min-width: 0 !important;
  min-height: 0 !important;
  margin: 0 !important;
  padding: var(--widget-close-padding) !important;
  border: 0 !important;
  border-radius: var(--widget-close-radius) !important;
  color: var(--lq-ink) !important;
  background: var(--glass-btn-fill) !important;
  box-shadow: var(--glass-btn-edge) !important;
  cursor: pointer;
}

:root .desk-root .board > .item[data-item][data-widget] > .widget-tile-controls > .widget-tile-close > svg {
  display: block;
  width: var(--widget-close-icon-size) !important;
  height: var(--widget-close-icon-size) !important;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  pointer-events: none;
}

:root .desk-root .board > .item[data-item][data-widget] > .widget-tile-controls > .widget-tile-close::after {
  content: none !important;
}

:root .desk-root .board > .item[data-item][data-widget] > .widget-tile-controls > .widget-tile-close::before {
  content: none !important;
}

@media (any-pointer: coarse) {
  :root .desk-root .board > .item[data-item][data-widget] > .widget-tile-controls > .widget-tile-close::before {
    content: "" !important;
    position: absolute;
    inset: -9.5px !important;
  }
}

:root .desk-root .board > .item[data-item][data-widget] > .widget-tile-controls > .widget-tile-close:active {
  box-shadow: var(--press) !important;
}

:root .desk-root .board > .item[data-item][data-widget].controls-open > .widget-tile-controls,
:root .desk-root .board > .item[data-item][data-widget] > .widget-tile-controls:has(:focus-visible) {
  opacity: 1 !important;
  pointer-events: auto;
}

@media (any-hover: hover) {
  :root .desk-root .board > .item[data-item][data-widget]:hover > .widget-tile-controls {
    opacity: 1 !important;
    pointer-events: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  :root .desk-root .board > .item[data-item][data-widget] > .lights.widget-tile-controls { transition: none !important; }
}

/* Finder has its own pointer and keyboard interactions. */
.board > .item[data-widget].spot { z-index: 500 !important; }

@media (min-width:744px) and (hover:hover) and (pointer:fine) {
  :root .desk-root .board > .item[data-widget],
  :root .desk-root .board > .item[data-widget] > :not(.lights),
  :root .desk-root .board > .item[data-widget] :is(.ct-closed-open, .profile-open, .music-cover-next),
  :root .desk-root .board > .item[data-widget] > :not(.lights) :not(:where(
    :is(button, a, input, textarea, select, label, summary, [contenteditable], [data-nodrag]),
    :is(button, a, input, textarea, select, label, summary, [contenteditable], [data-nodrag]) *
  )) {
    cursor: grab;
  }

  :root :is(.desk-root, .finder-overlay) [style*="--edge-cursor:"],
  :root :is(.desk-root, .finder-overlay) :is(.item[data-widget], .wnd, .finder)[style*="--edge-cursor:"] *,
  :root :is(.desk-root, .finder-overlay)[style*="--active-drag-cursor:"],
  :root :is(.desk-root, .finder-overlay)[style*="--active-drag-cursor:"] * {
    cursor: var(--active-drag-cursor, var(--edge-cursor)) !important;
  }
}

/* Desktop frames use the same compact layouts as the touch cards. */
@media (min-width:744px) and (hover:hover) and (pointer:fine) {
  :root .desk-root .board > .item[data-resize-measuring] {
    display: block !important;
    visibility: hidden;
  }
  :root .desk-root .board > .item[data-resize-visibility="shown"] {
    display: block !important;
  }
  :root .desk-root .board > .item[data-resize-visibility="hidden"]:not([data-resize-measuring]) {
    display: none !important;
  }
  :root .desk-root .board > .item[data-resize-size]:not([data-resize-measuring]) {
    width: var(--desk-resize-width) !important;
  }
  :root .desk-root .board > .item[data-resize-active] {
    z-index: 999 !important;
    translate: var(--desk-resize-x, 0px) var(--desk-resize-y, 0px) !important;
  }
  :root .desk-root .board > .item[data-resize-active] > :not(.lights, .sc-placeholder),
  :root .desk-root .board > .item[data-resize-size] > .ct-card {
    animation: none !important;
  }
  :root .desk-root .board > .item[data-resize-size]:not([data-resize-measuring]) > :not(.lights, .sc-placeholder) {
    box-sizing: border-box;
    width: var(--desk-resize-width) !important;
    height: var(--desk-resize-height) !important;
    min-width: 0 !important;
    min-height: 0 !important;
    max-width: none !important;
    max-height: none !important;
  }
  :root .desk-root .board > .item[data-resize-measuring="s"] > :not(.lights, .sc-placeholder) {
    box-sizing: border-box;
    width: var(--desk-compact-side) !important;
    height: var(--desk-compact-side) !important;
    min-width: 0 !important;
    min-height: 0 !important;
    max-width: none !important;
    max-height: none !important;
  }
  :root .desk-root .board > .item[data-item="cal"][data-resize-size="m"]:not([data-resize-active]) > .cal {
    height: auto !important;
  }
  :root .desk-root .board > .item:is([data-item="cal"], [data-item="how"], [data-item="snake"])[data-resize-size="s"] .sq-open {
    display: block;
    position: absolute;
    inset: 0;
    z-index: 3;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    background: transparent !important;
    box-shadow: none !important;
    cursor: pointer;
  }
  .item[data-item="player"][data-resize-size="s"] > .music-card .music-play {
    left: 50%;
  }
  .item[data-item="services"][data-resize-size="s"] > .ab-rem {
    display: grid;
    place-items: center;
  }
  .item[data-item="services"][data-resize-size="s"] :is(.ab-rem-head, .ab-rem-list),
  .item[data-item="how"][data-resize-size="s"] :is(.how-steps, .how-book),
  .item[data-item="cal"][data-resize-size="s"] .cal > :not(.cal-toolbar, .sq-open),
  .item[data-item="cal"][data-resize-size="s"] .cal-toolbar > :not(.cal-top),
  .item[data-item="cal"][data-resize-size="s"] .cal-year {
    display: none !important;
  }
  .item[data-item="how"][data-resize-size="s"] > .how-card,
  .item[data-item="cal"][data-resize-size="s"] > .cal,
  .item[data-item="cal"][data-resize-size="s"] :is(.cal-top, .cal-heading) {
    display: flex !important;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
  }
  .item[data-item="how"][data-resize-size="s"] .how-head {
    flex-direction: column;
    align-items: center;
    gap: var(--g-xs);
    padding: 0;
  }
  .item[data-item="cal"][data-resize-size="s"] :is(.cal-top, .cal-heading) {
    flex: none;
    gap: 0;
  }
  .item[data-item="cal"][data-resize-size="s"] .cal-toolbar {
    justify-content: center;
    padding-inline: 0;
    margin-inline: 0;
    min-height: 0;
  }
  .item[data-item="cal"][data-resize-size="s"] .cal-month-name { order: 1; }
  .item[data-item="cal"][data-resize-size="s"] .cal-number { order: 2; }
  .item[data-item="ttt"][data-resize-size="s"] .ttt-board {
    width: 100%;
    flex: 1 1 0;
    min-height: 0;
    aspect-ratio: auto;
    grid-template-rows: repeat(3, minmax(0, 1fr));
    gap: var(--g-xs);
  }
  .item[data-item="ttt"][data-resize-size="s"] .ttt-board .cell {
    min-height: 0 !important;
    aspect-ratio: auto;
  }
  .item[data-item="ttt"][data-resize-size="s"] .ttt-mark {
    inset: auto;
    height: 62%;
    aspect-ratio: 1;
  }
  .item[data-item="snake"][data-resize-size="s"] > .snake-card {
    display: flex !important;
    flex-direction: column;
    align-items: stretch !important;
    justify-content: center;
    gap: var(--g-s) !important;
  }
  .item[data-item="snake"][data-resize-size="s"] .snake-card > div:first-of-type {
    height: auto !important;
    padding: var(--p-btn) !important;
    flex: none;
  }
  .item[data-item="snake"][data-resize-size="s"] .snake-card > div:first-of-type > div {
    grid-template-columns: repeat(16, minmax(0, 1fr)) !important;
  }
  .item[data-item="snake"][data-resize-size="s"] .snake-card > div:first-of-type span {
    width: auto !important;
    height: auto !important;
    aspect-ratio: 1;
  }
  .item[data-item="snake"][data-resize-size="s"] .snake-card > div:nth-of-type(2) {
    display: none !important;
  }
  .item[data-item="typo"][data-resize-size="s"] > .typo-card {
    padding: 0 !important;
  }
  .item[data-item="typo"][data-resize-size="s"] .typo-card-media {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: none;
  }
}
