:root {
  --fg: #fff;
  --fg-dim: rgba(255, 255, 255, .72);
  --fg-faint: rgba(255, 255, 255, .45);
  --glass: rgba(16, 18, 28, .38);
  --glass-edge: rgba(255, 255, 255, .14);
  --accent: #7fe3ff;
  --rec: #ff4d5e;
  --ok: #4dffa6;
  --gutter: clamp(18px, 3.2vw, 56px);
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; }
[hidden] { display: none !important; }

html, body {
  height: 100%;
  background: #05060a;
  color: var(--fg);
  font-family: 'Outfit', system-ui, sans-serif;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

body { transition: filter 3s ease; }
body.night { filter: brightness(.42) saturate(.7); }
body.idle, body.idle * { cursor: none !important; }

/* ---------- Background slideshow ---------- */
#bg, #shade { position: fixed; inset: 0; }
#bg .layer {
  position: absolute;
  inset: -4%;
  background: #05060a center / cover no-repeat;
  opacity: 0;
  transition: opacity 2.4s ease;
  will-change: transform, opacity;
}
#bg .layer.show { opacity: 1; }
#bg .layer.kb-a { animation: kbA 60s ease-in-out forwards; }
#bg .layer.kb-b { animation: kbB 60s ease-in-out forwards; }
#bg .layer.kb-c { animation: kbC 60s ease-in-out forwards; }
@keyframes kbA { from { transform: scale(1.02) translate(0, 0); } to { transform: scale(1.12) translate(-2%, -1%); } }
@keyframes kbB { from { transform: scale(1.12) translate(2%, 1%); } to { transform: scale(1.02) translate(0, 0); } }
@keyframes kbC { from { transform: scale(1.05) translate(-1.5%, 1%); } to { transform: scale(1.14) translate(1.5%, -1%); } }

#shade {
  background:
    radial-gradient(ellipse 80% 70% at 10% 95%, rgba(0,0,0,.62), transparent 70%),
    linear-gradient(to bottom, rgba(0,0,0,.45), transparent 22%, transparent 55%, rgba(0,0,0,.6));
  pointer-events: none;
}

.glass {
  background: var(--glass);
  border: 1px solid var(--glass-edge);
  backdrop-filter: blur(22px) saturate(1.4);
  -webkit-backdrop-filter: blur(22px) saturate(1.4);
  border-radius: 22px;
  box-shadow: 0 10px 40px rgba(0,0,0,.25), inset 0 1px 0 rgba(255,255,255,.08);
}

/* ---------- Top bar ---------- */
#top {
  position: fixed;
  top: var(--gutter); left: var(--gutter); right: var(--gutter);
  display: flex; justify-content: space-between; align-items: center;
  z-index: 5;
}
.dots { display: flex; align-items: center; gap: 12px; height: 40px; }
.sdot {
  width: 12px; height: 12px; padding: 0; border: 0; border-radius: 50%;
  background: rgba(255,255,255,.4);
  box-shadow: 0 0 0 3px rgba(0,0,0,.28); /* keeps dots visible on bright photos */
}
button.sdot { cursor: pointer; }
.sdot.cam.live { background: var(--ok); box-shadow: 0 0 0 3px rgba(0,0,0,.28), 0 0 10px var(--ok); }
.sdot.cam.err { background: #ffb84d; }
.sdot.watch { background: var(--accent); }
.sdot.mic { background: #a98bff; }

.icon-btn {
  width: 40px; height: 40px; display: grid; place-items: center;
  color: var(--fg-dim); background: rgba(0,0,0,.25);
  border: 1px solid rgba(255,255,255,.12); border-radius: 50%;
  cursor: pointer; transition: opacity .4s;
}
body.idle .icon-btn { opacity: 0; }

/* ---------- Clock ---------- */
#hero {
  position: fixed;
  left: var(--gutter);
  bottom: calc(var(--gutter) + clamp(110px, 17vh, 170px));
  z-index: 2;
  text-shadow: 0 4px 40px rgba(0,0,0,.35);
}
#greeting {
  font-weight: 300; font-size: clamp(18px, 2.3vw, 34px);
  color: var(--fg-dim); letter-spacing: .02em;
  margin-bottom: -.2em; padding-left: .3vw;
}
#clock {
  font-weight: 150;
  font-size: clamp(96px, 19vw, 300px);
  line-height: .95;
  letter-spacing: -.035em;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  display: flex; align-items: flex-start;
}
#clock .colon { opacity: .75; margin: 0 .02em; transform: translateY(-.06em); animation: colon 2s steps(1) infinite; }
@keyframes colon { 50% { opacity: .25; } }
#ampm { font-size: .2em; font-weight: 300; letter-spacing: .08em; margin: .45em 0 0 .3em; color: var(--fg-dim); }
#date {
  font-weight: 300; font-size: clamp(20px, 2.8vw, 44px);
  color: var(--fg); letter-spacing: .01em; padding-left: .4vw;
}
#secbar {
  margin: 18px 0 0 .5vw; width: clamp(140px, 22vw, 360px); height: 2px;
  background: rgba(255,255,255,.15); border-radius: 2px; overflow: hidden;
}
#secbar span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), #fff); border-radius: 2px; }

