/* Vivarium — a dark room with one glowing tank.
   Palette: room #0b0d0a · wood #2b1d12/#3a2818 · moss #6f8f5a
            amber #e8a13d · mist #cfe3da · uv #8f6bd8                     */

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

:root {
  --room: #0b0d0a;
  --wood-dark: #241809;
  --wood: #2b1d12;
  --wood-hi: #4a341f;
  --moss: #6f8f5a;
  --amber: #e8a13d;
  --mist: #cfe3da;
  --uv: #8f6bd8;
  --brass: #b08d4f;
  --text: #d7ddd3;
  --text-dim: #7d857a;
}

html, body { background: var(--room); color: var(--text); min-height: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
}

.room {
  max-width: 560px;
  margin: 0 auto;
  padding: 28px 16px 40px;
  min-height: 100vh;
  /* the LED's light physically spills into the room */
  background:
    radial-gradient(ellipse 90% 45% at 50% 22%,
      rgba(232, 161, 61, var(--spill, 0)) 0%, transparent 70%),
    var(--room);
  transition: background 1.6s ease;
}
.room:has(.tank[data-led="on"]) { --spill: 0.10; }

/* ------------------------------------------------------------ tank */

.tank { position: relative; }

.canopy {
  height: 18px;
  margin: 0 6px;
  border-radius: 6px 6px 2px 2px;
  background: linear-gradient(#171a15, #0e100c);
  border: 1px solid #1e2119;
  border-bottom: none;
  position: relative;
}
.canopy-slit {
  position: absolute; left: 12%; right: 12%; bottom: 2px; height: 3px;
  border-radius: 3px;
  background: #131510;
  transition: background 1.2s ease, box-shadow 1.2s ease;
}
.tank[data-led="on"] .canopy-slit {
  background: var(--amber);
  box-shadow: 0 2px 14px 2px rgba(232, 161, 61, 0.55);
}

.glass {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: 3px;
  background: #10140f;
  border: 1px solid #262b22;
  box-shadow:
    inset 0 0 40px rgba(0, 0, 0, 0.55),
    0 14px 40px -12px rgba(0, 0, 0, 0.9);
  transition: filter 1.6s ease;
}
.tank[data-led="off"] .glass { filter: brightness(0.72) saturate(0.85); }

.glass video,
.glass .feed-img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.feed-offline {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  color: var(--text-dim);
  font-size: 14px;
  letter-spacing: 0.04em;
}

/* faint always-on water shimmer */
.caustics {
  position: absolute; inset: 0;
  background:
    repeating-linear-gradient(105deg,
      transparent 0 26px, rgba(207, 227, 218, 0.028) 26px 34px,
      transparent 34px 70px);
  mix-blend-mode: screen;
  animation: caustic 11s linear infinite;
  pointer-events: none;
}
@keyframes caustic {
  from { transform: translateX(-70px); }
  to   { transform: translateX(0); }
}
/* the fan stirs the water light a little faster */
.tank[data-fan="on"] .caustics { animation-duration: 5s; }

/* fog: three soft blobs drifting across the glass */
.fog-layer {
  position: absolute; inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 2.5s ease;
}
.tank[data-fog="on"] .fog-layer { opacity: 1; }
.fog {
  position: absolute;
  width: 85%; height: 55%;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(207, 227, 218, 0.34), transparent 72%);
  filter: blur(6px);
  mix-blend-mode: screen;
}
.fog-a { bottom: -12%; left: -30%; animation: drift 16s linear infinite; }
.fog-b { bottom: 4%;  left: -55%; animation: drift 23s linear infinite 3s; height: 42%; }
.fog-c { bottom: -18%; left: -40%; animation: drift 19s linear infinite 8s; width: 110%; }
@keyframes drift {
  from { transform: translateX(0); }
  to   { transform: translateX(160%); }
}

.uv-rim {
  position: absolute; inset: 0;
  box-shadow: inset 0 0 34px 6px rgba(143, 107, 216, 0);
  transition: box-shadow 1.4s ease;
  pointer-events: none;
}
.tank[data-uv="on"] .uv-rim {
  box-shadow: inset 0 0 34px 6px rgba(143, 107, 216, 0.38);
}

