/* Page structure, after design/app-reference.html: the sidebar beside the page, as a
 * drawer behind a top bar under 860px. Colours come from tokens.css only. */

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

.topbar {
  display: none;
}

/* ---------- sidebar ---------- */

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: var(--sunken);
}

.sidebar__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 20px 20px 14px;
}

.sidebar__brand,
.topbar__brand {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0.5px;
  color: var(--ink);
  text-decoration: none;
}

.topbar__brand {
  font-size: 18px;
}

.sidebar__brand::after,
.topbar__brand::after {
  content: ".";
  color: var(--accent);
}

.sidebar__brand:hover,
.topbar__brand:hover {
  color: var(--ink);
}

.sidebar__sub {
  margin: 2px 0 0;
  font-size: 10.5px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--muted);
}

.sidebar__close {
  display: none;
}

.sidebar__scroll {
  flex: 1;
  overflow-y: auto;
  padding: 4px 12px;
}

.sidebar__links {
  list-style: none;
  margin: 0 0 8px;
  padding: 0;
}

.sidebar__link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: var(--radius);
  font-size: 13.5px;
  color: var(--ink-soft);
  text-decoration: none;
}

.sidebar__link .icon {
  width: 15px;
  height: 15px;
  opacity: 0.7;
}

.sidebar__link:hover {
  background: var(--bg);
  color: var(--ink-soft);
}

.sidebar__link[aria-current="page"] {
  background: var(--selected);
  font-weight: 500;
  color: var(--ink);
}

.sidebar__heading {
  margin: 0;
  padding: 14px 10px 6px;
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  color: var(--muted);
}

.sidebar__companies,
.sidebar__contracts {
  list-style: none;
  margin: 0;
  padding: 0;
}

.sidebar__company {
  margin-bottom: 2px;
}

.sidebar__company-head {
  display: flex;
  align-items: center;
  border-radius: var(--radius);
}

.sidebar__company-head:hover {
  background: var(--bg);
}

.sidebar__toggle {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 30px;
  padding: 0 0 0 4px;
  border: 0;
  background: none;
  color: var(--ink-soft);
}

.sidebar__toggle .icon {
  width: 11px;
  height: 11px;
  opacity: 0.55;
  transition: transform 0.2s ease;
}

.sidebar__toggle[aria-expanded="true"] .icon {
  transform: rotate(90deg);
}

.sidebar__company-link {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  padding: 7px 10px 7px 4px;
  font-size: 13px;
  color: var(--ink-soft);
  text-decoration: none;
}

.sidebar__company-link:hover {
  color: var(--ink);
}

.sidebar__company-link[aria-current] {
  font-weight: 500;
  color: var(--ink);
}

