/*
  The shell, ported from the prototype: a fixed navigation column on the left and the work area on the right
  (MainLayout), and the plain card layout of the pages outside the app (PlainLayout: sign-in, errors).
  Below 860px the navigation column becomes a top bar.
*/

/* Skip link: the first tab stop, invisible until focused. */
.skip {
  position: absolute;
  left: 8px;
  top: -64px;
  z-index: 100;
  padding: 8px 12px;
  border-radius: var(--r-control);
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  text-decoration: none;
}

.skip:focus {
  top: 8px;
}

.app {
  display: grid;
  grid-template-columns: var(--nav-width) minmax(0, 1fr);
  min-height: 100vh;
  padding-left: max(0px, env(safe-area-inset-left, 0px));
  padding-right: max(0px, env(safe-area-inset-right, 0px));
}

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

.brand {
  display: grid;
  gap: 2px;
}

.brand-name {
  font-family: var(--f-display);
  font-weight: 600;
  font-size: 22px;
  letter-spacing: .08em;
  color: var(--fg);
  text-decoration: none;
}

.brand-sub {
  color: var(--muted);
  font-size: var(--fs-small);
  overflow-wrap: anywhere;
}

/* The search box between the brand and the navigation; the field fills it. */
.search input {
  width: 100%;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* Positioned, so the counter's text for screen readers (.sr, absolute) stays inside its item. */
.nav a {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 9px 10px;
  border-radius: var(--r-control);
  color: var(--fg);
  font-weight: 500;
  text-decoration: none;
}

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

.nav a.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.nav-group {
  margin: 12px 10px 2px;
  font-size: var(--fs-label);
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

.who {
  margin-top: auto;
  display: grid;
  gap: 2px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: var(--fs-small);
  color: var(--muted);
}

.who strong {
  color: var(--fg);
  font-weight: 600;
  overflow-wrap: anywhere;
}

.who-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
}

.who-actions form {
  margin: 0;
}

.lang {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
}

.main {
  min-width: 0;
  padding-block: 20px 96px;
  padding-left: max(var(--gutter), env(safe-area-inset-left, 0px));
  padding-right: max(var(--gutter), env(safe-area-inset-right, 0px));
}

.main:focus {
  outline: none;
}

.wrap {
  display: grid;
  gap: var(--page-gap);
  max-width: var(--content-max);
  margin: 0 auto;
}

/* Staff viewing as a tenant: always in sight (the "view as" contract asks for a clear banner). */
.view-as-banner {
  position: sticky;
  top: 8px;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  max-width: var(--content-max);
  margin: 0 auto 18px;
  padding: 10px 14px;
  border-left: 4px solid var(--warn);
  border-radius: var(--r);
  background: var(--warn-soft);
  color: var(--fg);
  font-size: var(--fs-sub);
  font-weight: 500;
  box-shadow: var(--shadow-float);
}

.view-as-banner form {
  margin: 0;
}

/* The pages outside the app: a card on the background, the wordmark above it and the language below it. */
.plain {
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 24px;
  min-height: 100vh;
  padding: max(24px, env(safe-area-inset-top, 0px)) max(var(--gutter), env(safe-area-inset-right, 0px)) max(24px, env(safe-area-inset-bottom, 0px)) max(var(--gutter), env(safe-area-inset-left, 0px));
}

.plain-head,
.plain-foot {
  display: flex;
  justify-content: center;
}

.plain-main {
  display: grid;
  align-content: start;
  justify-items: center;
  padding-top: 6vh;
}

.plain-main .view-as-banner {
  position: static;
  width: 100%;
  max-width: 460px;
  margin: 0 0 14px;
}

.plain-main:focus {
  outline: none;
}

.card {
  display: grid;
  gap: 14px;
  width: 100%;
  max-width: 460px;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
}

.card .actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.card .small-print {
  overflow-wrap: anywhere;
}

@media (max-width: 860px) {
  /* One column: the top bar takes its own height, and only the work area takes what is left of a short page. */
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  .side {
    position: static;
    height: auto;
    overflow: visible;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 18px;
    padding: 12px max(var(--gutter), env(safe-area-inset-right, 0px)) 12px max(var(--gutter), env(safe-area-inset-left, 0px));
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .nav {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 4px;
  }

  .nav a {
    width: auto;
  }

  /* In the top bar the search box takes a line of its own beside the brand. */
  .search {
    flex: 1 1 220px;
  }

  /* Staff viewing as a tenant: their own items start on a line of their own, under the heading. */
  .nav-group {
    flex-basis: 100%;
    margin: 6px 10px 0;
  }

  /* Unlike the prototype, which hides it: signing out and the language must stay within reach on a phone. */
  .who {
    flex-basis: 100%;
    margin-top: 0;
    padding-top: 10px;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 4px 12px;
  }

  .who-via {
    display: none;
  }

  .who-actions {
    margin-top: 0;
  }
}

@media (max-width: 520px) {
  h1 {
    font-size: var(--fs-h1-small);
  }

  .card {
    padding: 18px;
  }
}