/* diagonal glass reflection */
.sheen {
  position: absolute; inset: 0;
  background: linear-gradient(112deg,
    transparent 38%, rgba(190, 215, 205, 0.075) 45%,
    rgba(190, 215, 205, 0.02) 52%, transparent 58%,
    transparent 72%, rgba(190, 215, 205, 0.05) 78%, transparent 84%);
  pointer-events: none;
}
.frame-edge {
  position: absolute; inset: 0;
  border: 1px solid rgba(220, 235, 228, 0.09);
  border-radius: 3px;
  pointer-events: none;
}

.fs-btn {
  position: absolute; right: 10px; bottom: 10px;
  z-index: 5;
  width: 40px; height: 40px;
  border-radius: 6px;
  border: 1px solid rgba(220, 235, 228, 0.18);
  background: rgba(10, 12, 8, 0.55);
  color: var(--mist);
  display: grid; place-items: center;
  cursor: pointer;
  opacity: 0.65;
  transition: opacity 0.2s ease, background 0.2s ease;
}
.fs-btn:hover, .fs-btn:focus-visible { opacity: 1; background: rgba(10, 12, 8, 0.85); }

.zoom-btn { right: 56px; }
.zoom-btn[data-zoomed="true"] { color: var(--amber); opacity: 1; }

.glass video, .glass .feed-img { transition: transform 0.35s ease; }

/* fullscreen: show the whole native frame, no crop */
.glass:fullscreen { aspect-ratio: auto; border-radius: 0; }
.glass:fullscreen video, .glass:fullscreen .feed-img { object-fit: contain; }
.glass.fake-full {
  position: fixed; inset: 0;
  z-index: 50;
  aspect-ratio: auto;
  border-radius: 0;
  background: #000;
}
.glass.fake-full video, .glass.fake-full .feed-img { object-fit: contain; }
body.noscroll { overflow: hidden; }

.nameplate {
  display: flex; justify-content: center;
  margin-top: -1px;
}
.nameplate span {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 11px;
  letter-spacing: 0.32em;
  padding: 4px 18px 3px 22px;
  color: #d8bd82;
  background: linear-gradient(#8a6d3c, #6e5327 60%, #85683a);
  border-radius: 0 0 4px 4px;
  border: 1px solid #55401e;
  border-top: none;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.6);
}

/* ------------------------------------------------------------ stand */

