/* Daya Link · Rumah Cerdas
   Friendly demo: light sky palette, a big welcoming title, Robi the guide robot,
   and a blue "blueprint" floor plan where lit rooms glow warm yellow. */

:root {
  color-scheme: light;
  font-family: "Plus Jakarta Sans", system-ui, sans-serif;

  --sky-50: #f3f9ff;
  --sky-100: #e2f0ff;
  --sky-200: #c7e2ff;
  --sky-300: #8fd0ff;
  --sky-500: #3a9cf2;
  --sky-600: #2481db;
  --sky-700: #1a64b8;
  --navy: #0f2b4a;
  --sun: #ffc83d;
  --sun-soft: #fff1c2;

  --bg: #e9f4ff;
  --surface: #ffffff;
  --ink: #0f2b4a;
  --ink-2: #4b6582;
  --line: #d3e3f4;
  --line-strong: #a9c3de;

  --plan: #1e5fae;        /* blueprint blue */
  --plan-room: #2669ba;
  --plan-line: #8cb8ea;
  --plan-text: #ffffff;
  --plan-text-2: #c8defa;
  --lit: #ffe49a;
  --lit-core: #fffbe9;

  --ok: #1f9d6b;
  --alarm: #e0453b;

  /* chart series, validated with the dataviz checker (all-pairs, light) */
  --series-1: #3d5a99;
  --series-2: #e0662f;
  --series-3: #14996a;

  --radius: 18px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px #0f2b4a0f, 0 8px 24px -12px #1a64b833;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

* { box-sizing: border-box; }
[x-cloak] { display: none !important; }
html { scroll-padding-top: 84px; scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body { margin: 0; min-width: 0; background: var(--bg); color: var(--ink); line-height: 1.55; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
:focus-visible { outline: 3px solid var(--sky-500); outline-offset: 3px; border-radius: 6px; }
h1, h2, p { margin: 0; }
h2 { font-size: 1.15rem; font-weight: 750; letter-spacing: -.01em; }
dl, dd { margin: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.hint { font-size: .87rem; color: var(--ink-2); }

.wrap { width: min(1240px, calc(100% - 3rem)); margin-inline: auto; }

/* ---------- top bar ---------- */
.top { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--sky-50) 88%, transparent); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.top-inner { min-height: 64px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 1.5rem; }
.brand { display: inline-flex; width: max-content; align-items: center; gap: .6rem; font-weight: 800; letter-spacing: -.01em; }
.brand-mark { width: 32px; height: 32px; }
.top nav { display: flex; gap: .35rem; font-size: .93rem; font-weight: 600; color: var(--ink-2); }
.top nav a { padding: .45rem .85rem; border-radius: 999px; transition: background-color .15s, color .15s; }
.top nav a:hover { background: var(--sky-100); color: var(--ink); }
.connection { justify-self: end; display: inline-flex; align-items: center; gap: .5rem; padding: .35rem .8rem; border-radius: 999px; background: var(--surface); box-shadow: var(--shadow); font-size: .84rem; font-weight: 600; color: var(--ink-2); white-space: nowrap; }
.indicator { width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong); flex: 0 0 auto; }
.connection.live { color: var(--ink); }
.connection.live .indicator { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 22%, transparent); }

/* ---------- hero ---------- */
.hero { position: relative; overflow: hidden; background: linear-gradient(180deg, var(--sky-50), var(--bg)); }
.hero::after { content: ""; position: absolute; inset: auto 0 0; height: 1px; background: var(--line); }
.hero-inner { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); align-items: center; gap: 2rem; padding-block: clamp(2.5rem, 6vw, 4.5rem) clamp(2rem, 4vw, 3rem); }
h1 {
  font-size: clamp(3.4rem, 9vw, 7.25rem); line-height: .95; letter-spacing: -.045em; font-weight: 800;
  color: var(--navy);
}
.tagline { margin-top: 1.1rem; max-width: 30ch; font-size: clamp(1.1rem, 1.8vw, 1.35rem); line-height: 1.45; color: var(--ink-2); font-weight: 500; }
.hero-actions { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: 1.75rem; }
.hero-facts { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 2rem; }
.hero-facts > div { padding: .65rem 1rem; border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); }
.hero-facts dt { font-size: .78rem; font-weight: 600; color: var(--ink-2); }
.hero-facts dd { font-size: 1.25rem; font-weight: 800; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }

.hero-art { position: relative; }
.scene { display: block; width: 100%; height: auto; overflow: visible; }

