/*
 * theme.css — ToolPort's design system values.
 *
 * Direction: a control room for API ports. Dense and exact like Linear,
 * warm like a printed spec sheet: paper-warm neutrals, graphite ink, and one
 * signal orange that means "live / act". Space Grotesk for headings and
 * figures, DM Sans for reading, JetBrains Mono for endpoints and payloads.
 * Dark mode is a warm graphite panel with a brighter signal, not an inversion.
 */

:root {
  --canvas: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #efede7;
  --border: #e2dfd6;
  --border-strong: #bab6ab;
  --ink: #1c1b18;
  --muted: #625e56;
  --accent: #c2410c;
  --accent-hover: #a8380a;
  --accent-ink: #ffffff;
  --accent-text: #ad3a0a;
  --accent-strong: #8a2d08;
  --accent-soft: #fbe8dd;
  --accent-border: #f1bc9e;
  --success: #2f7a3c;
  --success-ink: #ffffff;
  --success-soft: #e1efe1;
  --success-strong: #24642f;
  --warning: #a16207;
  --warning-ink: #ffffff;
  --warning-soft: #f7ecd6;
  --warning-strong: #845005;
  --danger: #b42318;
  --danger-ink: #ffffff;
  --danger-soft: #f8e1de;
  --danger-strong: #9a1d14;
  --chart-1: #c2410c;
  --chart-2: #2f6f73;
  --chart-3: #5b4fc4;
  --chart-4: #a87a05;
  --chart-5: #3f7d3a;
  --chart-6: #a23b6e;

  --font-display: "Space Grotesk Variable", ui-sans-serif, system-ui, sans-serif;
  --font-body: "DM Sans Variable", ui-sans-serif, system-ui, sans-serif;
  --font-sans: "DM Sans Variable", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "JetBrains Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --display-weight: 600;
  --display-tracking: -0.025em;
  --eyebrow-tracking: 0.08em;

  --radius-btn: 8px;
  --radius-card: 12px;
  --radius-input: 8px;
  --border-w: 1px;
  --border-strong-w: 1px;
  --shadow-card: 0 1px 0 rgba(0, 0, 0, 0.03);
  --shadow-btn: none;
  --card-pad: 1.25rem;
  --btn-weight: 600;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --canvas: #131210;
  --surface: #1b1a17;
  --surface-2: #24231f;
  --border: #33312b;
  --border-strong: #57534a;
  --ink: #f2f0ea;
  --muted: #a7a297;
  --accent: #f4844a;
  --accent-hover: #f89a66;
  --accent-ink: #1d0d03;
  --accent-text: #f79a66;
  --accent-strong: #fbc19f;
  --accent-soft: #3a2216;
  --accent-border: #7a3a17;
  --success: #4ea35c;
  --success-ink: #0b1a0d;
  --success-soft: #1a2c1d;
  --success-strong: #86c991;
  --warning: #d69a2d;
  --warning-ink: #1d1303;
  --warning-soft: #33280f;
  --warning-strong: #e8c06e;
  --danger: #e5584b;
  --danger-ink: #1f0604;
  --danger-soft: #3a1714;
  --danger-strong: #f19a91;
  --chart-1: #f4844a;
  --chart-2: #5fb3b5;
  --chart-3: #9c92ee;
  --chart-4: #d9ab3a;
  --chart-5: #78b86f;
  --chart-6: #db7aa8;
}

/*
 * app.css — what no primitive covers: the app shell, the port lamps, the
 * endpoint strips, payload panes and the parameter grid. Tokens only.
 */

/* ---- Shell: a left rail on desktop, a drawer on a phone ------------------ */
.shell { min-height: 100vh; }
.side {
  position: fixed;
  inset: 0 auto 0 0;
  width: 15.5rem;
  display: flex;
  flex-direction: column;
  padding: 1.25rem 0.75rem;
  background: var(--surface);
  border-right: 1px solid var(--border);
  z-index: var(--z-drawer);
  transform: translateX(-100%);
  transition: transform 260ms var(--ease-out);
  overflow-y: auto;
}
.navopen:checked ~ .shell .side { transform: none; box-shadow: var(--shadow-raised); }
.side-scrim {
  position: fixed;
  inset: 0;
  background: color-mix(in srgb, var(--ink) 40%, transparent);
  z-index: var(--z-scrim);
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms var(--ease);
}
.navopen:checked ~ .shell .side-scrim { opacity: 1; pointer-events: auto; }
.mobile-bar {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: color-mix(in srgb, var(--canvas) 92%, transparent);
  border-bottom: 1px solid var(--border);
}
.main-pane { padding: 1.5rem 1rem 4rem; max-width: 92rem; }
@media (min-width: 64rem) {
  .mobile-bar, .side-scrim { display: none; }
  .side { transform: none; transition: none; }
  .main-pane { margin-left: 15.5rem; padding: 2.5rem 2.5rem 5rem; }
}