.stand {
  position: relative;
  margin: 0 2px;
  padding: 18px 14px 14px;
  border-radius: 0 0 10px 10px;
  background:
    repeating-linear-gradient(92deg,
      rgba(0, 0, 0, 0.12) 0 3px, transparent 3px 9px),
    linear-gradient(#3a2818, var(--wood) 30%, var(--wood-dark));
  border: 1px solid #1d130a;
  border-top: 2px solid #503a22;
  box-shadow: 0 18px 30px -18px rgba(0, 0, 0, 0.9);
}

.panel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 10px;
  padding: 12px 10px;
  border-radius: 6px;
  background: linear-gradient(#151710, #0e100b);
  border: 1px solid #060704;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.switch {
  appearance: none;
  border: 1px solid #23261d;
  border-radius: 5px;
  background: linear-gradient(#181a13, #101208);
  color: var(--text-dim);
  padding: 10px 8px 9px;
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  cursor: pointer;
  font: inherit;
  transition: color 0.3s ease;
}
.switch:focus-visible { outline: 2px solid var(--moss); outline-offset: 2px; }
.switch[data-on="true"] { color: var(--text); }
.switch:disabled { opacity: 0.45; cursor: default; }

.lamp {
  width: 7px; height: 7px; border-radius: 50%;
  background: #262a20;
  box-shadow: none;
  transition: background 0.3s ease, box-shadow 0.3s ease;
}
.switch[data-on="true"] .lamp {
  background: var(--amber);
  box-shadow: 0 0 8px 2px rgba(232, 161, 61, 0.55);
}

.rocker {
  width: 26px; height: 40px;
  border-radius: 4px;
  background: linear-gradient(#0a0c07, #131509);
  border: 1px solid #060704;
  position: relative;
}
.rocker::after {
  content: "";
  position: absolute; left: 2px; right: 2px; height: 17px;
  border-radius: 3px;
  background: linear-gradient(#3b4034, #23271e);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
  top: 19px;
  transition: top 0.16s ease;
}
.switch[data-on="true"] .rocker::after {
  top: 2px;
  background: linear-gradient(#59614c, #39402f);
}

.switch .label {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.switch .rename {
  font-size: 10px;
  color: var(--text-dim);
  text-decoration: underline dotted;
  background: none; border: none; cursor: pointer; padding: 0;
}

/* small brass padlock guarding the switch panel */
.lock-btn {
  position: absolute;
  top: 4px; right: 12px;
  z-index: 6;
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 1px solid #55401e;
  background: linear-gradient(#8a6d3c, #6e5327 60%, #85683a);
  color: #2a1e0c;
  display: grid; place-items: center;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}
.lock-btn:hover, .lock-btn:focus-visible { color: #120d05; }
.lock-btn svg { width: 13px; height: 13px; }
.lock-btn .open { display: none; }
.lock-btn[data-locked="false"] .open { display: block; }
.lock-btn[data-locked="false"] .closed { display: none; }
.lock-btn[data-locked="false"] { opacity: 0.75; }

.panel[data-locked="true"] .switch { opacity: 0.5; }

.unlock-bar {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  margin-top: 10px;
}
.unlock-bar input {
  flex: 1; min-width: 120px;
  background: #171a12; color: var(--text);
  border: 1px solid #2a2f24; border-radius: 5px;
  padding: 8px 10px; font: inherit; font-size: 14px;
}
.unlock-bar .gate-err { flex-basis: 100%; }

.statusline {
  margin-top: 12px;
  text-align: center;
  font-size: 12.5px;
  letter-spacing: 0.05em;
  color: var(--text-dim);
}
.statusline.err { color: #c98a6b; }

/* ------------------------------------------------------------ keeper's log */

.keeper {
  margin-top: 26px;
  border: 1px solid #232720;
  border-radius: 8px;
  background: #101309;
  padding: 16px 14px;
}
.keeper-head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 12px;
}
.keeper-head h2 {
  font-family: Georgia, serif;
  font-weight: normal;
  font-size: 15px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--moss);
}

.sched-list { list-style: none; margin-bottom: 16px; }
.sched-list li {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 4px;
  border-bottom: 1px solid #1b1f17;
  font-size: 14px;
}
.sched-list .when { font-variant-numeric: tabular-nums; min-width: 76px; }
.sched-list .what { flex: 1; color: var(--text-dim); }
.sched-list .what b { color: var(--text); font-weight: 600; }
.sched-list .days-tag { font-size: 11px; color: var(--text-dim); }
.sched-list li.disabled .when, .sched-list li.disabled .what { opacity: 0.4; }
.sched-list button {
  background: none; border: none; color: var(--text-dim);
  cursor: pointer; font-size: 13px; padding: 4px 6px;
}
.sched-list button:hover { color: var(--text); }

.sched-form .sched-row {
  display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; align-items: center;
}
.sched-form input[type="time"], .sched-form select {
  background: #171a12;
  color: var(--text);
  border: 1px solid #2a2f24;
  border-radius: 5px;
  padding: 8px 10px;
  font: inherit;
  font-size: 14px;
}
.days button {
  width: 34px; height: 30px;
  border-radius: 5px;
  border: 1px solid #2a2f24;
  background: #14170f;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 12px;
}
.days button[data-sel="true"] {
  background: #26301c;
  color: var(--mist);
  border-color: var(--moss);
}

button.solid {
  background: var(--moss);
  color: #10140c;
  border: none; border-radius: 5px;
  padding: 9px 16px;
  font: inherit; font-size: 14px; font-weight: 600;
  cursor: pointer;
}
button.ghost {
  background: none;
  border: 1px solid #2a2f24;
  color: var(--text-dim);
  border-radius: 5px;
  padding: 8px 14px;
  font: inherit; font-size: 13px;
  cursor: pointer;
}

/* ------------------------------------------------------------ gate + floor */

.gate { margin-top: 26px; display: flex; justify-content: center; }
.gate form {
  display: flex; flex-direction: column; gap: 10px;
  width: min(280px, 100%);
  padding: 18px;
  border: 1px solid #232720;
  border-radius: 8px;
  background: #101309;
}
.gate label {
  font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--text-dim);
}
.gate input {
  background: #171a12; color: var(--text);
  border: 1px solid #2a2f24; border-radius: 5px;
  padding: 9px 10px; font: inherit;
}
.gate-err { color: #c98a6b; font-size: 13px; min-height: 1em; }

.floor { margin-top: 34px; text-align: center; }
.admin-link {
  color: #3c443a;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-decoration: none;
}
.admin-link:hover, .admin-link:focus-visible { color: var(--text-dim); }

@media (prefers-reduced-motion: reduce) {
  .caustics, .fog { animation: none; }
  .room, .glass, .fog-layer { transition: none; }
}