/* ---------- Weather ---------- */
#weather {
  position: fixed;
  top: calc(var(--gutter) + 58px);
  right: var(--gutter);
  width: clamp(270px, 27vw, 420px);
  padding: clamp(16px, 1.6vw, 26px);
  z-index: 3;
  animation: rise .9s ease both;
}
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
.wx-now { display: flex; align-items: center; gap: 6px; margin: -10px 0 0 -12px; }
#wxIcon { width: clamp(96px, 9vw, 150px); height: auto; filter: drop-shadow(0 6px 20px rgba(0,0,0,.25)); }
.wx-temp { font-weight: 200; font-size: clamp(54px, 5.6vw, 92px); line-height: 1; letter-spacing: -.03em; }
.wx-temp sup { font-size: .45em; vertical-align: top; position: relative; top: .25em; color: var(--fg-dim); }
.wx-cond { font-size: clamp(15px, 1.25vw, 20px); color: var(--fg-dim); margin-top: 2px; }
.wx-place { font-size: 13px; letter-spacing: .14em; text-transform: uppercase; color: var(--fg-faint); margin: 2px 0 12px; }
.wx-meta { display: flex; justify-content: space-between; gap: 6px; font-size: clamp(12px, 1vw, 15px); color: var(--fg-dim); padding-bottom: 14px; border-bottom: 1px solid rgba(255,255,255,.1); }
.wx-meta span { display: inline-flex; align-items: center; gap: 2px; white-space: nowrap; }
.wx-meta img { width: 26px; height: 26px; margin: -6px -2px -6px -6px; }
.wx-meta b { font-weight: 500; color: var(--fg); }
.wx-hours { display: grid; grid-template-columns: repeat(6, 1fr); padding: 12px 0; border-bottom: 1px solid rgba(255,255,255,.1); text-align: center; }
.wx-hours div { display: flex; flex-direction: column; align-items: center; font-size: clamp(11px, .95vw, 14px); color: var(--fg-dim); }
.wx-hours img { width: clamp(34px, 3.2vw, 50px); margin: -2px 0; }
.wx-hours b { color: var(--fg); font-weight: 500; font-size: 1.1em; }
.wx-hours .pp { font-size: .82em; color: var(--accent); min-height: 1.2em; }
.wx-days { padding-top: 8px; }
.wx-day { display: grid; grid-template-columns: 3.4em 34px 1fr; align-items: center; gap: 8px; font-size: clamp(13px, 1.05vw, 16px); padding: 1px 0; }
.wx-day .dn { color: var(--fg-dim); }
.wx-day img { width: 34px; }
.range { display: grid; grid-template-columns: 2.2em 1fr 2.2em; align-items: center; gap: 8px; }
.range .lo { color: var(--fg-faint); text-align: right; }
.range .bar { height: 4px; border-radius: 4px; background: rgba(255,255,255,.12); position: relative; }
.range .bar i { position: absolute; top: 0; bottom: 0; border-radius: 4px; background: linear-gradient(90deg, #7fd0ff, #ffd36e, #ff8a5c); }

/* ---------- Bottom: headlines ---------- */
#bottom {
  position: fixed; left: var(--gutter); right: var(--gutter); bottom: var(--gutter);
  z-index: 3;
}
#caption {
  text-align: right; font-size: 12px; color: var(--fg-faint);
  margin-bottom: 10px; letter-spacing: .02em;
  text-shadow: 0 1px 6px rgba(0,0,0,.6);
  transition: opacity 1s;
}
#caption b { color: var(--fg-dim); font-weight: 500; }
#news {
  display: grid; grid-template-columns: auto 1fr; align-items: center;
  gap: 18px; padding: 16px 22px 18px; position: relative; overflow: hidden;
  border-radius: 18px;
}
.news-src {
  font-size: 11px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase;
  color: #05060a; background: var(--accent); padding: 5px 9px; border-radius: 6px; white-space: nowrap;
}
.news-title {
  font-size: clamp(16px, 1.75vw, 28px); font-weight: 400; line-height: 1.25;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: opacity .6s ease, transform .6s ease;
}
.news-title.out { opacity: 0; transform: translateY(8px); }
.news-title small { color: var(--fg-faint); font-size: .62em; margin-left: .7em; letter-spacing: .03em; }
.news-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 2px; }
.news-bar span { display: block; height: 100%; width: 0; background: rgba(255,255,255,.35); }

