/* PiHub Portal — builds on /static/css/universal.css tokens */

* {
  -webkit-tap-highlight-color: transparent;
  box-sizing: border-box;
}
html { -webkit-text-size-adjust: 100%; }
html[data-theme="dark"] { color-scheme: dark; }

.no-scrollbar { scrollbar-width: none; }
.no-scrollbar::-webkit-scrollbar { display: none; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--pi-border-strong); border-radius: 9999px; }

/* ── Header ─────────────────────────────────────────────── */
.portal-logo {
  width: 28px; height: 28px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--pi-on-accent);
  background: var(--pi-accent);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
  flex-shrink: 0;
}
.portal-search-trigger { min-width: var(--pi-btn-h); }
.portal-kbd {
  display: inline-flex; align-items: center;
  font: 500 11px/1 var(--pi-font);
  color: var(--pi-text-dim);
  border: 1px solid var(--pi-border);
  border-radius: 4px;
  padding: 3px 5px;
}

.portal-menu {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 60;
  min-width: 190px; padding: 4px;
  background: var(--pi-surface-card);
  border: 1px solid var(--pi-border-strong);
  border-radius: var(--pi-radius-panel);
  box-shadow: var(--pi-shadow-pop);
}
.portal-menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 10px; border: none; border-radius: 6px;
  background: transparent; color: var(--pi-text);
  font: 500 13px var(--pi-font); text-align: left; text-decoration: none;
  cursor: pointer;
}
.portal-menu-item i { width: 14px; font-size: 12px; color: var(--pi-text-muted); }
.portal-menu-item:hover { background: var(--pi-surface-hover); }
.portal-menu-sep { height: 1px; margin: 4px 6px; background: var(--pi-border); }

/* ── Page ───────────────────────────────────────────────── */
.portal-main {
  display: flex; flex-direction: column;
  gap: clamp(20px, 3vw, 32px);
  padding-block: clamp(20px, 4vw, 40px);
}
@media (max-height: 560px) { .portal-main { padding-block: 14px; gap: 14px; } }

/* ── Headings ───────────────────────────────────────────── */
.portal-title {
  margin: 0;
  font-size: var(--pi-fs-2xl);
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--pi-text);
}
.portal-subtitle { margin: 0; font-size: var(--pi-fs-base); color: var(--pi-muted); }
.portal-link {
  background: none; border: none; padding: 0; cursor: pointer;
  font: 500 var(--pi-fs-sm) var(--pi-font); color: var(--pi-muted);
}
.portal-link:hover { color: var(--pi-text); }

/* ── Service cards ──────────────────────────────────────── */
.portal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
  gap: var(--pi-gap);
}
.portal-list { display: flex; flex-direction: column; gap: 6px; }

.service-card {
  position: relative;
  display: flex;
  background: var(--pi-surface-card);
  border: 1px solid var(--pi-border);
  border-radius: var(--pi-radius-panel);
  color: var(--pi-text);
  text-decoration: none;
  transition: border-color 0.15s, background-color 0.15s;
}
a.service-card:hover, .service-card:has(> a:hover) {
  border-color: var(--pi-border-strong);
  background: var(--pi-raised);
}
.service-card-grid { flex-direction: column; gap: 12px; padding: 16px; min-height: 148px; }
@media (max-height: 560px) { .service-card-grid { min-height: 0; padding: 12px; gap: 8px; } }
.service-card-row { align-items: center; gap: 12px; padding: 10px 12px; }

.service-icon {
  width: 40px; height: 40px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  color: var(--tone);
  background: color-mix(in srgb, var(--tone) 14%, transparent);
}
.service-card-row .service-icon { width: 34px; height: 34px; font-size: 14px; border-radius: 9px; }

.service-name { font-size: var(--pi-fs-base); font-weight: 600; letter-spacing: -0.01em; margin: 0; }
.service-desc {
  font-size: var(--pi-fs-sm); line-height: 1.45; color: var(--pi-muted); margin: 0;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.service-meta { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--pi-text-dim); }

