/*
  Apple-style look: Lock Screen clock + StandBy widgets.
  Designed to be read from across a kitchen.
  Sizes use vw/vh (times --s, the TV size setting) so it scales to any TV. Big "hero"
  text (clock, dates) uses cq units so it fills whatever grid cell the
  widget is placed in.
*/
:root {
  --s: 1;   /* size: set by app.js from the TV size setting */
  /* Apple dark-mode system colors */
  --label: #FFFFFF;
  /* Apple's secondary/tertiary labels, a little brighter so they're readable
     across a room (at least 4.5:1 on the backgrounds) */
  --label-2: rgba(235, 235, 245, 0.7);
  --label-3: rgba(235, 235, 245, 0.45);
  --red: #FF453A;                        /* systemRed: today, Calendar */
  --orange: #FF9F0A;                     /* systemOrange */
  --blue: #0A84FF;                       /* systemBlue */
  --green: #30D158;                      /* systemGreen */

  /* Widget "material": frosted dark glass */
  --material: rgba(28, 28, 30, 0.55);
  --material-edge: rgba(255, 255, 255, 0.08);
  --radius: calc(2.2vw * var(--s));

  /* SF Pro on Apple devices, Inter everywhere else (e.g. the Pi) */
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter",
          "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;            /* a TV never scrolls */
  background: #000;
  color: var(--label);
  font-family: var(--font);
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  cursor: none;                /* hide the mouse pointer on the TV */
}

/* ---------- Screens ---------- */
.stage {
  position: fixed;
  inset: 0;
}

/* Every screen is stacked in the same place; the active one fades in */
.screen {
  position: absolute;
  display: grid;               /* columns/rows come from the layout */
  /* Margin around the screen, and the space between widgets. The grid
     itself has no gaps: each widget keeps half a gap around itself, so
     the grid can be as fine as you like. */
  /* --edge and --spacing come from the Display settings (1 = 100%) */
  --pad-y: calc(5vh * var(--s) * var(--edge, 1));
  --pad-x: calc(3.5vw * var(--s) * var(--edge, 1));
  --gap-y: calc(2.4vh * var(--s) * var(--spacing, 1));
  --gap-x: calc(1.6vw * var(--s) * var(--spacing, 1));
  /* Where the grid starts: the margin, minus the half-gap each widget keeps
     around itself. With a very small margin that's negative, which padding
     can't be, so the screen reaches past the TV's edge by that much instead. */
  --edge-y: calc(var(--pad-y) - var(--gap-y) / 2);
  --edge-x: calc(var(--pad-x) - var(--gap-x) / 2);
  padding: max(0px, var(--edge-y)) max(0px, var(--edge-x));
  inset: min(0px, var(--edge-y)) min(0px, var(--edge-x));
  opacity: 0;
  /* How long a screen change takes: System window > TV picture */
  transition: opacity var(--screen-fade, 1.5s) ease-in-out;
}

.screen.active { opacity: 1; }

/* In the admin panel's preview, changes appear instantly */
.editing .screen { transition: none; }

/* Backgrounds are set by app.js from lib/backgrounds.js */

/* ---------- Widgets ---------- */
.widget {
  position: relative;          /* so z-index stacks widgets in layout order */
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  container-type: size;        /* lets the content size itself to the cell */
  margin: calc(var(--gap-y) / 2) calc(var(--gap-x) / 2);
}

/* Frosted glass. Over the smooth gradient backgrounds, blurring what's behind
   changes nothing you can see, and the blur is what makes a Raspberry Pi
   stutter during fades, so cards only blur when they sit over another
   widget (app.js adds .glass-blur, e.g. a clock over a photo). */
.widget-glass {
  background: var(--material);
  backdrop-filter: saturate(180%);
  -webkit-backdrop-filter: saturate(180%);
  border: 1px solid var(--material-edge);
  border-radius: var(--radius);
  padding: calc(3vh * var(--s)) calc(2.2vw * var(--s));
  box-shadow: 0 calc(1vw * var(--s)) calc(3vw * var(--s)) rgba(0, 0, 0, 0.25);
}

.widget-empty {
  font-size: calc(1.6vw * var(--s));
  font-weight: 600;
  color: var(--label);
}

.widget-hint {
  margin-top: calc(0.8vh * var(--s));
  font-size: calc(1.25vw * var(--s));
  line-height: 1.4;
  color: var(--label-2);
  max-width: 24ch;
}

/* ---------- Clock ---------- */
.clock {
  height: 100%;
  display: flex;
  flex-direction: column;
  /* Padding is a share of the box's shorter side. The clock is its own
     size container, so the date and time shrink to fit inside it. */
  padding: calc(var(--clock-pad, 0) * 1cqmin);
  container-type: size;
  text-shadow: 0 calc(0.2vw * var(--s)) calc(1.2vw * var(--s)) rgba(0, 0, 0, 0.3);
}

.clock-date {
  font-size: calc(min(13cqh, 6.5cqw) * var(--clock-date, 1));
  font-weight: 500;
  color: rgba(255, 255, 255, 0.85);
  letter-spacing: -0.01em;
  margin-left: 0.04em;
}

.clock-time {
  font-size: calc(min(75cqh, 38cqw) * var(--clock-time, 1));
  font-weight: 300;
  line-height: 1;
  letter-spacing: -0.045em;
}

/* The date and time, stacked (or on one line when compact) */
.clock-line {
  display: flex;
  flex-direction: column;
}

/* Where the clock sits in its box */
.clock-h-left { align-items: flex-start; text-align: left; }
.clock-h-center { align-items: center; text-align: center; }
.clock-h-right { align-items: flex-end; text-align: right; }
.clock-h-left .clock-line { align-items: flex-start; }
.clock-h-center .clock-line { align-items: center; }
.clock-h-right .clock-line { align-items: flex-end; }
.clock-v-top { justify-content: flex-start; }
.clock-v-middle { justify-content: center; }
.clock-v-bottom { justify-content: flex-end; }

/* One line: "Thu, Oct 1   10:30" */
.clock-compact .clock-line {
  flex-direction: row;
  align-items: baseline;
  gap: 0.6em;
}

.clock-compact .clock-date { font-size: calc(min(32cqh, 9cqw) * var(--clock-date, 1)); }
.clock-compact .clock-time { font-size: calc(min(80cqh, 22cqw) * var(--clock-time, 1)); letter-spacing: -0.03em; }

/* ---------- Calendar: agenda ---------- */
.cal-agenda {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.cal-weekday {
  font-size: calc(1.3vw * var(--s) * var(--cal-head, 1));
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--red);
}

.cal-day {
  font-size: calc(5.5vw * var(--s) * var(--cal-head, 1));
  font-weight: 300;
  line-height: 1;
  letter-spacing: -0.03em;
}

