/* ==========================================================================
   Mono — "Today" widget (web ?widget page, PWA shortcut, desktop widget window)
   Builds on the tokens and .glass / .cat-* classes from style.css.
   ========================================================================== */

html.widget-mode, html.widget-mode body { overflow: hidden; }

.widget {
  position: fixed; inset: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  user-select: none;
  -webkit-user-select: none;
  cursor: default;
}
/* Desktop widget window: leave the strip under the traffic lights free (and draggable).
   Windows has a real title bar above the page. */
html.widget-window .widget { padding: 30px 8px 8px; }
html.widget-window.windows .widget { padding: 8px; }
html.widget-window .w-card { border-radius: 18px; height: 100%; max-height: none; }
html.widget-window .w-body { flex: 1 1 auto; }

.w-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 420px;
  /* Hug the content; the list scrolls once the card reaches the window edge. */
  height: auto;
  max-height: min(100%, 680px);
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 16px 14px 10px;
  border-radius: 24px;
  overflow: hidden;
  animation: w-in .75s var(--ease) both;
}

/* ---------- Header: big day number + weekday ---------- */
.w-head {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 4px 12px;
}
.w-daynum {
  font-family: var(--font-display);
  font-size: 54px;
  font-weight: 250;
  line-height: .9;
  letter-spacing: -.045em;
  font-variant-numeric: tabular-nums;
  color: var(--fg);
  animation: w-rise .7s var(--ease) .05s both;
}
.w-date { min-width: 0; animation: w-rise .7s var(--ease) .1s both; }
.w-wd { font-size: 15px; font-weight: 650; letter-spacing: -.01em; color: var(--fg); }
.w-dm { font-size: 12.5px; color: var(--fg-2); margin-top: 1px; }
.w-sum { font-size: 11.5px; color: var(--fg-3); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Scrollable body ---------- */
.w-body {
  position: relative;
  flex: 0 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 2px 0 10px;
  scrollbar-width: none;
  -webkit-mask-image: linear-gradient(180deg, #000 calc(100% - 18px), transparent);
  mask-image: linear-gradient(180deg, #000 calc(100% - 18px), transparent);
}
.w-body::-webkit-scrollbar { display: none; }

/* ---------- "Now" / "Up next" card ---------- */
.w-now {
  flex: none;
  padding: 11px 12px 12px;
  border-radius: 16px;
  background: rgba(var(--ink), .065);
  box-shadow: inset 0 0 0 .5px rgba(var(--ink), .08), inset 0 1px 0 rgba(var(--ink), .06);
  animation: w-rise .7s var(--ease) .14s both;
  transition: background .4s var(--ease);
}
.w-next { background: rgba(var(--ink), .04); }
.w-now-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 7px; }
.w-live, .w-label {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--fg-2);
}
.w-live-dot {
  width: 6px; height: 6px; border-radius: 50%;
  position: relative;
  background: var(--fg);
}
/* Three composited beats instead of an endless repaint (the widget stays on screen for hours). */
.w-live-dot::after { content: ""; position: absolute; inset: 0; border-radius: 50%; background: inherit; animation: ring 2.4s cubic-bezier(.2, .6, .4, 1) 3; }
html.widget-mode .blob, html.widget-window .blob { animation: none; }
.w-now-left { font-size: 11.5px; color: var(--fg-3); font-variant-numeric: tabular-nums; white-space: nowrap; }
.w-now-title { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 15px; font-weight: 600; letter-spacing: -.01em; }
.w-now-meta { display: flex; align-items: center; gap: 10px; min-width: 0; margin-top: 4px; font-size: 12px; color: var(--fg-2); font-variant-numeric: tabular-nums; }
.w-loc { display: inline-flex; align-items: center; gap: 3px; min-width: 0; color: var(--fg-3); }
.w-bar { position: relative; height: 3px; margin-top: 10px; border-radius: 3px; background: rgba(var(--ink), .12); overflow: hidden; }
.w-bar-fill {
  position: absolute; inset: 0 auto 0 0;
  border-radius: inherit;
  background: var(--fg);
  transition: width 1.2s var(--ease);
  animation: w-grow 1s var(--ease) .3s both;
  transform-origin: left center;
}

/* ---------- Lists ---------- */
.w-sec { flex: none; }
.w-sec-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 6px 5px;
  font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--fg-3);
  animation: w-fade .6s var(--ease) .2s both;
}
.w-count { font-variant-numeric: tabular-nums; letter-spacing: 0; font-weight: 600; }
.w-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1px; }

