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

:root {
  --bg-deep:    #080c18;
  --bg-mid:     #0d1428;
  --accent-blue: #4f8ef7;
  --accent-purple: #7b5ea7;
  --text-primary: #e8eeff;
  --text-muted:   #7a90c0;
  --glass-bg:   rgba(10, 18, 40, 0.72);
  --glass-border: rgba(79, 142, 247, 0.18);
}

html, body {
  height: 100%;
  background: var(--bg-deep);
  color: var(--text-primary);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  overflow-x: hidden;
}

/* Starfield canvas */
#starfield {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

/* Nav */
.topnav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  height: 64px;
  background: rgba(8, 12, 24, 0.6);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--glass-border);
}

.nav-logo img { display: block; }
.nav-actions { display: flex; align-items: center; gap: 1rem; }
.nav-user { color: var(--text-muted); font-size: 0.9rem; }

/* Buttons */
.btn {
  display: inline-block;
  padding: 0.45rem 1.2rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
}
.btn-primary {
  background: var(--accent-blue);
  color: #fff;
}
.btn-primary:hover { background: #3a78e0; }
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--glass-border);
}
.btn-ghost:hover { color: var(--text-primary); border-color: var(--accent-blue); }

.btn-cta {
  display: inline-block;
  padding: 0.9rem 2.5rem;
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
  color: #fff;
  font-size: 1.1rem;
  font-weight: 600;
  border-radius: 12px;
  text-decoration: none;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 4px 24px rgba(79, 142, 247, 0.3);
}
.btn-cta:hover { transform: translateY(-2px); box-shadow: 0 8px 32px rgba(79, 142, 247, 0.45); }

/* Gradient text */
.gradient-text {
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ---- HOME PAGE ---- */
.home-page .home-main {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding-top: 64px;
}

.hero {
  text-align: center;
  padding: 2rem;
}
.hero-title {
  font-size: clamp(3rem, 8vw, 6rem);
  font-weight: 800;
  letter-spacing: -1px;
  line-height: 1.1;
  margin-bottom: 1rem;
}
.hero-sub {
  font-size: 1.2rem;
  color: var(--text-muted);
  margin-bottom: 3rem;
  letter-spacing: 0.5px;
}

/* Portal button */
.btn-portal {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 3rem;
  background: transparent;
  border: 2px solid;
  border-image: linear-gradient(135deg, var(--accent-blue), var(--accent-purple)) 1;
  color: var(--text-primary);
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: 1px;
  cursor: pointer;
  transition: all 0.3s;
  border-radius: 0;
  background: linear-gradient(135deg, rgba(79,142,247,0.1), rgba(123,94,167,0.1));
}
.btn-portal:hover {
  background: linear-gradient(135deg, rgba(79,142,247,0.2), rgba(123,94,167,0.2));
  box-shadow: 0 0 40px rgba(79,142,247,0.3), 0 0 80px rgba(123,94,167,0.15);
  transform: scale(1.03);
}
.portal-btn-icon {
  font-size: 1.4rem;
  animation: spin-slow 6s linear infinite;
}
@keyframes spin-slow { to { transform: rotate(360deg); } }

/* Portal overlay animation */
.portal-overlay {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
}
.portal-overlay.hidden { display: none; }
#portalCanvas { position: absolute; inset: 0; width: 100%; height: 100%; }

/* ---- PORTAL PAGE ---- */
.portal-page .portal-main {
  position: relative;
  z-index: 10;
  min-height: 100vh;
  padding: 100px 2rem 4rem;
  max-width: 900px;
  margin: 0 auto;
}

.portal-title {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
}
.portal-sub {
  color: var(--text-muted);
  margin-bottom: 2.5rem;
  font-size: 1rem;
}

.service-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.25rem;
}

