/* ─────────────────────────────────────────────────────────────────────
   The rail: one strip of desert sand down the left of every inner page.
   It holds the way home (desert, projects, me), this page's contents and
   the next project, and looks the same on every page. Pages that open out
   of the sand (body.sand) are sand all the way across; on the others the
   page is a sheet laid beside the sand, and casts a little shadow on it.
   On phones the rail is a bar across the top; its menu is a sheet of sand.
   Needs: <body class="has-rail"> and the markup in any project page.
   ───────────────────────────────────────────────────────────────────── */
.cs-rail {
  --r-ink: #231c12;
  --r-ink-2: #4c3f2d;
  --r-muted: #78684f;
  --r-line: rgba(80, 56, 24, 0.17);
  --r-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --rail: 236px;
}
body.has-rail { --rail: 236px; }

.cs-rail {
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 30;
  width: var(--rail);
  overflow: hidden; isolation: isolate;
  color: var(--r-ink);
  font-family: "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px; line-height: 1.45; text-align: left;
  -webkit-font-smoothing: antialiased;
}
/* the sand is pinned to the window, so it lines up with a sand page's */
.cs-rail::before {
  content: ""; position: absolute; top: 0; left: 0; z-index: -1;
  width: 100vw; height: 100vh; height: 100lvh;
  background: #d0bd9f url("../img/sand.jpg") center / cover no-repeat;
}
/* where the page lies on the sand */
.cs-rail::after {
  content: ""; position: absolute; top: 0; right: 0; bottom: 0; width: 20px; pointer-events: none;
  background: linear-gradient(to left, rgba(84, 58, 24, 0.2), rgba(84, 58, 24, 0));
}
body.sand .cs-rail::before, body.sand .cs-rail::after { display: none; }
body.sand::before {
  content: ""; position: fixed; inset: 0; z-index: -1;
  background: #d0bd9f url("../img/sand.jpg") center / cover no-repeat;
}

.cs-rail-in {
  height: 100%; overflow-y: auto; overscroll-behavior: contain;
  display: flex; flex-direction: column; gap: 30px;
  padding: 24px 22px 22px;
}
.cs-rail-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
/* the round back button only shows on phones; the rail has its own way back */
.cs-back { display: none; }
.cs-rail-body { display: flex; flex-direction: column; gap: 30px; flex: 1; min-height: 0; }

