/* Orion: one stylesheet for the website and the Keycloak login theme (website/site/css/site.css
   is a symlink to this file). Every value comes from the tokens on :root. Pages are a column:
   .site-header with the .brand, a main area, .site-footer.

   The look is voxels seen from above at an angle. Raised things are blocks: a .card and the
   primary button are a lit top face with a stepped side face cast down and to the right (a
   pixel stair, not a soft shadow), and the button sinks into its footprint when pressed.
   Inputs are the opposite: cells dug into the ground, shaded on their upper-left walls. The
   footer is the ground itself: turf, soil, sandstone and stone in layers under a stepped
   horizon. Everything else stays flat and quiet. */

/* ---- Tokens ---------------------------------------------------------------------------- */

:root {
  color-scheme: light dark;

  /* Ground and surfaces: a block's top face, its side, and a dug cell */
  --bg: #dbe1dc;            /* pale lichen grey: the page */
  --bg-grid: rgb(24 33 43 / 0.045); /* the voxel grid on the page */
  --surface: #f7f9f6;       /* a block's top face: cards */
  --surface-side: #a5b1ab;  /* its side face, stepped below and to the right */
  --surface-sunk: #e9eee9;  /* a dug cell: inputs, quiet panels */
  --sunk-shade: #c3ccc6;    /* the dug cell's shaded upper-left walls */
  --line: #bfc9c3;
  --line-strong: #7f8c86;

  /* Ink */
  --text: #18212b;
  --muted: #4b5961;

  /* Malachite: the one accent, as a lit face over a dark side */
  --accent: #1a7d62;
  --accent-hover: #146b54;
  --accent-side: #0d4f3d;
  --accent-ink: #ffffff;
  --accent-text: #177358;   /* the accent as large type on the page */
  --link: #155fa0;

  /* Strata: the ground under every page (footer) */
  --turf: #8fa56a;
  --soil: #7a5d47;
  --sand: #c4a46e;
  --stone: #5d6876;
  --stone-ink: #eef1f4;
  --ore: #ffb547;

  /* Messages */
  --danger: #b4321c;
  --danger-bg: #fbe5e0;
  --success: #24703f;
  --success-bg: #ddf0e2;
  --warning: #855a00;
  --warning-bg: #fbefcf;
  --info: #155fa0;
  --info-bg: #e0ebf6;

  --focus: #1f63d6;

  /* Type: a narrow, engineered face for headings and the brand (Bahnschrift, DIN and the
     condensed grotesques that ship with each system), the system UI face for reading.
     Nothing is downloaded. */
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial,
    sans-serif;
  --font-display: "Bahnschrift", "DIN Alternate", "DIN Condensed", "Avenir Next Condensed",
    "Roboto Condensed", "Liberation Sans Narrow", "Arial Narrow", "Nimbus Sans Narrow",
    var(--font);
  --text-s: 0.875rem;
  --text-m: 1rem;
  --text-l: 1.25rem;
  --text-xl: 1.75rem;
  --text-xxl: clamp(2.25rem, 6vw, 3.5rem);
  --leading: 1.5;

  /* Shape and space: blocks have square corners */
  --radius-s: 0;
  --radius: 0;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --gutter: var(--space-4);
  --measure: 34rem;
  --card-width: 28rem;
  --step: 2px;              /* one stair of a block's side face */
  --block-depth: 8px;       /* a card's side face: four stairs */
  --button-depth: 4px;      /* the primary button's: two stairs */
  --horizon: 12px;          /* height of the stepped horizon over the footer */
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a2029;
    --bg-grid: rgb(255 255 255 / 0.03);
    --surface: #27303b;
    --surface-side: #0e1218;
    --surface-sunk: #1e252e;
    --sunk-shade: #12171d;
    --line: #3a4552;
    --line-strong: #64727f;
    --text: #e7ece9;
    --muted: #a5b2b9;
    --accent: #36b98e;
    --accent-hover: #4dcca1;
    --accent-side: #0f5a44;
    --accent-ink: #08261d;
    --accent-text: #47c79b;
    --link: #8cc4ff;
    --turf: #56683f;
    --soil: #4a3a2e;
    --sand: #7f6a47;
    --stone: #353c4d;
    --stone-ink: #c9d1d9;
    --danger: #ff9a86;
    --danger-bg: #3a1a15;
    --success: #8fd6a0;
    --success-bg: #15301d;
    --warning: #ffd36b;
    --warning-bg: #352a0c;
    --info: #9cc3ff;
    --info-bg: #142540;
    --focus: #8cb8ff;
  }
}

/* ---- Base ------------------------------------------------------------------------------ */

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

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

/* `hidden` beats any class that sets display (.btn, .alert, …). */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--text-m);
  line-height: var(--leading);
  color: var(--text);
  background-color: var(--bg);
  /* The ground grid seen from above, barely there. */
  background-image:
    linear-gradient(var(--bg-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px);
  background-size: 32px 32px;
}