/* ---------- Camera preview ---------- */
#preview {
  position: fixed; z-index: 6;
  top: calc(var(--gutter) + 58px); left: var(--gutter);
  width: clamp(220px, 22vw, 340px); padding: 8px; border-radius: 16px;
}
#preview video { width: 100%; border-radius: 10px; display: block; transform: scaleX(-1); background: #000; }
.meter { height: 6px; margin-top: 8px; border-radius: 6px; background: rgba(255,255,255,.12); position: relative; overflow: hidden; }
.meter span { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: var(--ok); transition: width .2s; }
.meter span.hot { background: var(--rec); }
.meter i { position: absolute; top: -2px; bottom: -2px; width: 2px; background: #fff; }

/* ---------- Login ---------- */
.login-gate {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center;
  background: radial-gradient(circle at 30% 20%, #1d2a4a, #05060a 70%);
}
.login-card {
  width: min(360px, calc(100vw - 32px)); padding: 36px 30px; text-align: center;
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.12); border-radius: 24px;
  display: flex; flex-direction: column; gap: 12px;
}
.login-card h1 { font-weight: 300; font-size: 34px; letter-spacing: .02em; }
.login-card p { color: var(--fg-dim); margin-top: -6px; }
.login-card input, .login-card button {
  font: inherit; font-size: 17px; padding: 14px 16px; border-radius: 14px; border: 1px solid rgba(255,255,255,.18);
  background: rgba(0,0,0,.3); color: #fff; outline: none;
}
.login-card input:focus { border-color: var(--accent); }
.login-card button { background: var(--accent); color: #05060a; font-weight: 600; border: 0; cursor: pointer; }
.login-card button:disabled { opacity: .6; }
.login-err { color: #ff8a95; min-height: 1.2em; font-size: 14px; }
.login-logo { width: 64px; height: 64px; margin: 0 auto 4px; border-radius: 50%; background: conic-gradient(from 200deg, #7fe3ff, #a98bff, #ff7fb5, #7fe3ff); display: grid; place-items: center; }
.login-logo span { width: 44px; height: 44px; border-radius: 50%; background: #0b0f1c; box-shadow: inset 0 0 0 3px rgba(127,227,255,.35); }

/* Short / narrow screens: stack the weather card under the clock area */
@media (max-height: 640px) {
  .wx-days { display: none; }
}
@media (max-width: 820px) {
  #weather { top: auto; bottom: calc(var(--gutter) + 120px); width: calc(100vw - 2 * var(--gutter)); }
  #hero { bottom: auto; top: calc(var(--gutter) + 60px); }
  .wx-days { display: none; }
}
