/* ===================== WIDGET LIBRARY ===================== */
/* The drawer element also carries .atmos-panel, so surface, blur, radius,
   tokens and colour hierarchy are the Atmosphere primitive 1:1. Everything
   below is geometry, the row primitive and the drag affordances.
   Monochrome: white through grey on black. */

/* Motion tokens. On :root, not .wl-panel, because the drag chip and the slot
   layer live outside the panel. The curve is the house curve already used by
   the panel, atmosViewIn and the wear panels — nothing new is introduced. */
:root {
  --wl-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --wl-fast: 150ms;
  --wl-base: 220ms;
  --wl-step: 25ms;
}

@keyframes wlInRight { from { opacity: 0; transform: translateX(14px); } }
@keyframes wlInLeft { from { opacity: 0; transform: translateX(-14px); } }
@keyframes wlFlash { from { background: rgba(255, 255, 255, 0.14); } }
@keyframes wlPop { from { opacity: 0; transform: scale(0.8); } }
@keyframes wlChipIn { from { opacity: 0; transform: translate(-50%, -50%) scale(0.92); } }
@keyframes wlWidgetIn { from { opacity: 0; transform: scale(0.96); } }
@keyframes wlConfirmIn { from { opacity: 0; max-height: 0; } to { opacity: 1; max-height: 48px; } }

/* trigger — the shared .icon-btn treatment, untouched */
.icon-btn .wl-trigger__glyph { stroke-width: 1.25; }

/* Right-anchored drawer: never over the top bar, never over the floating dock.
   Open/close motion is the .atmos-panel one 1:1 — same 0.3s curve, same
   scale-and-lift — with only the centring translate dropped, since this panel
   is pinned to the right edge rather than centred. */
.wl-panel {
  position: fixed;
  right: 24px;
  top: var(--panel-top);
  bottom: 112px;
  left: auto;
  width: 420px;
  max-height: none;
  height: auto;
  gap: 12px;
  /* the footer rides the drawer's bottom edge, so almost no padding under it */
  padding: 20px 20px 4px;
  overflow: hidden;
  transform: none;
  transform-origin: top center;
  transition:
    opacity 0.3s var(--wl-ease),
    transform 0.3s var(--wl-ease),
    visibility 0s linear 0s;
}
.wl-panel.hidden {
  opacity: 0;
  transform: scale(0.94) translateY(-10px);
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity 0.3s var(--wl-ease),
    transform 0.3s var(--wl-ease),
    visibility 0s linear 0.3s;
}

/* header */
.wl-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.wl-titles { min-width: 0; }
.wl-crumb {
  margin-top: 4px;
  font-size: 12px;
  font-weight: 300;
  letter-spacing: -0.01em;
  color: var(--wear-primary);
  opacity: 0.4;
}
.wl-close {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--wear-primary);
  opacity: 0.45;
  transition: opacity 0.15s ease, transform var(--wl-fast) var(--wl-ease);
}
.wl-close svg { width: 16px; height: 16px; }
.wl-close:hover { opacity: 1; }
.wl-close:active { transform: scale(0.96); }
.wl-close:focus-visible { outline: 2px solid rgba(255, 255, 255, 0.25); outline-offset: 2px; border-radius: 6px; }

/* search — the shared field, full width */
.wl-search {
  flex: 0 0 auto;
  position: relative;
  display: flex;
  align-items: center;
}
.wl-search__icon {
  position: absolute;
  left: 12px;
  width: 15px;
  height: 15px;
  pointer-events: none;
  color: var(--wear-primary);
  opacity: 0.4;
}
.wl-search__input {
  width: 100%;
  height: 40px;
  padding: 0 12px 0 36px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 300;
  letter-spacing: -0.01em;
  color: var(--wear-primary);
}
.wl-search__input::placeholder { color: var(--wear-primary); opacity: 0.4; }
.wl-search__input:focus { outline: 2px solid rgba(255, 255, 255, 0.25); outline-offset: 1px; }
.wl-search__input::-webkit-search-cancel-button { display: none; }

/* tab bar — the Atmosphere bar, scaled to this width */
.wl-tabs {
  position: relative;
  flex: 0 0 auto;
  gap: 24px;
  margin-bottom: 0;
}
.wl-tab { font-size: 13px; padding: 8px 2px; }
/* the underline is one element that slides between tabs, so the shared static
   ::after is switched off for this bar only */
