/* Project cards + portfolio Services table, ported from local Ring
   (theonering dashboard.css / layout.css) so the cloud home + services match
   its look. Loaded AFTER styles.css so these win over the cloud's older
   .project-card rules. Tokens are identical between the two apps, so the
   rules are verbatim except: a padding:0 reset on .project-card (the old
   cloud rule set padding), a .status-dot.orphan variant, and the grid rule
   also targets the cloud's .projects-grid container class. */

/* ---- Grid ---------------------------------------------------------- */
.project-grid,
.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

/* ---- Project card -------------------------------------------------- */
.project-card {
  position: relative;
  padding: 0;                 /* neutralize the old cloud .project-card padding */
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.2s, transform 0.15s;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  outline: none;
}
.project-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}
.project-card:active { transform: translateY(0); box-shadow: var(--shadow); transition-duration: 0.05s; }
.project-card:focus-visible { border-color: var(--primary); box-shadow: 0 0 0 3px var(--accent-brand-bg), var(--shadow); }
.project-card:hover .project-card-title { color: var(--primary); }

.project-card-head { padding: 16px 18px 10px; display: flex; align-items: flex-start; gap: 10px; }
.project-card-title-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.project-card-title { font-weight: 600; font-size: 15px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; transition: color 0.15s; }
.project-card-folder { font-family: var(--font-mono); font-size: 11px; color: var(--text-subtle); display: flex; align-items: center; gap: 2px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-card-folder-sep { opacity: 0.5; }

/* Geometry + ramp come from the shared dot rule in styles.css. Only the
   size override is local: this dot leads a card title, not a table row. */
.status-dot { width: 10px; height: 10px; }
.status-dot.active { box-shadow: 0 0 9px var(--sig-ok-glow); }
.status-dot.disappeared { background: var(--sig-warn); box-shadow: 0 0 9px var(--sig-warn-glow); }

.project-card-links { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 18px 0; }
.project-card-links:empty { display: none; }

/* A count and a route out — never the detail (ADR 0010 D8). */
.project-card-link,
.project-card-services {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px;
  background: transparent; border: 1px solid var(--border); border-radius: 10px; color: var(--text-muted);
  font-family: var(--font-mono); font-size: 11px; cursor: pointer;
  transition: background 120ms, border-color 120ms, color 120ms; align-self: flex-start;
}
.project-card-link:hover, .project-card-services:hover { background: var(--bg-subtle); border-color: var(--border-strong); color: var(--text); }
.project-card-services-text { white-space: nowrap; }
.project-card-link { text-decoration: none; }
/* .svc-dot-bullet inherits the shared rule entirely; only the two states
   the shared rule does not name need saying. */
.svc-dot-bullet.error { background: var(--sig-warn); box-shadow: 0 0 8px var(--sig-warn-glow); }
.svc-dot-bullet.unknown { background: var(--sig-idle); opacity: 0.6; }

.project-card-tags { padding: 8px 18px 0; display: flex; flex-wrap: wrap; gap: 4px; }
.tag { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; padding: 2px 7px; border-radius: 999px; background: var(--primary-bg); color: var(--primary); }

.project-card-meta { padding: 12px 18px; color: var(--text-muted); font-size: 12px; display: flex; gap: 12px; flex-wrap: wrap; }
.project-card-meta-item { display: flex; align-items: center; gap: 4px; }

.project-card-summary { padding: 8px 18px 0; color: var(--text-muted); font-size: 13px; line-height: 1.4; }

/* ---- Subprojects block (G1) — indented rows inside the parent card -- */
.project-card-children { margin: 10px 18px 0; border-top: 1px solid var(--border); padding-top: 8px; }
.project-card-children-title { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); margin-bottom: 4px; }
.child-row { display: flex; align-items: center; gap: 8px; padding: 5px 6px; border-radius: var(--radius); cursor: pointer; font-size: 13px; }
.child-row:hover { background: var(--primary-bg); }
.child-row-name { color: var(--text); font-weight: 500; }
.child-row-meta { color: var(--text-muted); font-size: 11px; margin-left: auto; }

.projects-grid-notice { grid-column: 1 / -1; }

