/*
 * grund, the product. The tokens are grund/website's (site/styles.css), taken
 * from the dashboard design, so the site and the product read as one thing.
 * /style-guide renders every component below, with example data. Everything is served from this origin: the CSP allows no
 * inline style and no other origin.
 */

@font-face {
  font-family: "Inter";
  src: url("/static/fonts/inter-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "JetBrains Mono";
  src: url("/static/fonts/jetbrains-mono-latin.woff2") format("woff2");
  font-weight: 100 800;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: dark;

  --bg: #141c18;
  --bg-raised: #18201c;
  --surface: #1f2722;
  --surface-hover: #253029;
  --border: #262f29;
  --border-strong: #313c35;
  --active: #28352c;

  --text: #eef3ef;
  --text-2: #c3ccc6;
  --muted: #8a948e;

  --accent: #b8dab3;
  --accent-hover: #c9e6c4;
  --accent-ink: #0e1710;
  --accent-text: #b5d8a8;
  --ok: #a9d8a0;
  --blue: #7fb6ea;
  --orange: #e8a57a;
  --violet: #b48fe6;
  --danger: #ef9a8f;
  --danger-surface: #2c1f1d;

  --radius: 12px;
  --radius-lg: 16px;
  --radius-sm: 8px;
  --sidebar: 256px;
  --topbar: 74px;
  --content: 1160px;
  --gutter: clamp(1.25rem, 4vw, 3.75rem);

  --sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 400 1rem/1.55 var(--sans);
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

svg {
  display: block;
}

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

a:hover {
  color: var(--accent-hover);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 6px;
}

h1,
h2,
h3 {
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.02em;
}

p {
  margin: 0;
}

code,
.mono {
  font-family: var(--mono);
  font-size: 0.9375em;
  letter-spacing: 0;
}

.sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

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

.skip {
  position: absolute;
  left: 1rem;
  top: -3rem;
  padding: 0.5rem 0.75rem;
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: var(--radius-sm);
  font-weight: 600;
  z-index: 10;
}

.skip:focus {
  top: 1rem;
}

.icon {
  width: 1.375rem;
  height: 1.375rem;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-sm {
  width: 1.125rem;
  height: 1.125rem;
}

.icon-lg {
  width: 2.25rem;
  height: 2.25rem;
}

.tone-ok {
  color: var(--ok);
}

.tone-blue {
  color: var(--blue);
}

.tone-orange {
  color: var(--orange);
}

.tone-violet {
  color: var(--violet);
}

.tone-muted {
  color: var(--muted);
}

/* ------------------------------------------------------------ brand */

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text);
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.brand:hover {
  color: var(--text);
}

.brand-mark {
  width: 2.375rem;
  height: 1.8rem;
  color: var(--accent);
}

/* ------------------------------------------------------------ app shell */

.shell {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding: 1.5rem 1.25rem 1.5rem;
  background: var(--bg-raised);
  border-right: 1px solid var(--border);
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar .brand {
  padding: 0 0.5rem 2.75rem;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.nav-foot {
  margin-top: auto;
}

.nav-item {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 0.875rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 1rem;
}

a.nav-item:hover {
  background: var(--surface);
  color: var(--text);
}

.nav-item.is-active {
  background: var(--active);
  color: var(--text);
  font-weight: 500;
}

.nav-item[aria-disabled="true"] {
  color: var(--muted);
  cursor: default;
}

.nav-item .tag {
  margin-left: auto;
}

.avatar {
  display: inline-grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  margin: 0.5rem 0.5rem 0;
  border-radius: 50%;
  background: var(--active);
  color: var(--text);
  font-weight: 600;
  font-size: 0.9375rem;
  text-transform: uppercase;
}

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  height: var(--topbar);
  padding: 0 var(--gutter);
  border-bottom: 1px solid var(--border);
}

.crumbs {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--text);
}

.crumbs li + li::before {
  content: "/";
  margin-right: 1rem;
  color: var(--muted);
}

.topbar-end {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.content {
  width: 100%;
  max-width: calc(var(--content) + 2 * var(--gutter));
  padding: 4.25rem var(--gutter) 5rem;
}

/* ------------------------------------------------------------ page parts */

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 2rem;
  margin-bottom: 2.75rem;
}

.page-title {
  font-size: clamp(2.25rem, 4vw, 3rem);
  line-height: 1.1;
  letter-spacing: -0.035em;
}

.status-line {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  margin-top: 1rem;
  color: var(--text-2);
  font-size: 1.1875rem;
}

.section {
  margin-top: 4rem;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.section-title {
  font-size: 1.875rem;
  letter-spacing: -0.03em;
}

.count {
  margin-left: 0.75rem;
  color: var(--muted);
  font-weight: 400;
}

.link-more {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  font-weight: 500;
}

/* ------------------------------------------------------------ buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  min-height: 3rem;
  padding: 0.75rem 1.5rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font: inherit;
  font-weight: 600;
  font-size: 1.0625rem;
  cursor: pointer;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
}

.btn-primary:hover {
  background: var(--accent-hover);
  color: var(--accent-ink);
}

.btn-secondary {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text);
}

.btn-secondary:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.btn-ghost {
  background: none;
  color: var(--accent-text);
  padding-left: 0;
  padding-right: 0;
  min-height: 0;
}

.btn-danger {
  background: var(--danger-surface);
  border-color: var(--danger-surface);
  color: var(--danger);
}

.btn-block {
  width: 100%;
}

.btn-sm {
  min-height: 2.25rem;
  padding: 0.375rem 0.875rem;
  font-size: 0.9375rem;
}

/* ------------------------------------------------------------ callout */

.callout {
  display: flex;
  align-items: center;
  gap: 1.75rem;
  padding: 1.75rem 2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.callout-body {
  flex: 1;
  min-width: 0;
}

.callout-title {
  font-size: 1.1875rem;
  font-weight: 600;
}

.callout-text {
  margin-top: 0.25rem;
  color: var(--text-2);
}

.callout-danger {
  background: var(--danger-surface);
  border-color: var(--danger-surface);
}

.spinner {
  width: 2.25rem;
  height: 2.25rem;
  flex: none;
  border: 3px solid var(--border-strong);
  border-top-color: var(--blue);
  border-right-color: var(--blue);
  border-radius: 50%;
  animation: spin 1.1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation: none;
  }
}

/* ------------------------------------------------------------ resource rows */

.rows {
  margin: 0;
  padding: 0;
  list-style: none;
}

.row {
  display: grid;
  grid-template-columns: 4.25rem minmax(0, 1fr) minmax(0, 14rem) minmax(2rem, auto);
  align-items: center;
  gap: 0.5rem;
  min-height: 5.75rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}

.row:last-child {
  border-bottom: 0;
}

.row-icon {
  display: grid;
  place-items: center;
}

.row-name {
  font-size: 1.1875rem;
  font-weight: 500;
  color: var(--text);
}

.row-sub {
  margin-top: 0.125rem;
  color: var(--text-2);
  font-family: var(--mono);
  font-size: 0.9375rem;
  overflow-wrap: anywhere;
}

.row-status {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text-2);
  font-size: 1.0625rem;
}

.row-end {
  justify-self: end;
  color: var(--text-2);
}

.row-plain {
  grid-template-columns: minmax(0, 1fr) auto;
}

/* ------------------------------------------------------------ notices and stats */

.notice {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 2.5rem;
  font-size: 1.0625rem;
}

.notice .link-more {
  margin-left: auto;
}

.stats {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1.5rem;
  margin: 3.5rem 0 0;
  padding: 0;
  list-style: none;
  color: var(--text-2);
  font-size: 1.0625rem;
}

.stats li {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.stats li + li::before {
  content: "•";
  margin-right: 0.75rem;
  color: var(--muted);
}

.tag {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.tag-ok {
  border-color: var(--active);
  background: var(--active);
  color: var(--ok);
}

.empty {
  padding: 2.5rem;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  color: var(--text-2);
}

.empty strong {
  display: block;
  margin-bottom: 0.375rem;
  color: var(--text);
  font-size: 1.1875rem;
}

/* ------------------------------------------------------------ forms */

.auth {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 3rem var(--gutter);
}

.auth-card {
  width: 100%;
  max-width: 27rem;
}

.auth-card .brand {
  margin-bottom: 2.75rem;
}

.auth-title {
  font-size: 2rem;
  letter-spacing: -0.03em;
}

.auth-lede {
  margin-top: 0.625rem;
  color: var(--text-2);
}

.form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  margin-top: 2rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.field label {
  font-weight: 500;
  color: var(--text);
}

.field input {
  width: 100%;
  min-height: 3rem;
  padding: 0.75rem 1rem;
  background: var(--bg-raised);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
}

.field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgb(184 218 179 / 0.18);
}

.field input[aria-invalid="true"] {
  border-color: var(--danger);
}

.hint {
  color: var(--muted);
  font-size: 0.875rem;
}

.field-error {
  color: var(--danger);
  font-size: 0.9375rem;
}

.form-error,
.form-ok {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
}

.form-error {
  background: var(--danger-surface);
  color: var(--danger);
}

.form-ok {
  background: var(--active);
  color: var(--ok);
}

.form-foot {
  margin-top: 1.75rem;
  color: var(--text-2);
  font-size: 0.9375rem;
}

.form-foot p + p {
  margin-top: 0.5rem;
}

.or {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 1.75rem 0 1.25rem;
  color: var(--muted);
  font-size: 0.875rem;
}

.or::before,
.or::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border-strong);
}

.providers {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.inline-form {
  display: inline;
}

/* ------------------------------------------------------------ organisations */

.crumbs a {
  color: inherit;
}

.crumbs a:hover {
  color: var(--accent-text);
}

.org-mark {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: var(--radius-sm);
  background: var(--active);
  color: var(--accent-text);
  font-weight: 600;
  font-size: 0.875rem;
  text-transform: uppercase;
}

.org-mark-lg {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  font-size: 1rem;
}

.org-switch {
  position: relative;
  margin-top: -1.75rem;
}

.org-switch-current {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  list-style: none;
}

.org-switch-current::-webkit-details-marker {
  display: none;
}

.org-switch-current:hover {
  background: var(--surface-hover);
}

.org-switch-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.org-switch-name {
  color: var(--text);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.org-switch-role {
  color: var(--muted);
  font-size: 0.8125rem;
}

.org-switch-chevron {
  margin-left: auto;
  color: var(--muted);
  transform: rotate(90deg);
  transition: transform 0.15s ease;
}

.org-switch[open] .org-switch-chevron {
  transform: rotate(-90deg);
}

.org-switch-menu {
  position: absolute;
  z-index: 10;
  top: calc(100% + 0.375rem);
  left: 0;
  right: 0;
  margin: 0;
  padding: 0.375rem;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: 0 12px 32px rgb(0 0 0 / 0.35);
}

.org-switch-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.625rem;
  border-radius: 6px;
  color: var(--text-2);
}

.org-switch-item:hover,
.org-switch-item.is-current {
  background: var(--active);
  color: var(--text);
}

.org-switch-new {
  margin-top: 0.25rem;
  border-top: 1px solid var(--border);
  border-radius: 0 0 6px 6px;
  color: var(--accent-text);
}

.select,
.field select {
  min-height: 2.5rem;
  padding: 0.5rem 2.25rem 0.5rem 0.875rem;
  background: var(--bg-raised);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
}

.field select {
  min-height: 3rem;
}

.select:focus,
.field select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgb(184 218 179 / 0.18);
}

.field input:disabled {
  color: var(--muted);
}

.row-form {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.invite-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 11rem auto;
  align-items: start;
  gap: 1rem;
}

.invite-form .form-error {
  grid-column: 1 / -1;
}

.invite-form > .btn {
  margin-top: 2rem;
}

.form-narrow {
  max-width: 32rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ------------------------------------------------------------ style guide */

.sg-swatches {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr));
  gap: 1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.sg-swatch {
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
}

.sg-chip {
  height: 3rem;
  margin-bottom: 0.625rem;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
}

.sg-bg { background: var(--bg); }
.sg-bg-raised { background: var(--bg-raised); }
.sg-surface { background: var(--surface); }
.sg-active { background: var(--active); }
.sg-border { background: var(--border-strong); }
.sg-text { background: var(--text); }
.sg-text-2 { background: var(--text-2); }
.sg-muted { background: var(--muted); }
.sg-accent { background: var(--accent); }
.sg-ok { background: var(--ok); }
.sg-blue { background: var(--blue); }
.sg-orange { background: var(--orange); }
.sg-violet { background: var(--violet); }
.sg-danger { background: var(--danger); }

.sg-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
}

