/* Raven's page layout. The components themselves are styled in raven.css, which comes from
   the design system and is never edited here. This file only places them on the page.
   Every colour, space and corner is a token from tokens.css. */

html,
body {
  margin: 0;
}

body {
  min-height: 100vh;
  background: var(--canvas);
}

.btn-block {
  width: 100%;
}

/* ---------- small pieces used on many pages ---------- */

.app-title {
  margin: 0;
  font: 600 26px/32px var(--font-sans);
  letter-spacing: -0.01em;
}

.app-p {
  margin: 0;
}

/* A long link that must wrap instead of pushing the page sideways. */
.app-link {
  margin: 0;
  padding: var(--space-2) var(--space-3);
  background: var(--surface);
  border-radius: var(--radius-2);
  overflow-wrap: anywhere;
  user-select: all;
}

a.rv-brand {
  text-decoration: none;
}

/* ---------- the signed out screens: logo on Raven black, one box ---------- */

.auth {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-8);
  padding: var(--space-12) var(--space-4);
  background: var(--feather);
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  color: var(--on-feather);
}

.auth-logo svg {
  width: 68px;
  height: 62px;
  fill: currentColor;
  flex: none;
}

.auth-logo span {
  font: 400 60px/64px var(--font-wordmark);
  letter-spacing: 0.01em;
}

.auth-box {
  width: 100%;
  max-width: 400px;
  padding: var(--space-8);
  background: var(--surface);
  border-radius: var(--radius-3);
  box-shadow: var(--shadow-modal);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.auth-head {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.auth-head h1 {
  margin: 0;
  font: 600 18px/24px var(--font-sans);
}

.auth-head p,
.auth-form .rv-notice p {
  margin: 0;
}

.auth-link {
  align-self: center;
  color: var(--gloss);
  font: 400 12px/16px var(--font-sans);
}

.auth-link:hover {
  color: var(--gloss-hover);
}

.auth-foot {
  margin: 0;
  color: var(--on-feather);
  font: 400 12px/16px var(--font-sans);
  text-align: center;
}

.auth-foot a {
  color: var(--on-feather);
  text-decoration: underline;
}

.auth-steps {
  margin: 0;
  padding-left: var(--space-5);
  color: var(--ink-2);
}

.auth-qr {
  align-self: center;
  padding: var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-2);
  line-height: 0;
}

.auth-key {
  color: var(--ink);
  font-weight: 500;
  overflow-wrap: anywhere;
}

.auth-codes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2) var(--space-4);
  margin: 0;
  padding: var(--space-4);
  list-style: none;
  background: var(--surface-sunken);
  border-radius: var(--radius-2);
  font: 500 14px/20px var(--font-narrow);
  overflow-wrap: anywhere;
}

/* Six boxes for the six digit code. app.js builds them from one plain field. */
.code-boxes {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: var(--space-2);
}

.code-boxes input {
  height: 56px;
  min-width: 0;
  padding: 0;
  text-align: center;
  font: 600 18px/1 var(--font-narrow);
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-2);
}

.code-boxes input:focus {
  outline: none;
  border-color: var(--gloss);
  box-shadow: 0 0 0 3px var(--gloss-tint);
}

.code-boxes.is-invalid input {
  border-color: var(--stop);
}

@media (max-width: 640px) {
  .auth-logo span {
    font-size: 44px;
    line-height: 48px;
  }

  .auth-logo svg {
    width: 50px;
    height: 46px;
  }

  .auth-box {
    padding: var(--space-6);
  }
}

/* ---------- icons: Lucide, drawn in the colour of the text around them ---------- */

.app-icon {
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.app-icon--sm {
  width: 16px;
  height: 16px;
}

/* A button that is only an icon, such as Sign out. It always has an aria-label. */
.app-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-2);
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
}

.app-icon-btn:hover {
  background: var(--canvas);
  color: var(--ink);
}

/* ---------- the frame: sidebar on the left, bar across the top, the page in the middle ---------- */

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

.app-side {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-5) var(--space-4) var(--space-4);
  background: var(--surface);
  border-right: 1px solid var(--line);
}