.wl-tabs .wl-tab.is-active::after { display: none; }
.wl-tabs__ink {
  position: absolute;
  left: 0;
  bottom: -1px;
  height: 2px;
  border-radius: 2px;
  background: var(--wear-primary);
  pointer-events: none;
}
/* the first placement must land, not travel from zero */
.wl-tabs__ink.is-ready {
  transition:
    transform var(--wl-base) var(--wl-ease),
    width var(--wl-base) var(--wl-ease);
}

/* The edge-fade lengths only animate once registered; where @property is
   unsupported the mask cuts exactly as it does today. */
@property --wl-tf { syntax: "<length>"; inherits: false; initial-value: 0px; }
@property --wl-bf { syntax: "<length>"; inherits: false; initial-value: 0px; }

/* body — the only scrolling region; no bar, no track, no arrows.
   overflow-x is hidden: the tab-switch slide offsets children by 14px. */
.wl-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden auto;
  margin: 0 -20px;
  padding: 0 20px;
  --wl-tf: 0px;
  --wl-bf: 0px;
  scrollbar-width: none;
  -ms-overflow-style: none;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 var(--wl-tf), #000 calc(100% - var(--wl-bf)), transparent 100%);
  mask-image: linear-gradient(to bottom, transparent 0, #000 var(--wl-tf), #000 calc(100% - var(--wl-bf)), transparent 100%);
  transition: --wl-tf var(--wl-fast) ease, --wl-bf var(--wl-fast) ease;
}
.wl-body::-webkit-scrollbar { width: 0; height: 0; display: none; }
.wl-body.is-fade-top { --wl-tf: 24px; }
.wl-body.is-fade-bottom { --wl-bf: 24px; }

/* tab switch — the list reads as one sheet entering from the side the tab
   moved towards, with a light cascade behind it */
.wl-body.wl-in--right > * { animation: wlInRight var(--wl-base) var(--wl-ease) both; }
.wl-body.wl-in--left > * { animation: wlInLeft var(--wl-base) var(--wl-ease) both; }
.wl-body.wl-in--right > *,
.wl-body.wl-in--left > * { animation-delay: calc(var(--wl-i, 0) * 18ms); }

.wl-section {
  padding: 20px 0 6px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--wear-primary);
  opacity: 0.4;
}
.wl-section:first-child { padding-top: 4px; }
.wl-empty {
  padding: 20px 0;
  font-size: 12.5px;
  font-weight: 300;
  color: var(--wear-primary);
  opacity: 0.4;
}

/* row — a single 56px line; hovering never moves a neighbouring row */
.wl-row {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  cursor: grab;
  touch-action: pan-y;
  -webkit-user-select: none;
  user-select: none;
  transition: background 0.15s ease, opacity var(--wl-fast) var(--wl-ease);
}
.wl-row:last-child { border-bottom: none; }
.wl-row:hover,
.wl-row:focus-visible,
.wl-row:focus-within { background: rgba(255, 255, 255, 0.06); }
.wl-row:focus-visible { outline: 2px solid rgba(255, 255, 255, 0.25); outline-offset: -2px; }
.wl-row.is-dragging { opacity: 0.4; }
.wl-row--saved { cursor: default; }
/* add / remove: the touched row acknowledges the click, every other row was
   also re-rendered and stays perfectly still */
.wl-row.is-justchanged { animation: wlFlash 420ms var(--wl-ease); }
.wl-row.is-justchanged .wl-add,
.wl-row.is-justchanged .wl-action { animation: wlPop 200ms var(--wl-ease) both; }

.wl-row__line {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 56px;
  padding: 0 8px;
}
.wl-tile {
  flex: 0 0 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  box-sizing: border-box;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.06);
  color: var(--wear-primary);
  transition:
    transform var(--wl-fast) var(--wl-ease),
    box-shadow var(--wl-fast) var(--wl-ease);
}
/* contained inside the 48px square, so hovering still never moves a neighbour */
.wl-row:hover .wl-tile,
.wl-row:focus-visible .wl-tile,
.wl-row:focus-within .wl-tile {
  transform: scale(1.04);
  box-shadow: 0 0 16px rgba(255, 255, 255, 0.1);
}
.wl-tile svg { width: 24px; height: 24px; }
/* An image mark is already a finished icon: a squircle carrying its own light
   rim and dark interior. Drawing the framed tile behind it double-draws the
   edge, so for these the box only reserves the space. */
.wl-tile:has(.wl-tile__img) {
  border: 0;
  background: none;
  box-shadow: none;
}
/* `contain`, not `cover`: the artwork must be shown whole. The scale eats the
   transparent margin it ships with and stops there — cropping past the rim is
   what used to leave the quieter marks reading as a smudge. */
