/* ─────────────────────────────────────────────
   emodia — home lab dashboard
   ───────────────────────────────────────────── */

:root {
  --bg:          #0b0c10;
  --surface:     #141619;
  --surface-hi:  #1a1d23;
  --border:      #23262c;
  --border-hi:   #33373f;
  --text:        #eceef1;
  --text-mid:    #9aa1ad;
  --text-dim:    #6d7480;
  --indigo:      #7b87ff;
  --green:       #4ade80;
  --red:         #f87171;
  --amber:       #fbbf24;
  --radius:      12px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --ease: cubic-bezier(.22, .8, .3, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── ambient backdrop ────────────────────── */

.ambient {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
}
.glow-a {
  top: -260px; left: -160px;
  width: 620px; height: 620px;
  background: rgba(99, 110, 240, 0.16);
  transition: background 1.2s var(--ease);
}
.glow-b {
  bottom: -320px; right: -180px;
  width: 660px; height: 660px;
  background: rgba(190, 90, 220, 0.10);
  transition: background 1.2s var(--ease);
}

/* If anything stops responding the room turns warm — a peripheral
   cue you notice before you've read a single word. */
body.has-outage .glow-a { background: rgba(248, 113, 113, 0.15); }
body.has-outage .glow-b { background: rgba(251, 146, 60, 0.09); }

/* Film grain. Breaks up the flat fills so large dark areas
   read as a surface rather than an absence of pixels. */
.grain {
  position: absolute;
  inset: 0;
  opacity: .04;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}

.dots {
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, 0.16) 1px, transparent 1px);
  background-size: 26px 26px;
  opacity: .17;
  -webkit-mask-image: radial-gradient(ellipse 78% 58% at 50% 0%, #000 20%, transparent 78%);
          mask-image: radial-gradient(ellipse 78% 58% at 50% 0%, #000 20%, transparent 78%);
}

.page {
  position: relative;
  z-index: 1;
  max-width: 1060px;
  margin: 0 auto;
  padding: 76px 28px 52px;
}

/* ── entrance ────────────────────────────── */

@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: none; }
}
.header, .searchbar, .footer { animation: rise .5s var(--ease) backwards; }
.header    { animation-delay: .02s; }
.searchbar { animation-delay: .10s; }
.footer    { animation-delay: .34s; }

/* ── header ──────────────────────────────── */

.header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  margin-bottom: 34px;
}

.greeting {
  font-size: 13px;
  font-weight: 500;
  color: var(--indigo);
  margin-bottom: 7px;
  letter-spacing: -0.005em;
}

.header h1 {
  font-size: 34px;
  font-weight: 600;
  letter-spacing: -0.028em;
  line-height: 1.1;
  background: linear-gradient(180deg, #ffffff 20%, #a8adbb 130%);
  -webkit-background-clip: text;
          background-clip: text;
  color: transparent;
}

.subtitle {
  margin-top: 8px;
  color: var(--text-dim);
  font-size: 13.5px;
}
.dom { color: var(--text-mid); }

.header-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 4px;
}

.summary {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 13px;
  color: var(--text-mid);
  padding: 7px 14px 7px 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(20, 22, 25, 0.7);
  backdrop-filter: blur(8px);
  white-space: nowrap;
  transition: border-color .2s var(--ease);
}