.side-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-btn);
  color: var(--muted);
  font-size: 0.9375rem;
  font-weight: 500;
  text-decoration: none;
  transition: background-color 150ms var(--ease), color 150ms var(--ease);
}
.side-link:hover { background: var(--surface-2); color: var(--ink); }
.side-link.is-active { background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; }

.crumb {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.875rem;
  color: var(--muted);
  text-decoration: none;
}
.crumb:hover { color: var(--ink); }

/* ---- The port lamp: the one thing that moves --------------------------- */
.lamp {
  position: relative;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 999px;
  background: var(--border-strong);
  flex-shrink: 0;
}
.lamp.is-on { background: var(--success); }
.lamp.is-on::after {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 999px;
  border: 1.5px solid var(--success);
  opacity: 0;
  animation: lamp-pulse 2.4s var(--ease-out) infinite;
}
@keyframes lamp-pulse {
  0% { transform: scale(0.6); opacity: 0.7; }
  70%, 100% { transform: scale(1.6); opacity: 0; }
}

/* ---- Endpoints and method tags ---------------------------------------- */
.endpoint {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--muted);
}
.method {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 3.5rem;
  height: 1.375rem;
  padding: 0 0.375rem;
  border-radius: 5px;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  flex-shrink: 0;
  background: var(--surface-2);
  color: var(--ink);
}
.method-get { background: var(--success-soft); color: var(--success-strong); }
.method-post { background: var(--accent-soft); color: var(--accent-strong); }
.method-put, .method-patch { background: var(--warning-soft); color: var(--warning-strong); }
.method-delete { background: var(--danger-soft); color: var(--danger-strong); }

/* ---- Key figures: a ruled strip, not four floating cards ---------------- */
.figures {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  overflow: hidden;
}
@media (min-width: 64rem) { .figures { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.figure { padding: 1.25rem 1.5rem; border-color: var(--border); border-style: solid; border-width: 0; }
.figure:nth-child(odd) { border-right-width: 1px; }
.figure:nth-child(-n + 2) { border-bottom-width: 1px; }
@media (min-width: 64rem) {
  .figure { border-width: 0; }
  .figure + .figure { border-left-width: 1px; }
}
.figure-label { font-size: 0.8125rem; color: var(--muted); }
.figure-value {
  margin-top: 0.375rem;
  font-family: var(--font-display);
  font-size: 2.25rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.figure-note { margin-top: 0.5rem; font-size: 0.8125rem; color: var(--muted); }

/* ---- Rows of ports on the dashboard ------------------------------------- */
.port-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  color: inherit;
  text-decoration: none;
  transition: background-color 150ms var(--ease);
}
@media (min-width: 40rem) { .port-row { grid-template-columns: minmax(0, 1fr) 8rem 7rem 4.5rem; } }
.port-row + .port-row { border-top: 1px solid var(--border); }
.port-row:hover { background: var(--surface-2); }

.server-card { display: flex; flex-direction: column; color: inherit; text-decoration: none; transition: border-color 150ms var(--ease); }
.server-card:hover { border-color: var(--border-strong); }

/* ---- Copyable values, code and payloads --------------------------------- */
.copyline {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  padding: 0.25rem 0.25rem 0.25rem 0.75rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-input);
}
.copyline-text {
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  white-space: nowrap;
  font-size: 0.8125rem;
  scrollbar-width: none;
}
.copyline-text.is-secret { filter: blur(4px); transition: filter 150ms var(--ease); }
.copyline:hover .copyline-text.is-secret, .copyline:focus-within .copyline-text.is-secret { filter: none; }

.codebox { border: 1px solid var(--border); border-radius: var(--radius-input); overflow: hidden; background: var(--surface-2); }
.codebox-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.25rem 0.25rem 0.25rem 0.875rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--muted);
}
.codebox pre { margin: 0; padding: 0.875rem; font-size: 0.8125rem; line-height: 1.55; }

.payload {
  margin: 0;
  max-height: 16rem;
  overflow: auto;
  padding: 0.875rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-input);
  font-size: 0.78rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}
.payload-tall { max-height: 32rem; }

.steps { list-style: decimal; padding-left: 1.25rem; margin-bottom: 1rem; display: flex; flex-direction: column; gap: 0.5rem; font-size: 0.9375rem; }

/* ---- Parameter rows in the tool editor --------------------------------- */
.param-row {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0.875rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-input);
}

/* ---- Import list ------------------------------------------------------- */
.op-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; padding: 0.875rem 1.25rem; }
.op-row + .op-row { border-top: 1px solid var(--border); }
.op-row:hover { background: var(--surface-2); }

/* ---- Logs filters ------------------------------------------------------ */
.filters { display: grid; gap: 0.75rem; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 48rem) { .filters { grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(0, 1.4fr) auto; } }

/* ---- Sign-in ground: a faint rule grid, like a patch panel ------------- */
.auth-ground {
  background-color: var(--canvas);
  background-image:
    linear-gradient(color-mix(in srgb, var(--ink) 5%, transparent) 1px, transparent 1px),
    linear-gradient(90deg, color-mix(in srgb, var(--ink) 5%, transparent) 1px, transparent 1px);
  background-size: 32px 32px;
}
