/* ══════════════════════════════════════════════════════════════════
   Hafta — design system.

   Written against one idea: a surface should behave like a real material
   lit from above. That gives depth without a single drop shadow doing all
   the work, and it is the difference between "layered" and "boxes with
   blur on them".

   Every material below is the same four things stacked:
     1. a translucent fill        — it sits *on* the page, not in it
     2. a hairline border         — brighter on the top edge, dimmer below
     3. an inset top highlight    — the light catching the leading edge
     4. an ambient shadow         — contact with what's underneath

   Restraint is the other rule. The previous version ran fifteen looping
   animations at once, which is the surest tell of a generated page: when
   everything moves, nothing means anything. Three things animate here, and
   each one is doing a job.
   ══════════════════════════════════════════════════════════════════ */

:root {
  /* ── Base. Cool near-black; every surface is built by layering on top,
        never by picking a second background colour. ── */
  --bg:          #08090c;
  --bg-raised:   #0b0d12;

  /* ── Ink. Four steps, and no more — a fifth grey always ends up used
        arbitrarily. ── */
  --ink:         #eef1f7;
  --ink-2:       #a8b1c4;
  --ink-3:       #6b7488;
  --ink-4:       #454d5e;

  /* ── One accent. The old palette ran indigo, cyan, green and amber
        simultaneously; with four accents nothing is emphasised. Indigo
        carries the product. Cyan appears *only* on live numbers, so it
        means "this came from the server" rather than "this is pretty". ── */
  --accent:      #6d81ff;
  --accent-soft: rgba(109, 129, 255, 0.14);
  --accent-line: rgba(109, 129, 255, 0.32);
  --data:        #4fd1c5;
  --positive:    #34d399;
  --negative:    #f87171;

  /* ── Material. The top-edge highlight is what sells the light source. ── */
  --edge:        rgba(255, 255, 255, 0.09);
  --edge-strong: rgba(255, 255, 255, 0.16);
  --fill-1:      rgba(255, 255, 255, 0.024);
  --fill-2:      rgba(255, 255, 255, 0.045);
  --fill-3:      rgba(255, 255, 255, 0.07);

  --shadow-1: 0 1px 2px rgba(0,0,0,.5);
  --shadow-2: 0 8px 24px -12px rgba(0,0,0,.8), 0 2px 6px -2px rgba(0,0,0,.5);
  --shadow-3: 0 28px 64px -32px rgba(0,0,0,.95), 0 8px 20px -8px rgba(0,0,0,.6);

  /* ── Type. Display sizes need negative tracking or they read loose;
        body needs none. ── */
  --ff: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Inter,
        Roboto, "Helvetica Neue", sans-serif;
  --fm: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  /* ── Rhythm. Everything is a multiple of 4; nothing is eyeballed. ── */
  --s1: 4px;  --s2: 8px;  --s3: 12px; --s4: 16px;
  --s5: 24px; --s6: 32px; --s7: 48px; --s8: 64px; --s9: 96px;

  --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-xl: 22px;
  --max: 1120px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--ff);
  font-size: 16px;
  line-height: 1.6;
  letter-spacing: -0.006em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "kern" 1, "liga" 1, "cv11" 1;
  overflow-x: hidden;
}

.wrap { max-width: var(--max); margin: 0 auto; padding: 0 var(--s5); }
a { color: inherit; text-decoration: none; }

/* ══════════════════════════════════════════════════════════════════
   MATERIAL
   ══════════════════════════════════════════════════════════════════ */

.mat {
  position: relative;
  background: var(--fill-1);
  border: 1px solid var(--edge);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-2);
}
/* The leading edge. One pixel, and it does more for perceived depth than
   any amount of blur — it reads as light landing on the top of a panel. */
.mat::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 1px;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  background: linear-gradient(90deg, transparent, var(--edge-strong) 22%,
              var(--edge-strong) 78%, transparent);
  pointer-events: none;
}
.mat-2 { background: var(--fill-2); box-shadow: var(--shadow-3); }
.mat-inset {
  background: rgba(0,0,0,.28);
  border: 1px solid rgba(0,0,0,.5);
  box-shadow: inset 0 1px 2px rgba(0,0,0,.6), inset 0 -1px 0 var(--edge);
  border-radius: var(--r-md);
}
.mat-inset::before { display: none; }

/* Glass is used exactly twice — nav and dialogs — because it costs GPU and
   stops meaning anything when it is everywhere. */
.glass {
  background: rgba(8, 9, 12, 0.72);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
}

/* ══════════════════════════════════════════════════════════════════
   TYPE
   ══════════════════════════════════════════════════════════════════ */

.display {
  font-size: clamp(38px, 6.2vw, 68px);
  line-height: 1.04;
  letter-spacing: -0.04em;
  font-weight: 680;
  margin: 0;
}
.h2 {
  font-size: clamp(25px, 3.4vw, 36px);
  line-height: 1.14;
  letter-spacing: -0.028em;
  font-weight: 660;
  margin: 0 0 var(--s3);
}
.h3 { font-size: 16.5px; font-weight: 620; letter-spacing: -0.012em; margin: 0 0 var(--s2); }
.lede { font-size: clamp(16.5px, 1.8vw, 19px); line-height: 1.6; color: var(--ink-2); margin: 0; }
.body { color: var(--ink-2); font-size: 15px; margin: 0; }
.small { font-size: 13px; color: var(--ink-3); }

