/* ==========================================================================
   layout — the page shell, the left instrument rail, section framing
   ========================================================================== */

.page {
  position: relative;
  z-index: 1;
  padding-left: 0;
}

.shell {
  width: 100%;
  max-width: var(--shell);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  gap: var(--s-5);
  height: 52px;
  padding-inline: var(--gutter);
  border-bottom: 1px solid var(--rule);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
}

.topbar__mark {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  font-family: var(--font-display);
  font-size: var(--t-base);
  color: var(--txt);
  text-decoration: none;
  letter-spacing: 0.02em;
}

.topbar__mark:hover { color: var(--phos); }

.topbar__nav {
  display: flex;
  gap: var(--s-5);
  margin-left: auto;
  font-size: var(--t-sm);
}

.topbar__nav a {
  color: var(--txt-2);
  text-decoration: none;
  position: relative;
  padding-block: 2px;
}

.topbar__nav a::after {
  content: "";
  position: absolute;
  left: 0;
  right: 100%;
  bottom: 0;
  height: 1px;
  background: var(--phos);
  transition: right var(--dur-mid) var(--ease-out);
}

.topbar__nav a:hover { color: var(--phos); }
.topbar__nav a:hover::after { right: 0; }

.topbar__status {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  font-size: var(--t-xs);
  color: var(--amber);
  letter-spacing: 0.06em;
  padding: 2px var(--s-2);
  border: 1px solid var(--amber-dim);
}

@media (max-width: 860px) {
  .topbar__nav { display: none; }
}

/* ---- sections ---------------------------------------------------------- */

.section {
  position: relative;
  padding-block: var(--s-9) var(--s-8);
}

/* The divider sits on the content column, not on the shell's outer edge. */
.section::before {
  content: "";
  position: absolute;
  top: 0;
  left: var(--gutter);
  right: var(--gutter);
  height: 1px;
  background: var(--rule);
}

.section--flush { padding-block: var(--s-8); }

.section__head {
  display: grid;
  gap: var(--s-4);
  margin-bottom: var(--s-7);
  max-width: 92ch;
}

/* Used exactly once, in the hero: the session's opening line, before the
   wordmark. It is chrome, not a kicker — a label above a heading is banned
   outright, and an invented shell command restating the heading below it is
   that kicker in costume. Do not reintroduce it above section headings. */
.prompt {
  display: flex;
  align-items: baseline;
  gap: var(--s-2);
  font-size: var(--t-sm);
  color: var(--txt-3);
  letter-spacing: 0.02em;
}

.prompt__user { color: var(--phos-mid); }
.prompt__path { color: var(--cyan-dim); }
.prompt__cmd  { color: var(--txt-2); }

.prompt__caret {
  width: 7px;
  height: 14px;
  background: var(--phos);
  display: inline-block;
  translate: 0 2px;
  animation: caret 1.05s steps(1) infinite;
}

@keyframes caret {
  0%, 49%   { opacity: 1; }
  50%, 100% { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .prompt__caret { animation: none; opacity: 0.7; }
}

/* ---- grids ------------------------------------------------------------- */

.grid { display: grid; gap: var(--s-5); }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid--split { grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: var(--s-7); }
.grid--rail { grid-template-columns: 220px minmax(0, 1fr); gap: var(--s-7); }

@media (max-width: 1080px) {
  .grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid--split, .grid--rail { grid-template-columns: minmax(0, 1fr); gap: var(--s-6); }
}

@media (max-width: 720px) {
  .grid--2, .grid--3, .grid--4 { grid-template-columns: minmax(0, 1fr); }
}

.stack { display: grid; gap: var(--s-4); }
.stack--tight { gap: var(--s-2); }
.stack--loose { gap: var(--s-6); }

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-3);
}

/* ---- footer ------------------------------------------------------------ */

.footer {
  border-top: 1px solid var(--rule);
  padding-block: var(--s-8) var(--s-7);
  font-size: var(--t-sm);
  color: var(--txt-3);
}

.footer__grid {
  display: grid;
  grid-template-columns: 1.4fr repeat(3, minmax(0, 1fr));
  gap: var(--s-6);
}

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

.footer h3 {
  font-family: var(--font-display);
  font-size: var(--t-sm);
  color: var(--txt-2);
  letter-spacing: 0.08em;
  margin-bottom: var(--s-3);
}

.footer li + li { margin-top: var(--s-2); }
.footer a { color: var(--txt-2); text-decoration: none; }
.footer a:hover { color: var(--phos); }

.footer__legal {
  margin-top: var(--s-7);
  padding-top: var(--s-4);
  border-top: 1px solid var(--rule);
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-4);
  justify-content: space-between;
  color: var(--txt-3);
  font-size: var(--t-xs);
}

/* ---- primary nav: current page, and the small-screen drawer ------------ */

.topbar__nav a[aria-current="page"] { color: var(--phos); }
.topbar__nav a[aria-current="page"]::after { right: 0; }

.topbar__menu {
  display: none;
  margin-left: auto;
  padding: 5px var(--s-3);
  border: 1px solid var(--rule-bright);
  font-family: var(--font-display);
  font-size: var(--t-xs);
  letter-spacing: 0.12em;
  color: var(--txt-2);
}

.topbar__menu:hover { color: var(--phos); border-color: var(--rule-hot); }
.topbar__menu[aria-expanded="true"] { color: var(--bg); background: var(--phos); border-color: var(--phos); }

.mobilenav {
  position: sticky;
  top: 52px;
  z-index: 79;
  border-bottom: 1px solid var(--rule);
  background: color-mix(in srgb, var(--bg) 96%, transparent);
  backdrop-filter: blur(10px);
}

.mobilenav[hidden] { display: none; }

.mobilenav__inner {
  display: grid;
  gap: 2px;
  padding: var(--s-4) var(--gutter) var(--s-5);
  max-height: calc(100svh - 52px);
  overflow-y: auto;
}

.mobilenav__group {
  font-family: var(--font-display);
  font-size: var(--t-xs);
  letter-spacing: 0.14em;
  color: var(--txt-3);
  padding-top: var(--s-4);
  padding-bottom: var(--s-1);
}

.mobilenav__group:first-child { padding-top: 0; }

.mobilenav a {
  display: block;
  padding: 9px 0;
  border-bottom: 1px solid var(--rule);
  color: var(--txt-2);
  text-decoration: none;
  font-size: var(--t-sm);
}

.mobilenav a:hover { color: var(--phos); }
.mobilenav a[aria-current="page"] { color: var(--phos); }

@media (max-width: 1080px) {
  .topbar__nav { display: none; }
  .topbar__menu { display: inline-block; }
}

/* ---- page header (every page but the homepage) ------------------------- */

.pagehead {
  position: relative;
  padding-block: var(--s-8) var(--s-7);
}

.pagehead::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: var(--gutter);
  right: var(--gutter);
  height: 1px;
  background: var(--rule);
}

.pagehead__inner { display: grid; gap: var(--s-4); max-width: 92ch; }

.crumbs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
  font-size: var(--t-sm);
  color: var(--txt-3);
}

.crumbs a { color: var(--txt-3); text-decoration: none; }
.crumbs a:hover { color: var(--phos); }
.crumbs span[aria-current] { color: var(--txt-2); }
