/* Shell layout: sidebar + in-place content frame. Served with the shell CSP (no inline styles). */

:root {
  color-scheme: dark;
  --bg: #14213d;
  --bg-raised: #1f3158;
  --bg-active: #2a4175;
  --ink: #f1f5f9;
  --ink-muted: #cbd5e1;
  --ink-dim: #94a3b8;
  --accent: #fca311;
  --line: #33507d;
  --topbar-h: 3.25rem;
  --sidebar-w: 240px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-padding-top: var(--topbar-h);
}

body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font: 1rem/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}

a:focus-visible,
button:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

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

/* ---- skip link ------------------------------------------------------------------------------------- */

.skip-link {
  position: absolute;
  z-index: 60;
  top: 0.5rem;
  left: 0.5rem;
  transform: translateY(-150%);
  padding: 0.55rem 0.9rem;
  border-radius: 0.5rem;
  background: var(--accent);
  color: #1a1206;
  font-weight: 600;
  text-decoration: none;
}

.skip-link:focus-visible {
  transform: none;
}

/* ---- top bar --------------------------------------------------------------------------------------- */

.topbar {
  position: relative;
  z-index: 30;
  flex: none;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 1rem;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}

.brand {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Hidden by default: without scripting there is no drawer to open. */
.nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  margin-inline-start: -0.5rem;
  padding: 0;
  border: 0;
  border-radius: 0.5rem;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.nav-toggle:hover {
  background: var(--bg-raised);
}

.js .nav-toggle {
  display: inline-flex;
}

/* ---- shell grid ------------------------------------------------------------------------------------ */

.shell {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: 1fr;
  min-height: 0;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 1rem 0.75rem 1.5rem;
  background: var(--bg-raised);
  border-bottom: 1px solid var(--line);
}

/* Drawer, script only: with JS off the sidebar stays a plain list above the content. */
.js .sidebar {
  position: fixed;
  inset-block: 0;
  inset-inline-start: 0;
  z-index: 50;
  width: 248px;
  max-width: 84vw;
  overflow-y: auto;
  border-bottom: 0;
  border-inline-end: 1px solid var(--line);
  transform: translateX(-100%);
  visibility: hidden;
  transition: transform 0.2s ease, visibility 0s linear 0.2s;
}

.js .sidebar.is-open {
  transform: none;
  visibility: visible;
  transition: transform 0.2s ease;
}

.sidebar__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0 0.5rem 0.5rem;
}

.sidebar__title {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.sidebar__close {
  display: none;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  margin-inline-end: -0.35rem;
  padding: 0;
  border: 0;
  border-radius: 0.5rem;
  background: transparent;
  color: var(--ink-muted);
  cursor: pointer;
}

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

.js .sidebar__close {
  display: inline-flex;
}

/* ---- section links --------------------------------------------------------------------------------- */

.sections {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.section-item {
  position: relative;
  display: flex;
}

.section {
  flex: 1;
  display: block;
  padding: 0.6rem 2.4rem 0.6rem 0.75rem;
  border: 1px solid transparent;
  border-radius: 0.6rem;
  color: inherit;
  text-decoration: none;
}

.section:hover {
  background: var(--bg-active);
}

/* Active section: background + inset bar + aria-current, so it is never colour alone. */
.section[aria-current="page"] {
  background: var(--bg-active);
  border-color: #3d5a92;
  box-shadow: inset 3px 0 0 var(--accent);
}

.section__label {
  display: block;
  font-weight: 600;
}

.section__meta {
  display: block;
  font-size: 0.8rem;
  color: var(--ink-muted);
}

.section--soon {
  padding-right: 0.75rem;
  color: var(--ink-dim);
  cursor: default;
}

.section--soon:hover {
  background: none;
}

.section--soon .section__label {
  font-weight: 500;
}

.section__tab {
  position: absolute;
  inset-block-start: 0.4rem;
  inset-inline-end: 0.4rem;
  display: grid;
  place-items: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 0.4rem;
  color: var(--ink-muted);
  text-decoration: none;
  line-height: 1;
}

.section__tab:hover {
  background: #33507d;
  color: var(--ink);
}

/* ---- content --------------------------------------------------------------------------------------- */

.content {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.content:focus-visible {
  outline-offset: -2px;
}

.intro {
  width: 100%;
  max-width: 34rem;
  padding: 2rem 1.25rem 3rem;
}

.intro__title {
  margin: 0 0 0.375rem;
  font-size: 1.35rem;
}

.intro__lead {
  margin: 0 0 1.5rem;
  color: var(--ink-muted);
}

.cards {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.75rem;
}

.card {
  display: block;
  padding: 1rem 1.25rem;
  border: 1px solid transparent;
  border-radius: 0.75rem;
  background: var(--bg-raised);
  color: inherit;
  text-decoration: none;
}

.card:hover,
.card:focus-visible {
  background: var(--bg-active);
}

.card strong {
  display: block;
  font-size: 1.05rem;
}

.card span {
  color: var(--ink-muted);
  font-size: 0.9rem;
}

/* The frame is display:none until a section is selected: with JS off it never shows an empty box. */
.frame {
  display: none;
  width: 100%;
  height: calc(100dvh - var(--topbar-h));
  border: 0;
  background: #fff;
}

.js .content.has-section #intro {
  display: none;
}

.js .content.has-section:not(.has-gate) .frame {
  display: block;
}

/* ---- scrim ----------------------------------------------------------------------------------------- */

.scrim {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgb(6 10 20 / 62%);
}

.scrim.is-open {
  display: block;
}

/* ---- wide layout ----------------------------------------------------------------------------------- */

@media (min-width: 768px) {
  .shell {
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  }

  .sidebar {
    border-bottom: 0;
    border-inline-end: 1px solid var(--line);
    padding-top: 1.25rem;
  }

  .js .sidebar {
    position: static;
    width: auto;
    max-width: none;
    height: calc(100dvh - var(--topbar-h));
    overflow-y: auto;
    transform: none;
    visibility: visible;
    transition: none;
  }

  .js .nav-toggle,
  .js .sidebar__close {
    display: none;
  }

  .scrim,
  .scrim.is-open {
    display: none;
  }
}

/* ---- motion ---------------------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  .js .sidebar,
  .js .sidebar.is-open {
    transition: none;
  }
}

/* Scroll lock while the drawer covers the page (set by the script, mobile only). */
.js.drawer-open {
  overflow: hidden;
}
