/* ============================================================
   FONT: Red Hat Display (self-hosted, CSP-safe)
   ============================================================ */

@font-face {
  font-family: "Red Hat Display";
  src: url("/fonts/RedHatDisplay-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Red Hat Display";
  src: url("/fonts/RedHatDisplay-Medium.ttf") format("truetype");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Red Hat Display";
  src: url("/fonts/RedHatDisplay-SemiBold.ttf") format("truetype");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Red Hat Display";
  src: url("/fonts/RedHatDisplay-Bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* ============================================================
   ROOT TOKENS
   ============================================================ */

:root {
  color-scheme: light;

  /* =========================
     CORE COLOUR ROLES
     ========================= */

  --color-bg-app: #000000;
  --color-bg-card: #f2f2f2;

  --color-text-primary: #d90852;
  --color-text-muted: #64748b;

  --color-accent-primary: #d70651;
  --color-accent-hover: #ad0442;
  --color-accent-active: #810332;

  --color-border-default: rgba(15, 23, 42, 0.12);
  --color-ring-focus: rgba(155, 6, 105, 0.38);

  --color-text-on-accent: #ffffff;

  /* =========================
     SURFACE & NEUTRALS
     ========================= */

  --surface-1: rgba(0, 0, 0, 0.04);
  --surface-2: rgba(0, 0, 0, 0.06);
  --surface-divider: rgba(0, 0, 0, 0.12);

  /* =========================
     SHAPE
     ========================= */

  --radius-sm: 10px;
  --radius-md: 20px;
  --radius-lg: 30px;

  /* =========================
     ELEVATION
     ========================= */

  --shadow-lg: 0 18px 50px rgba(0, 0, 0, 0.28);

  /* =========================
     SPACING
     ========================= */

  --space-xs: 8px;
  --space-sm: 12px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;

  --page-padding: var(--space-lg);

  /* =========================
     BUTTONS
     ========================= */

  --btn-height: 36px;
  --btn-height-sm: 32px;
  --btn-height-xs: 28px;

  --btn-padding-x: 16px;
  --btn-radius: var(--radius-md);

  /* =========================
     EMBEDS
     ========================= */

  --embed-padding: 14px;
  --embed-padding-bottom: 18px;
  --embed-header-height: 46px;

  --embed-title-size: 14px;
  --embed-subtitle-size: 12px;

  /* =========================
     TYPOGRAPHY
     ========================= */

  --font-ui: "Red Hat Display",
             system-ui,
             -apple-system,
             Segoe UI,
             Roboto,
             Arial,
             sans-serif;
}

/* ============================================================
   BASE
   ============================================================ */

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  padding: var(--page-padding);

  background-color: var(--color-bg-app);
  background-repeat: no-repeat;
  background-position: top center;
  background-size: auto;

  font-family: var(--font-ui);
  color: var(--color-text-primary);
}

/* ============================================================
   LAYOUT SHELL
   ============================================================ */

.auth-shell {
  width: 100%;
  min-height: calc(100vh - (var(--page-padding) * 2));
  display: grid;
  place-items: center;
}

.auth-shell.top {
  place-items: start center;
  margin-top: 48px;
}

/* ============================================================
   ROUTER LOADING
   ============================================================ */

.router-loading-page {
  padding: 0;
}

.router-loader-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.router-loader {
  width: 56px;
  height: 56px;
  border: 5px solid rgba(255, 255, 255, 0.18);
  border-top-color: var(--color-accent-primary);
  border-radius: 50%;
  animation: router-spin 0.75s linear infinite;
}

@keyframes router-spin {
  to {
    transform: rotate(360deg);
  }
}

/* ============================================================
   CARDS
   ============================================================ */

.auth-card,
.app-card {
  background: var(--color-bg-card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);

  padding: 28px 32px 32px;
  display: grid;
  gap: 18px;

  text-align: left;
}

.auth-card {
  width: min(420px, 92vw);
}

.app-card {
  width: min(900px, 92vw);
}

/* ============================================================
   BRANDING
   ============================================================ */

.auth-img {
  display: block;
  margin: 0 auto;
  max-width: 100%;
  max-height: 140px;
  object-fit: contain;
}

/* ============================================================
   TYPOGRAPHY
   ============================================================ */

.auth-title {
  margin: 0;
  font-size: 24px;
  font-weight: 600;
  text-align: center;
}

.auth-subtitle {
  margin: -8px 0 8px;
  font-size: 14px;
  color: var(--color-text-muted);
  text-align: center;
}

.normal-text {
  margin: 6px 0 0;
  font-size: 13px;
  line-height: 1.4;
  color: var(--color-text-muted);
}

.normal-text.emphasis {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--surface-divider);
}

/* ============================================================
   BUTTONS
   ============================================================ */

.main-btn {
  width: 100%;
  height: var(--btn-height);

  display: inline-flex;
  align-items: center;
  justify-content: center;

  padding: 0 var(--btn-padding-x);
  text-decoration: none;
  border-radius: var(--btn-radius);

  background: var(--color-accent-primary);
  border: 1px solid var(--color-border-default);
  box-shadow: var(--shadow-lg);
  cursor: pointer;

  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.main-btn:hover {
  background: var(--color-accent-hover);
}

.main-btn:active {
  transform: translateY(1px);
  background: var(--color-accent-active);
}

.main-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--color-ring-focus);
}

.main-btn.small {
  width: auto;
  height: var(--btn-height-sm);
  box-shadow: none;
}

.main-btn.small.fixed {
  max-width: 150px;
  height: var(--btn-height-xs);
}

.label {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text-on-accent);
}

.main-btn.small.fixed .label,
.main-btn.small.fixed .label span {
  font-size: 12px;
}

/* ============================================================
   NAVBAR
   ============================================================ */

.navbar {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 20px;
}

.nav-left,
.nav-right {
  display: flex;
  gap: 20px;
}

.navbar a {
  color: var(--color-text-muted);
  text-decoration: none;
  font-size: 16px;
  font-weight: 500;
}

.navbar a:hover,
.navbar a.selected {
  color: var(--color-accent-primary);
}

.navbar a.selected {
  font-weight: 600;
}

/* ============================================================
   EMBEDS
   ============================================================ */

.embed-wrap {
  width: 100%;
  margin-top: 12px;
  display: grid;
  place-items: center;
}

.embed-box {
  width: 100%;
  height: 500px;
  border-radius: var(--radius-md);
  background: var(--color-bg-card);
  overflow: hidden;
}

.embed-box iframe {
  width: 100%;
  height: 100%;
  border: 0;
}

@media (max-width: 560px) {
  .embed-box {
    height: min(500px, 70vh);
  }
}

/* ============================================================
   CODE / JSON OUTPUT
   ============================================================ */

.code-box {
  padding: 12px 14px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--surface-divider);
  background: var(--surface-1);

  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ============================================================
   EMBED MODE (IFRAMES)
   ============================================================ */

html:has(body.embed-body),
body.embed-body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;

  background: transparent;
}

body.embed-body .embed-stage {
  width: 100%;
  height: 100vh;
  padding: var(--embed-padding) var(--embed-padding) var(--embed-padding-bottom);
}

body.embed-body .embed-head {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
}

body.embed-body .embed-title {
  font-size: var(--embed-title-size);
  font-weight: 700;
}

body.embed-body .embed-sub {
  font-size: var(--embed-subtitle-size);
  opacity: 0.75;
}

body.embed-body .embed-chart {
  height: calc(100vh - var(--embed-header-height));
}
