/* TV: cornice scura, celle chiare. Nomi arancioni, titoli neri, orari azzurri.
   Lo spostamento a scatti riduce il burn-in senza sfocare il testo. */
:root {
  --ink: #161616;
  --orange: #e06500;
  --azure: #0e8ec4;
  --muted: #5c6b7a;
  --absent: #6d7580;
  --line: #d5dde6;
  --client: #161616;
  --cell: #fff;
  --card: #fff;
  --stage: #e7eef4;
  --sat: 0.72fr;
  font-family: Inter, "Segoe UI", Roboto, "Liberation Sans", "Noto Sans", "DejaVu Sans", sans-serif;
}

body.sat-equal { --sat: 1fr; }

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: #121a22;
  color: #f4f7fb;
}

body {
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

.ambient {
  position: fixed;
  left: -8%;
  top: -12%;
  width: 116%;
  height: 124%;
  background:
    radial-gradient(ellipse at 10% 0%, rgba(240, 194, 122, 0.14), transparent 42%),
    radial-gradient(ellipse at 100% 100%, rgba(20, 90, 120, 0.2), transparent 46%);
  animation: drift 140s ease-in-out infinite alternate;
  z-index: 0;
}

.shift {
  position: relative;
  z-index: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  animation: nudge 240s step-end infinite;
}

@keyframes drift {
  from { transform: translate3d(0, 0, 0); }
  to { transform: translate3d(-2%, 1.4%, 0); }
}

@keyframes nudge {
  0% { transform: translate(0, 0); }
  25% { transform: translate(1px, 0); }
  50% { transform: translate(1px, 1px); }
  75% { transform: translate(0, 1px); }
  100% { transform: translate(0, 0); }
}

@media (prefers-reduced-motion: reduce) {
  .ambient, .shift { animation: none; }
}

.top {
  height: 108px;
  flex: none;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 28px 0 22px;
}

.brand { display: flex; align-items: center; gap: 14px; min-width: 0; flex: none; }

.logo {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  background: #e8b86d;
  color: #1a1308;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 24px;
  overflow: hidden;
  flex: none;
}

.logo img { width: 100%; height: 100%; object-fit: cover; display: block; }

.eyebrow {
  margin: 0;
  color: #f0c27a;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1.05;
  letter-spacing: -0.03em;
  font-weight: 700;
}

.sub { margin: 2px 0 0; color: #d5e0ea; font-size: 15px; }

.range {
  flex: 1;
  min-width: 0;
  color: #d5e0ea;
  font-size: 18px;
  font-weight: 600;
  text-align: center;
}

.now { text-align: right; flex: none; }

.weekday {
  margin: 0;
  color: #f0c27a;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.date { margin: 0; font-size: 22px; font-weight: 650; }
.clock {
  margin: 0;
  font-size: 40px;
  line-height: 1;
  font-weight: 700;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}
.updated { margin: 2px 0 0; color: #d5e0ea; font-size: 13px; font-variant-numeric: tabular-nums; }

body.theme-dark {
  --client: #f4f7fb;
  --cell: #1b2632;
  --card: #243140;
  --stage: #101820;
  --line: #314152;
  --absent: #a8b3bf;
  --azure: #5ec8f5;
  --muted: #b7c3d0;
  --orange: #ffb15a;
}
body.theme-dark .dow { color: #d5e0ea; }
body.theme-dark .cell.is-past { background: #151d27; }
body.theme-dark .cell.is-today { background: #2a2418; }
body.theme-dark .cell.is-past .card { background: #1a2430; }
body.theme-dark .chip { background: rgba(255, 177, 90, 0.14); color: #ffe7d0; border-color: #ffb15a; }
body.theme-dark .status-dot { box-shadow: 0 0 0 2px #1b2632; }
body.theme-dark .status-dot.is-no { box-shadow: 0 0 0 2px #1b2632, 0 0 0 3.5px #ffd7ad; }
body.theme-dark .type-tag { background: #2c3c4c; color: #d5e0ea; }
body.theme-dark .weather { color: #d5e0ea; }
body.theme-dark .more { color: #f0c27a; }

.stage {
  flex: 1;
  min-height: 0;
  margin: 0 14px 14px;
  background: var(--stage);
  border-radius: 16px;
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
  color: var(--client);
}

.dows, .row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr 1fr var(--sat);
  gap: 8px;
}

.dows { flex: none; margin-bottom: 6px; }

.dow {
  color: #3e4c5a;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding-left: 4px;
}

.dow.is-sat { color: #8a5a12; }

.weeks {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-rows: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.row { min-height: 0; }

.cell {
  background: var(--cell);
  border: 1px solid var(--line);
  border-radius: 12px;
  min-width: 0;
  min-height: 0;
  padding: 5px 7px 4px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.cell.is-past { background: #e6ebf0; }
.cell.is-past .cell-jobs { opacity: 0.42; }
.cell.is-today {
  background: #fffdf6;
  box-shadow: inset 0 0 0 3px #e2a31a;
}

.cell-top {
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex: none;
  margin-bottom: 4px;
}

.num {
  font-size: 20px;
  font-weight: 700;
  color: var(--client);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.cell.is-today .num { color: #8a5a00; }
.mon { font-size: 13px; font-weight: 700; color: #5c6b7a; text-transform: lowercase; }

.cell-jobs { flex: 1; min-height: 0; overflow: hidden; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 2px 6px 2px;
  margin-bottom: 3px;
}

.cell.is-past .card { background: #f4f6f8; }

.line1, .line2 {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

.when {
  color: var(--azure);
  font-weight: 700;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  margin-right: 6px;
}

.title {
  color: var(--client);
  font-weight: 700;
  font-size: 15px;
}

.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; border-radius: 999px;
  background: rgba(224, 101, 0, 0.12); color: #6d2e00; border: 1.5px solid #e06500;
  font-weight: 700; font-size: 14px; padding: 2px 8px 2px 6px; white-space: nowrap;
}
.status-dot {
  width: 9px; height: 9px; border-radius: 50%; flex: none;
  box-shadow: 0 0 0 2px #fff;
}
.status-dot.is-yes { background: #1f9d55; }
.status-dot.is-no { background: #e06500; box-shadow: 0 0 0 2px #fff, 0 0 0 3.5px #6d2e00; }
.types { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 3px; }
.type-tag {
  font-size: 11px; font-weight: 700; color: #3e5163; background: #eef3f7;
  border-radius: 999px; padding: 1px 6px;
}
.none { color: var(--muted); font-size: 13px; }

.more {
  color: #8a5a12;
  font-size: 13px;
  font-weight: 700;
  margin: 0;
}

.absent {
  flex: none;
  margin: 1px 0 0;
  color: var(--absent);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.weather {
  flex: none;
  margin-top: 2px;
  min-height: 18px;
  display: flex;
  align-items: center;
  gap: 6px;
  color: #243140;
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.weather svg { width: 18px; height: 18px; flex: none; display: block; }
.precip { color: #0e8ec4; font-weight: 700; }

.loading { margin: 24px; color: #3e4c5a; font-size: 22px; }

.banner, .noscript {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  z-index: 5;
  background: #4a2323;
  color: #ffe4e4;
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 16px;
}

.agenda { overflow: auto; min-height: 0; }
.week-label {
  position: sticky; top: 0; z-index: 2; margin: 0 0 6px; padding: 8px 4px;
  background: var(--stage); color: var(--client); font-size: 15px;
}
.day-block { background: var(--cell); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px; overflow: hidden; }
.day-block.is-past { opacity: 0.72; }
.day-block.is-today { box-shadow: inset 0 0 0 2px #e2a31a; }
.day-toggle {
  width: 100%; text-align: left; background: transparent; border: 0; color: var(--client);
  font-weight: 700; font-size: 16px; padding: 10px 12px;
}
.day-body { display: none; padding: 0 10px 10px; }
.day-block.is-open .day-body { display: block; }
.day-body .card { margin-bottom: 6px; }

@media (max-width: 760px) {
  body { overflow: auto; }
  .shift { height: auto; min-height: 100%; }
  .top { height: auto; flex-wrap: wrap; padding: 12px 14px; }
  h1 { font-size: 24px; }
  .clock { font-size: 32px; }
  .date { font-size: 16px; }
  .range { flex: 1 1 100%; text-align: left; font-size: 14px; }
  .stage { margin: 0; border-radius: 0; max-height: none; }
  .chip { font-size: 15px; }
}

@media (max-height: 820px) {
  .top { height: 74px; }
  h1 { font-size: 26px; }
  .clock { font-size: 32px; }
  .title { font-size: 14px; }
  .when, .who { font-size: 13px; }
}