.service-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-left: 3px solid var(--accent, var(--accent-blue));
  border-radius: 12px;
  text-decoration: none;
  color: var(--text-primary);
  backdrop-filter: blur(12px);
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
  box-shadow: 0 2px 16px rgba(0,0,0,0.3);
}
.service-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4), 0 0 0 1px var(--accent, var(--accent-blue));
}
.service-icon { font-size: 2rem; flex-shrink: 0; }
.service-info { flex: 1; }
.service-name { font-weight: 600; font-size: 1rem; margin-bottom: 0.2rem; }
.service-desc { font-size: 0.8rem; color: var(--text-muted); }
.service-arrow { color: var(--text-muted); font-size: 1.1rem; flex-shrink: 0; transition: transform 0.2s; }
.service-card:hover .service-arrow { transform: translateX(4px); color: var(--accent, var(--accent-blue)); }

.no-services {
  grid-column: 1/-1;
  text-align: center;
  padding: 3rem;
  color: var(--text-muted);
  background: var(--glass-bg);
  border-radius: 12px;
  border: 1px dashed var(--glass-border);
}

/* ─── Service-card icon for portal grid ──────────────────────────────────── */
.svc-icon-svg {
  width: 32px;
  height: 32px;
  display: block;
  border-radius: 8px;
  object-fit: cover;
}

/* ─── Portal sections (grouped tile rows) ────────────────────────────────── */
.portal-section { margin-bottom: 2.5rem; }
.portal-section-title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text-primary);
  margin: 0 0 0.25rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--glass-border);
}
.portal-section-sub {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin: 0 0 1rem;
}
.portal-section-title + .service-grid { margin-top: 1rem; }

/* ─── Featured weather banner (replaces Ryan Weather tile) ────────────────── */
.weather-banner {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 1.25rem 1.5rem;
  margin-bottom: 2.5rem;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-left: 3px solid #38bdf8;
  border-radius: 12px;
  text-decoration: none;
  color: var(--text-primary);
  backdrop-filter: blur(12px);
  box-shadow: 0 2px 16px rgba(0,0,0,0.3);
  transition: transform 0.2s, box-shadow 0.2s;
  cursor: pointer;
}
.weather-banner:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4), 0 0 0 1px #38bdf8;
}
.weather-current { display: flex; align-items: center; gap: 1rem; flex-shrink: 0; }
.weather-now-emoji { font-size: 2.75rem; line-height: 1; }
.weather-now-temp { font-size: 2.25rem; font-weight: 700; line-height: 1; }
.weather-now-cond { font-size: 0.95rem; color: var(--text-primary); margin-top: 0.15rem; }
.weather-now-meta { font-size: 0.78rem; color: var(--text-muted); margin-top: 0.15rem; }