.summary-dot {
  position: relative;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--text-dim);
  flex: none;
}
.summary-dot::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0;
}
.summary[data-state="checking"] .summary-dot { background: var(--amber); }
.summary[data-state="ok"]       .summary-dot { background: var(--green); color: var(--green); }
.summary[data-state="ok"]       .summary-dot::after { animation: halo 2.6s var(--ease) infinite; }
.summary[data-state="partial"]  .summary-dot { background: var(--amber); }
.summary[data-state="down"]     .summary-dot { background: var(--red); }
.summary[data-state="ok"]       { border-color: rgba(74, 222, 128, 0.28); color: #b7f3cd; }

@keyframes halo {
  0%   { opacity: .30; transform: scale(.6); }
  70%  { opacity: 0;   transform: scale(1.5); }
  100% { opacity: 0;   transform: scale(1.5); }
}

.refresh {
  display: grid;
  place-items: center;
  width: 33px; height: 33px;
  color: var(--text-mid);
  background: rgba(20, 22, 25, 0.7);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: 9px;
  cursor: pointer;
  transition: color .18s var(--ease), border-color .18s var(--ease), background .18s var(--ease);
}
.install {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 13px;
  font-family: inherit;
  font-size: 12.5px;
  color: var(--indigo);
  background: rgba(123, 135, 255, 0.09);
  border: 1px solid rgba(123, 135, 255, 0.28);
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .18s var(--ease), border-color .18s var(--ease);
}
.install:hover { background: rgba(123, 135, 255, 0.16); border-color: rgba(123, 135, 255, 0.45); }
.install:focus-visible { outline: 2px solid var(--indigo); outline-offset: 2px; }
.install svg { width: 13px; height: 13px; }
.install[hidden] { display: none; }

.refresh:hover { color: var(--text); border-color: var(--border-hi); background: var(--surface-hi); }
.refresh:focus-visible { outline: 2px solid var(--indigo); outline-offset: 2px; }
.refresh svg { width: 14px; height: 14px; }
.refresh.busy { color: var(--indigo); pointer-events: none; }
.refresh.busy svg { animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── search ──────────────────────────────── */

.searchbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 13px;
  margin-bottom: 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: border-color .18s var(--ease), box-shadow .18s var(--ease);
}
.searchbar:focus-within {
  border-color: rgba(123, 135, 255, 0.5);
  box-shadow: 0 0 0 3px rgba(123, 135, 255, 0.09);
}

.search-icon { width: 15px; height: 15px; color: var(--text-dim); flex: none; }
.searchbar:focus-within .search-icon { color: var(--indigo); }

#search {
  flex: 1;
  padding: 11px 0;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
}
#search::placeholder { color: var(--text-dim); }

.slash-hint {
  font-family: inherit;
  font-size: 11px;
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 6px;
  flex: none;
  transition: opacity .15s;
}
.searchbar:focus-within .slash-hint { opacity: 0; }

/* ── sections ────────────────────────────── */

.section + .section { margin-top: 30px; }
.section.hidden { display: none; }

.section-title {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 13px;
  padding-left: 2px;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-dim);
  animation: rise .5s var(--ease) backwards;
}

/* subtle count chip beside each heading */
.section-count {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0;
  color: var(--text-dim);
  background: var(--surface-hi);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 7px;
  line-height: 1.5;
}

/* ── grid ────────────────────────────────── */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(252px, 1fr));
  gap: 13px;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 19px;
  text-decoration: none;
  color: inherit;
  background: linear-gradient(180deg, #171a1f 0%, var(--surface) 42%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  isolation: isolate;
  animation: rise .5s var(--ease) backwards;
  /* top inner highlight — the card catches light from above */
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .045);
  transition: border-color .22s var(--ease), background .22s var(--ease),
              transform .22s var(--ease), box-shadow .22s var(--ease);
}

/* cursor spotlight, tinted with the service's own colour */
.card::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: radial-gradient(340px circle at var(--mx, 50%) var(--my, 0%),
              color-mix(in srgb, var(--accent) 13%, transparent), transparent 72%);
  opacity: 0;
  transition: opacity .3s var(--ease);
}
.card:hover::before, .card:focus-visible::before { opacity: 1; }

/* hairline of colour along the top edge */
.card::after {
  content: '';
  position: absolute;
  top: 0; left: 18%; right: 18%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0;
  transition: opacity .3s var(--ease), left .35s var(--ease), right .35s var(--ease);
}
.card:hover::after, .card:focus-visible::after { opacity: .85; left: 0; right: 0; }

.card:hover {
  background: linear-gradient(180deg, #1e222a 0%, var(--surface-hi) 45%);
  border-color: color-mix(in srgb, var(--accent) 34%, var(--border));
  transform: translateY(-3px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .075),
    0 18px 34px -18px rgba(0, 0, 0, .9),
    0 6px 14px -10px color-mix(in srgb, var(--accent) 55%, transparent);
}
.card:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 15px;
}

