/* ==========================================================================
   components.css — buttons, cards, badges, status, grids

   Shared building blocks used across every page. Page-specific layout lives
   in static/css/pages/*.css, never here.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  /* Keeps every button a comfortable touch target on mobile. */
  min-height: 2.75rem;
  padding: var(--space-3) var(--space-5);
  border: 1px solid transparent;
  border-radius: var(--r-md);
  font-size: var(--fs-sm);
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease),
    color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease),
    box-shadow var(--t-fast) var(--ease);
}

.btn:active {
  transform: translateY(1px);
}

.btn svg {
  flex: none;
}

/* Primary --------------------------------------------------------------- */

.btn--primary {
  background: linear-gradient(140deg, var(--accent-soft), var(--accent));
  color: var(--accent-contrast);
  box-shadow: 0 6px 20px -8px var(--accent-glow);
}

.btn--primary:hover {
  box-shadow: 0 10px 28px -8px var(--accent-glow);
  color: var(--accent-contrast);
}

/* Secondary ------------------------------------------------------------- */

.btn--ghost {
  border-color: var(--border-strong);
  background: var(--surface-1);
  color: var(--text);
}

.btn--ghost:hover {
  border-color: var(--accent-line);
  background: var(--surface-2);
}

/* Quiet ----------------------------------------------------------------- */

.btn--quiet {
  padding-inline: var(--space-3);
  color: var(--text-dim);
}

.btn--quiet:hover {
  background: var(--surface-2);
  color: var(--text);
}

.btn--block {
  width: 100%;
}

.btn--sm {
  min-height: 2.25rem;
  padding: var(--space-2) var(--space-4);
  font-size: var(--fs-xs);
}

.btn--lg {
  min-height: 3.25rem;
  padding: var(--space-4) var(--space-7);
  font-size: var(--fs-base);
}

/* Disabled, used where a link is not configured yet. Rendered as a <span>
   rather than a dead <a>, so it is not focusable or clickable. */
.btn--disabled {
  border-color: var(--border);
  background: transparent;
  color: var(--text-mute);
  cursor: not-allowed;
}

/* Arrow nudges on hover — the one bit of motion on a button. */
.btn .arrow {
  transition: transform var(--t-base) var(--ease);
}

.btn:hover .arrow {
  transform: translateX(3px);
}

/* --------------------------------------------------------------------------
   Cards
   -------------------------------------------------------------------------- */

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: var(--space-5);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface-1);
  transition: border-color var(--t-base) var(--ease), background var(--t-base) var(--ease),
    transform var(--t-base) var(--ease);
}

/* Interactive cards lift very slightly. Deliberately restrained: the whole
   card is a link target, so motion must not make it feel unstable. */
.card--link:hover {
  border-color: var(--accent-line);
  background: var(--surface-2);
  transform: translateY(-2px);
}

/* Focus the card when the link inside it is focused. */
.card--link:focus-within {
  border-color: var(--accent);
}

/* Stretched link: makes the whole card clickable while keeping a real <a>
   for keyboard and screen-reader users. */
.stretch::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
}

.card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}

.card__title {
  font-size: var(--fs-md);
  font-weight: 650;
  letter-spacing: -0.02em;
}

.card__tagline {
  margin-top: var(--space-1);
  color: var(--accent-soft);
  font-size: var(--fs-sm);
}

.card__body {
  flex: 1;
  color: var(--text-dim);
  font-size: var(--fs-sm);
  line-height: var(--lh-normal);
}

.card__foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-top: var(--space-5);
}

/* Icon tile ------------------------------------------------------------- */

.tile {
  display: grid;
  place-items: center;
  flex: none;
  width: 2.75rem;
  height: 2.75rem;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--accent-wash);
  color: var(--accent-soft);
  transition: border-color var(--t-base) var(--ease), color var(--t-base) var(--ease);
}

.card--link:hover .tile {
  border-color: var(--accent-line);
  color: var(--accent);
}

