/* Sign-in, sign-up and invitation pages: the splash ground (devise/shared/_splash).
   Topographic lines on the page ground (contour_lines_controller), the logo and
   the brand headline, then one white panel holding the form.

   Every colour is a brand token. Light by default; the dark splash follows the
   device's colour scheme. Inputs and buttons are at least 48px tall and 16px
   text, so phones neither miss taps nor zoom in on focus. */

.as {
  --as-ground-rgb: var(--brand-neutral-50-rgb);
  --as-line: rgb(var(--brand-primary-rgb) / 0.22);
  --as-line-index: rgb(var(--brand-primary-rgb) / 0.46);
  --as-ink: var(--brand-neutral-900);
  /* Harbour's text shade: dark enough to read as a heading, softer than Ink */
  --as-headline: var(--brand-primary-dark);
  --as-body: var(--brand-neutral-600);
  --as-muted: var(--brand-neutral-500);
  --as-panel: white;
  --as-panel-border: var(--brand-neutral-200);
  --as-field: white;
  --as-field-quiet: var(--brand-neutral-100);
  --as-field-border: var(--brand-neutral-300);
  --as-link: var(--brand-primary);
  --as-link-hover: var(--brand-primary-hover);
  --as-focus: var(--brand-primary);
  --as-note: rgb(var(--brand-primary-rgb) / 0.08);
  --as-note-warn: var(--brand-highlight-surface);
  --as-note-danger: var(--brand-danger-surface);
  --as-danger: var(--brand-danger);

  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: clip;
  background: rgb(var(--as-ground-rgb));
  color: var(--as-body);
  font-family: var(--brand-font-sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

@media (prefers-color-scheme: dark) {
  .as {
    --as-ground-rgb: var(--brand-accent-rgb);
    --as-line: rgb(var(--brand-primary-light-rgb) / 0.15);
    --as-line-index: rgb(var(--brand-primary-light-rgb) / 0.34);
    --as-ink: var(--brand-neutral-100);
    --as-headline: var(--brand-primary-light);
    --as-body: rgb(var(--brand-neutral-100-rgb) / 0.82);
    --as-muted: rgb(var(--brand-primary-light-rgb) / 0.85);
    --as-panel: rgb(var(--brand-accent-dark-rgb) / 0.94);
    --as-panel-border: rgb(var(--brand-primary-light-rgb) / 0.18);
    --as-field: rgb(var(--brand-accent-rgb));
    --as-field-quiet: rgb(var(--brand-primary-light-rgb) / 0.06);
    --as-field-border: rgb(var(--brand-primary-light-rgb) / 0.32);
    --as-link: var(--brand-primary-light);
    --as-link-hover: var(--brand-neutral-100);
    --as-focus: var(--brand-primary-light);
    --as-note: rgb(var(--brand-primary-light-rgb) / 0.1);
    --as-note-warn: rgb(var(--brand-highlight-rgb) / 0.14);
    --as-note-danger: rgb(var(--brand-danger-rgb) / 0.22);
    --as-danger: var(--brand-danger-surface);
    color-scheme: dark;
  }
}

.as-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}

.as-inner {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  min-height: 100dvh;
  max-width: 1120px;
  margin: 0 auto;
  padding: 24px 16px 32px;
  display: grid;
  align-content: center;
  gap: 20px;
}

/* --- Brand block -------------------------------------------------------- */

.as-brand {
  display: grid;
  justify-items: center;
  gap: 10px;
  text-align: center;
}
.as-logo-wrap { line-height: 0; }
/* Phones: the lockup at the design system's 120px floor plus a little, so the
   form, not the brand, owns the first screen. */
.as .as-logo { width: 132px; height: auto; }
.as-logo--dark { display: none; }
@media (prefers-color-scheme: dark) {
  .as-logo--light { display: none; }
  .as-logo--dark { display: inline-block; }
}
.as-headline {
  margin: 0;
  max-width: 26ch;
  color: var(--as-headline);
  font: 600 16px/1.3 var(--brand-font-heading);
  letter-spacing: -0.02em;
  text-wrap: balance;
}

/* --- Panel -------------------------------------------------------------- */

.as-panel {
  width: 100%;
  padding: 24px 20px;
  background: var(--as-panel);
  border: 1px solid var(--as-panel-border);
  border-radius: var(--brand-radius-card);
  box-shadow: var(--brand-shadow-card);
}
.as-title {
  margin: 0;
  color: var(--as-ink);
  font: 600 22px/1.25 var(--brand-font-heading);
  letter-spacing: -0.011em;
}
.as-lede { margin: 6px 0 0; }
/* The panel's heading block is centred, like the brand block above it; the
   form below stays left-aligned so labels and fields scan straight down. */
.as-title, .as-lede { text-align: center; text-wrap: balance; }
.as-lede strong { color: var(--as-ink); font-weight: 600; }

.as-notes { display: grid; gap: 10px; margin-top: 20px; }
.as-note {
  margin: 0;
  padding: 12px 14px;
  border-radius: var(--brand-radius-control);
  background: var(--as-note);
  color: var(--as-ink);
  font-size: 14px;
  line-height: 1.45;
}
.as-note p { margin: 0; }
.as-note p + p { margin-top: 4px; }
.as-note ul { margin: 6px 0 0; padding-left: 18px; }
.as-note--warn { background: var(--as-note-warn); }
.as-note--alert { background: var(--as-note-danger); color: var(--as-danger); }

/* --- Form --------------------------------------------------------------- */

.as-form { display: grid; gap: 16px; margin-top: 24px; }
.as-label {
  display: block;
  margin-bottom: 6px;
  color: var(--as-ink);
  font-size: 14px;
  font-weight: 500;
}
.as-input {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--as-field-border);
  border-radius: var(--brand-radius-control);
  background: var(--as-field);
  color: var(--as-ink);
  font: 400 16px/1.2 var(--brand-font-sans);
  box-shadow: none;
}
.as-input:focus {
  outline: 2px solid var(--as-focus);
  outline-offset: 1px;
  border-color: var(--as-focus);
  box-shadow: none;
}
.as-input[readonly] { background: var(--as-field-quiet); color: var(--as-body); }
.as-hint { margin: 6px 0 0; color: var(--as-muted); font-size: 13px; }