.service-status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--pi-text-muted); white-space: nowrap; }
.service-status .pi-dot { color: var(--pi-success); }
.service-status.is-down { color: var(--pi-danger); }
.service-status.is-down .pi-dot { color: var(--pi-danger); }

.service-copy {
  position: relative; z-index: 2;
  width: var(--pi-btn-h-sm); height: var(--pi-btn-h-sm); border-radius: var(--pi-radius); border: none;
  background: transparent; color: var(--pi-text-dim); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; font-size: 11px;
  opacity: 0; transition: opacity 0.12s, background-color 0.12s, color 0.12s;
}
.service-card:hover .service-copy, .service-copy:focus-visible { opacity: 1; }
.service-copy:hover { background: var(--pi-surface-hover); color: var(--pi-text); }
@media (hover: none) { .service-copy { opacity: 1; } }

/* Whole card is the launch target; the copy button sits above it */
.service-link { position: absolute; inset: 0; border-radius: inherit; z-index: 1; }

.portal-recent {
  display: inline-flex; align-items: center; gap: 8px; flex-shrink: 0;
  height: var(--pi-btn-h); padding: 0 12px 0 6px; border-radius: var(--pi-radius);
  background: var(--pi-surface-card); border: 1px solid var(--pi-border);
  color: var(--pi-text); font: 500 13px var(--pi-font); text-decoration: none;
}
.portal-recent:hover { border-color: var(--pi-border-strong); }
.portal-recent .service-icon { width: 24px; height: 24px; font-size: 11px; border-radius: 6px; }

.portal-empty {
  grid-column: 1 / -1;
  padding: 48px 16px; text-align: center;
  border: 1px dashed var(--pi-border-strong); border-radius: var(--pi-radius-panel);
  color: var(--pi-text-muted); font-size: 13px;
}

.portal-skeleton { height: 148px; animation: portalPulse 1.4s ease-in-out infinite; }
@keyframes portalPulse { 50% { opacity: 0.55; } }

/* Tones map the service catalogue's `color` field */
.tone-indigo  { --tone: #6366f1; }
.tone-violet  { --tone: #8b5cf6; }
.tone-purple  { --tone: #a855f7; }
.tone-cyan    { --tone: #06b6d4; }
.tone-sky     { --tone: #0ea5e9; }
.tone-blue    { --tone: #3b82f6; }
.tone-teal    { --tone: #14b8a6; }
.tone-emerald { --tone: #10b981; }
.tone-green   { --tone: #22c55e; }
.tone-amber   { --tone: #f59e0b; }
.tone-yellow  { --tone: #eab308; }
.tone-orange  { --tone: #f97316; }
.tone-rose    { --tone: #f43f5e; }
.tone-red     { --tone: #ef4444; }
.tone-pink    { --tone: #ec4899; }
.tone-slate   { --tone: #64748b; }

/* ── Overlays ───────────────────────────────────────────── */
.portal-scrim { background: var(--pi-scrim); }
.portal-step { padding: 12px; border-radius: var(--pi-radius); background: var(--pi-surface-hover); border: 1px solid var(--pi-border); }

.spotlight-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px; border-radius: 8px; cursor: pointer; color: var(--pi-text);
}
.spotlight-item.is-selected, .spotlight-item:hover { background: var(--pi-surface-hover); }
.spotlight-item .service-icon { width: 30px; height: 30px; font-size: 12px; border-radius: 8px; }

.portal-footer {
  margin-top: auto;
  border-top: 1px solid var(--pi-border);
  padding-block: 18px;
  font-size: 12px;
  color: var(--pi-text-dim);
}

/* Device adaptations */
[data-screen="pi-display"] .portal-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 639px) {
  .service-card-grid { min-height: 0; }
}