.sidebar__company-name,
.sidebar__contract-name {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.sidebar__count {
  flex: none;
  min-width: 22px;
  padding: 1px 8px;
  border: 1px solid var(--line-soft);
  border-radius: 20px;
  background: var(--bg);
  font-size: 11px;
  font-weight: 400;
  text-align: center;
  color: var(--muted);
}

/* A contract, one level under its company, with its own toggle for its amendments. */
.sidebar__contract-head {
  display: flex;
  align-items: center;
  padding-left: 12px;
  border-radius: var(--radius);
}

.sidebar__contract-head:hover {
  background: var(--bg);
}

.sidebar__contract-head:has(> [aria-current]) {
  background: var(--selected);
}

.sidebar__contract-head .sidebar__toggle,
.sidebar__toggle-space {
  flex: none;
  width: 20px;
  height: 28px;
  padding: 0;
}

.sidebar__contract {
  display: flex;
  flex: 1;
  align-items: center;
  min-width: 0;
  padding: 6px 10px 6px 4px;
  font-size: 12.5px;
  color: var(--muted);
  text-decoration: none;
}

.sidebar__contract:hover {
  color: var(--ink-soft);
}

.sidebar__contract[aria-current] {
  font-weight: 500;
  color: var(--ink);
}

/* An amendment, one level further in, after a small corner marker. */
.sidebar__amendments {
  list-style: none;
  margin: 0;
  padding: 0;
}

.sidebar__amendment {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 4px 10px 4px 40px;
  border-radius: var(--radius);
  font-size: 12px;
  color: var(--muted);
  text-decoration: none;
}

.sidebar__amendment::before {
  content: "└";
  flex: none;
  font-size: 11px;
  opacity: 0.7;
}

.sidebar__amendment:hover {
  background: var(--bg);
  color: var(--ink-soft);
}

.sidebar__amendment[aria-current] {
  background: var(--selected);
  font-weight: 500;
  color: var(--ink);
}

.sidebar__amendment-name {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* Not in force: terminated itself, or its base contract is. */
.sidebar__amendment[data-status="terminated"],
.sidebar__amendment[data-status="inactive"] {
  opacity: 0.6;
}

.sidebar__none,
.sidebar__empty {
  padding: 4px 10px 6px 30px;
  font-size: 12px;
  font-style: italic;
  color: var(--muted);
}

.sidebar__empty {
  padding-left: 10px;
}

.sidebar__foot {
  padding: 12px;
  border-top: 1px solid var(--line);
}

.sidebar__user {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 10px;
}

.sidebar__avatar {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  font-size: 12px;
  font-weight: 600;
  color: var(--on-accent);
}

.sidebar__email {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 12px;
  color: var(--ink-soft);
}

.sidebar__logout {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  background: none;
  color: var(--muted);
}

.sidebar__logout:hover {
  background: var(--bg);
  color: var(--ink);
}

.sidebar__logout .icon {
  width: 15px;
  height: 15px;
}

.sidebar__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

/* The language switch and theme toggle (controls.js): in the sidebar and on the sign-in page. */
.lang-switch {
  display: flex;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.lang-switch button {
  padding: 4px 9px;
  border: 0;
  background: none;
  font-size: 11.5px;
  color: var(--muted);
}

.lang-switch button[aria-pressed="true"] {
  background: var(--selected);
  font-weight: 600;
  color: var(--ink);
}

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
}

.theme-toggle .icon {
  width: 15px;
  height: 15px;
}

.sidebar-backdrop {
  display: none;
}

.topbar__menu {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: none;
  color: var(--ink);
}

.topbar__menu .icon {
  width: 17px;
  height: 17px;
}

/* ---------- under 860px: a top bar, and the sidebar as a drawer ---------- */

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

  .topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
    background: var(--sunken);
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 50;
    width: 264px;
    max-width: 86vw;
    transform: translateX(-100%);
    visibility: hidden;
    transition:
      transform 0.25s ease,
      visibility 0s linear 0.25s;
  }

  .sidebar[data-open="true"] {
    transform: none;
    visibility: visible;
    transition: transform 0.25s ease;
  }

  .sidebar__close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: none;
    color: var(--ink);
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: block;
    background: var(--backdrop);
  }
}

/* ---------- the page ---------- */

.page {
  width: 100%;
  max-width: 920px;
  padding: 34px 44px 80px;
}

.page--narrow {
  max-width: 420px;
  margin-inline: auto;
  padding-top: 64px;
}

@media (max-width: 860px) {
  .page {
    padding: 22px 18px 70px;
  }
}

/* ---------- the context column ---------- */

/* A page with a context column: what needs attention, the risk picture, the verdict.
   Above 1200px it stands beside the page's own content (.page__main), sticky while that
   scrolls; below, it follows the content. The contract overview places its verdict in
   the column itself (contract.css). */
.page--context {
  --context-width: clamp(260px, 22vw, 320px);
  --context-gap: 36px;
}

.page__main {
  min-width: 0;
}

.context {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 40px;
}

@media (min-width: 1200px) {
  .page--context {
    max-width: calc(920px + var(--context-gap) + var(--context-width));
  }

  .page--columns {
    display: grid;
    grid-template-columns: minmax(0, 1fr) var(--context-width);
    column-gap: var(--context-gap);
    align-items: start;
  }

  .page--columns > .context {
    position: sticky;
    top: 24px;
    max-height: calc(100vh - 48px);
    margin-top: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
}

.page__title {
  margin: 0 0 6px;
  font-size: 26px;
}

.page__lead {
  margin-bottom: 26px;
  font-size: 14px;
  color: var(--muted);
}

.page__lead--tight {
  margin-bottom: 0;
}

.page-section {
  margin-top: 30px;
}

.section-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.section-heading h2,
.section-heading .page__title {
  margin: 0;
}

.breadcrumbs {
  margin-bottom: 14px;
  font-size: 12.5px;
}

.breadcrumbs a {
  color: var(--muted);
  text-decoration: none;
}

.breadcrumbs a:hover {
  color: var(--ink);
  text-decoration: underline;
}

.breadcrumbs__list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
}

.breadcrumbs__list li + li::before {
  content: "/";
  margin-right: 8px;
  color: var(--line);
}