.as-password { position: relative; }
.as-password .as-input { padding-right: 52px; }
.as-eye {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: var(--brand-radius-control);
  background: none;
  color: var(--as-muted);
  cursor: pointer;
}
.as-eye:hover { color: var(--as-ink); }
.as-eye:focus-visible { outline: 2px solid var(--as-focus); outline-offset: -2px; }
.as-eye svg { width: 20px; height: 20px; color: inherit; }

.as-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 12px;
}
.as-check {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  color: var(--as-ink);
  font-size: 14px;
  cursor: pointer;
}
.as-check input { width: 18px; height: 18px; margin: 0; accent-color: var(--brand-primary); }

.as-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--as-link);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
}
.as-link:hover { color: var(--as-link-hover); text-decoration: underline; }
.as-link:focus-visible { outline: 2px solid var(--as-focus); outline-offset: 2px; border-radius: 4px; }

.as-button {
  display: flex;
  width: 100%;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: var(--brand-radius-control);
  background: var(--brand-primary);
  color: white;
  font: 600 16px/1 var(--brand-font-sans);
  text-decoration: none;
  box-shadow: var(--brand-shadow-button);
  cursor: pointer;
  transition: background-color 0.12s;
}
.as-button:hover { background: var(--brand-primary-hover); }
.as-button:focus-visible { outline: 2px solid var(--as-focus); outline-offset: 2px; }
.as-button--quiet {
  background: transparent;
  border-color: var(--as-field-border);
  color: var(--as-ink);
  box-shadow: none;
}
.as-button--quiet:hover { background: var(--as-field-quiet); }

/* Invitation details: who it is for, which team, which role */
.as-facts {
  display: grid;
  gap: 2px;
  margin: 20px 0 0;
  padding: 14px 16px;
  border: 1px solid var(--as-panel-border);
  border-radius: var(--brand-radius-control);
}
.as-facts dt { color: var(--as-muted); font-size: 13px; }
.as-facts dd { margin: 0 0 8px; color: var(--as-ink); font-weight: 600; overflow-wrap: anywhere; }
.as-facts dd:last-child { margin-bottom: 0; }

