/*
 * The World Model portal theme: frosted glass on a cold, bright canvas.
 *
 * Basecoat (vendor/basecoat-1.1.0) gives the components. This file sets Basecoat's design
 * tokens to the portal palette, then adds the canvas, the glass surfaces and the page layout.
 * It loads after Basecoat and has no layers, so its rules win over Basecoat's layered rules.
 */

@font-face {
  font-family: "Instrument Sans";
  src: url("/static/vendor/instrument-sans-5.3.0/instrument-sans-latin-wght-normal.woff2")
    format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}

:root {
  /* The palette. */
  --frost: #f4f7fb;
  --ink: #16213a;
  --ink-muted: #5a6884;
  --glacier: #2e6be6;
  --glacier-deep: #2258c4;
  --danger: #b42318;
  --hairline: rgba(22, 33, 58, 0.08);

  /* Glass. */
  --glass: rgba(255, 255, 255, 0.64);
  --glass-strong: rgba(255, 255, 255, 0.8);
  --glass-quiet: rgba(255, 255, 255, 0.42);
  --glass-edge: rgba(255, 255, 255, 0.92);
  --glass-blur: blur(20px) saturate(160%);
  --shadow-panel: 0 1px 1px rgba(22, 33, 58, 0.04), 0 22px 48px -28px rgba(22, 33, 58, 0.28);

  /* Radius hierarchy: panels are softest, fields are tighter, actions are pills. */
  --radius-panel: 18px;
  --radius-aside: 14px;
  --radius-field: 10px;

  /* Basecoat tokens, set to the palette. */
  --background: var(--frost);
  --foreground: var(--ink);
  --card: var(--glass);
  --card-foreground: var(--ink);
  --popover: var(--glass-strong);
  --popover-foreground: var(--ink);
  --primary: var(--glacier);
  --primary-foreground: #ffffff;
  --secondary: rgba(22, 33, 58, 0.05);
  --secondary-foreground: var(--ink);
  --muted: rgba(22, 33, 58, 0.04);
  --muted-foreground: var(--ink-muted);
  --accent: rgba(46, 107, 230, 0.08);
  --accent-foreground: var(--ink);
  --destructive: var(--danger);
  --border: rgba(22, 33, 58, 0.1);
  --input: rgba(22, 33, 58, 0.14);
  --ring: rgba(46, 107, 230, 0.45);
  --radius: 0.625rem;
  --font-sans: "Instrument Sans", ui-sans-serif, system-ui, -apple-system, sans-serif;
}

/* ---------- Canvas ---------- */

html {
  background: var(--frost);
}

body {
  min-height: 100dvh;
  margin: 0;
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  /* The cold light behind the glass: three faint washes, fixed to the window. */
  background:
    radial-gradient(56rem 38rem at 8% -12%, rgba(168, 202, 255, 0.55), transparent 62%),
    radial-gradient(48rem 34rem at 100% 4%, rgba(178, 232, 222, 0.42), transparent 60%),
    radial-gradient(70rem 46rem at 55% 118%, rgba(208, 218, 255, 0.55), transparent 62%),
    var(--frost);
  background-attachment: fixed;
}

h1,
h2,
h3 {
  margin: 0;
  color: var(--ink);
  font-weight: 600;
  letter-spacing: -0.015em;
}

h1 {
  font-size: 1.75rem;
  line-height: 1.2;
}

h2 {
  font-size: 1.0625rem;
  line-height: 1.3;
}

p {
  margin: 0;
}

a:not(.btn) {
  color: var(--glacier-deep);
  text-underline-offset: 3px;
}

:focus-visible {
  outline: 2px solid var(--glacier);
  outline-offset: 2px;
}

/* ---------- Glass surfaces ---------- */

.glass {
  background: var(--glass);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-edge);
  box-shadow: var(--shadow-panel), inset 0 1px 0 rgba(255, 255, 255, 0.75);
}

/* The main panel of a page: a list or the sign-in pane. */
.panel {
  border-radius: var(--radius-panel);
}

/* The supporting panel beside a list: lighter, flatter, so the list leads. */
.aside-panel {
  border-radius: var(--radius-aside);
  background: var(--glass-quiet);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border: 1px solid rgba(255, 255, 255, 0.7);
  padding: 22px;
}

.aside-panel h2 {
  margin-bottom: 4px;
}

.aside-panel > .hint {
  margin-bottom: 18px;
}

/* ---------- Top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(244, 247, 251, 0.62);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--hairline);
}

.topbar-inner {
  display: flex;
  align-items: center;
  gap: 28px;
  max-width: 1080px;
  height: 60px;
  margin: 0 auto;
  padding: 0 24px;
}

a.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
  text-decoration: none;
}

/* The mark: a small frosted orb with one meridian. */
.wordmark-orb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 32% 28%, #ffffff 0 18%, transparent 46%),
    linear-gradient(145deg, #bcd4ff, #7fa8f5 55%, #2e6be6);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.7), 0 2px 6px -1px rgba(46, 107, 230, 0.5);
  position: relative;
}

.wordmark-orb::after {
  content: "";
  position: absolute;
  inset: 3px 8px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.65);
}

