/* ============================================================
   Moonwhisper Onboarding — "nocturnal onboarding desk" design system
   Extends the gamefin "nocturnal control room" system, see
   /var/www/moonwhisper/BRANDING.md. Dark canvas · purple accent ·
   glass cards · mono figures.
   ============================================================ */

:root {
  /* surfaces — near-black ink, layered violet-tinted panels */
  --ink:        #0f0d17;   /* page canvas */
  --ink-2:      #14111e;   /* inputs, recessed wells */
  --surface:    #1b1828;   /* card bottom */
  --surface-2:  #221e33;   /* card top (cards are a surface-2 -> surface gradient) */
  --surface-3:  #2a2540;   /* highest elevation */
  --line:        rgba(181, 128, 255, 0.13);  /* hairline borders */
  --line-strong: rgba(181, 128, 255, 0.24);  /* emphasized borders */

  /* text */
  --text:     #ece9f6;   /* primary */
  --text-dim: #b4adca;   /* secondary */
  --muted:    #8b84a3;   /* labels, hints */

  /* brand */
  --purple:        #b580ff;  /* the accent */
  --purple-2:      #9a6cf0;  /* gradient partner */
  --purple-bright: #cdb2ff;  /* links, active states */
  --glow:          rgba(181, 128, 255, 0.30);  /* box-shadow glow color */

  /* semantic */
  --ok:     #5fe3ad;  --ok-bg:     rgba(95, 227, 173, 0.12);
  --danger: #ff6f86;  --danger-bg: rgba(255, 111, 134, 0.12);
  --warn:   #ffce73;  --warn-bg:   rgba(255, 206, 115, 0.12);

  /* type */
  --font-display: "Bricolage Grotesque", "Hanken Grotesk", system-ui, sans-serif;
  --font-body:    "Hanken Grotesk", system-ui, -apple-system, sans-serif;
  --font-mono:    "JetBrains Mono", ui-monospace, "SFMono-Regular", monospace;

  --radius:    16px;   /* cards */
  --radius-sm: 10px;   /* buttons, inputs, nav pills */
  --shadow:    0 18px 40px -22px rgba(0, 0, 0, 0.85);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ink);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--purple-bright); text-decoration: none; }
a:hover { color: var(--purple); }

h1, h2, h3 { font-family: var(--font-display); font-weight: 700; letter-spacing: -0.01em; color: var(--text); line-height: 1.15; }
h1 { font-size: 1.7rem; margin: 0 0 0.35rem; }
h2 { font-size: 1.15rem; margin: 0 0 0.9rem; }

/* ============================================================
   Atmospheric background — fixed layer behind everything: three
   purple radial gradients breathing at the edges of the ink canvas,
   plus a masked dot-grid.
   ============================================================ */
.bg-atmosphere {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(900px 600px at 88% -8%, rgba(181, 128, 255, 0.16), transparent 60%),
    radial-gradient(700px 500px at -6% 12%, rgba(122, 86, 210, 0.12), transparent 55%),
    radial-gradient(1200px 800px at 50% 120%, rgba(95, 70, 160, 0.10), transparent 60%),
    var(--ink);
}
.bg-atmosphere::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(181, 128, 255, 0.05) 1px, transparent 1px);
  background-size: 26px 26px;
  mask-image: radial-gradient(circle at 50% 35%, #000 0%, transparent 78%);
  -webkit-mask-image: radial-gradient(circle at 50% 35%, #000 0%, transparent 78%);
}

/* ============================================================
   Shell — narrow centered layout for auth/onboarding; pages that
   need more room (admin, the document viewer) override
   `.shell { max-width: ... }` in their own inline <style> block,
   which — being later in the document than this stylesheet link —
   wins the cascade at equal specificity.
   ============================================================ */
.shell {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 380px;
  padding: 24px;
  margin: 0 auto;
}

.shell-mark { display: flex; justify-content: center; margin-bottom: 6px; }
.shell-mark-box {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: radial-gradient(circle at 50% 38%, var(--surface-3), var(--ink-2));
  border: 1px solid var(--line-strong);
  box-shadow: 0 0 22px -6px var(--glow);
}
.shell-mark-box img { width: 38px; height: 38px; object-fit: contain; display: block; }

/* ============================================================
   Brand line — the "MOONWHISPER / subtitle" wordmark each page
   renders for itself (see src/views/*.ejs); shared base styling so
   pages only need to set text-align/margins where they differ.
   ============================================================ */
.brand {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.01em;
  font-size: 1.4rem;
  margin: 0 0 4px;
  color: var(--text);
}
.brand small {
  display: block;
  font-family: var(--font-body);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 0.68rem;
  color: var(--muted);
  margin-top: 4px;
}

/* ============================================================
   Glass cards
   ============================================================ */
.card {
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  margin-top: 20px;
  box-shadow: var(--shadow);
}
.card h2 { margin: 0 0 16px; font-family: var(--font-display); font-size: 1.05rem; }

a.card { display: block; transition: transform 0.16s, border-color 0.16s, box-shadow 0.16s; }
a.card:hover { transform: translateY(-3px); border-color: var(--line-strong); box-shadow: 0 22px 44px -22px rgba(0, 0, 0, 0.9), 0 0 0 1px var(--line-strong); }

/* ============================================================
   Forms & buttons
   ============================================================ */
label {
  display: block;
  font-size: 0.82rem;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.field { margin-bottom: 16px; }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="file"],
select,
textarea {
  width: 100%;
  background: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 10px 12px;
  font-size: 0.95rem;
  font-family: var(--font-body);
}
textarea { resize: vertical; }
input::placeholder, textarea::placeholder { color: #5d566f; }

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--purple);
  box-shadow: 0 0 0 3px var(--glow);
}