/* ---- Section header + empty state ---------------------------------- */
.section-header { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 16px; }
.section-header h2 { font-size: 18px; font-weight: 600; color: var(--text); }
.section-meta { color: var(--text-muted); font-size: 13px; font-family: var(--font-mono); }
.section-header-left { display: flex; align-items: baseline; gap: 12px; }
.section-actions { display: flex; gap: 8px; align-items: center; }
.empty-state { padding: 48px 24px; text-align: center; color: var(--text-muted); background: var(--bg-card); border: 1px dashed var(--border-strong); border-radius: var(--radius-lg); }
.empty-state h3 { color: var(--text); margin-bottom: 6px; }
.empty-icon { font-size: 48px; margin-bottom: 12px; opacity: 0.4; }

.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ---- Portfolio Services table -------------------------------------- */
.portfolio-filter { display: inline-flex; background: var(--bg-subtle); border: 1px solid var(--border); border-radius: var(--radius); padding: 2px; gap: 0; }
.portfolio-filter button { background: transparent; border: none; padding: 5px 12px; font-family: inherit; font-size: 12px; color: var(--text-muted); cursor: pointer; border-radius: calc(var(--radius) - 2px); transition: background 120ms, color 120ms; }
.portfolio-filter button:hover { color: var(--text); }
.portfolio-filter button.active { background: var(--bg-card); color: var(--text); box-shadow: var(--shadow-sm); }
.portfolio-conflicts-banner { margin-bottom: 12px; padding: 10px 14px; background: var(--sig-warn-bg); border: 1px solid rgba(255,179,64,.35); border-radius: var(--radius); font-size: 12px; color: var(--text); }
.portfolio-conflicts-banner.hidden { display: none; }
.portfolio-conflicts-banner strong { margin-right: 8px; }
.portfolio-conflicts-banner code { background: var(--bg-subtle); padding: 1px 5px; border-radius: 3px; font-family: var(--font-mono); font-size: 11px; margin: 0 2px; }
.portfolio-table-wrap { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.portfolio-table { display: flex; flex-direction: column; }
.portfolio-row {
  display: grid;
  grid-template-columns: minmax(120px, 1.2fr) minmax(160px, 1.4fr) 90px minmax(200px, 2fr) 70px 130px 90px;
  align-items: center; gap: 14px; padding: 9px 14px; font-size: 12px;
  border-bottom: 1px solid var(--border); transition: background 120ms;
}
/* Per-project Services pane variant — no Project / Port columns. */
.portfolio-row-5 { grid-template-columns: minmax(160px, 1.4fr) 90px minmax(200px, 2fr) 150px 110px; }
.portfolio-row > * { min-width: 0; }
.portfolio-row:last-child { border-bottom: none; }
.portfolio-row:not(.portfolio-row-head):hover { background: var(--bg-subtle); }
.portfolio-row-head { background: var(--bg-subtle); color: var(--text-muted); font-family: var(--font-mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em; padding: 9px 14px; font-weight: 600; }
.portfolio-row-head > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.portfolio-row-head > span:last-child { text-align: right; }
.portfolio-project-link { background: transparent; border: none; color: var(--text); font-weight: 600; font-size: 12px; text-align: left; padding: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: inherit; }
.portfolio-service { font-family: var(--font-mono); font-size: 12px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.portfolio-ro { font-size: 9px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); border: 1px solid var(--border); border-radius: 4px; padding: 0 3px; }
.portfolio-env { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); text-transform: lowercase; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.portfolio-url { font-family: var(--font-mono); font-size: 11px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-decoration: none; display: block; }
.portfolio-url:hover { text-decoration: underline; color: var(--primary); }
.portfolio-port { font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); display: inline-flex; align-items: center; gap: 4px; justify-self: start; }
.portfolio-port.conflict { color: var(--sig-warn); font-weight: 600; }
.portfolio-port-none { opacity: 0.5; }
.portfolio-conflict { font-size: 11px; color: var(--sig-warn); cursor: help; }
.portfolio-status { font-family: var(--font-mono); font-size: 11px; text-transform: lowercase; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.portfolio-status.up { color: var(--sig-ok); }
.portfolio-status.down, .portfolio-status.error { color: var(--sig-bad); }
.portfolio-status.unavailable { color: var(--sig-warn); }
.portfolio-row-unavailable { opacity: 0.75; }
.portfolio-url-none { color: var(--text-muted); font-style: italic; pointer-events: none; }
.portfolio-actions { display: flex; gap: 4px; justify-content: flex-end; align-items: center; }
.portfolio-actions .btn { padding: 3px 8px; font-size: 10px; min-width: 50px; text-align: center; }

/* Utility. The `.hidden` class was in use by views/services-view.js and
   views/deployments-view.js with NO rule backing it anywhere — so every
   `classList.add("hidden")` was a no-op and the Services pane's empty state
   could never be hidden. Found by looking at the rendered Deployments pane;
   no test could catch a missing stylesheet rule.

   !important because this is a utility that must beat whatever layout display
   a component sets on itself (.empty-state, .portfolio-*), regardless of
   source order. */
.hidden { display: none !important; }

/* ---- Project card lifecycle menu ----------------------------------- */
/* The card itself opens the project, so these live behind a deliberate
   second click. Admin-only actions that change what the whole machine sees
   should not be one stray click away from the thing you do fifty times a day. */
.project-card-menu-wrap { position: relative; margin-left: auto; flex: none; }
.project-card-menu-btn {
  background: transparent; border: 1px solid transparent; border-radius: 6px;
  color: var(--text-subtle); cursor: pointer; font-size: 15px; line-height: 1;
  padding: 2px 7px;
}
.project-card:hover .project-card-menu-btn { color: var(--text-muted); border-color: var(--border); }
.project-card-menu-btn:hover { color: var(--text) !important; background: var(--bg-subtle); }
.project-card-menu {
  position: absolute; top: calc(100% + 4px); right: 0; z-index: var(--z-dock);
  min-width: 168px; padding: 4px;
  background: var(--bg-subtle); border: 1px solid var(--border-strong);
  border-radius: 8px; box-shadow: var(--shadow-lg);
}
.project-card-menu[hidden] { display: none; }
.project-card-menu button {
  display: block; width: 100%; text-align: left;
  padding: 7px 10px; border: 0; border-radius: 6px; background: transparent;
  color: var(--text); font: inherit; font-size: 13px; cursor: pointer;
}
.project-card-menu button:hover { background: var(--bg-inset); }
.project-card-menu button.danger:hover { color: var(--sig-bad); }
.project-card-menu .menu-note {
  padding: 6px 10px 4px; font-size: 11px; color: var(--text-subtle); border-top: 1px solid var(--border);
  margin-top: 4px;
}

/* --- Archive ------------------------------------------------------------
   Ignored and Retired projects, which ProjectTree.cs keeps out of the grid
   above. Collapsed by default: the point of ignoring something is not to
   look at it. This exists so the decision is reversible without hand-calling
   the API, which is what made Ignore a one-way door. */
.archive { margin-top: 18px; border-top: 1px solid var(--border); padding-top: 10px; }
.archive-summary {
  cursor: pointer; list-style: none; user-select: none;
  font-size: 12px; color: var(--text-subtle); padding: 4px 2px; border-radius: 5px;
}
.archive-summary::-webkit-details-marker { display: none; }
.archive-summary::before { content: "▸ "; display: inline-block; transition: transform .12s; }
.archive[open] .archive-summary::before { transform: rotate(90deg); }
.archive-summary:hover { color: var(--text); }
.archive-list { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.archive-row {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 9px; border: 1px solid var(--border); border-radius: 7px;
  background: var(--bg-subtle); font-size: 12px;
}
.archive-status {
  flex: none; font-family: var(--font-mono); font-size: 10px;
  letter-spacing: .06em; text-transform: uppercase;
  padding: 2px 6px; border-radius: 4px;
}
.archive-status--ignored { background: var(--sig-idle-bg); color: var(--text-subtle); }
.archive-status--retired { background: var(--warning-bg); color: var(--sig-warn); }
.archive-name { font-weight: 600; color: var(--text); }
/* The path is the only thing here that can overflow, so it is the only thing
   allowed to truncate — the page body must never scroll sideways. */
.archive-path {
  flex: 1; min-width: 0; color: var(--text-subtle);
  font-family: var(--font-mono); font-size: 10px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.archive-row .btn-ghost { flex: none; }