.weather-forecast {
  display: flex;
  gap: 0.5rem;
  flex: 1;
  justify-content: flex-end;
}
.weather-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  min-width: 56px;
  padding: 0.35rem 0.4rem;
  border-radius: 10px;
  background: rgba(255,255,255,0.03);
}
.weather-day-label { font-size: 0.72rem; color: var(--text-muted); }
.weather-day-emoji { font-size: 1.4rem; line-height: 1; }
.weather-day-temps { font-size: 0.78rem; white-space: nowrap; }
.weather-day-temps .wx-hi { font-weight: 700; }
.weather-day-temps .wx-lo { color: var(--text-muted); }
.weather-go { font-size: 0.82rem; color: #38bdf8; flex-shrink: 0; align-self: flex-start; }

/* ─── Related-card pair (QuackFlix On Plex + Media Requests) ──────────────── */
/* Two cards wrapped in a thin light ring to show they're related. The ring is a
   1px `outline` offset into the gutter (follows the rounded corners, adds no
   layout box so it never shifts/shrinks the cards). Base = mobile (flex column). */
.qf-pair {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;               /* match .service-grid gap so the two cards line up */
  border-radius: 16px;
  background: rgba(229,160,13,0.04);
  outline: 2px solid rgba(229,160,13,0.5);
  outline-offset: 8px;
}

/* Desktop: force 3 columns for the QuackFlix section and pin the pair to the
   right column. The pair is a SUBGRID so its two cards borrow the parent's
   row tracks — Plex lands exactly in row 1, Media Requests in row 2, each
   stretching to match the height of the left-column cards in that row. */
@media (min-width: 641px) {
  .section-quackflix .service-grid { grid-template-columns: repeat(3, 1fr); }
  .section-quackflix .service-grid .qf-pair {
    grid-column: 3;
    display: grid;
    grid-template-columns: 1fr;
    outline-offset: 10px;
  }
  /* Only span + subgrid-align both rows when the pair holds two cards. */
  .section-quackflix .service-grid .qf-pair:has(> .service-card:nth-child(2)) {
    grid-template-rows: subgrid;
    grid-row: 1 / span 2;
  }
  /* QuackTunes: full-width thin bar under the six QuackFlix tiles (desktop only).
     On mobile it stays a normal 1-col card, rendered last (after the Plex pair). */
  .section-quackflix .service-grid .service-card-bar {
    grid-column: 1 / -1;
    padding-top: 0.8rem;
    padding-bottom: 0.8rem;
  }
}

/* ─── Global wrap safety on small screens ──────────────────────────────── */
/* Anything monospace / long-token (config blocks, IPs, URLs, hashes) must
   either wrap or scroll inside its container — never push the page wide. */
@media (max-width: 640px) {
  pre, code { overflow-wrap: anywhere; word-break: break-word; }
  pre { white-space: pre-wrap; }
  /* …but keep pre blocks that are explicitly meant to scroll (wireguard
     conf, etc.) horizontally scrollable inside their card */
  .vpn-conf-text, .livetv-section pre { white-space: pre; }

  img, svg, video { max-width: 100%; height: auto; }

  /* Topnav: tighter padding + hide username text on tiny screens so the
     Sign Out / back-link button always fits */
  .topnav { padding: 0 0.85rem; gap: 0.5rem; }
  .nav-actions { gap: 0.5rem; }
  .nav-logo img { height: 36px !important; }
  .nav-user { display: none; }
  .btn { padding: 0.4rem 0.85rem; font-size: 0.85rem; }

  /* Main containers — reduce side padding so cards aren't a thin column */
  .portal-page .portal-main {
    padding: 84px 0.9rem 3rem;
  }
  .home-page .home-main { padding-top: 72px; }
  .hero { padding: 1.2rem 0.5rem; }
  .hero-sub { font-size: 1rem; margin-bottom: 2rem; }

  .btn-portal { padding: 0.85rem 2rem; font-size: 1rem; }
  .btn-cta { padding: 0.75rem 1.6rem; font-size: 1rem; }

  .portal-title { font-size: 1.5rem; }
  .portal-sub { font-size: 0.92rem; margin-bottom: 1.6rem; }

  .service-grid { grid-template-columns: 1fr; gap: 0.8rem; }
  .service-card { padding: 1rem 1.1rem; }

  /* Sections tighten up on phones */
  .portal-section { margin-bottom: 1.8rem; }
  .portal-section-title { font-size: 1.05rem; }

  /* Weather banner stacks; forecast row scrolls horizontally instead of
     forcing the page wide (min-width:0 lets the flex child shrink). */
  .weather-banner { flex-direction: column; align-items: stretch; gap: 1rem; padding: 1rem 1.1rem; }
  .weather-current { justify-content: flex-start; }
  .weather-now-emoji { font-size: 2.25rem; }
  .weather-now-temp { font-size: 1.9rem; }
  .weather-forecast {
    justify-content: flex-start;
    min-width: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0.25rem;
  }
  .weather-day { flex: 0 0 auto; }
  .weather-go { align-self: flex-end; }

  /* Pair flows as the last two cards (Plex 5th, Media Requests 6th) inside a
     thin band; tighten gap + ring to match the mobile single-column grid. */
  .qf-pair { gap: 0.8rem; outline-offset: 7px; }
}

