/* Kitchen: dark, big, touch-first. Laid out for the 1920×1080 screen; everything is in rem and
   the root size follows the screen width (20px at 1920), so phones and laptops get a scaled copy. */

@font-face {
  font-family: "Atkinson Next";
  src: url("../fonts/atkinson-next-wght.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}
/* Atkinson's zero has a slash through it, which looks odd on a clock. Digits come from Figtree. */
@font-face {
  font-family: "Kitchen Digits";
  src: url("../fonts/figtree-wght.woff2") format("woff2");
  font-weight: 300 900;
  font-display: swap;
  unicode-range: U+0030-0039;
}

:root {
  --bg: #0b0f14;
  --bg-raise: #131a23;
  --glass: rgba(12, 16, 22, 0.7);
  --line: rgba(255, 255, 255, 0.09);
  --text: #eef1f5;
  --muted: #9ba6b5;
  --faint: #6b7686;
  --accent: #f2b25c;
  --accent-ink: #1d1406;
  --rain: #8cc4ff;
  --danger: #ef7a6d;
  --radius: 1.25rem;
  --nav-h: 6rem;
  color-scheme: dark;
}

html { font-size: clamp(14px, 1.0417vw, 22px); }
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Kitchen Digits", "Atkinson Next", system-ui, sans-serif;
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input { font: inherit; color: inherit; }
a { color: var(--accent); }
h1, h2, h3 { text-wrap: balance; }

/* ---------- Shell: screen above, nav bar below ---------- */

body.shell {
  display: grid;
  grid-template-rows: minmax(0, 1fr) calc(var(--nav-h) + env(safe-area-inset-bottom));
  height: 100dvh;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}
.main { position: relative; overflow: auto; min-height: 0; }

.nav {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
  background: var(--bg-raise);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  color: var(--muted);
  text-decoration: none;
  font-size: 1.35rem;
  font-weight: 650;
  letter-spacing: 0.01em;
  border-top: 0.3rem solid transparent;
  touch-action: manipulation;
}
.nav-btn svg { width: 2.3rem; height: 2.3rem; }
.nav-btn[aria-current="page"] {
  color: var(--accent);
  border-top-color: var(--accent);
  background: rgba(242, 178, 92, 0.07);
}
.nav-btn:active { background: rgba(255, 255, 255, 0.06); }
.nav-btn:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }
.nav-settings { padding: 0 2.4rem; border-left: 1px solid var(--line); }

/* ---------- Home: clock, date, weather, and the Today panel ---------- */

.home {
  position: relative;
  min-height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 27rem;
  align-items: end;
  gap: 2.5rem;
  padding: 3rem 3.5rem 2.5rem;
}
/* Photo slideshow behind everything. The gradient shows until the first photo arrives. */
.home-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background:
    radial-gradient(70rem 40rem at 15% 10%, rgba(242, 178, 92, 0.11), transparent 60%),
    radial-gradient(60rem 45rem at 88% 92%, rgba(86, 132, 190, 0.15), transparent 60%),
    linear-gradient(160deg, #0f151d, #0a0d12);
}
.slides, .slide { position: absolute; inset: 0; }
.slide { opacity: 0; transition: opacity 2s ease; }
.slide.is-front { opacity: 1; }
/* A tiny copy of the photo, stretched: fills the bands beside photos that don't match the screen. */
.slide-fill {
  position: absolute;
  inset: -4%;
  background-size: cover;
  background-position: center;
  filter: brightness(0.7) saturate(1.1);
}
.slide-img, .slide-motion { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.slide-img:not([src]) { display: none; }
.slide-motion { opacity: 0; transition: opacity 0.6s ease; }
.slide-motion.is-playing { opacity: 1; }
/* Shade along the bottom and left so the clock reads on bright photos. */
.home-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(to top, rgba(6, 9, 13, 0.82) 0%, rgba(6, 9, 13, 0.4) 40%, rgba(6, 9, 13, 0) 65%),
    linear-gradient(to right, rgba(6, 9, 13, 0.5) 0%, rgba(6, 9, 13, 0) 45%);
}
.photo-alert {
  position: absolute;
  z-index: 2;
  top: 1.2rem;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.5rem 1.1rem;
  font-size: 1.1rem;
  font-weight: 650;
  color: var(--accent-ink);
  background: var(--accent);
  border-radius: 999px;
}
.home-main, .home-side { position: relative; z-index: 1; }
.home-main { display: flex; flex-direction: column; justify-content: flex-end; min-width: 0; }

.clock { display: flex; align-items: baseline; gap: 0.7rem; }
.clock-time {
  font-size: 10rem;
  font-weight: 300;
  line-height: 0.85;
  letter-spacing: -0.035em;
  font-variant-numeric: tabular-nums;
}
.clock-ampm { font-size: 2.6rem; font-weight: 500; color: #c3cad4; }
.clock, .clock-date { text-shadow: 0 2px 24px rgba(0, 0, 0, 0.5); }
.clock-date { font-size: 2.4rem; font-weight: 500; color: #e4e8ee; margin: 1rem 0 1.6rem; }

.weather {
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.2rem 1.6rem;
  max-width: 46rem;
}
.wx-now { display: grid; grid-template-columns: auto auto minmax(0, 1fr); align-items: center; gap: 1.4rem; }
.wx-icon { width: 5.6rem; height: 5.6rem; margin: -0.8rem -0.5rem; }
.wx-temp { font-size: 4.6rem; font-weight: 300; line-height: 1; font-variant-numeric: tabular-nums; }
.wx-desc { font-size: 1.8rem; font-weight: 650; }
.wx-sub { font-size: 1.25rem; color: #b4bdc9; margin-top: 0.15rem; }
.wx-hours {
  list-style: none;
  margin: 1rem 0 0;
  padding: 0.9rem 0 0;
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.5rem;
}
.wx-hours li { display: flex; flex-direction: column; align-items: center; }
.wx-h-time { font-size: 1rem; font-weight: 650; color: #b4bdc9; }
.wx-hours img { width: 2.7rem; height: 2.7rem; }
.wx-h-temp { font-size: 1.35rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.wx-h-pop { font-size: 1.05rem; color: var(--rain); min-height: 1.4em; }
.wx-stale { margin-top: 1rem; font-size: 1.2rem; color: var(--accent); }
.wx-missing { font-size: 1.5rem; color: var(--muted); }

.home-side {
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.6rem 1.8rem;
  display: flex;
  flex-direction: column;
  gap: 1.3rem;
}
.side-title { font-size: 1.9rem; font-weight: 700; margin: 0; }
.side-block h3 {
  font-size: 1.15rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
  margin: 0 0 0.6rem;
}
.soon { font-size: 1.3rem; color: #b4bdc9; margin: 0; }

/* ---------- Screens still to come ---------- */

.soon-panel {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1rem;
  padding: 4rem 5rem;
  max-width: 64rem;
}
.soon-panel h1 { font-size: 4rem; margin: 0; }
.soon-panel p { font-size: 1.8rem; color: var(--muted); margin: 0; max-width: 40em; }
.soon-panel .soon-when { font-size: 1.3rem; color: var(--accent); font-weight: 650; }

/* ---------- Sign-in, password and pairing pages ---------- */

body.auth {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: 1.5rem;
  background:
    radial-gradient(50rem 30rem at 20% 0%, rgba(242, 178, 92, 0.09), transparent 60%),
    var(--bg);
}
.auth-card {
  width: min(28rem, 100%);
  background: var(--bg-raise);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 2.4rem 2.2rem;
}
.auth-card h1 { font-size: 2.6rem; margin: 0 0 1.4rem; }
.auth-lead { font-size: 1.35rem; margin: 0 0 1.2rem; }
.auth-note { font-size: 1.05rem; color: var(--faint); margin: 1.4rem 0 0; }

.form { display: grid; gap: 1.1rem; }
.form label { display: grid; gap: 0.45rem; font-size: 1.15rem; font-weight: 650; color: var(--muted); }
input:not([type="hidden"]) {
  min-height: 3.4rem;
  padding: 0.8rem 1rem;
  font-size: 1.3rem;
  color: var(--text);
  background: #0d1219;
  border: 1px solid #2a3442;
  border-radius: 0.8rem;
}
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.form-error { color: var(--danger); font-size: 1.15rem; margin: 0; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 3.4rem;
  padding: 0 1.4rem;
  font-size: 1.25rem;
  font-weight: 700;
  background: #1a222d;
  border: 1px solid #2f3a49;
  border-radius: 0.8rem;
  cursor: pointer;
  touch-action: manipulation;
}
.btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn-danger { background: transparent; color: var(--danger); border-color: rgba(239, 122, 109, 0.5); }

/* ---------- Settings ---------- */

body.page { min-height: 100dvh; }
.page-wrap { max-width: 56rem; margin: 0 auto; padding: 2rem 1.5rem 4rem; display: grid; gap: 1.5rem; }
.page-head { display: flex; align-items: center; gap: 1.2rem; }
.page-head h1 { font-size: 2.4rem; margin: 0; }
.back { color: var(--muted); text-decoration: none; font-size: 1.2rem; font-weight: 650; padding: 0.6rem 0.2rem; }
.card { background: var(--bg-raise); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.6rem 1.8rem; }
.card h2 { font-size: 1.6rem; margin: 0 0 0.9rem; }
.card p { font-size: 1.15rem; }
.muted { color: var(--muted); }
.table-scroll { overflow-x: auto; margin-bottom: 1.2rem; }
.devices { width: 100%; border-collapse: collapse; font-size: 1.1rem; }
.devices th {
  text-align: left;
  font-size: 0.9rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--line);
}
.devices td { padding: 0.8rem 0.6rem; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
.status-locked { color: var(--danger); font-weight: 650; }
.confirm summary { list-style: none; cursor: pointer; color: var(--danger); font-weight: 650; padding: 0.4rem 0; }
.confirm summary::-webkit-details-marker { display: none; }
.confirm form { margin-top: 0.5rem; }
.notice {
  background: rgba(242, 178, 92, 0.08);
  border: 1px solid rgba(242, 178, 92, 0.35);
  border-radius: 0.9rem;
  padding: 0.4rem 1.2rem;
  margin-bottom: 1.2rem;
}
.secret {
  display: block;
  word-break: break-all;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 1rem;
  background: #0d1219;
  padding: 0.8rem;
  border-radius: 0.6rem;
  user-select: all;
}
.inline-form { display: flex; flex-wrap: wrap; gap: 0.8rem; }
.inline-form input { flex: 1 1 14rem; }

/* ---------- Phones and narrow windows ---------- */

@media (max-width: 760px) {
  :root { --nav-h: 4.6rem; }
  .home { grid-template-columns: 1fr; gap: 1.2rem; padding: 1.6rem 1.1rem 2rem; }
  .home-main { justify-content: flex-start; }
  .clock-time { font-size: 6.5rem; }
  .clock-ampm { font-size: 1.8rem; }
  .clock-date { font-size: 1.6rem; margin: 0.7rem 0 1.2rem; }
  .weather { padding: 1.1rem; }
  .wx-now { grid-template-columns: auto minmax(0, 1fr); gap: 0.8rem; }
  .wx-words { grid-column: 1 / -1; }
  .wx-icon { width: 5rem; height: 5rem; }
  .wx-temp { font-size: 4rem; }
  .wx-desc { font-size: 1.5rem; }
  .wx-sub { font-size: 1.1rem; }
  .wx-hours img { width: 2.4rem; height: 2.4rem; }
  .wx-h-time { font-size: 0.95rem; }
  .wx-h-temp { font-size: 1.2rem; }
  .home-side { padding: 1.4rem 1.3rem; gap: 1.2rem; }
  .side-title { font-size: 1.7rem; }
  .soon { font-size: 1.2rem; }
  .nav-btn { font-size: 1rem; }
  .nav-btn svg { width: 1.7rem; height: 1.7rem; }
  .nav-settings { padding: 0 1.1rem; }
  .soon-panel { padding: 2rem 1.3rem; }
  .soon-panel h1 { font-size: 2.4rem; }
  .soon-panel p { font-size: 1.25rem; }
}
