/* powertrue-portal foundation styles. Builders extend with page-specific rules;
   the primitives here (nav, card, stat, ring, bar, pill, button, skeleton, motion)
   are the shared visual system defined in DESIGN.md. transform/opacity motion only. */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background:
    radial-gradient(1200px 600px at 70% -10%, rgba(194,112,61,0.06), transparent 60%),
    var(--surface-0);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
h1, h2, h3 { font-family: var(--font-display); color: var(--text-hi); line-height: 1.1; margin: 0; font-weight: 600; }
a { color: inherit; text-decoration: none; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

.skip-link {
  position: absolute; left: -999px; top: 0; z-index: 100;
  background: var(--surface-2); color: var(--text-hi);
  padding: 10px 16px; border-radius: var(--radius-sm);
}
.skip-link:focus { left: 16px; top: 16px; }

:focus-visible { outline: 2px solid var(--copper); outline-offset: 2px; border-radius: 4px; }

/* --- nav --- */
.nav { position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--surface-1) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--hairline); }
.nav__wrap { max-width: var(--wrap-max); margin: 0 auto; padding: 0 var(--gutter);
  height: 60px; display: flex; align-items: center; gap: 32px; }
.nav__brand { font-family: var(--font-display); font-size: var(--fs-lg); color: var(--text-hi);
  display: flex; align-items: baseline; gap: 8px; }
.nav__mark { color: var(--copper); }
.nav__sub { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--text-mute);
  text-transform: uppercase; letter-spacing: .08em; }
.nav__links { display: flex; gap: 4px; margin-left: 8px; }
.nav__link { padding: 8px 14px; font-size: var(--fs-sm); color: var(--text-mute);
  border-radius: var(--radius-sm); position: relative; transition: color var(--dur-fast); }
.nav__link:hover { color: var(--text); }
.nav__link.is-active { color: var(--text-hi); }
.nav__link.is-active::after { content: ""; position: absolute; left: 14px; right: 14px; bottom: -1px;
  height: 2px; background: var(--copper); border-radius: 2px; view-transition-name: nav-underline; }
.nav__session { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.nav__logout { font-size: var(--fs-sm); color: var(--text-mute); }
.nav__logout:hover { color: var(--text); }

.main { max-width: var(--wrap-max); margin: 0 auto; padding: 40px var(--gutter) 80px; }

/* --- pill / button --- */
.pill { font-family: var(--font-mono); font-size: var(--fs-xs); padding: 3px 9px;
  border-radius: 999px; border: 1px solid var(--hairline-strong); color: var(--text-mute);
  text-transform: uppercase; letter-spacing: .06em; }
.pill--demo { color: var(--copper-light); border-color: color-mix(in srgb, var(--copper) 40%, transparent); }

.btn { font-family: var(--font-body); font-size: var(--fs-sm); font-weight: 500;
  padding: 10px 18px; border-radius: var(--radius-sm); border: 1px solid transparent;
  cursor: pointer; transition: transform var(--dur-fast), background var(--dur-fast); }
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--copper); color: #1B1210; }
.btn--primary:hover { background: var(--copper-light); }
.btn--ghost { background: transparent; border-color: var(--hairline-strong); color: var(--text); }
.btn--ghost:hover { border-color: var(--copper); color: var(--text-hi); }

/* --- card --- */
/* layered depth: a very slight top-to-bottom gradient (raised top edge) over the
   surface, never a flat gray box (DESIGN.md). */
.card { background: linear-gradient(180deg, var(--surface-2), var(--surface-1) 58%);
  border: 1px solid var(--hairline);
  border-radius: var(--radius); box-shadow: var(--shadow-card); padding: 24px; position: relative; }
.card--link { transition: transform var(--dur-fast), border-color var(--dur-fast), box-shadow var(--dur-fast); }
.card--link:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--copper) 45%, var(--hairline));
  box-shadow: var(--shadow-lift); }
/* status edge-light on cards */
.card--good { border-left: 2px solid var(--good); }
.card--warning { border-left: 2px solid var(--warning); }
.card--critical { border-left: 2px solid var(--critical); }

/* --- stat tile --- */
.stat { display: flex; flex-direction: column; gap: 4px; }
.stat__label { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--text-mute);
  text-transform: uppercase; letter-spacing: .07em; }
.stat__value { font-family: var(--font-mono); font-size: var(--fs-3xl); color: var(--text-hi);
  font-variant-numeric: tabular-nums; line-height: 1; }

