/* Dormir 2.0 pages: the Dashboard and Rooms. Light comes from the rooms themselves:
   tiles bleed the colours their zones are showing, and the home ribbon lays every zone
   in the home side by side. */

.page { padding: 36px 40px 72px; }
.page > * { max-width: 1240px; margin-inline: auto; }

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.page-head h1 { font-size: 2rem; font-weight: 640; letter-spacing: -0.035em; outline: none; }
.page-sub { margin: 6px 0 0; color: var(--muted); font-size: 0.92rem; font-variant-numeric: tabular-nums; }
.page-actions { display: flex; gap: 8px; }

.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.section-head h2 { margin: 0; font-size: 1rem; font-weight: 620; letter-spacing: -0.01em; }

/* ---------- The home ribbon: every zone, in its colour ---------- */
.home-light { position: relative; margin: 0 auto 30px; }
.home-ribbon, .home-bleed { display: block; width: 100%; height: 14px; border-radius: 999px; }
.home-ribbon { position: relative; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12); }
.home-bleed { position: absolute; top: 2px; left: 4%; width: 92%; height: 34px; filter: blur(22px) saturate(1.3); opacity: 0.55; pointer-events: none; }
.home-light figcaption { margin-top: 8px; }
.ribbon-legend { display: flex; gap: 2px; color: var(--faint); font-size: 0.72rem; }
.ribbon-legend span { min-width: 0; overflow: hidden; padding-left: 2px; white-space: nowrap; text-overflow: ellipsis; border-left: 1px solid var(--line); }

/* ---------- Layout ---------- */
.dash-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; align-items: start; gap: 24px; }
.dash-rooms, .dash-side { display: grid; gap: 24px; min-width: 0; }
.dash-card {
  padding: 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.025), transparent 40%), var(--card);
  border: 1px solid var(--edge);
  border-radius: var(--r-lg);
  box-shadow: var(--sheen);
}

/* ---------- Room tiles ---------- */
.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 18px; }
.tile-grid.large { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 22px; }

.room-tile {
  --a: transparent; --b: transparent; --c: transparent;
  position: relative;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent 30%), var(--card);
  border: 1px solid var(--edge);
  border-radius: var(--r-lg);
  box-shadow: var(--sheen), 0 20px 40px -28px rgba(0, 0, 0, 0.9);
  transition: border-color var(--med), transform var(--med) var(--ease);
}
.room-tile.current { border-color: var(--edge-strong); }
/* The room's own light, bleeding out from behind its tile */
.tile-glow {
  position: absolute;
  z-index: -1;
  inset: -6% 4% 30%;
  background:
    radial-gradient(60% 70% at 18% 30%, var(--a), transparent 70%),
    radial-gradient(60% 70% at 50% 20%, var(--b), transparent 70%),
    radial-gradient(60% 70% at 82% 30%, var(--c), transparent 70%);
  filter: blur(34px);
  opacity: 0.5;
  transition: opacity var(--slow);
  pointer-events: none;
}
.room-tile.off .tile-glow { opacity: 0; }

.tile-photo {
  position: relative;
  display: block;
  aspect-ratio: 16 / 9;
  margin: 8px 8px 0;
  padding: 0;
  overflow: hidden;
  background: var(--elevated);
  border: 0;
  border-radius: var(--r-md);
}
.tile-photo img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform var(--slow) var(--ease), filter var(--slow); }
.tile-photo::after { content: ""; position: absolute; inset: 0; border-radius: inherit; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08); pointer-events: none; }
.room-tile.off .tile-photo img { filter: grayscale(0.7) brightness(0.45); }
@media (hover: hover) and (pointer: fine) {
  .room-tile:hover { border-color: var(--edge-strong); transform: translateY(-2px); }
  .room-tile:hover .tile-glow { opacity: 0.7; }
  .tile-photo:hover img { transform: scale(1.03); }
}