.card-icon {
  width: 36px; height: 36px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background:
    linear-gradient(180deg,
      color-mix(in srgb, var(--accent) 18%, transparent),
      color-mix(in srgb, var(--accent) 8%, transparent));
  border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
  box-shadow: inset 0 1px 0 color-mix(in srgb, var(--accent) 28%, transparent);
  color: var(--accent);
  flex: none;
  transition: transform .22s var(--ease), box-shadow .22s var(--ease);
}
.card:hover .card-icon {
  transform: scale(1.07) translateY(-1px);
  box-shadow:
    inset 0 1px 0 color-mix(in srgb, var(--accent) 40%, transparent),
    0 6px 16px -6px color-mix(in srgb, var(--accent) 60%, transparent);
}
.card-icon svg { width: 19px; height: 19px; }

.card-arrow {
  width: 15px; height: 15px;
  color: var(--accent);
  opacity: 0;
  transform: translate(-4px, 4px);
  transition: opacity .22s var(--ease), transform .22s var(--ease);
}
.card:hover .card-arrow, .card:focus-visible .card-arrow { opacity: 1; transform: none; }

.card-name {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 15.5px;
  font-weight: 600;
  letter-spacing: -0.012em;
  margin-bottom: 5px;
}

.lock {
  width: 13px;
  height: 13px;
  flex: none;
  color: var(--text-dim);
  transition: color .2s var(--ease);
}
.card:hover .lock { color: var(--indigo); }

.card-desc {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.55;
  margin-bottom: 17px;
  flex: 1;
}

.card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 13px;
  border-top: 1px solid var(--border);
}

.card-host {
  flex: 1;
  min-width: 0;
  font-size: 12.5px;
  color: var(--text-mid);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color .2s var(--ease);
}
.card:hover .card-host { color: var(--text); }

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--text-dim);
  flex: none;
}
.status-dot {
  position: relative;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text-dim);
  flex: none;
}
.status-dot::after {
  content: '';
  position: absolute;
  inset: -3.5px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0;
}
.status[data-state="checking"] .status-dot { background: var(--amber); }
.status[data-state="checking"] { color: var(--amber); animation: breathe 1.1s var(--ease) infinite; }
@keyframes breathe { 0%, 100% { opacity: .45; } 50% { opacity: .95; } }
.status[data-state="online"] .status-dot { background: var(--green); color: var(--green); }
.status[data-state="online"] .status-dot::after { animation: halo 2.6s var(--ease) infinite; }
.status[data-state="online"] { color: #8fdcae; }
.status[data-state="protected"] .status-dot { background: var(--indigo); color: var(--indigo); }
.status[data-state="protected"] .status-dot::after { animation: halo 2.6s var(--ease) infinite; }
.status[data-state="protected"] { color: #b3bbff; }
.status[data-state="offline"] .status-dot { background: var(--red); }
.status[data-state="offline"] { color: #eda1a1; }

.status { cursor: help; }

.latency {
  font-size: 11px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.latency::before { content: '·'; margin-right: 5px; opacity: .55; }
.latency[data-grade="slow"] { color: var(--amber); }

.card.hidden { display: none; }

/* ── empty + footer ──────────────────────── */

.empty {
  padding: 40px 0;
  text-align: center;
  color: var(--text-dim);
  font-size: 13.5px;
}

.footer {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 12.5px;
}
.footer-sep { color: var(--border-hi); }
.tunnel { display: inline-flex; align-items: center; gap: 6px; }
.tunnel-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: #f6821f;
  opacity: .85;
}
.footer-time { margin-left: auto; font-variant-numeric: tabular-nums; }

/* ── responsive ──────────────────────────── */

@media (max-width: 640px) {
  .page { padding: 44px 18px 40px; }
  .header { flex-direction: column; align-items: flex-start; gap: 18px; }
  .header h1 { font-size: 28px; }
  .slash-hint { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}