.as-foot {
  margin-top: 20px;
  padding-top: 12px;
  border-top: 1px solid var(--as-panel-border);
  color: var(--as-muted);
  font-size: 14px;
  text-align: center;
}
.as-foot p { margin: 0; }
.as-small { margin: 16px 0 0; color: var(--as-muted); font-size: 13px; text-align: center; }

/* --- Need help? (devise/shared/_support) -------------------------------- */

.as-side { display: grid; gap: 16px; width: 100%; max-width: 440px; margin: 0 auto; min-width: 0; }
/* A soft plate in the page ground, so the contour lines don't run through the links */
.as-help {
  display: grid;
  gap: 2px;
  justify-items: center;
  padding: 10px 12px 2px;
  border-radius: var(--brand-radius-card);
  background: rgb(var(--as-ground-rgb) / 0.88);
  text-align: center;
}
.as-help-head { display: flex; align-items: center; justify-content: center; gap: 10px; }
.as-faces { display: inline-flex; flex: none; }
.as-faces img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  /* A ring in the page ground separates the overlapping faces */
  box-shadow: 0 0 0 2px rgb(var(--as-ground-rgb));
}
.as-faces img + img { margin-left: -10px; }
.as-help-title { margin: 0; color: var(--as-ink); font-size: 15px; font-weight: 600; }
.as-help-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0 16px;
  margin: 0;
  padding: 0;
  list-style: none;
}
/* Email on its own line, WhatsApp and phone together under it */
.as-help-email { flex-basis: 100%; display: flex; justify-content: center; }
.as-help-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  color: var(--as-link);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  font-variant-numeric: tabular-nums;
  /* A flex item may shrink to its longest word, which broke the phone
     number across two lines. A contact link is read whole. */
  white-space: nowrap;
}
.as-help-link svg { width: 18px; height: 18px; flex: none; }
.as-help-link:hover { color: var(--as-link-hover); text-decoration: underline; }
.as-help-link:focus-visible { outline: 2px solid var(--as-focus); outline-offset: 2px; border-radius: 4px; }
.as-sr {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* --- Desktop: brand on the left, the form on the right, like the banner -- */

@media (min-width: 960px) {
  .as-inner {
    grid-template-columns: minmax(0, 1fr) minmax(380px, 440px);
    align-items: center;
    gap: 64px;
    padding: 48px 40px;
  }
  .as-brand {
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    justify-items: start;
    gap: 28px;
    text-align: left;
  }
  /* Sized by width, so a stacked lockup and a wide one both scale evenly.
     The headline is a supporting line: about the wordmark's own height, so
     the logo stays the one thing the eye lands on before the form. */
  .as .as-logo { width: 200px; height: auto; }
  .as-headline { max-width: none; font-size: 22px; line-height: 1.25; }
  .as-headline span { display: block; }
  .as-panel { padding: 32px; }
  .as-side { margin: 0; }
}

/* Short phones (an iPhone SE with the keyboard's worth of space in mind): the
   headline goes, the logo and the form stay. */
@media (max-height: 640px) and (max-width: 959px) {
  .as-headline, .as-lede { display: none; }
  .as-inner { padding-top: 12px; gap: 12px; }
  .as .as-logo { width: 120px; }
  .as-panel { padding: 18px 16px; }
  .as-title { font-size: 20px; }
  .as-form { gap: 12px; margin-top: 16px; }
  .as-row { flex-wrap: nowrap; }
  .as-check, .as-link { font-size: 13px; white-space: nowrap; }
}

/* While Turbo submits, the button says so (data-turbo-submits-with) and is
   disabled by Turbo; dim it so a slow rural connection doesn't read as a dead tap. */
.as-button:disabled { opacity: 0.7; cursor: progress; }

/* Overscroll and rubber-banding show the page behind .as: match its ground. */
@media (prefers-color-scheme: dark) {
  html:has(.as) { background: var(--brand-accent); }
}