.w-ev, .w-task {
  --i: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  height: 30px;
  padding: 0 6px;
  border-radius: 9px;
  font-size: 13px;
  transition: background .25s var(--ease);
  animation: w-rise .6s var(--ease) both;
  animation-delay: calc(170ms + var(--i) * 40ms);
}
.w-ev:hover, .w-task:hover { background: rgba(var(--ink), .045); }
.w-time {
  flex: none;
  width: 44px;
  font-size: 11.5px;
  color: var(--fg-3);
  font-variant-numeric: tabular-nums;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.w-ev.all-day .w-time { display: flex; align-items: center; }
.w-ev.all-day .w-time::before { content: ""; width: 18px; height: 2px; border-radius: 2px; background: var(--fg-4); }
.w-tag {
  flex: none;
  max-width: 40%;
  padding: 1px 6px;
  border-radius: 6px;
  font-size: 10px; font-weight: 600; letter-spacing: .02em;
  color: var(--fg-3);
  background: rgba(var(--ink), .06);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.w-ev-title, .w-task-title { flex: 1; }
.w-ellip { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Category glyph chip (palette colour from the .cat-* classes) */
.w-sw {
  flex: none;
  display: grid; place-items: center;
  width: 18px; height: 18px;
  border-radius: 6px;
}
.w-now-title .w-sw { width: 20px; height: 20px; border-radius: 7px; }
.w-sw .icon { stroke-width: 2; }

/* Importance flag */
.w-prio { flex: none; display: grid; color: var(--prio, var(--fg-4)); }

/* Read-only checkbox look */
.w-check {
  flex: none;
  width: 15px; height: 15px;
  border-radius: 50%;
  border: 1.5px solid var(--fg-3);
}
.w-check.prio-high { border-color: var(--prio-high); }
.w-check.prio-med  { border-color: var(--prio-med); }
.w-check.prio-low  { border-color: var(--prio-low); }
.w-due { flex: none; font-size: 11px; font-weight: 600; color: var(--fg-2); white-space: nowrap; }
.w-due::before { content: "!"; margin-right: 3px; font-weight: 800; color: var(--fg); }

.w-more { padding: 4px 6px 0; font-size: 11.5px; color: var(--fg-3); animation: w-fade .6s var(--ease) .4s both; }

.w-empty {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 22px 8px;
  border-radius: 14px;
  font-size: 13px;
  color: var(--fg-3);
  background: rgba(var(--ink), .025);
  box-shadow: inset 0 0 0 1px var(--line);
  animation: w-rise .7s var(--ease) .18s both;
}

/* ---------- Footer ---------- */
.w-foot { flex: none; padding-top: 8px; border-top: 1px solid var(--line); }
.w-open {
  display: flex; align-items: center; gap: 8px;
  width: 100%;
  height: 32px;
  padding: 0 10px;
  border-radius: 10px;
  font-size: 12.5px;
  font-weight: 550;
  color: var(--fg-2);
  text-decoration: none;
  transition: background .25s var(--ease), color .25s var(--ease), transform .3s var(--spring);
}
.w-open span { flex: 1; text-align: left; }
.w-open:hover { background: rgba(var(--ink), .06); color: var(--fg); }
.w-open:active { transform: scale(.97); }
.w-open .icon:last-child { opacity: .5; transition: transform .35s var(--spring), opacity .25s; }
.w-open:hover .icon:last-child { transform: translateX(2px); opacity: .9; }

/* ---------- Motion ---------- */
@keyframes w-in { from { opacity: 0; transform: translateY(10px) scale(.97); filter: blur(6px); } to { opacity: 1; transform: none; filter: none; } }
@keyframes w-rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes w-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes w-grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes w-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(var(--ink), .45); }
  70% { box-shadow: 0 0 0 6px rgba(var(--ink), 0); }
}

@media (prefers-reduced-motion: reduce) {
  .w-card, .w-daynum, .w-date, .w-now, .w-ev, .w-task, .w-sec-head, .w-more, .w-empty, .w-bar-fill, .w-live-dot { animation: none !important; }
}

/* ---------- Sizes ---------- */
@media (max-width: 340px), (max-height: 420px) {
  .w-card { padding: 12px 10px 8px; }
  .w-daynum { font-size: 44px; }
  .w-head { padding-bottom: 9px; }
}
/* Phone home-screen (PWA): a little more air, bigger touch rows. */
@media (max-width: 520px) and (min-height: 560px) {
  .widget { align-items: flex-start; }
  .w-card { max-width: none; max-height: 100%; }
  .w-ev, .w-task { height: 34px; font-size: 14px; }
}