.wl-tile__img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transform: scale(1.18);
}
.wl-row__text {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.wl-row__name {
  font-size: 13.5px;
  font-weight: 300;
  letter-spacing: -0.01em;
  color: var(--wear-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wl-row__desc {
  font-size: 11.5px;
  font-weight: 300;
  color: var(--wear-primary);
  opacity: 0.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wl-grip {
  flex: 0 0 auto;
  display: inline-flex;
  margin-right: 4px;
  color: var(--wear-primary);
  opacity: 0;
  transition: opacity 0.15s ease;
}
.wl-grip svg { width: 18px; height: 18px; fill: currentColor; }
.wl-row:hover .wl-grip,
.wl-row:focus-visible .wl-grip,
.wl-row:focus-within .wl-grip { opacity: 0.4; }

.wl-add {
  flex: 0 0 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  color: var(--wear-primary);
  opacity: 0.45;
  transition: opacity 0.15s ease, transform var(--wl-fast) var(--wl-ease);
}
.wl-add svg { width: 16px; height: 16px; }
.wl-add:hover,
.wl-add:focus-visible { opacity: 1; transform: scale(1.15); }
.wl-add:active { transform: scale(0.9); }
.wl-add:focus-visible { outline: 2px solid rgba(255, 255, 255, 0.25); outline-offset: 2px; }
.wl-action { flex: 0 0 auto; font-size: 12.5px; }

/* inline confirmation — the Profile & Account pattern; never a modal */
.wl-confirm {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 8px 12px;
  overflow: hidden;
  animation: wlConfirmIn 260ms var(--wl-ease);
}
.wl-confirm__text {
  font-size: 11.5px;
  font-weight: 300;
  color: var(--wear-primary);
  opacity: 0.55;
}
.wl-confirm__acts { display: flex; align-items: center; gap: 14px; }

/* footer */
.wl-footer {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 56px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.wl-ask {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 300;
  letter-spacing: -0.01em;
  color: var(--wear-primary);
  opacity: 0.55;
  transition: opacity 0.15s ease, transform var(--wl-fast) var(--wl-ease);
}
.wl-ask:hover { opacity: 1; }
.wl-ask:focus-visible { outline: 2px solid rgba(255, 255, 255, 0.25); outline-offset: 2px; border-radius: 6px; }
.wl-ask__icon { width: 16px; height: 16px; opacity: 0.82; }
.wl-ask:active,
.wl-arrange:active,
.wl-tab:active { transform: scale(0.96); }
.wl-arrange { transition: background 0.15s ease, transform var(--wl-fast) var(--wl-ease); }
.wl-tab { transition: color 0.2s ease, transform var(--wl-fast) var(--wl-ease); }

/* drag chip — the card surface, following the pointer with no lag */
.wl-chip {
  position: fixed;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px 8px 8px;
  border-radius: 10px;
  background: rgba(38, 42, 41, 0.72);
  backdrop-filter: blur(26px) saturate(135%);
  -webkit-backdrop-filter: blur(26px) saturate(135%);
  color: rgba(243, 242, 238, 0.94);
  pointer-events: none;
  transform: translate(-50%, -50%);
  animation: wlChipIn 160ms var(--wl-ease);
}
.wl-chip__name { font-size: 12.5px; font-weight: 300; letter-spacing: -0.01em; }

/* a widget landing from a drop materialises rather than flipping into being */
.draggable-widget.is-materializing { animation: wlWidgetIn 320ms var(--wl-ease); }

/* reduced motion — nothing travels or scales; opacity still carries the state
   changes, only faster */
@media (prefers-reduced-motion: reduce) {
  :root { --wl-step: 0ms; }
  .wl-body.wl-in--right > *,
  .wl-body.wl-in--left > *,
  .wl-row.is-justchanged,
  .wl-row.is-justchanged .wl-add,
  .wl-row.is-justchanged .wl-action,
  .wl-confirm,
  .wl-chip,
  .draggable-widget.is-materializing {
    animation: none;
  }
  .wl-row:hover .wl-tile,
  .wl-row:focus-visible .wl-tile,
  .wl-row:focus-within .wl-tile,
  .wl-add:hover,
  .wl-add:focus-visible,
  .wl-add:active,
  .wl-ask:active,
  .wl-arrange:active,
  .wl-tab:active,
  .wl-close:active {
    transform: none;
  }
  .wl-tabs__ink.is-ready { transition: none; }
}