.tile--lg {
  width: 3.5rem;
  height: 3.5rem;
  border-radius: var(--r-lg);
}

/* --------------------------------------------------------------------------
   Badges
   -------------------------------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  background: var(--surface-2);
  color: var(--text-dim);
  font-family: var(--ff-mono);
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.badge--accent {
  border-color: var(--accent-line);
  background: var(--accent-wash);
  color: var(--accent-soft);
}

/* Project status badges. Each pairs a colour with a distinct word, so the
   meaning never depends on the colour alone. */
.badge--live {
  border-color: rgba(61, 220, 151, 0.3);
  background: var(--ok-dim);
  color: var(--ok);
}

.badge--wip {
  border-color: rgba(247, 185, 85, 0.3);
  background: var(--warn-dim);
  color: var(--warn);
}

.badge--planned,
.badge--archived {
  color: var(--text-mute);
}

/* --------------------------------------------------------------------------
   Status indicators

   Used by the status page and the homepage preview. Every state pairs a
   colour with a shape and a label, never colour alone.
   -------------------------------------------------------------------------- */

.dot {
  position: relative;
  flex: none;
  width: 0.625rem;
  height: 0.625rem;
  border-radius: var(--r-full);
  background: var(--idle);
}

.dot--operational {
  background: var(--ok);
}

/* A slow pulse on healthy services — the only always-on animation on the
   site, and it stops entirely under reduced-motion. */
.dot--operational::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: inherit;
  animation: dot-pulse 2.4s var(--ease) infinite;
}

.dot--degraded {
  background: var(--warn);
}

.dot--down {
  background: var(--bad);
}

.dot--unknown {
  background: var(--idle);
}

@keyframes dot-pulse {
  0% {
    opacity: 0.7;
    transform: scale(1);
  }
  70%,
  100% {
    opacity: 0;
    transform: scale(2.6);
  }
}

@media (prefers-reduced-motion: reduce) {
  .dot--operational::after {
    display: none;
  }
}

/* Status pill: dot plus label. */
.pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  background: var(--surface-2);
  font-size: var(--fs-xs);
  font-weight: 600;
  white-space: nowrap;
}

.pill--operational {
  border-color: rgba(61, 220, 151, 0.3);
  background: var(--ok-dim);
  color: var(--ok);
}

.pill--degraded {
  border-color: rgba(247, 185, 85, 0.3);
  background: var(--warn-dim);
  color: var(--warn);
}

.pill--down {
  border-color: rgba(255, 107, 107, 0.3);
  background: var(--bad-dim);
  color: var(--bad);
}

.pill--unknown {
  color: var(--text-dim);
}

/* Loading skeleton, shown while a fetch is in flight. Has a fixed height so
   content does not jump when the real data arrives. */
.skeleton {
  border-radius: var(--r-sm);
  background: linear-gradient(90deg, var(--surface-1), var(--surface-3), var(--surface-1));
  background-size: 200% 100%;
  animation: skeleton 1.4s linear infinite;
  color: transparent;
}

@keyframes skeleton {
  to {
    background-position: -200% 0;
  }
}

/* --------------------------------------------------------------------------
   Grids

   auto-fit + minmax means every grid reflows on its own. There are no
   device-specific column counts anywhere in this file.
   -------------------------------------------------------------------------- */

.grid {
  display: grid;
  gap: var(--space-4);
}

.grid--2 {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 1fr));
}

.grid--3 {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr));
}

.grid--4 {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr));
}

/* --------------------------------------------------------------------------
   Empty / unavailable state

   Shown whenever real data could not be loaded. It says so plainly rather
   than filling the space with invented numbers.
   -------------------------------------------------------------------------- */

.empty {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-5);
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface-1);
  color: var(--text-dim);
  font-size: var(--fs-sm);
}

.empty__icon {
  flex: none;
  color: var(--text-mute);
}

/* A note marking a link that has not been configured yet. */
.unconfigured {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--fs-xs);
  color: var(--text-mute);
  font-style: italic;
}