.signal path, .signal circle { opacity: .25; transition: opacity .4s; }
.hero-art.online .signal .s1 { animation: signal 2.4s infinite; }
.hero-art.online .signal .s2 { animation: signal 2.4s .25s infinite; }
.hero-art.online .signal .s3 { animation: signal 2.4s .5s infinite; }

.window rect { fill: var(--sky-200); transition: fill .4s; }
.window path { fill: none; stroke: #fff; stroke-width: 5; }
.window.lit rect { fill: var(--sun); filter: drop-shadow(0 0 14px #ffc83dcc); }
.door-frame { fill: var(--navy); }
.door-panel { fill: var(--sky-500); transform-box: fill-box; transform-origin: left center; transition: transform .5s var(--ease); }
.door-knob { fill: var(--sun); transition: opacity .3s; }
.door.open .door-panel { transform: scaleX(.28); }
.door.open .door-knob { opacity: 0; }
.porch rect { fill: var(--navy); }
.porch-glow { fill: var(--sun); opacity: 0; transition: opacity .4s; }
.porch.lit rect { fill: var(--sun); }
.porch.lit .porch-glow { opacity: .35; }

.antenna { fill: var(--line-strong); transition: fill .3s; }
.hero-art.online .antenna { fill: var(--sun); filter: drop-shadow(0 0 6px #ffc83d); }
.hero-art.alarm .antenna { fill: var(--alarm); filter: drop-shadow(0 0 6px var(--alarm)); }
.robot-body { animation: hover 4s ease-in-out infinite; }
.robot-shadow { transform-box: fill-box; transform-origin: center; animation: shadow 4s ease-in-out infinite; }
.wave-arm { transform-box: fill-box; transform-origin: 0% 100%; animation: wave 2.8s ease-in-out infinite; }
.eyes { transform-box: fill-box; transform-origin: center; animation: blink-eyes 5s infinite; }
.hero-art.alarm .eyes { fill: #ff8a80; }

.bubble {
  position: absolute; right: 2%; top: 4%; max-width: 15.5rem;
  padding: .8rem 1rem; border-radius: 18px 18px 6px 18px;
  background: var(--surface); box-shadow: var(--shadow); font-size: .92rem; font-weight: 600; line-height: 1.4;
}
.bubble::after { content: ""; position: absolute; right: 22%; bottom: -10px; border: 10px solid transparent; border-top-color: var(--surface); border-bottom: 0; }
.hero-art.alarm .bubble { background: var(--alarm); color: #fff; }
.hero-art.alarm .bubble::after { border-top-color: var(--alarm); }

/* ---------- buttons ---------- */
.action {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 46px; padding: .6rem 1.25rem; border-radius: 999px; border: 0;
  font-size: .95rem; font-weight: 700; transition: background-color .15s, color .15s, transform .15s;
}
.action:enabled:active, a.action:active { transform: translateY(1px); }
.action-primary { background: var(--sky-600); color: #fff; box-shadow: 0 6px 16px -6px #2481dbaa; }
.action-primary:enabled:hover, a.action-primary:hover { background: var(--sky-700); }
.action-ghost { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.action-ghost:hover { background: var(--sky-100); }
.action:disabled { opacity: .45; box-shadow: none; }

/* ---------- dashboard ---------- */
.dashboard { padding-block: clamp(2rem, 4vw, 3rem) 4rem; }
.stage { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 1.5rem; align-items: start; }
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: .25rem 1rem; margin-bottom: .9rem; }
.section-head h2 { font-size: 1.5rem; }
.section-head p { color: var(--ink-2); font-size: .95rem; }

.card { padding: 1.35rem; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }

/* the blueprint */
.blueprint {
  --gap: 6px; --outer: 10px;
  position: relative; padding: clamp(1rem, 2.2vw, 1.6rem); border-radius: var(--radius);
  background: var(--plan);
  background-image:
    linear-gradient(#ffffff14 1px, transparent 1px),
    linear-gradient(90deg, #ffffff14 1px, transparent 1px);
  background-size: 24px 24px;
  box-shadow: var(--shadow);
}
.floorplan {
  position: relative;
  display: grid; grid-template-columns: 1fr 1.3fr 1fr;
  grid-template-rows: minmax(168px, 1.4fr) minmax(92px, .75fr) minmax(128px, 1fr);
  grid-template-areas: "kamar1 tamu kamar2" "lorong tamu dapur" "lorong wc dapur";
  gap: var(--gap); padding: var(--outer); background: #eaf3ff; border-radius: 6px;
}
.cell-kamar1 { grid-area: kamar1; }
.cell-kamar2 { grid-area: kamar2; }
.cell-tamu { grid-area: tamu; }
.cell-lorong { grid-area: lorong; }
.cell-wc { grid-area: wc; }
.cell-dapur { grid-area: dapur; }

.cell {
  position: relative; isolation: isolate; min-width: 0; overflow: hidden; border-radius: 3px;
  background: var(--plan-room); color: var(--plan-text);
  transition: background-color .45s var(--ease), color .3s;
}
.room {
  position: absolute; inset: 0; z-index: 1;
  display: flex; flex-direction: column; justify-content: flex-end; align-items: flex-start;
  padding: .8rem .9rem; border: 0; background: transparent; color: inherit; text-align: start;
}
.room:enabled:hover { background: #ffffff14; }
.cell.lit .room:enabled:hover { background: #ffffff40; }
.room:focus-visible { outline: 3px solid var(--sun); outline-offset: -6px; }
.cell.lit .room:focus-visible { outline-color: var(--navy); }
.room-name { font-size: clamp(.92rem, 1.3vw, 1.05rem); font-weight: 750; line-height: 1.2; }
.room-state { font-size: .8rem; font-weight: 500; color: var(--plan-text-2); }

.bulb {
  position: absolute; z-index: -1; left: 50%; top: 50%; translate: -50% -50%;
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%;
  background: #ffffff1f; transition: box-shadow .6s var(--ease), background-color .3s;
}
.bulb svg { width: 22px; height: 22px; fill: none; stroke: var(--plan-text-2); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.cell.lit { background-color: var(--lit); color: var(--navy); }
.cell.lit .bulb { background: #fff; box-shadow: 0 0 46px 32px var(--lit-core), 0 0 130px 70px #fffbe9aa; }
.cell.lit .bulb svg { stroke: var(--navy); fill: var(--sun); }
.cell.lit .room-state, .cell.lit .climate { color: #5b4a17; }
.cell.waiting .room-state { animation: blink 1s steps(2, start) infinite; }
.blueprint.offline .cell { color: #ffffff99; }

.climate { position: absolute; z-index: 2; top: .75rem; left: .9rem; right: .9rem; pointer-events: none; display: grid; gap: .05rem; color: var(--plan-text-2); }
.climate-value { display: flex; align-items: center; gap: .45rem; font-size: clamp(1.2rem, 2vw, 1.55rem); font-weight: 800; letter-spacing: -.02em; line-height: 1.1; color: var(--plan-text); font-variant-numeric: tabular-nums; }
.cell.lit .climate-value { color: var(--navy); }
.climate-value small { font-size: .78rem; font-weight: 600; color: var(--plan-text-2); }
.cell.lit .climate-value small { color: #5b4a17; }
.climate-fan { display: inline-flex; align-items: center; gap: .35rem; font-size: .78rem; font-weight: 600; }
.fan { width: 13px; height: 13px; fill: currentColor; flex: 0 0 auto; }
.climate.running .climate-fan { color: #fff; }
.cell.lit .climate.running .climate-fan { color: var(--sky-700); }
.climate.running .fan { animation: spin 1.3s linear infinite; }
.series { width: 4px; height: .95em; border-radius: 2px; flex: 0 0 auto; box-shadow: 0 0 0 1.5px #fff; }
.series-1 { background: var(--series-1); }
.series-2 { background: var(--series-2); }
.series-3 { background: var(--series-3); }

.front-door { --w: 46px; position: absolute; bottom: 0; left: calc(var(--outer) + 6%); width: var(--w); height: var(--outer); background: var(--plan); z-index: 3; }
.door-leaf { position: absolute; left: 0; top: 50%; width: var(--w); height: 5px; margin-top: -2.5px; border-radius: 3px; background: #fff; transform-origin: 2.5px 50%; transition: rotate .5s var(--ease), background-color .3s; }
.door-swing { position: absolute; left: 0; top: 50%; width: var(--w); height: var(--w); border: 1.5px dashed var(--plan-line); border-left: 0; border-top: 0; border-bottom-right-radius: 100%; opacity: 0; transition: opacity .3s; }
.front-door b { position: absolute; left: calc(var(--w) + 8px); top: calc(100% + 6px); white-space: nowrap; font-size: .76rem; font-weight: 600; color: var(--plan-text-2); }
.front-door.open .door-leaf { rotate: 90deg; }
.front-door.open .door-swing { opacity: 1; }
.front-door.armed .door-leaf { background: #6ee7b7; }
.front-door.alarm .door-leaf { background: #ff8a80; animation: blink .7s steps(2, start) infinite; }
.front-door.alarm .door-swing { border-color: #ff8a80; }
.front-door.alarm b { color: #ffd2cd; }

.outside { display: grid; grid-template-columns: 1fr 1.3fr 1fr; gap: var(--gap); padding-inline: var(--outer); margin-top: 3.25rem; }
.outdoor { min-height: 70px; display: flex; flex-direction: column; justify-content: flex-end; padding: .6rem .85rem; background: transparent; border: 1.5px dashed var(--plan-line); border-radius: 8px; }
.outdoor .bulb { left: auto; right: .6rem; top: .6rem; translate: none; width: 30px; height: 30px; }
.outdoor .bulb svg { width: 17px; height: 17px; }
.outdoor-6 { grid-column: 1 / 3; }
.outdoor-7 { grid-column: 3; }
.plan-notice { margin-top: 1rem; padding: .65rem .9rem; border-radius: var(--radius-sm); background: #ffffff24; color: #fff; font-size: .9rem; font-weight: 600; }

/* rail */
.rail { display: grid; gap: 1.25rem; padding-top: 3.05rem; }
.card-icon { display: grid; place-items: center; width: 44px; height: 44px; margin-bottom: .8rem; border-radius: 14px; background: var(--sky-100); }
.card-icon svg { width: 24px; height: 24px; fill: none; stroke: var(--sky-700); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.card-icon .tick { opacity: 0; transition: opacity .3s; }
.security.armed .card-icon { background: #dcf5ea; }
.security.armed .card-icon svg { stroke: var(--ok); }
.security.armed .card-icon .tick { opacity: 1; }
.door-state { margin-top: .2rem; font-size: 1.6rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.2; }
.security-rows { display: flex; gap: 2rem; margin: .7rem 0 1.1rem; }
.security-rows dt, .air-rows dt { font-size: .82rem; font-weight: 600; color: var(--ink-2); }
.security-rows dd { font-weight: 750; }
.security.armed:not(.alarming) .security-rows div:first-child dd { color: var(--ok); }
.security-rows .alert { color: var(--alarm); }
.security .action { width: 100%; }
.security.alarming { background: var(--alarm); color: #fff; box-shadow: 0 0 0 6px #e0453b33, var(--shadow); }
.security.alarming .security-rows dt, .security.alarming .security-rows div dd { color: #fff; }
.security.alarming .card-icon { background: #ffffff33; }
.security.alarming .card-icon svg { stroke: #fff; }
.security.alarming .action-primary { background: #fff; color: var(--alarm); box-shadow: none; }

.air-rows { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: .8rem; }
.air-rows dd { font-size: 1.7rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.air .hint { margin-top: .6rem; }

.error { margin: 1.5rem 0 0; padding: .85rem 1.1rem; border-radius: var(--radius-sm); background: #fde8e6; color: #9b231a; font-weight: 600; }

/* history + thresholds */
.lower { margin-top: 1.5rem; display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 1.5rem; align-items: start; }
.history-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1rem; }
.history-filters { display: flex; flex-wrap: wrap; gap: .5rem; }
.segmented { display: inline-flex; padding: 4px; background: var(--sky-100); border-radius: 999px; }
.segmented button { min-height: 34px; padding: .3rem .9rem; border: 0; border-radius: 999px; background: transparent; color: var(--ink-2); font-size: .87rem; font-weight: 600; }
.segmented button:hover { color: var(--ink); }
.segmented button[aria-checked="true"] { background: var(--surface); color: var(--sky-700); box-shadow: 0 1px 3px #0f2b4a1f; }

.chart-frame { --plot-height: 290px; min-height: var(--plot-height); display: grid; }
.plot { position: relative; min-width: 0; height: var(--plot-height); }
.plot canvas { max-width: 100%; }
.chart-placeholder { display: grid; place-items: center; text-align: center; border-radius: var(--radius-sm); background: var(--sky-50); border: 1.5px dashed var(--line-strong); }
.chart-placeholder p { color: var(--ink-2); font-size: .93rem; font-weight: 500; }
.history-foot { display: flex; flex-wrap: wrap; gap: .25rem 1rem; margin-top: .6rem; font-size: .84rem; color: var(--ink-2); }

.thresholds .hint { margin-top: .35rem; }
.thresholds form { margin-top: 1rem; }
.thresholds table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.thresholds thead th { padding-bottom: .35rem; font-size: .8rem; font-weight: 700; color: var(--ink-2); text-align: start; }
.thresholds tbody th { width: 32%; padding-right: .5rem; font-weight: 750; text-align: start; font-size: .95rem; }
.thresholds tbody th small { font-weight: 500; color: var(--ink-2); }
.thresholds td { padding: .3rem .2rem; }
.thresholds input { width: 100%; min-height: 44px; padding: .45rem .7rem; border-radius: 12px; background: var(--sky-50); border: 1.5px solid var(--line); font-size: 1.02rem; font-weight: 700; }
.thresholds input:enabled:hover { border-color: var(--line-strong); }
.thresholds input:focus-visible { outline-offset: 0; border-color: var(--sky-500); background: #fff; }
.thresholds input:disabled { color: var(--ink-2); opacity: .7; }
.form-foot { display: grid; gap: .75rem; margin-top: 1rem; }
.form-foot .hint { font-size: .82rem; }

.foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5rem 1rem; padding-block: 1.25rem 2.25rem; border-top: 1px solid var(--line); color: var(--ink-2); font-size: .85rem; }

@keyframes spin { to { rotate: 360deg; } }
@keyframes blink { 50% { opacity: .35; } }
@keyframes hover { 50% { transform: translateY(-8px); } }
@keyframes shadow { 50% { transform: scaleX(.82); opacity: .6; } }
@keyframes wave { 0%, 60%, 100% { rotate: 0deg; } 70% { rotate: 14deg; } 80% { rotate: -6deg; } 90% { rotate: 10deg; } }
@keyframes blink-eyes { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(.1); } }
@keyframes signal { 0%, 100% { opacity: .25; } 40% { opacity: 1; } }

/* ---------- responsive ---------- */
@media (max-width: 1040px) {
  .hero-inner { grid-template-columns: minmax(0, 1fr); text-align: center; justify-items: center; gap: 1rem; }
  .tagline { margin-inline: auto; }
  .hero-actions, .hero-facts { justify-content: center; }
  .hero-art { width: min(560px, 100%); }
  .stage, .lower { grid-template-columns: minmax(0, 1fr); }
  .rail { padding-top: 0; grid-template-columns: 1fr 1fr; }
}
@media (max-width: 720px) {
  .wrap { width: calc(100% - 1.5rem); }
  .top-inner { grid-template-columns: 1fr auto; gap: .2rem .75rem; padding-block: .55rem .35rem; }
  .top nav { grid-column: 1 / -1; grid-row: 2; margin-left: -.85rem; font-size: .88rem; }
  .connection { grid-column: 2; grid-row: 1; font-size: .78rem; padding: .3rem .65rem; }
  html { scroll-padding-top: 112px; }
  .hero-inner { padding-top: 2rem; }
  .hero-facts > div { padding: .55rem .8rem; }
  .hero-facts dd { font-size: 1.1rem; }
  .bubble { position: relative; right: auto; top: auto; margin: -.5rem auto 0; max-width: 20rem; border-radius: 18px; }
  .bubble::after { right: auto; left: 50%; bottom: auto; top: -10px; translate: -50% 0; border: 10px solid transparent; border-bottom-color: var(--surface); border-top: 0; }
  .hero-art.alarm .bubble::after { border-bottom-color: var(--alarm); }
  .section-head h2 { font-size: 1.3rem; }
  .rail { grid-template-columns: minmax(0, 1fr); }
  .blueprint { --gap: 4px; --outer: 7px; padding: .6rem; border-radius: 14px; }
  .floorplan { grid-template-columns: 1fr 1.15fr 1fr; grid-template-rows: minmax(132px, 1.4fr) minmax(72px, .75fr) minmax(106px, 1fr); }
  .room { padding: .5rem .55rem; }
  .climate { top: .5rem; left: .55rem; right: .4rem; }
  .climate-value { font-size: 1.1rem; }
  .climate-fan { font-size: .68rem; }
  .bulb { width: 30px; height: 30px; top: 57%; }
  .bulb svg { width: 17px; height: 17px; }
  .room-name { font-size: .86rem; }
  .room-state { font-size: .7rem; }
  .front-door { --w: 34px; }
  .outside { margin-top: 2.6rem; }
  .outdoor { min-height: 60px; padding: .45rem .55rem; }
  .card { padding: 1.1rem; border-radius: 16px; }
  .chart-frame { --plot-height: 240px; }
  .history-head { flex-direction: column; align-items: flex-start; }
}
@media (max-width: 380px) {
  .climate-fan span { display: none; }
  .room-name { font-size: .78rem; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