.cal-events {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  /* Fade out at the bottom if there are more events than fit */
  -webkit-mask-image: linear-gradient(to bottom, #000 85%, transparent);
  mask-image: linear-gradient(to bottom, #000 85%, transparent);
}

.cal-events.has-head {
  margin-top: calc(3vh * var(--s));
  padding-top: calc(2.5vh * var(--s));
  border-top: 1px solid var(--material-edge);
}

.cal-none {
  font-size: calc(1.4vw * var(--s) * var(--cal-detail, 1));
  color: var(--label-2);
  margin-bottom: calc(1vh * var(--s));
}

.cal-day-label {
  margin: calc(2.6vh * var(--s)) 0 calc(1.2vh * var(--s));
  font-size: calc(1.1vw * var(--s) * var(--cal-label, 1));
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--label-2);
}

.cal-day-label:first-child { margin-top: 0; }

.event {
  display: flex;
  gap: calc(0.9vw * var(--s));
  margin-bottom: calc(1.6vh * var(--s));
}

.event-bar {
  flex: none;
  width: calc(0.3vw * var(--s));
  border-radius: calc(0.3vw * var(--s));
}

.event-text { min-width: 0; }

.event-title {
  font-size: calc(1.5vw * var(--s) * var(--cal-title, 1));
  font-weight: 600;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.event-time {
  margin-top: calc(0.3vh * var(--s));
  font-size: calc(1.2vw * var(--s) * var(--cal-detail, 1));
  color: var(--label-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Calendar: month ---------- */
.cal-month {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.month-head {
  font-size: calc(2.2vw * var(--s) * var(--mo-title, 1));
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: calc(1.5vh * var(--s));
}

.month-name { color: var(--red); }
.month-year { color: var(--label); font-weight: 300; margin-left: 0.2em; }

.month-weekdays {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  padding: 0 calc(0.4vw * var(--s)) calc(1vh * var(--s));
  font-size: calc(0.95vw * var(--s) * var(--mo-weekday, 1));
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--label-2);
}

.month-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-rows: repeat(var(--weeks), minmax(0, 1fr));
}

/* Each week is its own grid: day numbers, then bar rows, then day lists */
.month-week {
  min-height: 0;
  overflow: hidden;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  align-content: start;
  row-gap: calc(0.4vh * var(--s));
  border-top: 1px solid var(--material-edge);
}

/* Background of each day, behind its number, bars and list */
.month-day { grid-row: 1 / -1; }
.month-day.today { background: rgba(255, 69, 58, 0.08); border-radius: calc(0.6vw * var(--s)); }

.month-num {
  grid-row: 1;
  justify-self: start;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2em;
  height: 2em;
  margin: calc(0.6vh * var(--s)) 0 0 calc(0.3vw * var(--s));
  padding: 0 0.5em;
  border-radius: 1em;
  font-size: calc(1.1vw * var(--s) * var(--mo-num, 1));
  font-weight: 600;
}

.month-num.other-month { color: var(--label-2); }
.month-num.past { color: var(--label-2); }
.month-num.today { background: var(--red); color: #fff; font-weight: 700; }   /* bold, like Apple Calendar: readable on the red */

.month-list {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  padding: 0 calc(0.4vw * var(--s));
}

.month-list [hidden],
.month-week .month-bar[hidden] { display: none; }

.month-list.past,
.month-list.other-month { opacity: 0.7; }
.month-list.past .month-time { color: var(--label); }   /* the dimming already makes it gray */

.month-event {
  display: flex;
  align-items: center;
  gap: calc(0.35vw * var(--s));
  margin-bottom: calc(0.4vh * var(--s));
  font-size: calc(1vw * var(--s) * var(--mo-event, 1));
  font-weight: 500;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
}

.month-title { overflow: hidden; text-overflow: ellipsis; }
.month-time { flex: none; color: var(--label-2); font-variant-numeric: tabular-nums; }

/* All-day events: tinted pills; multi-day ones stretch across days */
.month-event.all-day,
.month-bar {
  display: block;
  padding: 0 calc(0.45vw * var(--s));
  border-radius: calc(0.35vw * var(--s));
  background: color-mix(in srgb, var(--c) 40%, transparent);
  text-overflow: ellipsis;
}

.month-bar {
  min-width: 0;
  /* Keep their height when space is short (they'd otherwise be squashed into
     thin lines); days with less room show "+N more" instead */
  min-height: 1.4em;
  margin: 0 calc(0.4vw * var(--s));
  font-size: calc(1vw * var(--s) * var(--mo-event, 1));
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  box-shadow: inset calc(0.25vw * var(--s)) 0 0 var(--c);
}

/* Bars that continue from last week / into next week run off the edge */
.month-bar.from-before { margin-left: 0; border-top-left-radius: 0; border-bottom-left-radius: 0; box-shadow: none; }
.month-bar.goes-on { margin-right: 0; border-top-right-radius: 0; border-bottom-right-radius: 0; }
.month-bar.past { opacity: 0.7; }

.month-dot {
  flex: none;
  width: calc(0.5vw * var(--s) * var(--mo-event, 1));
  height: calc(0.5vw * var(--s) * var(--mo-event, 1));
  border-radius: 50%;
}

.month-more {
  font-size: calc(0.9vw * var(--s) * var(--mo-event, 1));
  color: var(--label-2);
  padding-left: calc(0.2vw * var(--s));
}

/* "Show them all": each week is at least its share of the height and
   grows to fit its events; whatever runs past the bottom is cut off */
.month-show-all .month-grid {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.month-show-all .month-week {
  flex: none;
  min-height: calc(100% / var(--weeks));
  overflow: visible;
}
.month-show-all .month-list { overflow: visible; min-height: auto; padding-bottom: calc(0.4vh * var(--s)); }

/* Full event names: wrap instead of cutting off with "…" */
.month-wrap .month-event { white-space: normal; align-items: baseline; line-height: 1.25; }
.month-wrap .month-title { overflow: visible; overflow-wrap: anywhere; }
.month-wrap .month-dot { align-self: flex-start; margin-top: 0.45em; }
.month-wrap .month-event.all-day { padding-top: 0.1em; padding-bottom: 0.1em; }

/* "Scroll names that don't fit": still, glide to the end, still, glide back */
.marquee { text-overflow: clip !important; }
.marquee-text {
  display: inline-block;
  animation: marquee var(--marquee-time, 8s) ease-in-out infinite alternate;
}
@keyframes marquee {
  0%, 20% { transform: translateX(0); }
  80%, 100% { transform: translateX(var(--marquee-shift, 0)); }
}
/* Screens that aren't showing don't spend the Pi's effort on it */
.screen:not(.active) .marquee-text { animation-play-state: paused; }

/* ---------- Clock seconds ---------- */
.clock-sec {
  font-size: 0.28em;
  font-weight: 400;
  vertical-align: top;
  margin-left: 0.12em;
  letter-spacing: 0;
  position: relative;
  top: 0.18em;
}

/* ---------- Widgets that run to the screen edge ---------- */
.widget.bleed { border-radius: 0; }

/* ---------- Weather ---------- */
.wx {
  --u: min(1cqh, 0.55cqw);   /* one "unit": scales with the widget */
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: calc(var(--u) * 4);
}

.widget-plain .wx { text-shadow: 0 calc(0.15vw * var(--s)) calc(0.8vw * var(--s)) rgba(0, 0, 0, 0.45); }

.wx-now {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.wx-place {
  font-size: calc(var(--u) * 8.5 * var(--wx-place, 1));
  font-weight: 600;
}

.wx-temp {
  font-size: calc(var(--u) * 40 * var(--wx-temp, 1));
  font-weight: 300;
  line-height: 1;
  letter-spacing: -0.04em;
}

.wx-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  text-align: right;
}

.wx-icon svg {
  width: calc(var(--u) * 22 * var(--wx-icon, 1));
  height: calc(var(--u) * 22 * var(--wx-icon, 1));
  filter: drop-shadow(0 calc(0.2vw * var(--s)) calc(0.6vw * var(--s)) rgba(0, 0, 0, 0.25));
}

.wx-cond {
  font-size: calc(var(--u) * 8.5 * var(--wx-cond, 1));
  font-weight: 600;
}

.wx-sub {
  font-size: calc(var(--u) * 7.5 * var(--wx-cond, 1));
  color: var(--label-2);
}

.wx-forecast {
  display: grid;
  grid-template-columns: repeat(var(--n), minmax(0, 1fr));
  padding-top: calc(var(--u) * 3);
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  text-align: center;
}

.wx-col-name {
  font-size: calc(var(--u) * 7.5 * var(--wx-forecast, 1));
  font-weight: 600;
  color: var(--label-2);
}

.wx-col-icon svg {
  width: calc(var(--u) * 15 * var(--wx-forecast, 1));
  height: calc(var(--u) * 15 * var(--wx-forecast, 1));
  margin: calc(var(--u) * 1) 0;
}

.wx-pop {
  min-height: 1.3em;
  font-size: calc(var(--u) * 6 * var(--wx-forecast, 1));
  font-weight: 600;
  color: #64D2FF;
}

.wx-range {
  font-size: calc(var(--u) * 7.5 * var(--wx-forecast, 1));
  font-weight: 600;
  white-space: nowrap;
}

.wx-range span { color: var(--label-2); font-weight: 500; }

/* ---------- Photos ---------- */
.photos {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: #000;
}

.widget-type-photos { position: relative; }
.photos-rounded .photos { border-radius: var(--radius); }

.photo-layer {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity var(--screen-fade, 1.5s) ease-in-out;
}

.photo-layer.active { opacity: 1; }

.photo-img,
.photo-blur {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photos-contain .photo-img { object-fit: contain; }

/* "Whole photo": a soft, dimmed copy fills the space behind it */
.photo-blur {
  filter: blur(40px) brightness(0.55) saturate(1.2);
  transform: scale(1.15);
}

/* Made blurred and dimmed ahead of time (a tiny picture, stretched), so
   nothing has to be blurred while it fades */
.photo-blur.photo-blur-baked { filter: none; }

/* Slow zoom and drift while the photo is up, like Apple's Memories.
   It belongs to the photo itself (each photo is a new image, so it starts
   fresh), and holds its final size while the photo fades out. If it were
   tied to the showing layer, it would snap back to full size the moment
   the next photo started fading in, which looks like a jump. */
.ken-burns {
  animation: ken-burns var(--photo-seconds) ease-out forwards;
}

@keyframes ken-burns {
  from { transform: scale(1); }
  to { transform: scale(1.08) translate(var(--kx), var(--ky)); }
}

.photos-empty {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: calc(2vw * var(--s));
}

/* ---------- News ---------- */
.news {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.news-heading {
  font-size: calc(1.3vw * var(--s));
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: #FF375F;   /* Apple's pink-red, as in the News app */
}

.news-list {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  margin-top: calc(1.2vh * var(--s));
}

.news-item {
  display: flex;
  gap: calc(1vw * var(--s));
  align-items: flex-start;
  padding: calc(1.4vh * var(--s)) 0;
  border-top: 1px solid var(--material-edge);
}

.news-item:first-child { border-top: 0; padding-top: 0; }
.news-item[hidden] { display: none; }

.news-text { flex: 1; min-width: 0; }

.news-meta {
  font-size: calc(1vw * var(--s));
  font-weight: 600;
  color: var(--label-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.news-title {
  margin-top: calc(0.3vh * var(--s));
  font-size: calc(1.45vw * var(--s));
  font-weight: 700;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.news-thumb {
  flex: none;
  width: calc(6.5vw * var(--s));
  height: calc(6.5vw * var(--s));
  border-radius: calc(0.8vw * var(--s));
  object-fit: cover;
  background: rgba(255, 255, 255, 0.06);
}

/* One story at a time: a big picture with the headline over it */
.widget-type-news:has(.news-rotate) { padding: 0; }

.news-rotate {
  position: relative;
  height: 100%;
  overflow: hidden;
}

.news-slide {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  opacity: 0;
  transition: opacity 1.5s ease-in-out;
}

.news-slide.active { opacity: 1; }

.news-slide-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Darken the bottom of the picture so the headline reads */
.news-slide.has-image::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, transparent 30%, rgba(0, 0, 0, 0.85));
}

.news-slide-text {
  position: relative;
  z-index: 1;
  padding: calc(3vh * var(--s)) calc(2.2vw * var(--s));
  opacity: 0;
  transition: opacity 0.6s ease-in-out;
}

.news-slide.active .news-slide-text { opacity: 1; transition-delay: 0.9s; }
.news-slide.leaving .news-slide-text { opacity: 0; transition-delay: 0s; transition-duration: 0.4s; }

.news-slide.has-image .news-slide-text { text-shadow: 0 calc(0.1vw * var(--s)) calc(0.6vw * var(--s)) rgba(0, 0, 0, 0.5); }

.news-slide-title {
  margin-top: calc(0.6vh * var(--s));
  font-size: min(11cqh, 6cqw);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.01em;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Without a picture, the headline sits at the top of the card */
.news-slide:not(.has-image) { justify-content: flex-start; }

/* ---------- Card color (any widget) ---------- */
/* Your chosen color, deepened a little so white text reads, as frosted glass */
.widget-tinted {
  background: color-mix(in srgb, color-mix(in srgb, var(--tint) var(--tint-mix, 72%), #000) 85%, transparent);
  --label-2: rgba(255, 255, 255, 0.85);
  --label-3: rgba(255, 255, 255, 0.65);
  border: 1px solid color-mix(in srgb, var(--tint) 50%, transparent);
  border-radius: var(--radius);
  padding: calc(3vh * var(--s)) calc(2.2vw * var(--s));
  backdrop-filter: saturate(180%);
  -webkit-backdrop-filter: saturate(180%);
  box-shadow: 0 calc(1vw * var(--s)) calc(3vw * var(--s)) rgba(0, 0, 0, 0.25);
}

.widget-glass.glass-blur,
.widget-tinted.glass-blur {
  backdrop-filter: blur(40px) saturate(180%);
  -webkit-backdrop-filter: blur(40px) saturate(180%);
}

/* Over a photo, which can be bright: a thicker frosted card, so its text
   stays readable whatever the picture */
.widget-glass.over-photo:not(.widget-tinted) {
  background: rgba(28, 28, 30, 0.75);
  --label-2: rgba(235, 235, 245, 0.8);
}

/* A widget without a card over a photo (e.g. the clock): a soft, feathered
   shadow behind it (no hard edges), so it reads on a bright picture */
.widget-plain.over-photo { overflow: visible; }
.widget-plain.over-photo::before {
  content: "";
  position: absolute;
  inset: calc(-1.5vw * var(--s));
  z-index: -1;
  border-radius: calc(4vw * var(--s));
  background: rgba(0, 0, 0, 0.55);
  filter: blur(calc(1.8vw * var(--s)));
  pointer-events: none;
}

/* ---------- Weather alerts ---------- */
.widget.alert-hidden { visibility: hidden; }

/* A slow pulsing ring on warnings, to catch the eye */
.widget.alert-pulse::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 calc(0.25vw * var(--s)) rgba(255, 255, 255, 0.9);
  pointer-events: none;
  animation: alert-pulse 2s ease-in-out infinite;
}

@keyframes alert-pulse {
  0%, 100% { opacity: 0; }
  50% { opacity: 1; }
}

.alert {
  --u: min(1.5cqh, 0.42cqw);
  position: relative;
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: calc(var(--u) * 3);
}

.alert-top {
  display: flex;
  align-items: center;
  gap: calc(var(--u) * 5);
}

.alert-icon {
  flex: none;
  width: calc(var(--u) * 22);
  height: calc(var(--u) * 22);
}

.alert-heading { min-width: 0; }

.alert-event {
  font-size: calc(var(--u) * 15);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.01em;
}

.alert-meta {
  margin-top: calc(var(--u) * 1);
  font-size: calc(var(--u) * 7);
  font-weight: 600;
  color: rgba(255, 255, 255, 0.85);
}

/* The details: as much as fits, and if there's more, they scroll */
.alert-what {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  font-size: calc(var(--u) * 7.5);
  font-weight: 600;
  line-height: 1.3;
}
.alert-what p + p { margin-top: 0.4em; }
.alert-what b { font-weight: 800; }
/* Fade the edges, so it's clear there's more above or below */
.alert-scrolling {
  -webkit-mask-image: linear-gradient(transparent, #000 0.5em, #000 calc(100% - 0.8em), transparent);
  mask-image: linear-gradient(transparent, #000 0.5em, #000 calc(100% - 0.8em), transparent);
}
.alert-scrolling .alert-scroll {
  padding: 0.3em 0 0.6em;
  animation: alert-scroll var(--alert-time, 20s) ease-in-out infinite alternate;
}
@keyframes alert-scroll {
  0%, 20% { transform: translateY(0); }
  80%, 100% { transform: translateY(var(--alert-shift, 0)); }
}
.screen:not(.active) .alert-scroll { animation-play-state: paused; }

.alert-more {
  margin-top: auto;
  font-size: calc(var(--u) * 6.5);
  color: rgba(255, 255, 255, 0.85);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.alert-chip {
  position: absolute;
  top: 0;
  right: 0;
  padding: 0.2em 0.7em;
  border-radius: 1em;
  background: rgba(0, 0, 0, 0.35);
  font-size: calc(var(--u) * 5.5);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* On a colored card, red accents would clash: make them white */
.widget-tinted .news-heading,
.widget-tinted .cal-weekday,
.widget-tinted .month-name { color: #fff; }

/* ---------- Meals ---------- */
.meals {
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: calc(1.6vh * var(--s));
}

.meals-heading {
  display: flex;
  align-items: center;
  gap: calc(0.5vw * var(--s));
  font-size: calc(1.3vw * var(--s) * var(--meal-heading, 1));
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--orange);
}

.meals-icon { width: 1em; height: 1em; flex: none; }

.meal-days {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: calc(1.8vh * var(--s));
  overflow: hidden;
}

/* Side by side: one column per day, with a hairline between */
.meals-columns .meal-days {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: calc(1.6vw * var(--s));
}

.meals-columns .meal-day + .meal-day {
  padding-left: calc(1.6vw * var(--s));
  border-left: 1px solid var(--material-edge);
}

.meals:not(.meals-columns) .meal-day + .meal-day {
  padding-top: calc(1.6vh * var(--s));
  border-top: 1px solid var(--material-edge);
}

.meal-day { min-width: 0; }

.meal-day-name {
  font-size: calc(1.05vw * var(--s) * var(--meal-day, 1));
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--label-2);
}

.meal + .meal { margin-top: calc(1vh * var(--s)); }

.meal-label {
  margin-top: calc(0.4vh * var(--s));
  font-size: calc(0.95vw * var(--s) * var(--meal-day, 1));
  font-weight: 600;
  color: var(--orange);
}

.meal-title {
  margin-top: calc(0.3vh * var(--s));
  font-size: calc(1.6vw * var(--s) * var(--meal-title, 1));
  font-weight: 700;
  line-height: 1.2;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Today's meal is the one that matters most */
.meal-day.is-today .meal-title { font-size: calc(2.2vw * var(--s) * var(--meal-title, 1)); letter-spacing: -0.01em; }

.meal-notes {
  margin-top: calc(0.4vh * var(--s));
  font-size: calc(1.1vw * var(--s) * var(--meal-notes, 1));
  line-height: 1.35;
  color: var(--label-2);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.meal-none {
  margin-top: calc(0.4vh * var(--s));
  font-size: calc(1.3vw * var(--s) * var(--meal-title, 1));
  color: var(--label-3);
}

.widget-tinted .meals-heading,
.widget-tinted .meal-label { color: #fff; }

.meals [hidden] { display: none; }

/* ---------- Weather: wide boxes ---------- */
/* In a box much wider than it is tall, put the current conditions on the
   left and the forecast beside them in one row, instead of stacking them
   (which would leave everything tiny and the middle empty). */
@container (min-aspect-ratio: 5 / 2) {
  .wx {
    --u: min(1cqh, 0.25cqw);
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: calc(var(--u) * 7);
  }

  .wx-now {
    flex: none;
    align-items: center;
    gap: calc(var(--u) * 6);
  }

  .wx-place { font-size: calc(var(--u) * 11 * var(--wx-place, 1)); }
  .wx-temp { font-size: calc(var(--u) * 56 * var(--wx-temp, 1)); }

  .wx-side {
    align-items: flex-start;
    text-align: left;
  }

  .wx-icon svg {
    width: calc(var(--u) * 28 * var(--wx-icon, 1));
    height: calc(var(--u) * 28 * var(--wx-icon, 1));
  }

  .wx-cond { font-size: calc(var(--u) * 11 * var(--wx-cond, 1)); }
  .wx-sub { font-size: calc(var(--u) * 9.5 * var(--wx-cond, 1)); }

  .wx-forecast {
    flex: 1;
    min-width: 0;
    align-self: stretch;
    align-content: center;
    padding: 0 0 0 calc(var(--u) * 6);
    border-top: 0;
    border-left: 1px solid rgba(255, 255, 255, 0.18);
  }

  .wx-col-name { font-size: calc(var(--u) * 10.5 * var(--wx-forecast, 1)); }

  .wx-col-icon svg {
    width: calc(var(--u) * 24 * var(--wx-forecast, 1));
    height: calc(var(--u) * 24 * var(--wx-forecast, 1));
  }

  .wx-pop { font-size: calc(var(--u) * 8 * var(--wx-forecast, 1)); }
  .wx-range { font-size: calc(var(--u) * 10.5 * var(--wx-forecast, 1)); }
}

/* On the sky-colored card, gray and blue text get lost: lighten them */
.wx-sky .wx-sub,
.wx-sky .wx-col-name,
.wx-sky .wx-range span { color: rgba(255, 255, 255, 0.92); }
.wx-sky .wx-pop { color: #D2F4FF; }
.wx-sky .wx-forecast { border-color: rgba(255, 255, 255, 0.3); }

/* ---------- Weather: square and tall boxes ---------- */
/* Current conditions on top, and the forecast as a list below (one line
   per day: name, icon, chance of rain, high and low), like Apple's large
   weather widget. */
@container (max-aspect-ratio: 13 / 10) {
  .wx { --u: min(0.75cqh, 0.8cqw); }

  .wx-forecast {
    grid-template-columns: minmax(0, 1fr);
    row-gap: calc(var(--u) * 1.5);
    text-align: left;
  }

  .wx-col {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto 3.2em auto;
    align-items: center;
    column-gap: calc(var(--u) * 3);
  }

  .wx-col-name {
    font-size: calc(var(--u) * 8 * var(--wx-forecast, 1));
    color: var(--label);
  }

  .wx-col-icon svg {
    width: calc(var(--u) * 11 * var(--wx-forecast, 1));
    height: calc(var(--u) * 11 * var(--wx-forecast, 1));
    margin: 0;
  }

  .wx-pop {
    min-height: 0;
    text-align: right;
    font-size: calc(var(--u) * 6.5 * var(--wx-forecast, 1));
  }

  .wx-range {
    text-align: right;
    font-size: calc(var(--u) * 8 * var(--wx-forecast, 1));
  }
}

/* ---------- Weather: "Make bigger: the forecast" ---------- */
/* Current conditions on one line at the top; the forecast fills the rest,
   its text and icons as big as the space allows (fewer days, bigger). */
.wx-bigfc { --u: min(1cqh, 0.55cqw); gap: calc(var(--u) * 3); justify-content: flex-start; }

.wx-head {
  flex: none;
  display: flex;
  align-items: center;
  gap: calc(var(--u) * 3);
}
.wx-head .wx-icon svg { width: calc(var(--u) * 15 * var(--wx-icon, 1)); height: calc(var(--u) * 15 * var(--wx-icon, 1)); }
.wx-head .wx-temp { font-size: calc(var(--u) * 22 * var(--wx-temp, 1)); }
.wx-head-text { min-width: 0; margin-left: auto; text-align: right; }
.wx-head-text > * { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wx-head .wx-place { font-size: calc(var(--u) * 6.5 * var(--wx-place, 1)); }
.wx-head .wx-cond { font-size: calc(var(--u) * 6.5 * var(--wx-cond, 1)); }
.wx-head .wx-sub { font-size: calc(var(--u) * 5.5 * var(--wx-cond, 1)); }

.wx-bigfc .wx-forecast {
  flex: 1;
  min-height: 0;
  align-content: center;
}

/* Landscape boxes: days side by side, with big icons */
.wx-bigfc .wx-col { display: flex; flex-direction: column; align-items: center; justify-content: center; }
.wx-bigfc .wx-col-name { font-size: calc(var(--u) * 10 * var(--wx-forecast, 1)); color: var(--label); }
.wx-bigfc .wx-col-icon svg {
  width: calc(var(--u) * 22 * var(--wx-forecast, 1));
  height: calc(var(--u) * 22 * var(--wx-forecast, 1));
  margin: calc(var(--u) * 2) 0;
}
.wx-bigfc .wx-pop { font-size: calc(var(--u) * 7.5 * var(--wx-forecast, 1)); }
.wx-bigfc .wx-range { font-size: calc(var(--u) * 8.5 * var(--wx-forecast, 1)); }

/* Square and tall boxes: one row per day, the rows sharing the height */
@container (max-aspect-ratio: 13 / 10) {
  .wx-bigfc { --u: min(1cqh, 1.1cqw); }
  .wx-bigfc .wx-forecast {
    grid-template-columns: minmax(0, 1fr);
    grid-auto-rows: minmax(0, 1fr);
    row-gap: 0;
    align-content: stretch;
    text-align: left;
    /* Each row's text: as big as one row's share of the height allows */
    --row: min(calc(var(--u) * 9), calc(74cqh / var(--n) * 0.6));
  }
  .wx-bigfc .wx-col {
    display: grid;
    grid-template-columns: minmax(max-content, 1fr) auto 3.4em auto;   /* "Today" never runs into its icon */
    align-items: center;
    column-gap: calc(var(--u) * 4.5);
  }
  .wx-bigfc .wx-col-name { font-size: calc(var(--row) * var(--wx-forecast, 1)); }
  .wx-bigfc .wx-col-icon svg {
    width: calc(var(--row) * 1.4 * var(--wx-forecast, 1));
    height: calc(var(--row) * 1.4 * var(--wx-forecast, 1));
    margin: 0;
  }
  .wx-bigfc .wx-pop { min-height: 0; text-align: right; font-size: calc(var(--row) * 0.75 * var(--wx-forecast, 1)); }
  .wx-bigfc .wx-range { text-align: right; font-size: calc(var(--row) * var(--wx-forecast, 1)); }
}

/* Very wide boxes: the conditions on the left (as in the usual layout), and
   bigger days across the rest */
@container (min-aspect-ratio: 5 / 2) {
  .wx-bigfc { --u: min(1cqh, 0.25cqw); flex-direction: row; align-items: center; gap: calc(var(--u) * 6); }
  .wx-bigfc .wx-head { gap: calc(var(--u) * 4); }
  .wx-bigfc .wx-head .wx-icon svg { width: calc(var(--u) * 22 * var(--wx-icon, 1)); height: calc(var(--u) * 22 * var(--wx-icon, 1)); }
  .wx-bigfc .wx-head .wx-temp { font-size: calc(var(--u) * 44 * var(--wx-temp, 1)); }
  .wx-bigfc .wx-head-text { margin-left: 0; text-align: left; }
  .wx-bigfc .wx-head .wx-place,
  .wx-bigfc .wx-head .wx-cond { font-size: calc(var(--u) * 10 * var(--wx-cond, 1)); }
  .wx-bigfc .wx-head .wx-sub { font-size: calc(var(--u) * 8.5 * var(--wx-cond, 1)); }
  .wx-bigfc .wx-forecast { align-self: stretch; }
  .wx-bigfc .wx-col-name { font-size: calc(var(--u) * 13 * var(--wx-forecast, 1)); }
  .wx-bigfc .wx-col-icon svg { width: calc(var(--u) * 28 * var(--wx-forecast, 1)); height: calc(var(--u) * 28 * var(--wx-forecast, 1)); margin: calc(var(--u) * 1) 0; }
  .wx-bigfc .wx-pop { font-size: calc(var(--u) * 9 * var(--wx-forecast, 1)); }
  .wx-bigfc .wx-range { font-size: calc(var(--u) * 13 * var(--wx-forecast, 1)); }
}

/* ---------- School lunch ---------- */
.lunch {
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: calc(1.4vh * var(--s));
}

.lunch-heading {
  font-size: calc(1.3vw * var(--s) * var(--lunch-heading, 1));
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--green);
}

.lunch-days {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: calc(1.8vh * var(--s));
}

.lunch-day + .lunch-day {
  padding-top: calc(1.6vh * var(--s));
  border-top: 1px solid var(--material-edge);
}

.lunch-day-name {
  margin-bottom: calc(0.6vh * var(--s));
  font-size: calc(1.05vw * var(--s) * var(--lunch-day, 1));
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--label-2);
}

/* Each dish, with a small dot like a menu board */
.lunch-item {
  position: relative;
  padding-left: 1em;
  font-size: calc(1.45vw * var(--s) * var(--lunch-item, 1));
  font-weight: 600;
  line-height: 1.35;
}

.lunch-item::before {
  content: "";
  position: absolute;
  left: 0.15em;
  top: 0.55em;
  width: 0.35em;
  height: 0.35em;
  border-radius: 50%;
  background: var(--green);
}

.lunch-section {
  margin-top: calc(0.6vh * var(--s));
  font-size: calc(1vw * var(--s) * var(--lunch-item, 1));
  font-weight: 600;
  color: var(--label-2);
}

.lunch-note {
  padding-left: 1em;
  font-size: calc(1.15vw * var(--s) * var(--lunch-item, 1));
  font-style: italic;
  color: var(--label-2);
  line-height: 1.35;
}

.lunch-none { font-size: calc(1.3vw * var(--s)); color: var(--label-3); }
.lunch [hidden] { display: none; }

.widget-tinted .lunch-heading { color: #fff; }
.widget-tinted .lunch-item::before { background: #fff; }

/* ---------- Countdown ---------- */
.cd {
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: calc(1.4vh * var(--s));
}

.cd-heading {
  font-size: calc(1.3vw * var(--s) * var(--cd-name, 1));
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--blue);
}

.cd-list {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.cd-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1vw;
  padding: calc(1.2vh * var(--s)) 0;
  border-top: 1px solid var(--material-edge);
}

.cd-row:first-child { border-top: 0; padding-top: 0; }

.cd-name {
  min-width: 0;
  font-size: calc(1.5vw * var(--s) * var(--cd-name, 1));
  font-weight: 600;
  line-height: 1.25;
}

.cd-date {
  display: block;
  margin-top: calc(0.2vh * var(--s));
  font-size: 0.72em;
  font-weight: 500;
  color: var(--label-2);
}

.cd-days {
  flex: none;
  font-size: calc(1.2vw * var(--s) * var(--cd-number, 1));
  font-weight: 500;
  color: var(--label-2);
  white-space: nowrap;
}

.cd-num {
  font-size: 1.9em;
  font-weight: 300;
  letter-spacing: -0.02em;
  color: var(--label);
  margin-right: 0.15em;
}

.cd-today { font-size: 1.3em; font-weight: 700; color: var(--orange); }

/* Just the next one, large: fills its box */
.cd-big-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  container-type: size;
}

.cd-big-number {
  font-size: calc(min(55cqh, 45cqw) * var(--cd-number, 1));
  font-weight: 200;
  line-height: 1;
  letter-spacing: -0.04em;
}

.cd-big-unit {
  font-size: calc(min(8cqh, 6cqw) * var(--cd-name, 1));
  font-weight: 500;
  color: var(--label-2);
}

.cd-big-name {
  margin-top: 0.2em;
  font-size: calc(min(11cqh, 9cqw) * var(--cd-name, 1));
  font-weight: 700;
}

.cd-none { font-size: calc(1.3vw * var(--s)); color: var(--label-3); }

.widget-tinted .cd-heading,
.widget-tinted .cd-today { color: #fff; }

/* ---------- Now Playing (Sonos) ---------- */
.widget.np-hidden { visibility: hidden; }

/* Each room's card; when the rooms take turns, one fades into the next */
.np-slide {
  position: absolute;
  inset: 0;
  padding: inherit;
  opacity: 0;
  transition: opacity 0.9s ease;
}
.np-slide.np-in { opacity: 1; }
.np-slide.np-leaving { opacity: 0; }

/* Several rooms playing: which one this is */
.np-dots {
  position: absolute;
  right: calc(1.2vw * var(--s));
  bottom: calc(1.4vh * var(--s));
  display: flex;
  gap: calc(0.35vw * var(--s));
}
.np-dots span {
  width: calc(0.4vw * var(--s));
  height: calc(0.4vw * var(--s));
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.35);
  transition: background 0.9s ease;
}
.np-dots span.on { background: rgba(255, 255, 255, 0.9); }

/* Blurred album art filling the card, darkened so text reads */
.np-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: blur(30px) brightness(0.5) saturate(1.4);
  transform: scale(1.3);
}

.np {
  --u: min(1cqh, 0.3cqw);
  position: relative;
  height: 100%;
  display: flex;
  align-items: center;
  gap: calc(var(--u) * 7);
}

.np-art {
  flex: none;
  height: 100%;
  max-height: calc(var(--u) * 100);
  aspect-ratio: 1;
  border-radius: calc(var(--u) * 8);
  object-fit: cover;
  box-shadow: 0 calc(var(--u) * 3) calc(var(--u) * 10) rgba(0, 0, 0, 0.4);
}

.np-art-empty {
  background: linear-gradient(135deg, #FF375F, #BF5AF2);
}

.np-paused .np-art { opacity: 0.6; }

.np-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: calc(var(--u) * 2);
}

.np-room {
  display: flex;
  align-items: center;
  gap: 0.4em;
  font-size: calc(var(--u) * 10);
  font-weight: 600;
  color: var(--label-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.np-speaker { width: 1.1em; height: 1.1em; flex: none; }

.np-title {
  font-size: calc(var(--u) * 20 * var(--np-title, 1));
  font-weight: 700;
  line-height: 1.15;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.np-artist {
  font-size: calc(var(--u) * 14 * var(--np-artist, 1));
  font-weight: 500;
  color: var(--label-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.np-bar {
  margin-top: calc(var(--u) * 4);
  height: calc(var(--u) * 2.5);
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.2);
  overflow: hidden;
}

.np-bar span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: rgba(255, 255, 255, 0.85);
  transition: width 1s linear;
}

.np-chip {
  position: absolute;
  top: 0;
  right: 0;
  padding: 0.2em 0.7em;
  border-radius: 1em;
  background: rgba(0, 0, 0, 0.4);
  font-size: calc(var(--u) * 6.5);
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

/* Square or tall box: album art on top, words underneath */
@container (max-aspect-ratio: 6 / 5) {
  .np {
    --u: min(0.55cqh, 0.8cqw);
    flex-direction: column;
    align-items: stretch;
    text-align: left;
  }
  .np-art { height: auto; width: 100%; max-height: 60cqh; align-self: center; width: auto; }
}

/* ---------- Night mode ---------- */
.night {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  cursor: none;
}

/* A soft, dim red, like StandBy at night: easy on the eyes in the dark */
.night-clock {
  text-align: center;
  color: #A3281E;
  transition: transform 2s ease-in-out;
}

.night-time {
  font-size: 22vw;
  font-weight: 200;
  line-height: 1;
  letter-spacing: -0.04em;
}

.night-date {
  font-size: 2.4vw;
  font-weight: 500;
  opacity: 0.8;
}

/* "Turn the TV off": just black, in case the TV doesn't switch off */
.night-black .night-clock { display: none; }

/* ---------- List (to-dos, chores, groceries) ---------- */
.lst {
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: calc(1.2vh * var(--s));
  --lt: calc(var(--s) * var(--list-text, 1));
}

.lst-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-size: calc(1.6vw * var(--lt));
  font-weight: 700;
  color: var(--orange);
}

.lst-count { font-weight: 600; color: var(--label-2); }

.lst-items {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  list-style: none;
}

.li {
  display: flex;
  align-items: center;
  gap: calc(0.8vw * var(--lt));
  padding: calc(1vh * var(--lt)) 0;
  border-bottom: 1px solid var(--material-edge);
  font-size: calc(1.4vw * var(--lt));
  font-weight: 500;
}

.li[hidden] { display: none; }

/* An open circle, like Reminders */
.li-check {
  flex: none;
  width: 1.05em;
  height: 1.05em;
  border: 0.12em solid var(--label-3);
  border-radius: 50%;
}

.li-done .li-check {
  border-color: var(--orange);
  background: var(--orange);
  position: relative;
}

/* The check mark */
.li-done .li-check::after {
  content: "";
  position: absolute;
  left: 0.27em;
  top: 0.2em;
  width: 0.35em;
  height: 0.2em;
  border: solid #fff;
  border-width: 0 0 0.12em 0.12em;
  transform: rotate(-45deg);
}

.li-text {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.li-done .li-text { color: var(--label-3); text-decoration: line-through; }

.li-who {
  flex: none;
  padding: 0.1em 0.6em;
  border-radius: 1em;
  background: rgba(255, 255, 255, 0.1);
  font-size: 0.75em;
  font-weight: 600;
  color: var(--label-2);
}

.li-empty {
  padding-top: calc(1vh * var(--lt));
  font-size: calc(1.4vw * var(--lt));
  color: var(--label-3);
}

.widget-tinted .lst-head { color: #fff; }
.widget-tinted .li-done .li-check { border-color: #fff; background: #fff; }
.widget-tinted .li-done .li-check::after { border-color: #000; }

/* ---------- "Offline" badge ---------- */
.offline {
  position: fixed;
  right: calc(1.2vw * var(--s));
  bottom: calc(1.2vh * var(--s));
  z-index: 900;
  display: flex;
  align-items: center;
  gap: 0.4em;
  padding: 0.3em 0.8em;
  border-radius: 1em;
  background: rgba(0, 0, 0, 0.6);
  color: var(--orange);
  font-size: calc(0.9vw * var(--s));
  font-weight: 600;
}

.offline svg { width: 1.2em; height: 1.2em; }

/* ---------- Calendar legend ---------- */
.cal-legend {
  display: flex;
  flex-wrap: wrap;
  gap: calc(0.4vh * var(--s)) calc(1.1vw * var(--s));
  margin-bottom: calc(1.4vh * var(--s));
  font-size: calc(0.95vw * var(--s) * var(--cal-legend, 1));
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  color: var(--label-2);
}

.cal-legend-item { display: inline-flex; align-items: center; gap: 0.4em; white-space: nowrap; }
.cal-legend-item i { width: 0.6em; height: 0.6em; border-radius: 50%; flex: none; }

/* In the month view it sits on the right of the month name */
.month-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1vw; }
.month-head .cal-legend { margin: 0; justify-content: flex-end; }

/* ---------- Memories label, like Apple's ---------- */
.photo-memory {
  position: absolute;
  left: calc(2.5vw * var(--s));
  bottom: calc(3vh * var(--s));
  text-shadow: 0 0.1vw 0.8vw rgba(0, 0, 0, 0.6);
}

.pm-ago {
  font-size: calc(2.4vw * var(--s));
  font-weight: 700;
  letter-spacing: -0.01em;
}

.pm-date {
  font-size: calc(1.2vw * var(--s));
  font-weight: 500;
  color: rgba(255, 255, 255, 0.85);
}

/* A soft shade behind the label so it reads on bright photos */
.photo-layer:has(.photo-memory)::after {
  content: "";
  position: absolute;
  inset: 55% 0 0 0;
  background: linear-gradient(to bottom, transparent, rgba(0, 0, 0, 0.45));
  pointer-events: none;
}
.photo-memory { z-index: 1; }

/* ---------- Sports ---------- */
.sp {
  --st: calc(var(--s) * var(--sp-text, 1));
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: calc(1.4vh * var(--st));
  overflow: hidden;
}

.sp-team {
  display: flex;
  align-items: center;
  gap: calc(1vw * var(--st));
}

.sp-team + .sp-team {
  padding-top: calc(1.4vh * var(--st));
  border-top: 1px solid var(--material-edge);
}

.sp-logo {
  flex: none;
  width: calc(3.6vw * var(--st));
  height: calc(3.6vw * var(--st));
  object-fit: contain;
  filter: drop-shadow(0 0.1vw 0.3vw rgba(0, 0, 0, 0.4));
}

.sp-text { min-width: 0; }

.sp-name {
  font-size: calc(1.45vw * var(--st));
  font-weight: 700;
}

.sp-record {
  margin-left: 0.5em;
  font-weight: 500;
  color: var(--label-2);
  font-size: 0.85em;
}

.sp-line {
  margin-top: calc(0.2vh * var(--st));
  font-size: calc(1.15vw * var(--st));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sp-dim { color: var(--label-2); }
.sp-win { color: var(--green); }
.sp-loss { color: var(--red); }

/* Live: a pulsing red dot, like a broadcast */
.sp-live { font-weight: 700; }
.sp-dot {
  display: inline-block;
  width: 0.55em;
  height: 0.55em;
  margin-right: 0.45em;
  border-radius: 50%;
  background: var(--red);
  animation: sp-pulse 1.6s ease-in-out infinite;
}

@keyframes sp-pulse { 50% { opacity: 0.3; } }

/* ---------- Game Day ---------- */
/* One card per game, in a grid sized to how many there are (--gd-cols x --gd-rows).
   Each card is a size container, so one game is huge and four are smaller. */
.gd {
  height: 100%;
  display: grid;
  grid-template-columns: repeat(var(--gd-cols, 1), minmax(0, 1fr));
  grid-template-rows: repeat(var(--gd-rows, 1), minmax(0, 1fr));
  gap: var(--gap-y) var(--gap-x);
}

.gd-game {
  --gd-accent: var(--blue);
  --t: var(--gd-text, 1);
  container-type: size;
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 3cqw;
  padding: 6cqh 4cqw;
  overflow: hidden;
  border-radius: var(--radius);
  border: 1px solid var(--material-edge);
  /* Your team's color, glowing in from the corner */
  background:
    radial-gradient(120% 140% at 0% 0%, color-mix(in srgb, var(--gd-accent) 45%, transparent), transparent 60%),
    var(--material);
  box-shadow: 0 calc(1vw * var(--s)) calc(3vw * var(--s)) rgba(0, 0, 0, 0.25);
}

.gd-team {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 2cqh;
}

.gd-logo {
  width: calc(min(42cqh, 24cqw) * var(--t));
  height: calc(min(42cqh, 24cqw) * var(--t));
  object-fit: contain;
  filter: drop-shadow(0 0.4cqh 1.2cqh rgba(0, 0, 0, 0.45));
}

/* No logo from ESPN: the team's letters in a circle */
.gd-abbr {
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  font-size: calc(min(10cqh, 5.5cqw) * var(--t));
  font-weight: 800;
}

.gd-name {
  max-width: 100%;
  font-size: calc(min(9cqh, 4.6cqw) * var(--t));
  font-weight: 600;
  color: var(--label-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gd-ours .gd-name { color: var(--label); font-weight: 800; }

.gd-record {
  font-size: calc(min(6cqh, 3.2cqw) * var(--t));
  color: var(--label-3);
  font-variant-numeric: tabular-nums;
}

/* Who has the ball (football) */
.gd-ball {
  display: inline-block;
  width: 0.5em;
  height: 0.5em;
  margin-right: 0.4em;
  vertical-align: 0.15em;
  border-radius: 50%;
  background: var(--orange);
}

.gd-mid {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 2cqh;
}

.gd-score {
  display: flex;
  align-items: baseline;
  gap: 0.25em;
  font-size: calc(min(34cqh, 11cqw) * var(--t));
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.gd-dash { color: var(--label-3); font-weight: 400; }

/* After the final: the losing side fades back */
.gd-lost { opacity: 0.5; }

.gd-status {
  font-size: calc(min(8cqh, 4.4cqw) * var(--t));
  font-weight: 700;
  white-space: nowrap;
}

.gd-final { color: var(--label-2); text-transform: uppercase; letter-spacing: 0.06em; }

.gd-dot {
  display: inline-block;
  width: 0.55em;
  height: 0.55em;
  margin-right: 0.45em;
  vertical-align: 0.1em;
  border-radius: 50%;
  background: var(--red);
  animation: sp-pulse 1.6s ease-in-out infinite;
}

.gd-note {
  max-width: 34cqw;
  font-size: calc(min(5.5cqh, 3cqw) * var(--t));
  color: var(--label-2);
  text-wrap: balance;
}

/* A score that just changed glows for a few seconds */
.gd-score-pulse { animation: gd-scored 4s ease-out; }

@keyframes gd-scored {
  0%, 30% { color: var(--gd-accent); text-shadow: 0 0 0.25em var(--gd-accent); }
}

/* Room for the field and the last play under the teams and score */
/* Rows: the teams and score; each team's best player (under its team, so
   both teams line up even when only one has one); the field and last play */
.gd-game {
  grid-template-rows: auto auto auto;
  align-content: center;
  row-gap: 3.5cqh;
}
.gd-away { grid-area: 1 / 1; }
.gd-mid { grid-area: 1 / 2; }
.gd-home { grid-area: 1 / 3; }
.gd-star-away { grid-area: 2 / 1; justify-self: center; }
.gd-star-home { grid-area: 2 / 3; justify-self: center; }
.gd-below { grid-row: 3; }
/* An odd game out in a two-column grid spans the bottom row */
.gd-odd > .gd-game:last-child { grid-column: 1 / -1; }
.gd-game:has(.gd-below) .gd-logo {
  width: calc(min(30cqh, 20cqw) * var(--t));
  height: calc(min(30cqh, 20cqw) * var(--t));
}
.gd-game:has(.gd-star) .gd-score { font-size: calc(min(28cqh, 11cqw) * var(--t)); }

/* A team's best player so far */
.gd-star {
  display: flex;
  align-items: center;
  gap: 0.6em;
  max-width: 100%;
  padding: 0.35em 1em 0.35em 0.35em;
  border-radius: 1.65em;
  background: rgba(255, 255, 255, 0.07);
  font-size: calc(min(4.6cqh, 2.5cqw) * var(--t));
  text-align: left;
}
.gd-head {
  flex: none;
  width: 2.6em;
  height: 2.6em;
  border-radius: 50%;
  object-fit: cover;
  object-position: top;
  background: rgba(255, 255, 255, 0.1);
}
.gd-star-text { min-width: 0; }
.gd-star-name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gd-star-line {
  color: var(--label-2);
  font-variant-numeric: tabular-nums;
}


/* Baseball: the bases and the count */
.gd-diamond {
  display: flex;
  align-items: center;
  gap: 3cqw;
  font-size: calc(min(4.6cqh, 2.4cqw) * var(--t));
}
.gd-diamond svg { width: 5.5em; height: auto; overflow: visible; }
.gd-diamond rect {
  fill: rgba(255, 255, 255, 0.08);
  stroke: var(--label-3);
  stroke-width: 1.5;
}
.gd-diamond rect.gd-on { fill: var(--orange); stroke: var(--orange); }
.gd-count p { display: flex; align-items: center; gap: 0.35em; line-height: 1.45; }
.gd-count b { width: 1.1em; color: var(--label-2); font-weight: 700; }
.gd-count i {
  width: 0.7em;
  height: 0.7em;
  border-radius: 50%;
  border: 1.5px solid var(--label-3);
}
.gd-count i.gd-lit { background: var(--orange); border-color: var(--orange); }

/* Under the teams: the field (football) and the last play */
.gd-below {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2.5cqh;
  min-width: 0;
}

.gd-field {
  width: 100%;
  height: calc(min(9cqh, 5cqw) * var(--t));
  display: flex;
  border-radius: calc(var(--radius) / 2);
  overflow: hidden;
  font-size: calc(min(4cqh, 2.2cqw) * var(--t));
}
.gd-endzone {
  flex: 0 0 9%;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--ez, #636366) 75%, #000);
  font-weight: 800;
  letter-spacing: 0.05em;
}
.gd-turf {
  position: relative;
  flex: 1;
  background: linear-gradient(rgba(48, 209, 88, 0.22), rgba(48, 209, 88, 0.14));
}
.gd-turf i {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: rgba(255, 255, 255, 0.18);
}
.gd-turf i:nth-child(5) { background: rgba(255, 255, 255, 0.4); }   /* the 50 */

/* The ball: a dot on the line of scrimmage, with an arrow the way it's going */
.gd-spot {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 3px;
  margin-left: -1.5px;
  background: var(--blue);
}
.gd-spot::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 0;
  height: 0;
  border: 0.55em solid transparent;
  transform: translateY(-50%);
}
.gd-to-right::after { left: 3px; border-left-color: var(--label); }
.gd-to-left::after { right: 3px; border-right-color: var(--label); }
.gd-redzone .gd-spot { background: var(--red); }
.gd-redzone .gd-turf { box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--red) 70%, transparent); }

.gd-play {
  max-width: 90%;
  font-size: calc(min(5cqh, 2.7cqw) * var(--t));
  color: var(--label-2);
  text-align: center;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Crunch time: a close game near the end. The card glows red (team colors
   are often too dark to glow on a dark card), and says so in the corner */
.gd-crunch {
  border-color: var(--red);
  animation: gd-crunch 2.4s ease-in-out infinite;
}
@keyframes gd-crunch {
  0%, 100% { box-shadow: 0 0 0 0.2vw color-mix(in srgb, var(--red) 50%, transparent), 0 0 1vw color-mix(in srgb, var(--red) 20%, transparent); }
  50% { box-shadow: 0 0 0 0.2vw var(--red), 0 0 2.5vw color-mix(in srgb, var(--red) 55%, transparent); }
}
.gd-crunch-label {
  position: absolute;
  top: 4cqh;
  left: 3cqw;
  padding: 0.25em 0.7em;
  border-radius: 999px;
  background: var(--red);
  color: #fff;
  font-size: calc(min(4.5cqh, 2.4cqw) * var(--t));
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* "Show sample games": so nobody takes a made-up score for a real one */
.gd-game { position: relative; }
.gd-sample {
  position: absolute;
  top: 4cqh;
  right: 3cqw;
  padding: 0.25em 0.7em;
  border-radius: 999px;
  background: var(--orange);
  color: #1c1c1e;
  font-size: calc(min(4.5cqh, 2.4cqw) * var(--t));
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.gd-empty {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
}

/* A widget outside its scheduled times */
.widget.widget-off { visibility: hidden; }

/* In the editor's preview, a widget that's switched off is faded */
.editing .widget-switched-off { opacity: 0.3; }

/* ---------- Reduce motion ---------- */
/* If the device asks for less motion: no slow zoom on photos, no pulsing,
   and quick fades instead of slow ones */
@media (prefers-reduced-motion: reduce) {
  .ken-burns,
  .marquee-text,
  .alert-scroll,
  [class*="pulse"],
  .sp-dot,
  .gd-dot,
  .gd-crunch { animation: none !important; }
  .screen,
  .photo-layer,
  .np-slide,
  .news-slide,
  .news-slide-text { transition-duration: 0.3s !important; }
}

/* ---------- Welcome (before setup) ---------- */
.welcome {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2vh;
  padding: 6vw;
  text-align: center;
  background:
    radial-gradient(ellipse 70% 60% at 15% 20%, #2B3F8C 0%, transparent 60%),
    radial-gradient(ellipse 60% 70% at 85% 85%, #6A2C70 0%, transparent 60%),
    #0B0D1A;
}
.welcome-time { font-size: 2.2vw; font-weight: 300; color: var(--label-2); }
.welcome h1 { font-size: 4.6vw; font-weight: 700; letter-spacing: -0.02em; }
.welcome-lead { font-size: 2vw; color: var(--label-2); }
.welcome-url {
  margin-top: 1vh;
  padding: 1.6vh 3vw;
  border-radius: 2vw;
  background: rgba(255, 255, 255, 0.1);
  font-size: 4.2vw;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.welcome-alt { font-size: 1.7vw; color: var(--label-2); }
.welcome-note { margin-top: 3vh; font-size: 1.5vw; color: var(--label-2); }

.welcome-ways { display: flex; align-items: center; justify-content: center; gap: 4vw; margin-top: 2vh; }
.welcome-way { display: flex; flex-direction: column; align-items: center; gap: 1.6vh; }
.welcome-qr {
  width: 15vw;
  padding: 1.1vw;
  border-radius: 1.4vw;
  background: #fff;   /* dark on light: what phone cameras read best */
}
.welcome-qr svg { display: block; width: 100%; height: auto; }
.welcome-or { font-size: 1.8vw; color: var(--label-2); }

/* ---------- Holiday decorations (decorations.js) ----------
   Over the screens but under the "Offline" badge and night mode. They
   only move (transforms), so the Pi's graphics chip does the work. */
.decor {
  position: fixed;
  inset: 0;
  z-index: 800;
  overflow: hidden;
  pointer-events: none;
}
.decor svg { display: block; width: 100%; height: auto; overflow: visible; }

/* Ghosts drift slowly across, bobbing, see-through so text still reads */
.ghost {
  position: absolute;
  left: 0;
  width: var(--size);
  opacity: 0.32;
  animation: ghost-drift linear infinite;
  will-change: transform;
}
.ghost:nth-child(even) { animation-direction: reverse; }
.ghost-bob { animation: ghost-bob 3.5s ease-in-out infinite alternate; }
@keyframes ghost-drift {
  from { transform: translateX(-12vw); }
  to { transform: translateX(112vw); }
}
@keyframes ghost-bob {
  from { transform: translateY(-1.5vh) rotate(-5deg); }
  to { transform: translateY(1.5vh) rotate(5deg); }
}

/* Bats: a few fly over together, then the sky is clear for a while. Dark,
   with an orange glow so they show against the dark backgrounds. */
.bat {
  position: absolute;
  left: 0;
  width: var(--size);
  fill: #1A1022;
  filter: drop-shadow(0 0 0.35vw rgba(255, 140, 40, 0.75));
  transform: translateX(-10vw);
  animation: bat-fly linear infinite;
  will-change: transform;
}
.bat-wing {
  transform-origin: 60px 30px;
  animation: bat-flap 0.18s ease-in-out infinite alternate;
}
@keyframes bat-fly {
  0% { transform: translate(-10vw, 0); }
  10% { transform: translate(45vw, 8vh); }
  22%, 100% { transform: translate(112vw, -14vh); }
}
@keyframes bat-flap {
  to { transform: scaleY(0.25); }
}
.fx-light .bat { filter: none; fill: #3A2448; }

/* Falling (leaves, shamrocks, confetti) or rising (hearts), swaying as they go */
.fall {
  position: absolute;
  top: 0;
  width: var(--size);
  animation: fall linear infinite;
  will-change: transform;
}
.fall.rise { animation-name: rise; }
@keyframes fall {
  from { transform: translateY(-12vh); }
  to { transform: translateY(108vh); }
}
@keyframes rise {
  from { transform: translateY(108vh); }
  to { transform: translateY(-12vh); }
}
.flutter { animation: flutter ease-in-out infinite alternate; }
@keyframes flutter {
  from { transform: translateX(-2vw) rotate(-30deg); }
  to { transform: translateX(2vw) rotate(30deg); }
}
.tumble { animation: tumble linear infinite; }
@keyframes tumble {
  to { transform: rotate3d(1, 0.6, 0.3, 360deg); }
}
.confetti {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1.8;
  border-radius: 1px;
}

/* Snow: dots drifting down and sideways (--drift) */
.flake {
  position: absolute;
  top: 0;
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  background: #fff;
  animation: snowfall linear infinite;
  will-change: transform;
}
@keyframes snowfall {
  from { transform: translate(0, -3vh); }
  to { transform: translate(var(--drift), 103vh); }
}

/* Fireworks: each burst grows from a point, fades, and drifts down a little.
   The sparks are drawn once; only the burst moves. */
.burst {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
  animation: burst ease-out infinite;
  will-change: transform, opacity;
}
.burst i {
  position: absolute;
  background: var(--c);
  box-shadow: 0 0 0.6vw var(--c);
}
.burst .streak {
  left: -0.15vw;
  top: -1vw;
  width: 0.3vw;
  height: 2vw;
  border-radius: 0.15vw;
}
.burst .dot {
  left: -0.2vw;
  top: -0.2vw;
  width: 0.4vw;
  height: 0.4vw;
  border-radius: 50%;
}
@keyframes burst {
  0% { transform: scale(0.05); opacity: 0; }
  3% { opacity: 1; }
  25% { transform: scale(var(--size)); opacity: 0.95; }
  40%, 100% { transform: scale(calc(var(--size) * 1.1)) translateY(3vh); opacity: 0; }
}
.fx-light .burst i { box-shadow: none; }

@media (prefers-reduced-motion: reduce) {
  .decor { display: none; }
}

/* ---------- Light effects (System window > TV picture) ----------
   For a TV or Pi that isn't smooth: no frosted-glass blur, the costliest
   effect. Cards over photos are already dark enough to read without it. */
.fx-light *,
.fx-light *::before {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}
.fx-light .widget-plain.over-photo::before {
  filter: none;
  background: radial-gradient(closest-side, rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0.35) 70%, transparent);
}

/* The frame-rate counter */
.fps-counter {
  position: fixed;
  right: 1vw;
  bottom: 1vh;
  z-index: 9999;
  padding: 4px 10px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.7);
  color: #30D158;
  font: 600 18px/1.4 monospace;
  pointer-events: none;
}