a {
  color: var(--link);
  text-underline-offset: 0.2em;
}

a:hover {
  text-decoration-thickness: 2px;
}

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

img,
svg {
  max-width: 100%;
}

h1,
h2,
h3 {
  margin: 0 0 var(--space-3);
  font-family: var(--font-display);
  font-stretch: condensed;
  font-weight: 700;
  line-height: 1.1;
}

p {
  margin: 0 0 var(--space-4);
}

hr {
  border: 0;
  border-top: 2px solid var(--line);
  margin: var(--space-5) 0;
}

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

.page {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.page-main {
  flex: 1;
  width: 100%;
  max-width: calc(var(--card-width) + 2 * var(--gutter));
  margin: 0 auto;
  padding: var(--space-6) var(--gutter) var(--space-7);
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  width: 100%;
  max-width: 72rem;
  margin: 0 auto;
  padding: var(--space-4) var(--gutter);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 44px;
  color: var(--text);
  font-family: var(--font-display);
  font-stretch: condensed;
  font-size: var(--text-xl);
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
}

.brand img {
  width: 36px;
  height: auto;
  display: block;
}

.brand:hover {
  text-decoration: none;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2) var(--space-3);
}

.site-nav .btn-primary {
  margin-bottom: var(--button-depth);
}

.site-nav-user {
  font-weight: 700;
  color: var(--text);
}

/* The ground: strata under a stepped horizon. The bands sit behind the footer's text, which
   stays on the stone. */
.site-footer {
  position: relative;
  margin-top: var(--horizon);
  padding: 52px var(--gutter) var(--space-5);
  color: var(--stone-ink);
  font-size: var(--text-s);
  text-align: center;
  background: linear-gradient(
    to bottom,
    var(--turf) 0 10px,
    var(--soil) 10px 26px,
    var(--sand) 26px 34px,
    var(--stone) 34px
  );
}

/* The horizon: turf blocks of uneven height along the top edge. */
.site-footer::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: calc(-1 * var(--horizon) + 1px);
  height: var(--horizon);
  background: var(--turf);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='12'%3E%3Cpath d='M0 12V6h24V0h36v6h12v6h24V6h12V0h12v6h48v6h24V6h36V0h12v12z'/%3E%3C/svg%3E")
    left bottom / 240px var(--horizon) repeat-x;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='12'%3E%3Cpath d='M0 12V6h24V0h36v6h12v6h24V6h12V0h12v6h48v6h24V6h36V0h12v12z'/%3E%3C/svg%3E")
    left bottom / 240px var(--horizon) repeat-x;
  pointer-events: none;
}

.site-footer p {
  margin: 0;
}

/* ---- The block card -------------------------------------------------------------------- */

.card {
  position: relative;
  margin: 0 var(--block-depth) var(--block-depth) 0;
  padding: var(--space-6);
  background: var(--surface);
  border-radius: var(--radius);
  /* The side face: four stairs down and to the right. */
  box-shadow:
    calc(1 * var(--step)) calc(1 * var(--step)) 0 var(--surface-side),
    calc(2 * var(--step)) calc(2 * var(--step)) 0 var(--surface-side),
    calc(3 * var(--step)) calc(3 * var(--step)) 0 var(--surface-side),
    var(--block-depth) var(--block-depth) 0 var(--surface-side);
}

.card-header h1,
.card h1 {
  font-size: var(--text-xl);
}

.card-header {
  margin-bottom: var(--space-5);
}

.card-header .subtitle {
  margin: 0;
  color: var(--muted);
  font-size: var(--text-s);
}

.required {
  color: var(--danger);
}

/* "Signed in as …" with a restart link, on second-step pages */
#kc-username {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--surface-sunk);
  border-radius: var(--radius-s);
  box-shadow: inset 3px 3px 0 var(--sunk-shade);
  font-weight: 700;
}

#kc-username a {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 44px;
  font-size: var(--text-s);
  font-weight: 400;
}

.card-info {
  margin-top: var(--space-5);
  padding-top: var(--space-5);
  border-top: 2px solid var(--line);
  color: var(--muted);
}

.card-info p:last-child {
  margin-bottom: 0;
}

.card .instruction {
  color: var(--text);
}

#traceId {
  color: var(--muted);
  font-size: var(--text-s);
}

/* ---- Fields ---------------------------------------------------------------------------- */

.field {
  margin-bottom: var(--space-4);
}

.field-label-row {
  display: flex;
  gap: var(--space-1);
  align-items: baseline;
}

:where(.card label),
.field-label {
  display: inline-block;
  margin-bottom: var(--space-1);
  font-weight: 700;
}

