/* ==========================================================================
   LAYOUT — one centred column, Notion-style.

   Every band of the page (masthead, navigation row, content, footer) uses
   the same .wrap, so the whole site shares one centred measure and one pair
   of margins. Navigation is a SINGLE horizontal row.
   ========================================================================== */

/* --- The centred column -------------------------------------------------- */

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

/* A tighter reading measure inside the column, still left-aligned to it. */
.measure { max-width: var(--width-prose); }

body { display: flex; flex-direction: column; min-height: 100vh; }
main  { flex: 1 0 auto; }

/* --- Masthead ------------------------------------------------------------
   No wordmark: the row of pages IS the masthead, and it sits close to the
   top of the window.
   ------------------------------------------------------------------------ */

.masthead {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg);
  padding-block-start: var(--space-xs);
}

/* --- The navigation row --------------------------------------------------
   A single hairline runs the width of the column. Each page sits on it, and
   the current page is marked by a short tick in the rail beneath its label —
   a measuring scale rather than a tab bar.
   ------------------------------------------------------------------------ */

.railnav { position: relative; }

.railnav::after {
  content: "";
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  height: 1px;
  background: var(--rule);
}

/* The row: pages spread across the column, toggle pinned to its right edge. */
.railnav__inner {
  display: flex;
  align-items: stretch;
  gap: var(--space-m);
}

.railnav__list {
  display: flex;
  flex: 1;
  min-width: 0;
  align-items: flex-end;   /* labels share a baseline, kickers rise above */
  gap: clamp(0.85rem, 2.2vw, 1.6rem);
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity;
}

.railnav__list::-webkit-scrollbar { display: none; }

/* Once the row comfortably fits, spread it across the full column so the
   rail reads as a deliberate span rather than trailing off mid-way. */
@media (min-width: 40rem) {
  .railnav__list { justify-content: space-between; gap: var(--space-s); }
}

.railnav__item { flex: none; scroll-snap-align: start; }

.railnav__link {
  position: relative;
  display: block;
  padding-block: 0.7rem 0.85rem;
  font-size: var(--step--1);
  line-height: 1.3;
  color: var(--text-muted);
  text-decoration: none;
  white-space: nowrap;
  transition: color var(--dur-fast) var(--ease);
}

/* The tick in the rail. */
.railnav__link::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 0;
  height: 2px;
  background: var(--rule-strong);
  transform: translateX(-50%);
  transition: width var(--dur) var(--ease), background-color var(--dur) var(--ease);
}

.railnav__link:hover { color: var(--text); }
.railnav__link:hover::after { width: 1.15rem; }

.railnav__link[aria-current="page"] {
  color: var(--text);
  font-weight: 600;
}

.railnav__link[aria-current="page"]::after {
  width: 100%;
  background: var(--accent);
}

/* Not yet published: on the rail, clearly not clickable. */
.railnav__link--disabled {
  color: var(--text-faint);
  cursor: default;
  opacity: 0.75;
}

.railnav__link--disabled:hover { color: var(--text-faint); }
.railnav__link--disabled:hover::after { width: 0; }

.railnav__link--disabled::after { content: none; }


/* On narrow screens the row scrolls sideways; fade the edges to show it. */
@media (max-width: 52rem) {
  .railnav__inner {
    -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 var(--gutter),
                        #000 calc(100% - var(--gutter)), transparent 100%);
            mask-image: linear-gradient(90deg, transparent 0, #000 var(--gutter),
                        #000 calc(100% - var(--gutter)), transparent 100%);
  }
}

/* --- Buttons -------------------------------------------------------------- */

.icon-button {
  display: grid;
  place-items: center;
  width: 2.1rem;
  height: 2.1rem;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-m);
  background: none;
  color: var(--text-faint);
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease),
              color var(--dur-fast) var(--ease),
              border-color var(--dur-fast) var(--ease);
}

.icon-button:hover {
  background: var(--bg-tint);
  color: var(--text);
  border-color: var(--rule);
}

.icon-button svg { width: 1.05rem; height: 1.05rem; }

.theme-toggle__sun  { display: none; }
:root[data-theme="dark"] .theme-toggle__sun  { display: block; }
:root[data-theme="dark"] .theme-toggle__moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle__sun  { display: block; }
  :root:not([data-theme="light"]) .theme-toggle__moon { display: none; }
}

/* --- Section rhythm ------------------------------------------------------- */

.section { padding-block: var(--space-xl); }
.section--tight { padding-block: var(--space-l); }
.section + .section { padding-block-start: 0; }

.section-head {
  display: flex;
  align-items: baseline;
  gap: var(--space-m);
  margin-block-end: var(--space-l);
}

.section-head::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--rule);
}

.section-head__link {
  font-size: var(--step--1);
  text-decoration: none;
  white-space: nowrap;
}

.section-head__link:hover { text-decoration: underline; }

/* --- Footer --------------------------------------------------------------- */

.site-footer {
  margin-block-start: var(--space-2xs);
  border-block-start: 1px solid var(--rule);
  padding-block: var(--space-m);
  font-size: var(--step--1);
  color: var(--text-faint);
}

.site-footer__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-s) var(--space-m);
}

.site-footer a { color: var(--text-muted); text-decoration: none; }
.site-footer a:hover { color: var(--accent); text-decoration: underline; }

.site-footer__links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-m);
  list-style: none;
  margin: 0;
  padding: 0;
}

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

.grid { display: grid; gap: var(--space-m); }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr)); }

/* --- Theme toggle on the rail -------------------------------------------- */

.railnav__toggle {
  flex: none;
  align-self: center;
  margin-block-end: 0.15rem;
}

/* --- "Spatiotemporal" kicker above a nav label ---------------------------- */

.railnav__kicker {
  display: block;
  font-size: 0.62em;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  line-height: 1;
  color: var(--text-faint);
  margin-block-end: 0.4em;
  transition: color var(--dur-fast) var(--ease);
}

.railnav__link[aria-current="page"] .railnav__kicker { color: var(--highlight); }
.railnav__link:hover .railnav__kicker { color: var(--text-muted); }

.railnav__label { display: block; }