.sg-caption {
  margin-top: 0.75rem;
  color: var(--muted);
  font-size: 0.875rem;
}

/* ------------------------------------------------------------ small screens */

@media (max-width: 900px) {
  .invite-form {
    grid-template-columns: minmax(0, 1fr);
  }

  .invite-form > .btn {
    margin-top: 0;
  }

  .org-switch {
    order: 2;
    margin-top: 0;
    min-width: 12rem;
  }

  .shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem var(--gutter);
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .sidebar .brand {
    padding: 0;
    margin-right: auto;
    font-size: 1.375rem;
  }

  .nav {
    flex-direction: row;
    flex-wrap: wrap;
    order: 3;
    width: 100%;
  }

  .nav-item {
    padding: 0.5rem 0.75rem;
  }

  .nav-item .tag,
  .nav-item[aria-disabled="true"] {
    display: none;
  }

  .nav-foot {
    margin-top: 0;
  }

  .avatar {
    margin: 0;
    order: 2;
  }

  .topbar {
    height: auto;
    padding: 1rem var(--gutter);
  }

  .content {
    padding-top: 2.5rem;
  }

  .page-head {
    flex-direction: column;
  }

  .row {
    grid-template-columns: 3rem minmax(0, 1fr) 1.5rem;
  }

  .row-status {
    grid-column: 2;
    grid-row: 2;
  }

  .row-end {
    grid-row: 1 / span 2;
    grid-column: 3;
  }

  .callout {
    flex-wrap: wrap;
    padding: 1.25rem;
  }
}