.app-side-logo {
  padding: var(--space-1) var(--space-2);
}

/* The brand the screens are showing. A plain label until there is a second brand to switch to. */
.app-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-3);
  font: 500 13px/18px var(--font-sans);
}

.app-brand img {
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-2);
}

.app-nav {
  display: flex;
  flex-direction: column;
  gap: var(--space-12);
  margin-top: var(--space-8);
}

.app-nav ul {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  margin: 0;
  padding: 0;
  list-style: none;
}

.app-nav a,
.app-nav-later {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-2);
  font: 500 14px/20px var(--font-sans);
  color: var(--ink);
  text-decoration: none;
}

.app-nav a .app-icon {
  color: var(--ink-2);
}

.app-nav a:hover {
  background: var(--canvas);
}

.app-nav a[aria-current="page"] {
  background: var(--feather);
  color: var(--on-feather);
}

.app-nav a[aria-current="page"] .app-icon {
  color: var(--on-feather);
}

/* A screen that is not built yet: there, but quieter, and not a link. */
.app-nav-later {
  color: var(--ink-3);
  cursor: default;
}

.app-side-foot {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-top: auto;
  padding: var(--space-3) var(--space-2) var(--space-1);
  border-top: 1px solid var(--line);
}

.app-who {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.app-who strong {
  font: 500 13px/18px var(--font-sans);
  overflow-wrap: anywhere;
}

.app-who small {
  font: 400 12px/16px var(--font-sans);
  color: var(--ink-3);
}

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

.app-top {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: var(--space-4);
  height: 64px;
  padding: 0 var(--space-6) 0 var(--space-12);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.app-crumbs {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
  margin-right: auto;
  font: 400 14px/20px var(--font-sans);
  color: var(--ink-3);
}

.app-crumbs a {
  color: inherit;
  text-decoration: none;
}

.app-crumbs a:hover {
  color: var(--ink);
}

.app-crumb-sep {
  color: var(--line-strong);
}

.app-crumb-now {
  color: var(--ink);
  font-weight: 500;
}

/* Sign out in the top bar is for phones only: see the 560px rules below. */
.app-top-out {
  display: none;
}

.app-content {
  display: flex;
  flex-direction: column;
  gap: var(--space-8);
  width: 100%;
  max-width: 1240px;
  padding: var(--space-10) var(--space-12) var(--space-12);
}

/* ---------- the parts of a page ---------- */

/* The page's name on the left, its buttons on the right. */
.app-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-4);
}

.app-head-text {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  flex: 1 1 320px;
  min-width: 0;
}

.app-head-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

/* Tabs under a page's name. The selected one is marked with aria-current="page". */
.app-tabs {
  display: flex;
  gap: var(--space-6);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}

.app-tabs a,
.app-tabs span {
  margin-bottom: -1px;
  padding: var(--space-2) 0 var(--space-3);
  border-bottom: 2px solid transparent;
  color: var(--ink-2);
  font: 500 14px/20px var(--font-sans);
  text-decoration: none;
  white-space: nowrap;
}

.app-tabs span {
  color: var(--ink-3);
}

.app-tabs a:hover {
  color: var(--ink);
}

.app-tabs a[aria-current="page"] {
  border-bottom-color: var(--gloss);
  color: var(--gloss);
}

/* Panels side by side. They stack on a narrow screen. */
.app-two {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-6);
  align-items: start;
}

.app-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: var(--space-6);
  align-items: start;
}

.app-stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  min-width: 0;
}

.app-small {
  font: 400 13px/18px var(--font-sans);
}

.app-caption {
  font: 400 12px/16px var(--font-sans);
  color: var(--ink-3);
}

/* A link in running text. */
.app-go {
  color: var(--gloss);
}

.app-go:hover {
  color: var(--gloss-hover);
}

/* A panel with nothing in it yet: one plain sentence, at the panel's own padding. */
.rv-panel-body > .rv-empty {
  padding: 0;
}

