/* Page foundations and the application frame. */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-family: var(--font-sans);
  font-size: 100%;
  line-height: var(--leading-body);
  color: var(--text);
  background: var(--surface-page);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-size: var(--text-md);
}

h1,
h2,
h3,
h4,
p,
dl,
dd,
fieldset {
  margin: 0;
}

h1,
h2,
h3,
h4 {
  line-height: var(--leading-tight);
  font-weight: 650;
  letter-spacing: -0.01em;
}

h1 {
  font-size: var(--text-2xl);
}

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

h3 {
  font-size: var(--text-lg);
}

h4 {
  font-size: var(--text-md);
}

a {
  color: var(--accent-strong);
  text-underline-offset: 0.15em;
}

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  padding: 0.1em 0.35em;
  border-radius: var(--radius-sm);
  background: var(--surface-sunken);
  overflow-wrap: anywhere;
}

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

[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition-duration: 0s !important;
    animation-duration: 0s !important;
  }
}

/*
 * Frame. Wide screens: a sidebar of places with the account at its foot. Tablets: an icon rail.
 * Phones: a slim header and a bar of tabs at the bottom, within reach of a thumb.
 */
.frame {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 100vh;
  min-width: 0;
}

.frame-sidebar {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-5) var(--space-3) var(--space-4);
  background: var(--surface-sunken);
  border-right: 1px solid var(--border);
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 4;
  min-width: 0;
}

.frame-sidebar > .brand {
  padding: 0 var(--space-2);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-lg);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
}

.logo {
  width: 1.75rem;
  height: 1.75rem;
  flex: none;
}

.logo-tile {
  fill: var(--brand);
}

.logo-ink {
  fill: var(--on-brand);
  stroke: var(--on-brand);
}

/* The outlined Jaduvid wordmark: the text colour, then the brand lime. */
.wordmark {
  display: block;
  height: 1.05em;
  width: auto;
}

.wordmark-ink {
  fill: currentColor;
}

.wordmark-accent {
  fill: var(--brand-text);
}

.frame-start {
  width: 100%;
  min-height: 2.75rem;
  border-radius: var(--radius-lg);
}

.frame-nav {
  display: grid;
  align-content: start;
  gap: var(--space-1);
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

.frame-nav a {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: var(--control-height);
  padding: 0 var(--space-3);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-weight: 550;
  text-decoration: none;
  transition:
    background var(--motion-fast),
    color var(--motion-fast);
}

.frame-nav a.is-secondary:first-of-type,
.frame-nav a:not(.is-secondary) + a.is-secondary {
  margin-top: var(--space-4);
}

.frame-nav a:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.frame-nav a[aria-current='page'] {
  background: var(--surface-raised);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--border);
}

.frame-nav a[aria-current='page'] svg {
  color: var(--action);
}

.frame-nav svg {
  width: 1.125rem;
  height: 1.125rem;
  flex: none;
}

.frame-foot {
  margin: 0;
  font-size: var(--text-xs);
  line-height: var(--leading-tight);
  color: var(--text-muted);
}

.frame-main {
  padding: var(--space-6) var(--space-6) var(--space-7);
  min-width: 0;
}

/* The phone's bottom tabs; hidden on wider screens. */
.frame-tabbar {
  display: none;
}

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

.page.is-wide {
  max-width: 72rem;
}

.page-head {
  display: grid;
  gap: var(--space-2);
}

.page-head h1,
.page-head p {
  overflow-wrap: anywhere;
}

.page-head p {
  color: var(--text-muted);
}

.brief-text summary {
  cursor: pointer;
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.brief-text p {
  margin-top: var(--space-2);
  max-width: 70ch;
}

/* Tablets: the sidebar narrows to a rail of icons with short names below them. */
@media (max-width: 1100px) and (min-width: 761px) {
  .frame {
    grid-template-columns: 5.5rem minmax(0, 1fr);
  }

  .frame-sidebar {
    align-items: center;
    padding-inline: var(--space-2);
  }

  .frame-sidebar > .brand span,
  .frame-start span,
  .frame-user-text,
  .frame-user .button span,
  .frame-foot {
    display: none;
  }

  .frame-sidebar > .brand {
    padding: 0;
  }

  .frame-start {
    width: 3rem;
    padding: 0;
  }

  .frame-nav {
    width: 100%;
  }

  .frame-nav a {
    flex-direction: column;
    justify-content: center;
    gap: var(--space-1);
    min-height: 3.5rem;
    padding: var(--space-1);
    font-size: var(--text-xs);
    text-align: center;
  }
}

/* Phones: a slim header on top, tabs at the bottom. */
@media (max-width: 760px) {
  .frame {
    display: flex;
    flex-direction: column;
  }

  .frame-sidebar {
    flex-direction: row;
    align-items: center;
    gap: var(--space-3);
    height: auto;
    padding: var(--space-2) var(--space-4);
    border-right: 0;
    border-bottom: 1px solid var(--border);
    background: var(--surface-page);
  }

  .frame-sidebar > .brand {
    padding: 0;
    margin-right: auto;
  }

  .frame-nav,
  .frame-foot {
    display: none;
  }

  .frame-start {
    width: auto;
    order: 2;
    min-height: 2.25rem;
    padding: 0 var(--space-3);
  }

  .frame-main {
    padding: var(--space-5) var(--space-4) calc(var(--space-7) + 4rem);
  }

  .frame-tabbar {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    position: fixed;
    inset: auto 0 0;
    z-index: 5;
    padding: var(--space-1) var(--space-2) calc(var(--space-1) + env(safe-area-inset-bottom));
    background: var(--surface-sunken);
    border-top: 1px solid var(--border);
  }

  .frame-tabbar a {
    display: grid;
    justify-items: center;
    gap: 2px;
    padding: var(--space-2) 0;
    color: var(--text-muted);
    font-size: 0.6875rem;
    font-weight: 600;
    text-decoration: none;
  }

  .frame-tabbar a[aria-current='page'] {
    color: var(--text);
  }

  .frame-tabbar svg {
    width: 1.375rem;
    height: 1.375rem;
  }

  .frame-tabbar a[aria-current='page'] svg {
    color: var(--action);
  }
}
