/* v3 widgets: e-ink paper, grayscale, minimal typographic.
   Each widget is a query container; type scales to the widget's own width (cqi),
   so it looks right at any device size (hero, lineup, editor, previews).
   Fonts: Fraunces for the big numerals and italic captions (newspaper date feel),
   Schibsted Grotesk with tabular digits for everything that lines up.
   Both families must stay in FONTS_HREF in backend/app/services/png_generator/renderer.py. */

.v3w {
  width: 100%; height: 100%;
  background: var(--paper);
  color: var(--paper-ink);
  overflow: hidden;
  font-family: var(--font-ui);
  font-variant-numeric: tabular-nums;
  container-type: size;
}
.v3w-body {
  width: 100%; height: 100%;
  padding: min(7cqi, 9cqh) 8cqi;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.v3w-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 4cqi;
  margin-bottom: min(6cqi, 6cqh); flex-shrink: 0; min-width: 0;
}
.v3w-head-label {
  font-family: var(--font-ui);
  font-size: clamp(9px, 5.8cqi, 13.5px); font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--paper-ink); white-space: nowrap; flex-shrink: 0;
}
.v3w-head-meta {
  font-family: var(--font-ui);
  font-size: clamp(9px, 5.2cqi, 12px); letter-spacing: 0;
  color: #8a8a82; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.v3w-err { font-size: clamp(9px, 6cqi, 14px); line-height: 1.35; color: #8a8a82; overflow: hidden; }

/* Today */
.v3-today { justify-content: center; }
.v3-today-wd { font-family: var(--font-display); font-style: italic; font-weight: 400; font-size: clamp(9px, 9cqi, 17px); letter-spacing: 0; color: #6a6a62; line-height: 1.1; }
.v3-today-day { font-family: var(--font-display); font-weight: 600; font-size: clamp(22px, min(46cqi, 38cqh), 108px); line-height: 0.86; letter-spacing: -0.03em; margin: 1.5cqi 0; font-optical-sizing: auto; }
.v3-today-mo { font-family: var(--font-ui); font-weight: 500; font-size: clamp(9px, 12cqi, 20px); white-space: nowrap; letter-spacing: -0.005em; color: #4a4a44; }

/* Calendar */
.v3-cal { display: grid; grid-template-columns: repeat(7,1fr); gap: 1px 2px; flex: 1; min-height: 0; align-content: stretch; }
.v3-cal-dow { font-family: var(--font-ui); font-weight: 500; font-size: clamp(7px, min(5cqi, 4.5cqh), 11px); text-align: center; color: #a8a8a0; align-self: end; padding-bottom: min(3px, 1cqh); }
/* Rows share the remaining height (1fr each), so the whole month always fits the tile; digits scale with the smaller of width/height. */
.v3-cal-cell { font-size: clamp(7px, min(7cqi, 5.6cqh), 15px); font-weight: 500; display: flex; align-items: center; justify-content: center; min-height: 0; overflow: hidden; color: var(--paper-ink); }
.v3-cal-cell > span { display: flex; align-items: center; justify-content: center; height: min(100%, 2.1em); aspect-ratio: 1; }
.v3-cal-cell.is-today > span { background: var(--paper-ink); color: var(--paper); border-radius: 50%; }

/* Events */
.v3-ev { list-style: none; margin: 0; padding: 0; flex: 1; min-height: 0; overflow: hidden; }
.v3-ev-row { display: grid; grid-template-columns: auto minmax(0,1fr) auto; gap: 3.5cqi; align-items: baseline; padding: 3.2cqi 0; border-bottom: 1px solid rgba(26,26,24,0.08); }
.v3-ev-row:last-child { border-bottom: 0; }
.v3-ev-time { white-space: nowrap; font-family: var(--font-ui); font-size: clamp(9px, 5.8cqi, 13px); font-weight: 700; color: var(--paper-ink); }
.v3-ev-title { font-size: clamp(10px, 7cqi, 16px); font-weight: 500; line-height: 1.2; letter-spacing: -0.005em; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.v3-ev-day { font-size: clamp(8px, 5.2cqi, 12px); font-family: var(--font-display); font-style: italic; color: #8a8a82; text-transform: none; letter-spacing: 0; white-space: nowrap; }

/* Weather */
.v3-we-top { display: flex; align-items: center; gap: 5cqi; min-width: 0; flex-shrink: 0; }
.v3-we-meta { min-width: 0; overflow: hidden; }
.v3-we-unit { font-size: 0.34em; font-weight: 500; letter-spacing: 0; vertical-align: top; margin-left: 0.04em; color: #8a8a82; font-family: var(--font-ui); }
.v3-we-temp { font-family: var(--font-display); font-weight: 500; font-size: clamp(20px, min(26cqi, 30cqh), 78px); line-height: 0.9; letter-spacing: -0.03em; font-optical-sizing: auto; }
.v3-we-desc { font-size: clamp(10px, 7cqi, 16px); font-weight: 500; line-height: 1.2; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.v3-we-hl { white-space: nowrap; font-size: clamp(8px, 5.4cqi, 13px); color: #8a8a82; margin-top: 2px; letter-spacing: 0.01em; }
.v3-we-chart { display: flex; align-items: flex-end; justify-content: space-between; gap: 2.5cqi; flex: 1; margin-top: min(5cqi, 4cqh); padding-top: min(4cqi, 4cqh); border-top: 1px solid rgba(26,26,24,0.08); }
.v3-we-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.v3-we-bar { width: 60%; max-width: 14px; background: var(--paper-ink); border-radius: 3px 3px 0 0; min-height: 4px; }
.v3-we-lab { font-size: clamp(7px, 4.4cqi, 10px); color: #9a9a92; margin-top: 3px; }

/* Todo */
.v3-todo { list-style: none; margin: 0; padding: 0; flex: 1; min-height: 0; overflow: hidden; }
.v3-todo-row { display: flex; align-items: center; gap: 4.5cqi; padding: 2.6cqi 0; font-size: clamp(10px, 7cqi, 16px); font-weight: 500; letter-spacing: -0.005em; min-width: 0; }
.v3-todo-text { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.v3-todo-box { width: 1.05em; height: 1.05em; border: 1.5px solid var(--paper-ink); border-radius: 4px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.v3-todo-row.is-done .v3-todo-box { background: var(--paper-ink); color: var(--paper); }
.v3-todo-row.is-done .v3-todo-text { color: #a8a8a0; text-decoration: line-through; }

/* Countdown */
.v3-cd { justify-content: center; text-align: center; }
.v3-cd-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-family: var(--font-display); font-style: italic; font-weight: 400; font-size: clamp(9px, 9cqi, 15px); letter-spacing: 0; text-transform: none; color: #6a6a62; }
.v3-cd-num { font-family: var(--font-display); font-weight: 600; font-size: clamp(24px, min(48cqi, 36cqh), 112px); line-height: 0.86; letter-spacing: -0.03em; margin: 2cqi 0; font-optical-sizing: auto; }
.v3-cd-unit { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-family: var(--font-ui); font-weight: 500; font-size: clamp(10px, 9.5cqi, 15px); color: #4a4a44; letter-spacing: -0.005em; }

/* Currency */
.v3-fx { list-style: none; margin: 0; padding: 0; flex: 1; min-height: 0; overflow: hidden; }
.v3-fx-row { display: grid; grid-template-columns: minmax(0,1fr) auto auto; gap: 5cqi; align-items: baseline; padding: 3.2cqi 0; border-bottom: 1px solid rgba(26,26,24,0.08); }
.v3-fx-row:last-child { border-bottom: 0; }
.v3-fx-pair { font-size: clamp(9px, 5.8cqi, 12px); font-weight: 500; color: #6a6a62; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.v3-fx-val { font-family: var(--font-ui); font-weight: 700; font-size: clamp(12px, 8.5cqi, 18px); letter-spacing: -0.005em; }
.v3-fx-d { font-size: clamp(9px, 6cqi, 13px); color: var(--paper-ink); width: 12px; text-align: center; }

/* Timetable */
.v3w-head-label.v3-tt-title { flex-shrink: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.v3-tt-sum { display: flex; justify-content: space-between; gap: 4cqi; flex-shrink: 0; white-space: nowrap; font-size: clamp(8px, 5.2cqi, 12px); color: #8a8a82; padding-bottom: min(3cqi, 3cqh); border-bottom: 1px solid rgba(26,26,24,0.08); }
.v3-tt-sum-range { font-weight: 500; }
.v3-tt-sum-count { font-family: var(--font-display); font-style: italic; letter-spacing: 0; }
.v3-tt { list-style: none; margin: 0; padding: 0; flex: 1; min-height: 0; overflow: hidden; }
.v3-tt-row { display: grid; grid-template-columns: auto auto minmax(0,1fr); gap: 3cqi; align-items: baseline; padding: 3.2cqi 0; border-bottom: 1px solid rgba(26,26,24,0.08); color: var(--paper-ink); }
.v3-tt-row:last-child { border-bottom: 0; }
/* Marker column: filled square = now, hollow = next, empty for the rest so times stay aligned. */
.v3-tt-mark { display: inline-block; width: 0.5em; height: 0.5em; border: 1.5px solid transparent; font-size: clamp(9px, 5.8cqi, 13px); align-self: center; }
.v3-tt-now .v3-tt-mark { border-color: var(--paper-ink); background: var(--paper-ink); }
.v3-tt-next .v3-tt-mark { border-color: var(--paper-ink); }
.v3-tt-time { white-space: nowrap; font-family: var(--font-ui); font-size: clamp(9px, 5.8cqi, 13px); font-weight: 500; font-variant-numeric: tabular-nums; }
.v3-tt-label { font-size: clamp(10px, 7cqi, 16px); font-weight: 500; line-height: 1.2; letter-spacing: -0.005em; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.v3-tt-now .v3-tt-time, .v3-tt-now .v3-tt-label { font-weight: 700; }
.v3-tt-past { color: #a8a8a0; }
/* Narrow tiles and the 130 px palette preview: drop the summary line and the end times, keep title + rows. */
@container (max-width: 180px) {
  .v3-tt-sum { display: none; }
  .v3-tt-end { display: none; }
  .v3-tt-title + .v3w-head-meta { display: none; }
}

/* Text / quote */
.v3-text { justify-content: center; }
.v3-text-body { overflow: hidden; overflow-wrap: anywhere; font-family: var(--font-display); font-weight: 400; font-size: clamp(13px, 6.8cqi, 25px); line-height: 1.22; letter-spacing: -0.01em; font-optical-sizing: auto; }
.v3-text-attr { font-size: clamp(8px, 4.8cqi, 12px); font-family: var(--font-ui); color: #8a8a82; margin-top: 5cqi; letter-spacing: 0.01em; }

/* ---- Canvas of tiles ---- */
.v3-canvas { position: absolute; inset: 0; }
.v3-board { background: var(--paper); }
.v3-tile { position: absolute; overflow: hidden; }
.v3-canvas.has-gap .v3-tile > .v3w { border: 1px solid rgba(26,26,24,0.12); border-radius: 7px; }
.v3-canvas.has-gap .v3-tile { transform: scale(0.985); }
.v3w-hint { font-size: clamp(9px, 6cqi, 14px); line-height: 1.35; color: #9a9a92; font-style: italic; overflow: hidden; }
.v3w-skel { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.v3w-skel span { display: block; height: 10px; border-radius: 4px; background: rgba(26,26,24,0.07); }
.v3w-skel span:nth-child(2) { width: 78%; }
.v3w-skel span:nth-child(3) { width: 52%; }