/* A dug cell. By element inside a card (zero specificity, so any class rule wins), and by
   class. */
:where(.card input:not([type="checkbox"], [type="radio"], [type="submit"], [type="button"], [type="hidden"]), .card select, .card textarea),
.field-input {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: var(--space-2) var(--space-3);
  font: inherit;
  color: var(--text);
  background: var(--surface-sunk);
  border: 2px solid var(--line);
  border-radius: var(--radius-s);
  box-shadow: inset 3px 3px 0 var(--sunk-shade);
}

.card input:hover:not(:focus, [disabled]),
.card select:hover,
.card textarea:hover {
  border-color: var(--line-strong);
}

.card input:focus-visible,
.card select:focus-visible,
.card textarea:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 1px;
  border-color: var(--focus);
}

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

.card input[disabled] {
  opacity: 0.7;
}

.field-input-group {
  display: flex;
}

.field-input-group > input {
  flex: 1;
  min-width: 0;
}

.field-message,
.field-help {
  display: block;
  margin-top: var(--space-1);
  font-size: var(--text-s);
  color: var(--muted);
}

.field-message-error {
  color: var(--danger);
  font-weight: 700;
}

.field-group-title {
  font-family: var(--font-display);
  font-stretch: condensed;
  font-size: var(--text-l);
  font-weight: 700;
}

.card input[type="checkbox"],
.card input[type="radio"] {
  width: 18px;
  height: 18px;
  margin: 0 var(--space-2) 0 0;
  vertical-align: -3px;
  accent-color: var(--accent);
}

.checkbox label,
.choice-label {
  font-weight: 400;
}

.choice {
  display: flex;
  align-items: center;
  min-height: 44px;
  margin-bottom: var(--space-1);
}

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

/* Form options row: "Remember me", "Forgot password?", "Back to login" */
.form-settings {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2) var(--space-4);
  font-size: var(--text-s);
}

.form-options-row {
  font-size: var(--text-s);
  margin-bottom: var(--space-4);
}

.form-settings .form-options-row {
  margin-bottom: 0;
}

.form-buttons,
#kc-form-buttons {
  margin-top: var(--space-5);
}

.form-buttons-row,
.form-buttons:has(> .btn + .btn) {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}

#kc-form-buttons:has(> .btn + .btn) {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}

/* ---- Buttons --------------------------------------------------------------------------- */

/* By class, and by element inside a card (zero specificity: .btn-primary, .btn-quiet and their
   :hover / :active states always win). */
.btn,
:where(.card button:not(.btn-reveal), .card input[type="submit"], .card input[type="button"]) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 44px;
  padding: var(--space-2) var(--space-5);
  font: inherit;
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
  color: var(--text);
  background: var(--surface-sunk);
  border: 2px solid var(--line);
  border-radius: var(--radius-s);
  cursor: pointer;
}

/* A small block: lit face, two stairs of side, and it sinks into its footprint when pressed. */
.btn-primary {
  margin: 0 var(--button-depth) var(--button-depth) 0;
  color: var(--accent-ink);
  background: var(--accent);
  border-color: var(--accent);
  box-shadow:
    var(--step) var(--step) 0 var(--accent-side),
    var(--button-depth) var(--button-depth) 0 var(--accent-side);
  transition: transform 60ms ease-out, box-shadow 60ms ease-out;
}

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

.btn-primary:active {
  transform: translate(var(--button-depth), var(--button-depth));
  box-shadow: none;
}

.btn-quiet {
  color: var(--text);
  background: transparent;
  border-color: var(--line-strong);
}

.btn-quiet:hover {
  background: var(--surface-sunk);
}

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

/* A full-width block keeps its side face inside the card. */
.btn-block.btn-primary {
  width: calc(100% - var(--button-depth));
}

.btn-large {
  font-size: var(--text-m);
}