.cs-rail a { color: inherit; }
.cs-rail :focus-visible { outline: 2px solid #b4532f; outline-offset: 2px; border-radius: 6px; }

/* the name, as on the desert */
.cs-brand { display: flex; flex-direction: column; gap: 5px; text-decoration: none; }
.cs-brand b { font-weight: 650; font-size: 21px; line-height: 1; letter-spacing: -0.035em; }
.cs-brand span {
  font: 500 9.5px/1.4 "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;
  letter-spacing: 0.13em; text-transform: uppercase; color: var(--r-ink-2);
}

/* the way home: the desert's own glass pill */
.cs-site {
  display: flex; gap: 2px; padding: 3px; width: max-content; max-width: 100%;
  background: rgba(250, 248, 244, 0.62); border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 999px; box-shadow: 0 6px 20px rgba(70, 60, 40, 0.1);
  -webkit-backdrop-filter: blur(14px) saturate(1.2); backdrop-filter: blur(14px) saturate(1.2);
}
.cs-site a {
  padding: 6px 11px; border-radius: 999px; white-space: nowrap;
  font-size: 12.5px; font-weight: 500; letter-spacing: -0.005em; text-decoration: none; color: #191816;
  transition: background 0.2s, color 0.2s;
}
.cs-site a:hover { background: rgba(25, 24, 22, 0.07); }
.cs-site a.is-solid { background: #191816; color: #fbf8f2; }
.cs-site a.is-solid:hover { background: #000; }

/* this page */
.cs-label {
  margin: 0 0 10px;
  font: 500 10px/1.4 "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--r-muted);
}
.cs-toc ol { list-style: none; margin: 0; padding: 0; counter-reset: toc; border-left: 1px solid var(--r-line); }
.cs-toc li { counter-increment: toc; }
.cs-toc a {
  position: relative; display: flex; align-items: baseline; gap: 10px;
  padding: 5px 0 5px 14px;
  font-size: 13.5px; line-height: 1.35; text-decoration: none; color: var(--r-ink-2);
  transition: color 0.2s;
}
.cs-toc a::before {
  content: counter(toc, decimal-leading-zero); flex: none;
  font: 500 10px/1 "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace; color: var(--r-muted);
}
.cs-toc a::after {
  content: ""; position: absolute; left: -1px; top: 5px; bottom: 5px; width: 2px; border-radius: 2px;
  background: var(--r-ink); transform: scaleY(0); transition: transform 0.3s var(--r-ease);
}
.cs-toc a:hover { color: var(--r-ink); }
.cs-toc a.on { color: var(--r-ink); font-weight: 550; }
.cs-toc a.on::after { transform: scaleY(1); }

/* the next one */
.cs-rail-next {
  margin-top: auto; display: flex; flex-direction: column; gap: 3px;
  padding-top: 14px; border-top: 1px solid var(--r-line); text-decoration: none;
}
.cs-rail-next small {
  font: 500 10px/1.4 "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--r-muted);
}
.cs-rail-next b { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; transition: color 0.2s; }
.cs-rail-next:hover b { color: #8f3a1c; }

/* the other projects in this crate, the one you are on marked */
.cs-cluster { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--r-line); }
.cs-cluster ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.cs-cluster a {
  display: flex; align-items: center; gap: 10px; padding: 4px; margin: 0 -4px; border-radius: 8px;
  font-size: 13px; line-height: 1.25; text-decoration: none; color: var(--r-ink-2);
  transition: background 0.2s, color 0.2s;
}
.cs-cluster img {
  flex: none; width: 52px; height: 29px; object-fit: cover; border-radius: 4px;
  box-shadow: 0 0 0 1px rgba(25, 24, 22, 0.08); opacity: 0.85; transition: opacity 0.2s;
}
.cs-cluster a:hover { background: rgba(25, 24, 22, 0.05); color: var(--r-ink); }
.cs-cluster a:hover img { opacity: 1; }
.cs-cluster a[aria-current="page"] { color: var(--r-ink); font-weight: 600; }
.cs-cluster a[aria-current="page"] img { opacity: 1; box-shadow: 0 0 0 1.5px var(--r-ink); }

.cs-rail-menu { display: none; }

/* ── wide: the rail stands to the left of the page ──────────────────── */
@media (min-width: 981px) {
  body.has-rail { padding-left: var(--rail); }
}

/* ── narrow: a bar across the top; its menu is a sheet of sand ───────── */
@media (max-width: 980px) {
  .cs-rail { position: sticky; bottom: auto; width: auto; height: 56px; border-bottom: 1px solid var(--r-line); }
  .cs-rail::after { display: none; }
  body.sand .cs-rail {
    background: rgba(214, 196, 166, 0.72);
    -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  }
  .cs-rail-in { padding: 0 16px; gap: 0; overflow: visible; }
  .cs-rail-bar { height: 56px; flex: none; justify-content: flex-start; }
  .cs-rail-bar .cs-brand { margin-right: auto; min-width: 0; }
  .cs-back {
    display: inline-grid; place-items: center; flex: none; width: 38px; height: 38px; margin-right: 2px;
    border-radius: 50%; font-size: 17px; line-height: 1; color: #191816; text-decoration: none;
    background: rgba(250, 248, 244, 0.7); border: 1px solid rgba(255, 255, 255, 0.75);
    box-shadow: 0 4px 14px rgba(70, 60, 40, 0.1);
  }
  .cs-back:active { transform: scale(0.94); }
  .cs-brand { gap: 3px; }
  .cs-brand b { font-size: 18px; }
  .cs-brand span { font-size: 8.5px; letter-spacing: 0.11em; }
  .cs-rail-menu {
    display: inline-flex; align-items: center; gap: 7px; flex: none;
    padding: 8px 14px; border-radius: 999px; cursor: pointer;
    font-family: inherit; font-size: 13px; font-weight: 500; line-height: 1; color: #191816;
    background: rgba(250, 248, 244, 0.7); border: 1px solid rgba(255, 255, 255, 0.75);
    box-shadow: 0 4px 14px rgba(70, 60, 40, 0.1);
  }
  .cs-rail-menu i { display: block; width: 12px; height: 8px; position: relative; }
  .cs-rail-menu i::before, .cs-rail-menu i::after {
    content: ""; position: absolute; left: 0; right: 0; height: 1.5px; border-radius: 2px; background: currentColor;
    transition: transform 0.25s var(--r-ease), top 0.25s var(--r-ease);
  }
  .cs-rail-menu i::before { top: 0; }
  .cs-rail-menu i::after { top: 6.5px; }
  .cs-rail-body { display: none; }

  body.rail-open { overflow: hidden; }
  body.rail-open .cs-rail { position: fixed; inset: 0; height: auto; z-index: 60; }
  body.rail-open.sand .cs-rail { background: none; -webkit-backdrop-filter: none; backdrop-filter: none; }
  body.rail-open .cs-rail::before { display: block; }
  body.rail-open .cs-rail-in { height: 100%; overflow-y: auto; padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px)); }
  body.rail-open .cs-rail-body { display: flex; padding-top: 18px; gap: 28px; animation: cs-rail-in 0.35s var(--r-ease) both; }
  body.rail-open .cs-rail-menu i::before { top: 3.25px; transform: rotate(45deg); }
  body.rail-open .cs-rail-menu i::after { top: 3.25px; transform: rotate(-45deg); }
  .cs-toc a { font-size: 16px; padding: 8px 0 8px 14px; }
  .cs-rail-next, .cs-cluster { margin-top: 4px; }
  .cs-cluster a { font-size: 15px; }
}
@keyframes cs-rail-in { from { opacity: 0; transform: translateY(-6px); } }

@media (prefers-reduced-motion: reduce) {
  .cs-toc a::after, body.rail-open .cs-rail-body { transition: none; animation: none; }
}

/* finished or not: top right of the page, scrolling away with it */
.cs-status {
  position: absolute; top: 48px; right: 56px; z-index: 30;
  padding: 5px 11px 5px 10px; border-radius: 999px; display: inline-flex; align-items: center; gap: 6px;
  font: 500 11.5px/1 "Geist", -apple-system, BlinkMacSystemFont, sans-serif; letter-spacing: 0.01em; white-space: nowrap;
}
.cs-status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.cs-status.is-done { color: #b4532f; background: #fbe6d6; box-shadow: inset 0 0 0 1px rgba(180, 83, 47, 0.22); }
.cs-status.is-wip { color: #2f5fb3; background: #e3ecfa; box-shadow: inset 0 0 0 1px rgba(47, 95, 179, 0.22); }
@media (max-width: 980px) {
  .cs-status { top: 74px; right: 16px; }
  .cs-head > .cs-status { position: static; margin: 0 0 12px; }
}
