/* CloudCastle brand tokens — the single source of design truth.
 *
 * Served at /brand/brand.css. Every marketing page and the admin console link
 * this file and consume only its tokens: site.css and admin.css define no
 * colour, type, spacing, radius, shadow, or motion value of their own.
 *
 * Sections map 1:1 to the design language spec:
 *   D1 palette · D2 typography · D3 space/radius/elevation · D4 density
 *   D6 motion · D7 3D & depth utilities
 *
 * Dark-only. There is no light theme and no theme toggle.
 */

/* ── D2. Self-hosted Inter variable (no CDN fonts) ────────────────────────── */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/brand/inter-var.woff2") format("woff2-variations"),
       url("/brand/inter-var.woff2") format("woff2");
}

:root {
  /* ── D1. Palette ──────────────────────────────────────────────────────── */
  --canvas: #07070d;
  --canvas-2: #0b0b14;
  --surface-1: #10101c;
  --surface-2: #161626;
  --surface-3: #1d1d30;
  --ink: #f2f2f8;
  --ink-2: #b8b8cc;
  --muted: #7a7a92;
  --line: rgba(255, 255, 255, 0.07);
  --line-strong: rgba(255, 255, 255, 0.14);
  --accent: #e600a0;
  --accent-hi: #ff2eb8;
  --violet: #5b21b6;
  --brand-grad: linear-gradient(135deg, #ff2eb8 0%, #e600a0 55%, #5b21b6 100%);
  --ok: #22c55e;
  --warn: #f59e0b;
  --bad: #ef4444;
  --info: #38bdf8;

  /* Status tints: the same hue at 12% alpha, composited over the local surface. */
  --ok-tint: rgba(34, 197, 94, 0.12);
  --warn-tint: rgba(245, 158, 11, 0.12);
  --bad-tint: rgba(239, 68, 68, 0.12);
  --info-tint: rgba(56, 189, 248, 0.12);
  --accent-tint: rgba(230, 0, 160, 0.12);
  --accent-ring: rgba(230, 0, 160, 0.18);

  /* ── D2. Typography ───────────────────────────────────────────────────── */
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --fs-eyebrow: 11px;
  --fs-caption: 12px;
  --fs-compact: 13px;
  --fs-body: 14px;
  --fs-lead: 16px;
  --fs-h3: 20px;
  --fs-h2: 28px;
  --fs-h1: 40px;
  --fs-display: 56px;
  --fs-display-lg: 72px;
  --lh-heading: 1.2;
  --lh-body: 1.5;
  --lh-label: 1.35;
  --track-display: -0.04em;
  /* Mid tracking for a figure or heading at 20-28px, where display tracking is
     too tight and none at all reads loose. */
  --track-tight: -0.02em;
  --track-eyebrow: 0.12em;

  /* ── D3. Space ────────────────────────────────────────────────────────── */
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;
  --s7: 48px;
  --s8: 64px;

  /* ── D3. Radius ───────────────────────────────────────────────────────── */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-hero: 20px;
  --r-pill: 999px;

  /* ── D3. Elevation (dark surfaces need key light, not only drop shadow) ── */
  --e1: 0 1px 2px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  --e2: 0 8px 24px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  --e3: 0 24px 64px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  --scrim: rgba(4, 4, 10, 0.6);

  /* ── D6. Motion ───────────────────────────────────────────────────────── */
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-enter: cubic-bezier(0.16, 1, 0.3, 1);
  --t-micro: 120ms;
  --t-ui: 200ms;
  --t-scene: 400ms;
  --t-view: 150ms;

  /* ── D4. Density defaults (compact; the console overrides per mode) ────── */
  --row-h: 36px;
  --font-ui: 13px;
  --density-pad: 8px;
  --kpi-h: 64px;
  --tab-h: 32px;
  --btn-h: 32px;
}

/* ── D4. Density system — these six tokens are the whole mechanism ────────── */
[data-density="compact"] {
  --row-h: 36px;
  --font-ui: 13px;
  --density-pad: 8px;
  --kpi-h: 64px;
  --tab-h: 32px;
  --btn-h: 32px;
}

[data-density="comfortable"] {
  --row-h: 52px;
  --font-ui: 14px;
  --density-pad: 14px;
  --kpi-h: 84px;
  --tab-h: 40px;
  --btn-h: 40px;
}

/* ── Base ─────────────────────────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  font-weight: 400;
  color: var(--ink);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  line-height: var(--lh-heading);
  font-weight: 600;
  color: var(--ink);
}

h1 {
  font-size: var(--fs-h1);
  letter-spacing: var(--track-display);
}
h2 {
  font-size: var(--fs-h2);
}
h3 {
  font-size: var(--fs-h3);
}

p {
  margin: 0;
  color: var(--ink-2);
}

a {
  color: var(--ink);
  text-decoration: none;
}

/* Numbers are tabular everywhere they can be compared. */
.num,
.kpi-value,
table td,
table th {
  font-variant-numeric: tabular-nums;
}

.eyebrow {
  font-size: var(--fs-eyebrow);
  font-weight: 600;
  letter-spacing: var(--track-eyebrow);
  text-transform: uppercase;
  color: var(--muted);
  line-height: var(--lh-label);
}

.display {
  font-size: var(--fs-display);
  font-weight: 700;
  letter-spacing: var(--track-display);
  line-height: 1.05;
}

.wordmark {
  font-weight: 700;
  letter-spacing: var(--track-display);
}

/* Base-layer reset for the `hidden` attribute.

   The UA rule is `[hidden] { display: none }` at UA specificity, so ANY author
   `display` declaration silently beats it and an element marked `hidden` then
   renders. This has bitten twice: a console panel that could never be revealed,
   and a pricing notice that could never be hidden. Owning it here means every
   page linking brand.css is correct by construction rather than by luck.

   `admin.css` carries its own `[hidden]` copy, which IS redundant with this and
   harmless. `site.css` carries `[hidden], .hidden` — the `[hidden]` half is
   redundant, but the `.hidden` half is the ONLY definition of that class
   anywhere under `static/` and is load-bearing: 13 elements across
   `downloads.html`, `portal.html`, `accept-invite.html` and `pricing.html` are
   driven by `classList.toggle('hidden', …)`, including `#dashView`, whose loss
   would show a signed-out visitor the login form and the dashboard at once. It
   is an ACTIVE mechanism, not legacy. Do not delete site.css's rule as a
   duplicate of this one.

   Do NOT extend this to `[data-hidden]` — that attribute is seeded to an INLINE
   `display: none` precisely so `el.style.display = ''` can reveal it, and a
   stylesheet rule would survive that assignment. */
[hidden] {
  display: none !important;
}

/* ── D12. Accessibility floor — never suppressed ──────────────────────────── */
:focus-visible {
  outline: 2px solid var(--accent-hi);
  outline-offset: 2px;
}

/* ── D3. Glass (marketing sticky header, hero overlays) ───────────────────── */
.glass {
  backdrop-filter: blur(16px) saturate(1.3);
  -webkit-backdrop-filter: blur(16px) saturate(1.3);
  background: color-mix(in srgb, var(--canvas) 72%, transparent);
  border-bottom: 1px solid var(--line);
}

/* ── D11. The sanctioned scrollbar — only .data-list may scroll ───────────── */
.data-list {
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-gutter: stable;
  scrollbar-color: rgba(255, 255, 255, 0.14) transparent;
}
.data-list::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
.data-list::-webkit-scrollbar-track {
  background: transparent;
}
.data-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.14);
  border-radius: var(--r-pill);
}
.data-list::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.22);
}