/* A table that sits inside a panel, under the panel's heading, with no second frame. */
.rv-panel > .rv-table-wrap {
  border: 0;
  border-radius: 0 0 var(--radius-3) var(--radius-3);
}

.app-panel-foot {
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--line);
  font: 400 12px/16px var(--font-sans);
  color: var(--ink-3);
}

/* Rows of "what it is" on the left and "how many" on the right, divided by hairlines. */
.app-kv {
  margin: 0;
}

.app-kv > div {
  display: flex;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-3) 0;
  border-top: 1px solid var(--line);
  font: 400 13px/18px var(--font-sans);
}

.app-kv > div:first-child {
  border-top: 0;
  padding-top: 0;
}

.app-kv > div:last-child {
  padding-bottom: 0;
}

.app-kv dt {
  min-width: 0;
  color: var(--ink-2);
}

.app-kv dd {
  margin: 0;
  font-weight: 500;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* A field with its button on the same line. */
.app-inline-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-2);
}

.app-inline-form .rv-field {
  flex: 1 1 320px;
}

/* ---------- narrower screens ---------- */

@media (max-width: 1100px) {
  .app-split,
  .app-two {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* A tablet: the sidebar shrinks to a strip of icons. */
@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 72px minmax(0, 1fr);
  }

  .app-side {
    align-items: center;
    padding-inline: var(--space-3);
  }

  .app-side-logo span,
  .app-brand span,
  .app-nav a > span,
  .app-nav-later > span,
  .app-who {
    display: none;
  }

  .app-brand {
    padding: 0;
    border: 0;
  }

  .app-side-foot {
    justify-content: center;
    padding-inline: 0;
  }

  .app-top {
    padding: 0 var(--space-4);
  }

  .app-content {
    gap: var(--space-6);
    padding: var(--space-6) var(--space-4) var(--space-12);
  }
}

/* A phone: the sidebar becomes a bar of icons along the bottom, built screens only. */
@media (max-width: 560px) {
  .app-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .app-side {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 3;
    flex-direction: row;
    justify-content: center;
    height: auto;
    padding: var(--space-2);
    padding-bottom: calc(var(--space-2) + env(safe-area-inset-bottom, 0px));
    border-right: 0;
    border-top: 1px solid var(--line);
    overflow-x: auto;
  }

  .app-side-logo,
  .app-brand,
  .app-side-foot,
  .app-nav .is-later {
    display: none;
  }

  .app-nav,
  .app-nav ul {
    flex-direction: row;
    gap: var(--space-1);
    margin: 0;
  }

  .app-top-out {
    display: block;
  }

  .app-crumbs > :not(.app-crumb-now) {
    display: none;
  }

  .app-content {
    padding-bottom: calc(var(--space-12) + var(--space-12));
  }
}

/* A numbered list of steps, in running text. */
.app-steps {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin: 0;
  padding-left: var(--space-5);
  color: var(--ink-2);
}

.app-steps strong {
  color: var(--ink);
  font-weight: 600;
}

/* A long word, such as an email address, that must wrap and never push the page sideways. */
.app-wrap {
  overflow-wrap: anywhere;
}

/* ---------- emails shown inside Raven ---------- */

/* The two preview frames, desktop and phone. They scroll sideways inside their own row on a narrow screen. */
.app-previews {
  display: flex;
  align-items: flex-start;
  gap: var(--space-5);
  overflow-x: auto;
  padding-bottom: var(--space-2);
}

.app-preview {
  flex: none;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-2);
  background: var(--surface);
}

/* The list of checks: a status on the left, what it is and what was found on the right. */
.app-checks {
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
  list-style: none;
}

.app-checks li {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr);
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-top: 1px solid var(--line);
}

.app-checks li:first-child {
  border-top: 0;
  padding-top: 0;
}

.app-checks li:last-child {
  padding-bottom: 0;
}

.app-checks strong {
  font: 500 13px/18px var(--font-sans);
}

/* A box for HTML or plain text: one fixed-width face, so the code lines up. */
.app-code {
  font: 400 12px/18px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre;
  overflow: auto;
  tab-size: 2;
}