.eyebrow {
  font-family: var(--fm);
  font-size: 11px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--ink-3);
  display: flex;
  align-items: center;
  gap: var(--s3);
  margin-bottom: var(--s4);
}
.eyebrow::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--edge), transparent);
}

.mono { font-family: var(--fm); font-variant-numeric: tabular-nums; }
.num  { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }

/* Data comes from the server; the colour says so. */
.live { color: var(--data); }

/* ══════════════════════════════════════════════════════════════════
   CONTROLS
   ══════════════════════════════════════════════════════════════════ */

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--s2);
  height: 44px; padding: 0 var(--s5);
  border-radius: var(--r-md);
  font: inherit; font-size: 15px; font-weight: 580;
  letter-spacing: -0.011em;
  color: var(--ink);
  background: var(--fill-2);
  border: 1px solid var(--edge);
  box-shadow: var(--shadow-1), inset 0 1px 0 var(--edge-strong);
  cursor: pointer;
  transition: background .18s var(--ease), transform .18s var(--ease),
              border-color .18s var(--ease), box-shadow .18s var(--ease);
}
.btn:hover { background: var(--fill-3); border-color: var(--edge-strong); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn-primary {
  color: #fff;
  background: linear-gradient(180deg, #7b8dff, #5566f0);
  border-color: transparent;
  box-shadow: var(--shadow-2), inset 0 1px 0 rgba(255,255,255,.28),
              0 0 0 1px rgba(109,129,255,.4);
}
.btn-primary:hover {
  background: linear-gradient(180deg, #8b9bff, #6373f5);
  box-shadow: var(--shadow-3), inset 0 1px 0 rgba(255,255,255,.32),
              0 0 32px -8px rgba(109,129,255,.6);
}
.btn-sm { height: 34px; padding: 0 var(--s4); font-size: 13.5px; border-radius: var(--r-sm); }

.pill {
  display: inline-flex; align-items: center; gap: var(--s2);
  height: 30px; padding: 0 var(--s3) 0 var(--s1);
  border-radius: 99px;
  background: var(--fill-2);
  border: 1px solid var(--edge);
  font-size: 13px; color: var(--ink-2);
}
.pill .tag {
  font-family: var(--fm); font-size: 10px; letter-spacing: .1em;
  padding: 3px var(--s2); border-radius: 99px;
  background: var(--accent-soft); color: var(--accent);
  border: 1px solid var(--accent-line);
}

.tag-sm {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--fm); font-size: 10.5px; letter-spacing: .08em;
  padding: 3px var(--s2); border-radius: 6px;
  background: var(--fill-2); border: 1px solid var(--edge); color: var(--ink-3);
}
.tag-sm.on { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); }

/* ══════════════════════════════════════════════════════════════════
   LAYOUT
   ══════════════════════════════════════════════════════════════════ */

section { padding: var(--s9) 0; }
.grid { display: grid; gap: var(--s4); }
.g2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.g3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.g4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

.card { padding: var(--s5); }
.card .ico { display: block; color: var(--accent); margin-bottom: var(--s3); }
.card .ico svg { width: 20px; height: 20px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left; padding: var(--s3) var(--s3);
  font-family: var(--fm); font-size: 10.5px; letter-spacing: .12em;
  text-transform: uppercase; color: var(--ink-4); font-weight: 500;
  border-bottom: 1px solid var(--edge);
}
td { padding: var(--s4) var(--s3); border-bottom: 1px solid rgba(255,255,255,.045); color: var(--ink-2); }
tr:last-child td { border-bottom: 0; }
td.r, th.r { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--fm); }
.scroll-x { overflow-x: auto; margin: 0 calc(var(--s3) * -1); padding: 0 var(--s3); }

/* ══════════════════════════════════════════════════════════════════
   LOADING
   A dash reads as "no data". A shimmer reads as "not yet" — which is what
   is actually true for the first second and a half.
   ══════════════════════════════════════════════════════════════════ */

.skel {
  display: inline-block; min-width: 3.5ch; height: 1em;
  border-radius: 4px; vertical-align: -0.14em;
  background: linear-gradient(90deg, var(--fill-2) 25%, var(--fill-3) 37%, var(--fill-2) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  color: transparent;
}
@keyframes shimmer { to { background-position: -400% 0; } }

/* ══════════════════════════════════════════════════════════════════
   MOTION — all three of it
   ══════════════════════════════════════════════════════════════════ */

/* 1. Entrance. Fires once per element, never loops. */
.rise { opacity: 0; transform: translateY(14px); }
.rise.in {
  opacity: 1; transform: none;
  transition: opacity .6s var(--ease), transform .6s var(--ease);
}

/* 2. Ambient. One very slow gradient, the only thing that loops in the
      background, at a speed you notice only if you look for it. */
.ambient {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(720px 460px at 18% -6%, rgba(109,129,255,.13), transparent 62%),
    radial-gradient(620px 420px at 84% 8%, rgba(79,209,197,.075), transparent 64%);
  animation: breathe 24s ease-in-out infinite alternate;
}
@keyframes breathe { to { transform: translate3d(0, 22px, 0) scale(1.04); opacity: .82; } }

/* 3. Grain. Static, not animated. Large soft gradients band badly on cheap
      panels and this is the cheapest fix there is. */
.grain {
  position: fixed; inset: 0; z-index: 0; pointer-events: none; opacity: .3;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.4'/%3E%3C/svg%3E");
}

main, nav, footer { position: relative; z-index: 1; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
  .rise { opacity: 1; transform: none; }
  .skel { animation: none; background: var(--fill-2); }
}