.btn[disabled],
.btn.is-disabled,
.card input[type="submit"][disabled] {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* Show / hide password: a square cap on the input's right */
.btn-reveal {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  flex: 0 0 44px;
  padding: 0;
  color: var(--muted);
  background: var(--surface-sunk);
  border: 2px solid var(--line);
  border-left: 0;
  border-radius: var(--radius-s);
  cursor: pointer;
}

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

/* ---- Messages -------------------------------------------------------------------------- */

.alert {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
  margin-bottom: var(--space-5);
  padding: var(--space-3) var(--space-4);
  border-left: 6px solid currentColor;
  border-radius: var(--radius-s);
  color: var(--info);
  background: var(--info-bg);
}

.alert-text {
  color: var(--text);
}

.alert-error {
  color: var(--danger);
  background: var(--danger-bg);
}

.alert-success {
  color: var(--success);
  background: var(--success-bg);
}

.alert-warning {
  color: var(--warning);
  background: var(--warning-bg);
}

/* ---- Icons (masks in the text colour) -------------------------------------------------- */

.icon {
  display: inline-block;
  width: 20px;
  height: 20px;
  flex: none;
  background: currentColor;
  -webkit-mask: var(--icon) center / contain no-repeat;
  mask: var(--icon) center / contain no-repeat;
}

.icon-eye {
  --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2 12s3.6-7 10-7 10 7 10 7-3.6 7-10 7S2 12 2 12z'/%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3C/svg%3E");
}

.icon-eye-off {
  --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10.6 5.1A10 10 0 0 1 12 5c6.4 0 10 7 10 7a17 17 0 0 1-2.6 3.4M6.6 6.6C3.7 8.5 2 12 2 12s3.6 7 10 7a9.6 9.6 0 0 0 5.4-1.6M9.9 9.9a3 3 0 0 0 4.2 4.2M3 3l18 18'/%3E%3C/svg%3E");
}

.icon-restart {
  width: 16px;
  height: 16px;
  --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 12a9 9 0 1 0 3-6.7L3 8'/%3E%3Cpath d='M3 3v5h5'/%3E%3C/svg%3E");
}

/* Message markers: a small square block. */
.icon-alert,
.icon-info,
.icon-check {
  --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='4' y='4' width='16' height='16'/%3E%3C/svg%3E");
}

.kc-tooltip-text {
  font-size: var(--text-s);
}

/* ---- Identity providers ---------------------------------------------------------------- */

.social h2 {
  font-size: var(--text-m);
}

.social-list {
  display: grid;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.social-grid {
  grid-template-columns: 1fr 1fr;
}

/* ---- Landing page ---------------------------------------------------------------------- */

.page-main.page-wide {
  max-width: calc(72rem + 2 * var(--gutter));
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 0.9fr);
  align-items: center;
  gap: var(--space-6);
  margin-bottom: var(--space-7);
}

/* The name is a block too: the letters carry a stepped side face. */
.hero h1 {
  margin-bottom: var(--space-5);
  color: var(--accent-text);
  font-size: clamp(4rem, 13vw, 8.5rem);
  line-height: 0.9;
  text-shadow:
    0.02em 0.02em 0 var(--accent-side),
    0.04em 0.04em 0 var(--accent-side),
    0.06em 0.06em 0 var(--accent-side);
}

.hero-lead {
  max-width: 26ch;
  margin-bottom: var(--space-6);
  font-size: clamp(1.25rem, 2.4vw, 1.625rem);
  font-weight: 600;
  line-height: 1.35;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: var(--space-3);
}

/* The fortress cutaway: website/site/img/fortress.svg (website/tools/fortress_svg.py). */
.hero-art {
  display: block;
  width: 100%;
  max-width: 30rem;
  height: auto;
  margin: 0 auto;
}

.features {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-6);
}

.feature + .feature {
  padding-left: var(--space-6);
  border-left: 2px solid var(--line);
}

.feature h2 {
  font-size: var(--text-xl);
}

.feature p {
  margin: 0;
  color: var(--muted);
}

/* ---- Profile page ---------------------------------------------------------------------- */

.account {
  margin: 0 0 var(--space-5);
}

.account-row {
  padding: var(--space-3) 0;
  border-bottom: 2px solid var(--line);
}

.account-row:first-child {
  padding-top: 0;
}

.account dt {
  color: var(--muted);
  font-size: var(--text-s);
}

.account dd {
  margin: 0;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.badge {
  display: inline-block;
  margin-left: var(--space-1);
  padding: 0 var(--space-2);
  border-radius: var(--radius-s);
  font-size: var(--text-s);
  font-weight: 700;
  color: var(--warning);
  background: var(--warning-bg);
}

.badge-ok {
  color: var(--success);
  background: var(--success-bg);
}

/* ---- Utility --------------------------------------------------------------------------- */

.space-top {
  margin-top: var(--space-4);
}

.visually-hidden,
.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;
}

/* ---- Phone width ----------------------------------------------------------------------- */

@media (max-width: 52rem) {
  .hero {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-5);
  }

  .hero-art {
    max-width: 22rem;
  }

  .features {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-5);
  }

  .feature + .feature {
    padding-left: 0;
    padding-top: var(--space-5);
    border-left: 0;
    border-top: 2px solid var(--line);
  }
}

@media (max-width: 30rem) {
  .page-main {
    padding-top: var(--space-4);
  }

  .brand {
    font-size: var(--text-l);
  }

  .brand img {
    width: 28px;
  }

  .site-nav {
    gap: var(--space-2);
  }

  .site-nav .btn {
    padding: var(--space-1) var(--space-3);
    font-size: var(--text-s);
  }

  .card {
    padding: var(--space-5) var(--space-4);
  }
}

@media (prefers-reduced-motion: reduce) {
  .btn-primary {
    transition: none;
  }
}