/* --- score ring --- */
.ring { --size: 84px; width: var(--size); height: var(--size); position: relative; }
.ring svg { transform: rotate(-90deg); overflow: visible; }
/* visible track behind a thinner, round-capped value arc so near-full scores read
   as a progress ring, not a solid disk */
.ring__track { fill: none; stroke: rgba(203, 207, 212, 0.16); stroke-width: 6; }
.ring__val { fill: none; stroke-width: 5; stroke-linecap: round;
  transition: stroke-dashoffset var(--dur-slow) var(--ease-out); }
.ring__num { position: absolute; inset: 0; display: grid; place-items: center;
  font-family: var(--font-mono); font-size: var(--fs-xl); font-weight: 600;
  color: var(--text-hi); font-variant-numeric: tabular-nums; line-height: 1; }
/* softened, desaturated stroke colors (ring-only tokens) */
.is-good .ring__val, .val--good { stroke: var(--ring-good); }
.is-warning .ring__val, .val--warning { stroke: var(--ring-warning); }
.is-critical .ring__val, .val--critical { stroke: var(--ring-critical); }

/* --- metric bar (thin sequential fill) --- */
.bar { display: grid; grid-template-columns: 3.5rem 1fr auto; align-items: center; gap: 10px;
  font-family: var(--font-mono); font-size: var(--fs-xs); }
.bar__label { color: var(--text-mute); }
.bar__track { display: block; width: 100%; height: 6px; background: rgba(203, 207, 212, 0.12);
  border-radius: 6px; overflow: hidden; box-shadow: inset 0 0 0 1px rgba(0,0,0,0.25); }
.bar__fill { display: block; width: 100%; height: 100%; border-radius: 6px;
  background: linear-gradient(90deg, var(--copper-dark), var(--copper-light));
  box-shadow: 0 0 8px -1px color-mix(in srgb, var(--copper) 55%, transparent);
  transform-origin: left; transition: transform 700ms var(--ease-out); }
.bar__val { color: var(--text-hi); text-align: right; }

/* --- status token (icon + label, never color alone) --- */
.status { display: inline-flex; align-items: center; gap: 6px; font-family: var(--font-mono);
  font-size: var(--fs-xs); }
.status__ic { flex: none; width: 1em; height: 1em; }
.status--good { color: var(--good); }
.status--warning { color: var(--warning); }
.status--critical { color: var(--critical); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot--up { background: var(--good); box-shadow: 0 0 0 3px var(--good-glow); }
.dot--down { background: var(--critical); box-shadow: 0 0 0 3px var(--critical-glow); }

/* --- skeleton shimmer --- */
.skeleton { position: relative; overflow: hidden; background: var(--surface-2); border-radius: var(--radius-sm); }
.skeleton::after { content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.05), transparent);
  transform: translateX(-100%); }

/* --- motion --- */
@media (prefers-reduced-motion: no-preference) {
  .enter { animation: fade-up var(--dur) var(--ease-out) both; }
  .stagger > * { animation: fade-up var(--dur) var(--ease-out) both; }
  .stagger > *:nth-child(1) { animation-delay: 0ms; }
  .stagger > *:nth-child(2) { animation-delay: 40ms; }
  .stagger > *:nth-child(3) { animation-delay: 80ms; }
  .stagger > *:nth-child(4) { animation-delay: 120ms; }
  .stagger > *:nth-child(5) { animation-delay: 160ms; }
  .stagger > *:nth-child(6) { animation-delay: 200ms; }
  .skeleton::after { animation: shimmer 1.4s infinite; }
  .card--critical { animation: breathe 3s ease-in-out infinite; }
  @keyframes fade-up { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
  @keyframes shimmer { to { transform: translateX(100%); } }
  @keyframes breathe {
    0%,100% { box-shadow: var(--shadow-card); }
    50% { box-shadow: var(--shadow-card), 0 0 0 1px var(--critical-glow), 0 0 24px -4px var(--critical-glow); }
  }
  ::view-transition-old(root), ::view-transition-new(root) { animation-duration: 220ms; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* --- utility --- */
.grid { display: grid; gap: 24px; }
.grid--fleet { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.row { display: flex; align-items: center; gap: 12px; }
.muted { color: var(--text-mute); }
.page-head { margin-bottom: 32px; }
.page-head h1 { font-size: var(--fs-2xl); }
.page-head p { color: var(--text-mute); margin: 6px 0 0; font-size: var(--fs-sm); }