/* ── D7. 3D & depth utilities ─────────────────────────────────────────────── */
.tilt-scene {
  perspective: 900px;
}

.depth-panel {
  box-shadow: var(--e2);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface-1);
}

.parallax-layer {
  will-change: transform;
  pointer-events: none;
}

/* Marketing only, at most one per viewport. */
.glow-edge {
  position: relative;
  border-radius: var(--r-hero);
}
.glow-edge::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  padding: 1px;
  background: var(--brand-grad);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
  pointer-events: none;
}

@media (prefers-reduced-motion: no-preference) {
  .tilt-card {
    transition: transform 0.15s ease-out, border-color var(--t-micro) var(--ease);
    transform-style: preserve-3d;
  }

  .tilt-card::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    opacity: 0;
    transition: opacity var(--t-micro) var(--ease);
    background: radial-gradient(
      600px at var(--gx, 50%) var(--gy, 50%),
      rgba(255, 255, 255, 0.1),
      transparent 40%
    );
  }

  .tilt-card:hover::after {
    opacity: 0.12;
  }

  .fade-up {
    animation: cc-fade-up var(--t-scene) var(--ease-enter) both;
  }

  @keyframes cc-fade-up {
    from {
      opacity: 0;
      transform: translateY(8px);
    }
    to {
      opacity: 1;
      transform: none;
    }
  }
}

/* Touch devices get no tilt: there is no hover to drive it. */
@media (hover: none) {
  .tilt-card {
    transform: none !important;
  }
  .tilt-card::after {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