.topnav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  min-width: 0;
}

.topnav a {
  padding: 6px 12px;
  border-radius: 999px;
  color: var(--ink-muted);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}

.topnav a:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.55);
}

.topnav a[aria-current="page"] {
  color: var(--ink);
  background: var(--glass-strong);
  box-shadow: 0 1px 2px rgba(22, 33, 58, 0.06), inset 0 0 0 1px var(--glass-edge);
}

.topnav .company {
  color: var(--ink);
  font-weight: 600;
  font-size: 14px;
  padding-right: 8px;
  margin-right: 4px;
  border-right: 1px solid var(--hairline);
  white-space: nowrap;
}

.account {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0;
  color: var(--ink-muted);
  font-size: 13px;
}

/* ---------- Page ---------- */

.page {
  max-width: 1080px;
  margin: 0 auto;
  padding: 40px 24px 72px;
}

.page-header {
  margin-bottom: 28px;
}

.page-header p {
  margin-top: 6px;
  max-width: 62ch;
  color: var(--ink-muted);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 24px;
  align-items: start;
}

@media (max-width: 880px) {
  .workspace {
    grid-template-columns: minmax(0, 1fr);
  }
  /* The tabs move to a second row that scrolls sideways; the wordmark and sign-out stay on top. */
  .topbar-inner {
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 4px 16px;
    height: auto;
    padding: 10px 16px 8px;
  }
  .topnav {
    order: 3;
    flex-basis: 100%;
    overflow-x: auto;
  }
  .account .who {
    display: none;
  }
  .page {
    padding: 28px 16px 56px;
  }
}

.hint {
  color: var(--ink-muted);
  font-size: 13.5px;
}

/* ---------- Lists ---------- */

.panel .table-container {
  border-radius: var(--radius-panel);
}

.panel .table {
  font-size: 14px;
}

.panel .table th {
  padding: 14px 20px 12px;
  color: var(--ink-muted);
  font-size: 13px;
  font-weight: 500;
  text-align: left;
}

.panel .table td {
  padding: 14px 20px;
}

.panel .table tbody tr:hover {
  background: rgba(255, 255, 255, 0.45);
}

.panel .table tr {
  border-color: var(--hairline);
}

.cell-strong {
  font-weight: 600;
}

.cell-muted {
  color: var(--ink-muted);
}

.cell-actions {
  text-align: right;
}

.cell-actions form {
  display: inline;
}

.tabular {
  font-variant-numeric: tabular-nums;
}

.empty {
  padding: 48px 24px;
  text-align: center;
}

.empty h2 {
  margin-bottom: 6px;
}

.empty p {
  color: var(--ink-muted);
}

/* ---------- Forms ---------- */

.form-stack {
  display: grid;
  gap: 16px;
}

.form-stack .field label,
.form-stack label {
  font-size: 13.5px;
  font-weight: 500;
}

.input,
select.select {
  border-radius: var(--radius-field);
  /* The colour only: Basecoat draws the chevron of a select as a background image. */
  background-color: rgba(255, 255, 255, 0.82);
}

.btn {
  border-radius: 999px;
  font-weight: 500;
}

.btn.btn-block {
  width: 100%;
}

.btn.btn-quiet-danger {
  color: var(--danger);
}

.btn.btn-quiet-danger:hover {
  background: rgba(180, 35, 24, 0.07);
}

.form-fieldset {
  margin: 0;
  padding: 0;
  border: 0;
}

.form-fieldset[hidden] {
  display: none;
}

.message {
  padding: 10px 14px;
  border-radius: var(--radius-field);
  font-size: 14px;
}

.message-error {
  color: var(--danger);
  background: rgba(180, 35, 24, 0.06);
  border: 1px solid rgba(180, 35, 24, 0.16);
}

.badge-role {
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink);
  background: rgba(22, 33, 58, 0.05);
}

.badge-role[data-role="tenant_admin"] {
  color: var(--glacier-deep);
  background: rgba(46, 107, 230, 0.1);
}

.status-dot {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.status-dot::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #1f8a5b;
}

.status-dot[data-state="pending"]::before {
  background: #c7a034;
}

/* ---------- Sign-in and setup ---------- */

.auth {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: 32px 20px;
}

.auth-column {
  width: 100%;
  max-width: 400px;
}

.auth-column .wordmark {
  margin: 0 0 22px 4px;
}

.auth-pane {
  padding: 32px;
}

.auth-pane h1 {
  font-size: 1.5rem;
}

.auth-pane .lead {
  margin: 6px 0 24px;
  color: var(--ink-muted);
}

.auth-foot {
  margin-top: 18px;
  text-align: center;
  color: var(--ink-muted);
  font-size: 13px;
}

/* ---------- One-time link ---------- */

.link-box {
  display: flex;
  gap: 8px;
  margin: 20px 0 8px;
}

.link-box .input {
  font-variant-numeric: tabular-nums;
}

.narrow-panel {
  max-width: 640px;
}

.narrow-panel .hint {
  margin-top: 6px;
}

.panel-actions {
  margin-top: 20px;
}

/* ---------- Utilities ---------- */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.form-stack .input,
.form-stack select.select {
  width: 100%;
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}
