/* ---------- Reset & base ---------- */
* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
  color: #f5f5f5;
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

/* ---------- Rotating background ---------- */
.bg-layer {
  position: fixed;
  inset: 0;
  background-size: cover;
  background-position: var(--bg-position, center);
  opacity: 0;
  transition: opacity 2.5s ease-in-out;
  z-index: 0;
}
.bg-layer.visible { opacity: 1; }
.bg-layer video {
  position: absolute;
  inset: 0;
  width: 100%;
  object-position: var(--bg-position, center);
  height: 100%;
  object-fit: cover;
}

.bg-scrim {
  position: fixed;
  inset: 0;
  z-index: 1;
  background: linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.55) 0%,
    rgba(0, 0, 0, 0.08) 22%,
    rgba(0, 0, 0, 0.05) 55%,
    rgba(0, 0, 0, 0.65) 100%
  );
}

/* ---------- Layout shell ---------- */
#dashboard {
  position: relative;
  z-index: 2;
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.panel { text-shadow: 0 2px 8px rgba(0, 0, 0, 0.7); }

/* ============================================================
 * Top: 7-day calendar grid
 * ============================================================ */
.calendar-grid {
  flex: 0 0 auto;
  display: flex;
  padding: 10px 10px 0 10px;
  gap: 8px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.55), rgba(0,0,0,0.15) 90%, transparent);
}

.calendar-day {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 6px 8px 12px 8px;
}

.calendar-day-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 6px;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
}
.calendar-day-num { font-size: 1.9rem; font-weight: 700; }
.calendar-day-label { font-size: 1.05rem; opacity: 0.85; text-transform: capitalize; }

.calendar-day-events {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.calendar-event {
  border-left: 5px solid #4c8bf5;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 3px;
  padding: 4px 8px;
  font-size: 0.85rem;
  line-height: 1.3;
}
.calendar-event.all-day {
  border-left-color: rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.18);
}
.calendar-event .cal-time { opacity: 0.85; font-size: 0.78rem; }
.calendar-event .cal-title {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.calendar-loading { opacity: 0.6; font-size: 0.9rem; padding: 4px 8px; }

/* ============================================================
 * Middle spacer -- deliberately empty, lets the background photo show
 * ============================================================ */
#middle-spacer {
  flex: 1 1 auto;
  min-height: 0;
}

/* ============================================================
 * Bottom shelf
 * ============================================================ */
#bottom-shelf {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 22px;
  padding: 0 22px 14px 22px;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.75);
}

/* --- Family location list + clock --- */
#left-col {
  flex: 0 0 340px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.family-list-panel {
  height: 230px;
  display: flex;
  align-items: center;
  cursor: pointer;
}
.family-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
}
.family-list-item {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 1.2rem;
}
.family-list-avatar,
.family-list-avatar-fallback {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  flex: none;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.5);
}
.family-list-avatar-fallback {
  background: rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}
.family-list-name { font-weight: 700; flex: 0 0 100px; }
.family-list-state { opacity: 0.75; }
.family-list-state-icon { height: 26px; width: auto; display: block; align-self: center; }
.family-list-empty { opacity: 0.7; }

/* --- Full-screen family map overlay (opened by tapping the list) --- */
.family-map-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
}
.family-map-overlay.hidden { display: none; }
.family-map-overlay .family-map {
  width: 100%;
  height: 100%;
  border-radius: 12px;
  overflow: hidden;
  background: #1b1e26;
}
.family-map-close {
  position: absolute;
  top: 24px;
  right: 32px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
}

#clock-panel { line-height: 1; }
#clock-time {
  font-size: 3.4rem;
  font-weight: 300;
}

/* --- Weather --- */
#weather-panel {
  flex: 0 0 340px;
}
.weather-top {
  display: flex;
  align-items: center;
  gap: 10px;
}
.weather-icon-big { width: 46px; height: 46px; display: inline-flex; }
.weather-icon-big svg { width: 100%; height: 100%; }
#weather-temp { font-size: 3.2rem; font-weight: 300; }

.weather-metrics {
  display: flex;
  gap: 16px;
  margin-top: 6px;
  font-size: 0.95rem;
  opacity: 0.92;
}
.weather-metrics .metric {
  display: flex;
  align-items: center;
  gap: 5px;
}
.weather-metrics svg { width: 16px; height: 16px; flex: none; opacity: 0.85; }

#weather-desc { margin-top: 6px; font-size: 1.05rem; opacity: 0.9; }

.weather-forecast {
  display: flex;
  gap: 20px;
  margin-top: 8px;
  font-size: 1rem;
}
.weather-forecast .day { text-align: center; }
.weather-forecast .day-name { opacity: 0.85; margin-bottom: 2px; }
.weather-forecast .hi { font-weight: 700; }
.weather-forecast .lo { opacity: 0.7; margin-left: 4px; }

#weather-alert-banner {
  margin-top: 8px;
  font-size: 0.95rem;
  color: #ffd54a;
  font-weight: 700;
}

/* --- Lunch cards --- */
#lunch-cards {
  flex: 1 1 auto;
  display: flex;
  gap: 14px;
  min-width: 0;
  height: 165px;
}
#lunch-cards.hidden { display: none; }
.lunch-card {
  flex: 1 1 0;
  min-width: 0;
  border-radius: 10px;
  overflow: hidden;
  position: relative;
  background-size: cover;
  background-position: center;
  background-color: rgba(20, 20, 24, 0.6);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: flex-end;
}
.lunch-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.82) 30%, rgba(0,0,0,0.25) 75%, rgba(0,0,0,0.1));
}
.lunch-card-content {
  position: relative;
  z-index: 1;
  padding: 10px 12px;
  width: 100%;
}
.lunch-card-label {
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  opacity: 0.9;
  margin-bottom: 3px;
}
.lunch-card ul {
  list-style: none;
  font-size: 0.92rem;
  line-height: 1.35;
}
.lunch-card li {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============================================================
 * Ticker row: ScoreStream widget + keep-alive video, same height,
 * side by side (matches the reference layout)
 * ============================================================ */
#ticker-row {
  flex: 0 0 auto;
  display: flex;
  align-items: stretch;
  height: 78px;
}

#scorestream-panel {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: rgba(10, 10, 12, 0.9);
}

.keepalive-video {
  flex: 0 0 220px;
  height: 100%;
}
.keepalive-video iframe { width: 100%; height: 100%; border: 0; display: block; }

/* ============================================================
 * ESPN BottomLine-style ticker
 * ============================================================ */
#espn-ticker {
  flex: 0 0 58px;
  display: flex;
  align-items: stretch;
  background: #000;
  font-weight: 700;
  overflow: hidden;
}
.ticker-label {
  flex: 0 0 auto;
  background: #000;
  color: #fff;
  display: flex;
  align-items: center;
  padding: 0 18px;
}
.espn-logo {
  height: 48px;
  width: auto;
  display: block;
}
.ticker-track-wrap {
  flex: 1;
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  background: #000;
}
.ticker-track {
  white-space: nowrap;
  position: absolute;
  left: 0;
  font-size: 0.85rem;
  color: #fff;
  will-change: transform;
}

/* ---------- Leaflet dark tweaks ---------- */
.leaflet-container { background: #1b1e26 !important; }
.family-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 2px solid #fff;
  object-fit: cover;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
}
.family-avatar-fallback {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: #4c8bf5;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.1rem;
}