select {
  appearance: none;
  -webkit-appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: right 1rem center, right 0.75rem center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

button {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.9rem;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(135deg, var(--purple), var(--purple-2));
  border: 0;
  padding: 11px 18px;
  border-radius: var(--radius-sm);
  box-shadow: 0 10px 24px -12px var(--glow);
  transition: transform 0.14s, box-shadow 0.14s, filter 0.14s;
}
button:hover { transform: translateY(-1px); box-shadow: 0 14px 30px -12px var(--glow); filter: brightness(1.05); }
button:active { transform: translateY(0); }
.btn-block { width: 100%; padding: 0.7rem; margin-top: 0.4rem; }

/* quiet/table-row variant */
button.quiet, td button {
  padding: 0.34rem 0.6rem;
  font-size: 0.8rem;
  font-weight: 600;
  background: rgba(181, 128, 255, 0.10);
  color: var(--purple-bright);
  border: 1px solid var(--line);
  box-shadow: none;
}
button.quiet:hover, td button:hover { background: rgba(181, 128, 255, 0.2); color: #fff; box-shadow: none; transform: none; }

button.revoke, button.danger {
  background: transparent;
  border: 1px solid rgba(255, 111, 134, 0.35);
  color: var(--danger);
  box-shadow: none;
}
button.revoke:hover, button.danger:hover { background: var(--danger-bg); transform: none; box-shadow: none; filter: none; }

/* ============================================================
   Logout control — rendered by the shared layout (src/views/layout.ejs)
   on every page where a session is present. Pinned to the corner rather
   than inline in the shell so it doesn't compete with each page's own
   heading/brand line, and reuses the quiet button variant so it reads as
   a muted utility action, not a primary CTA.
   ============================================================ */
.logout-form {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 2;
  margin: 0;
}
.logout-btn { padding: 0.34rem 0.7rem; }

/* ============================================================
   Tables
   ============================================================ */
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--line-strong);
  color: var(--muted);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}
td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  color: var(--text-dim);
  font-size: 0.82rem;
  vertical-align: top;
}
tbody tr { transition: background 0.14s; }
tbody tr:hover td { background: rgba(181, 128, 255, 0.045); }
tbody tr:last-child td { border-bottom: 0; }
td .muted, .muted { color: var(--muted); }

/* ============================================================
   Badges, flashes
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid var(--line-strong);
}
.badge-role { color: var(--purple-bright); background: rgba(181, 128, 255, 0.12); }
.badge-ok { color: var(--ok); background: var(--ok-bg); border-color: rgba(95, 227, 173, 0.3); }
.badge-warn { color: var(--warn); background: var(--warn-bg); border-color: rgba(255, 206,115, 0.3); }
.badge-danger { color: var(--danger); background: var(--danger-bg); border-color: rgba(255, 111, 134, 0.3); }
.badge-muted { color: var(--muted); background: rgba(139, 132, 163, 0.1); }

.form-error, .flash-error {
  background: var(--danger-bg);
  border: 1px solid rgba(255, 111, 134, 0.3);
  color: var(--danger);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 0.85rem;
  margin-bottom: 16px;
}
.form-success, .flash-ok {
  background: var(--ok-bg);
  border: 1px solid rgba(95, 227, 173, 0.3);
  color: var(--ok);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 0.85rem;
  margin-bottom: 16px;
}

/* ============================================================
   Motion — respect prefers-reduced-motion everywhere above that
   animates (float, rise, etc. are opt-in per page; this is the
   shared guard for anything added later).
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