.tile-body { display: grid; gap: 2px; padding: 12px 16px 16px; }
.tile-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.tile-head h3 { margin: 0; overflow: hidden; color: var(--text); font-size: 1.05rem; font-weight: 620; letter-spacing: -0.015em; white-space: nowrap; text-overflow: ellipsis; }
.large .tile-head h3 { font-size: 1.2rem; }
.tile-power { min-height: 0; }
.tile-status { margin: 0; overflow: hidden; color: var(--muted); font-size: 0.82rem; white-space: nowrap; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }

.tile-strip { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.tile-zones { display: flex; flex: 1; gap: 2px; height: 8px; min-width: 0; }
.tile-zones i { flex: 1; min-width: 4px; border-radius: 2px; transition: background var(--slow); }
.tile-zones i:first-child { border-radius: 4px 2px 2px 4px; }
.tile-zones i:last-child { border-radius: 2px 4px 4px 2px; }
.tile-source { flex: none; color: var(--faint); font-size: 0.7rem; }
.room-tile .slider { margin-top: 8px; }

.tile-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 10px; margin-top: 8px; }
.tile-meta { margin: 0; color: var(--faint); font-size: 0.72rem; font-variant-numeric: tabular-nums; }
.tile-modes { display: flex; gap: 6px; }
.mode-chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px 2px 8px; color: var(--text); font-size: 0.7rem; font-weight: 560; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; }
.mode-chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--dot, var(--muted)); }
.mode-chip.screen { --dot: var(--cyan); }
.mode-chip.music { --dot: var(--magenta); }

/* ---------- Quick scenes ---------- */
.dash-scenes { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin: 0; padding: 0; list-style: none; }
.dash-scene {
  display: grid;
  gap: 8px;
  width: 100%;
  padding: 6px 6px 10px;
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 560;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  transition: border-color var(--fast), background var(--fast), transform var(--fast) var(--ease);
}
.dash-scene span { padding-inline: 4px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.dash-scene:hover { background: var(--surface-hover); border-color: var(--edge-strong); }
.dash-scene:active { transform: scale(0.98); }
.dash-scene[aria-pressed="true"] { border-color: color-mix(in srgb, var(--violet) 70%, transparent); background: color-mix(in srgb, var(--violet) 12%, transparent); }
.scene-swatch { display: block; height: 40px; background: var(--art); border-radius: 10px; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08); }

/* ---------- Devices ---------- */
.dash-devices { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; }
.dash-device { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 10px; padding: 8px 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); }
.dash-device-text { display: grid; min-width: 0; line-height: 1.3; }
.dash-device-text b { overflow: hidden; font-size: 0.84rem; font-weight: 580; white-space: nowrap; text-overflow: ellipsis; }
.dash-device-text small { overflow: hidden; color: var(--muted); font-size: 0.72rem; white-space: nowrap; text-overflow: ellipsis; }
.state-dot { width: 8px; height: 8px; border-radius: 50%; background: transparent; border: 1.5px solid var(--bad); }
.state-dot[data-status="online"] { background: var(--ok); border-color: var(--ok); }
.state-dot[data-status="connecting"] { border-color: var(--warn); animation: breathe 1.2s ease-in-out infinite; }

/* ---------- The All rooms controls inside the Dashboard ---------- */
.dash-global .sheet-body > .row:first-child { margin-top: 10px; }
.dash-global .sheet-body > .row:first-child > * { flex: 1; }
.dash-global .follow-list { display: grid; gap: 2px; }
.dash-global label.field.row { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; }
.dash-global label.field.row > span { color: var(--muted); }
.dash-global h3 { margin-top: 18px; }

@media (max-width: 1280px) {
  .dash-grid { grid-template-columns: minmax(0, 1fr); }
  .dash-side { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); align-items: start; }
}
@media (max-width: 1100px) {
  .page { padding: 20px 16px 32px; }
  .page-head h1 { font-size: 1.6rem; }
  .tile-grid, .tile-grid.large { grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); }
}
@media (prefers-reduced-motion: reduce) {
  .mode-chip::before, .state-dot[data-status="connecting"] { animation: none; }
  .tile-glow, .tile-zones i { transition: none; }
}
@media (prefers-reduced-transparency: reduce) {
  .tile-glow, .home-bleed { display: none; }
}
