/* ═══════════════════════════════════════════════════════════════
   widgets.css — desktop widgets

   A widget is the same glass as a window with the chrome taken off.
   It sits below the window layer so windows always win, and its
   layer is pointer-transparent so the desktop underneath still
   takes clicks and context menus.
   ═══════════════════════════════════════════════════════════════ */

.widgets {
  position: absolute;
  inset: calc(var(--menubar-h) + 10px) 10px calc(var(--dock-h) + 26px) 10px;
  z-index: 16;
  pointer-events: none;
}

.widget {
  position: absolute;
  pointer-events: auto;
  overflow: hidden;
  cursor: default;
  --g-alpha: .095;
  box-shadow: var(--g-inset), var(--shadow-lift);
  animation: wgIn 400ms var(--ease-back);
  transition: box-shadow 220ms var(--ease), transform 180ms var(--ease);

  /* Hold the widget on its own compositor layer and keep its repaints
     inside itself. Together with the diffed writes in widgets.js this
     is what stopped the once-a-second flicker. */
  contain: paint;
  backface-visibility: hidden;
}
@keyframes wgIn { from { opacity: 0; transform: scale(.9) translateY(10px); } }
.widget:hover { box-shadow: var(--g-inset), var(--shadow-deep); }
.widget.dragging {
  transform: scale(1.03);
  box-shadow: var(--g-inset), 0 8px 20px -6px rgb(0 0 0 / .4),
              0 40px 70px -20px rgb(0 0 0 / .6);
}

.wg-body {
  position: relative;
  z-index: 3;
  height: 100%;
  padding: 14px 15px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* ── clock ── */
.wg-time {
  font-size: 34px;
  font-weight: 200;
  letter-spacing: -.025em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.wg-date { font-size: 12px; color: var(--text-2); }
.wg-sub {
  margin-top: auto;
  font-size: 10.5px;
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── calendar ── */
.wg-cal-head {
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 8px;
  text-align: center;
}
.wg-cal {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  flex: 1;
}
.wg-cal i {
  display: grid;
  place-items: center;
  font-size: 10.5px;
  font-style: normal;
  border-radius: var(--g-radius-2xs);
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}
.wg-cal i.wg-dow {
  font-size: 9px;
  font-weight: 650;
  color: var(--text-3);
  letter-spacing: .04em;
}
.wg-cal i.today {
  color: #fff;
  font-weight: 650;
  background: linear-gradient(150deg, hsl(var(--accent) / .8), hsl(var(--accent-2) / .6));
  box-shadow: inset 0 1px 0 rgb(255 255 255 / .4),
              0 0 12px -3px hsl(var(--accent) / .7);
}

/* ── focus ── */
.wg-frow { display: flex; align-items: center; gap: 13px; }
.wg-ring { flex: none; width: 54px; height: 54px; }
.wg-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.wg-ring circle { fill: none; stroke-width: 3.4; stroke-linecap: round; }
.wg-ring .bg { stroke: rgb(var(--edge-hi) / .16); }
.wg-ring .fg {
  stroke: hsl(var(--accent) / .95);
  filter: drop-shadow(0 0 4px hsl(var(--accent) / .6));
  transition: stroke-dashoffset 280ms linear, stroke 400ms linear;
}
.widget[data-phase="break"] .wg-ring .fg { stroke: hsl(var(--ok) / .9); }
.widget[data-phase="break"] .wg-ftime { color: hsl(var(--ok) / 1); }
.wg-fcol { min-width: 0; }
.wg-ftime {
  font-size: 25px;
  font-weight: 250;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
}
.wg-fbtns { display: flex; gap: 7px; margin-top: auto; }
.wg-fbtns .g-btn { flex: 1; width: auto; }

/* ── sticky ── */
.wg-sticky {
  flex: 1;
  width: 100%;
  border: 0;
  outline: 0;
  resize: none;
  background: transparent;
  color: var(--text);
  font: 400 12.5px/1.6 -apple-system, "Segoe UI", system-ui, sans-serif;
  user-select: text;
  cursor: text;
}
.wg-sticky::placeholder { color: var(--text-3); }

/* ── stats ── */
.wg-kv {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-size: 11.5px;
  padding: 2px 0;
}
.wg-kv span { color: var(--text-3); }
.wg-kv b { font-weight: 600; font-variant-numeric: tabular-nums; }

/* ── now playing ── */
.wg-np { display: flex; align-items: center; gap: 11px; height: 100%; }
.wg-art {
  flex: none;
  width: 44px; height: 44px;
  border-radius: var(--g-radius-xs);
  background: rgb(var(--edge-hi) / .12);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / .35),
              0 0 0 .5px rgb(var(--edge-hi) / .22);
  transition: background 400ms var(--ease);
}
.wg-npc { flex: 1; min-width: 0; }
.wg-npc b {
  display: block; font-size: 12.5px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.wg-npc i {
  display: block; font-size: 10.5px; font-style: normal; color: var(--text-3);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.wg-npb { flex: none; }

/* an alarm firing flashes the whole desktop once */
.alarm-flash::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  background: hsl(var(--accent) / .3);
  animation: alarmFlash 1.4s var(--ease);
}
@keyframes alarmFlash {
  0%, 100% { opacity: 0; }
  10%, 45% { opacity: 1; }
  30%, 65% { opacity: 0; }
}

@media (max-width: 720px) {
  .widgets { display: none; }
}
