/* The service panel (docs/adr/0030-canvas-console.md §4): the right-hand panel
   over the canvas that an app, a database, a Redis instance or a create form
   opens in. panel.js draws the frame — grip, header, tab row, a scrolling body —
   and the object's own module fills it. Colours are tokens from app.css. */

/* ---- the frame ------------------------------------------------------------- */

.svc-panel {
  position: relative;
  display: flex;
  flex: none;
  width: max(560px, 55%);
  min-width: min(560px, 100%);
  max-width: 100%;
  height: 100%;
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: var(--panel-shadow);
  /* The body is a size container, so a section can lay itself out by the
     panel's width rather than the window's. */
  container-type: inline-size;
  container-name: svc;
}

.svc-panel.expanded { width: 100%; }
.svc-panel.enter { animation: svc-in 220ms var(--ease) both; }
.svc-panel.resizing { user-select: none; }
.svc-panel.resizing, .svc-panel.resizing * { cursor: col-resize; }

@keyframes svc-in {
  from { transform: translateX(28px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.svc-frame {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
}

/* The grip is the panel's left edge: 8px of target over a hairline that
   lights up under the pointer. */
.svc-grip {
  position: absolute;
  top: 0;
  bottom: 0;
  left: -4px;
  width: 8px;
  z-index: 3;
  cursor: col-resize;
  touch-action: none;
}
.svc-grip::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 3px;
  width: 2px;
  background: transparent;
  transition: background var(--dur) var(--ease);
}
.svc-grip:hover::after,
.svc-grip:focus-visible::after,
.svc-panel.resizing .svc-grip::after { background: var(--accent); }
.svc-grip:focus-visible { outline: none; }
.svc-panel.expanded .svc-grip { display: none; }

/* ---- the header ------------------------------------------------------------ */

.svc-head {
  flex: none;
  padding: var(--sp-4) var(--sp-5) 0;
}

.svc-head-row {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  min-width: 0;
}

.svc-mark {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--ink-2);
}
.svc-mark .icon { width: 18px; height: 18px; }
.svc-mark.kind-app { color: var(--accent); background: var(--accent-soft); border-color: var(--accent-line); }

.svc-title { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.svc-name-row { display: flex; align-items: center; gap: var(--sp-3); min-width: 0; flex-wrap: wrap; }
.svc-name {
  margin: 0;
  font-size: 20px;
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.25;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.svc-status { display: inline-flex; align-items: center; }
.svc-sub {
  display: flex;
  align-items: center;
  gap: var(--sp-2) var(--sp-3);
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--ink-2);
  min-width: 0;
}
.svc-sub-text { min-width: 0; overflow-wrap: anywhere; }
.svc-url { min-width: 0; overflow-wrap: anywhere; }
.svc-url:empty { display: none; }

.svc-actions {
  flex: none;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}
.svc-actions > .pop-host:empty, .svc-actions > span:empty { display: none; }
.svc-close { margin-left: var(--sp-1); }

/* ---- the tab row ----------------------------------------------------------- */

.svc-tabs {
  flex: none;
  padding: 0 var(--sp-5);
  border-bottom: 1px solid var(--line);
}
.svc-tabs .tabs.svc-tabrow {
  margin: var(--sp-3) 0 0;
  border-bottom: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.svc-tabs .tabs.svc-tabrow::-webkit-scrollbar { display: none; }
.svc-tabs .tabs.svc-tabrow button { white-space: nowrap; }
.svc-head:has(+ .svc-tabs[hidden]) { padding-bottom: var(--sp-4); border-bottom: 1px solid var(--line); }

/* ---- the body -------------------------------------------------------------- */

.svc-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--ground);
}

.svc-pane { padding: var(--sp-5); min-width: 0; }
.svc-pane > .cards, .svc-pane > * + * { min-width: 0; }
.svc-state { padding: var(--sp-6) var(--sp-5); display: flex; flex-direction: column; gap: var(--sp-3); align-items: flex-start; }

/* A two-column block from the kit reads as one column in a panel narrower
   than a page; an expanded panel gets its rail back. A create form is the
   exception: its rail holds the summary and the Create button, so it keeps
   the rail for as long as its own pane is wide enough (screens-data.css,
   .create-pane) and the rail sticks to the top of the panel's scroll. */
.svc-panel .twocol:not(.create-pane .twocol) { grid-template-columns: minmax(0, 1fr); }
@container svc (min-width: 1100px) {
  .svc-panel .twocol:not(.create-pane .twocol) { grid-template-columns: minmax(0, 1fr) var(--rail); }
}
.svc-panel .create-pane .rail { top: 0; }

/* Full width is for reading, not for rows 1500px long: the header, the tabs
   and the content keep a measure and sit in the middle. */
.svc-panel.expanded .svc-head-row,
.svc-panel.expanded .svc-tabs .tabs.svc-tabrow {
  max-width: 1240px;
  margin-inline: auto;
}
/* The pane's own padding is inside its box, so it is added to the measure to
   line its cards up with the header above. */
.svc-panel.expanded .svc-pane { max-width: calc(1240px + 2 * var(--sp-5)); margin-inline: auto; }

@media (max-width: 639px) {
  .svc-panel { width: 100%; min-width: 0; }
  .svc-grip { display: none; }
  .svc-head { padding: var(--sp-3) var(--sp-4) 0; }
  .svc-tabs { padding: 0 var(--sp-4); }
  .svc-pane { padding: var(--sp-4); }
}

@media (prefers-reduced-motion: reduce) {
  .svc-panel.enter { animation: none; }
  .svc-grip::after { transition: none; }
}
