/*
Theme Name: Rail
Theme URI: https://example.com/rail
Author: Xavier Zhapan Sullivan
Description: A two-column theme for lecture series and course sites. A sticky navigation rail on the left, a single measured content column on the right. Built for sites where the table of contents is part of the reading experience.
Version: 1.0.0
Requires at least: 6.0
Tested up to: 6.8
Requires PHP: 7.4
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: rail
Tags: two-columns, custom-menu, sticky-navigation, education, accessibility-ready
*/


/* ============================================================
   1. PALETTE  —  EDIT THESE SIX LINES TO RECOLOR THE SITE
   ============================================================
   Every color below is used by name throughout the stylesheet.
   Change a value here and it changes everywhere. Do not hunt
   through the file for individual hex codes.

   To match another site's palette, open that site, right-click
   → Inspect, and read the computed background-color and color
   values off the body and sidebar elements.
   ============================================================ */

:root {
  --paper:   #ffffff;   /* main content background          */
  --rail-bg: #f4f4f2;   /* left navigation column           */
  --ink:     #14140f;   /* body text                        */
  --muted:   #6f6f68;   /* dates, affiliations, captions    */
  --rule:    #d6d6d0;   /* hairlines and borders            */
  --accent:  #1b3df5;   /* links, current page, focus rings */

  /* Layout */
  --rail-width: 292px;
  --measure: 34rem;
  --gutter: clamp(1.5rem, 4vw, 4.5rem);

  /* Type */
  --sans: "Archivo", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --mono: "Space Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}


/* ============================================================
   2. RESET AND BASE
   ============================================================ */

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.6;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
}

img, svg, video { max-width: 100%; height: auto; display: block; }

a { color: var(--accent); text-decoration: underline; text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }

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

.screen-reader-text {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden; clip: rect(1px, 1px, 1px, 1px);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  top: -100px; left: 0.5rem;
  z-index: 100;
  background: var(--ink);
  color: var(--paper);
  padding: 0.75rem 1rem;
  text-decoration: none;
}
.skip-link:focus { top: 0.5rem; }


/* ============================================================
   3. THE TWO-COLUMN FRAME
   ============================================================ */

.frame {
  display: block;
}

@media (min-width: 900px) {
  .frame {
    display: grid;
    grid-template-columns: var(--rail-width) minmax(0, 1fr);
    align-items: start;
  }
}


/* ============================================================
   4. LEFT NAVIGATION RAIL
   ============================================================ */

.rail {
  background: var(--rail-bg);
  border-bottom: 1px solid var(--rule);
  padding: 1.5rem var(--gutter);
}

@media (min-width: 900px) {
  .rail {
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    overscroll-behavior: contain;
    border-bottom: 0;
    border-right: 1px solid var(--rule);
    padding: 2.75rem 1.75rem 3rem;
  }
}

.rail__masthead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.rail__title {
  margin: 0;
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.25;
}
.rail__title a { color: var(--ink); text-decoration: none; }
.rail__title a:hover { color: var(--accent); }

.rail__tagline {
  margin: 0.4rem 0 0;
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.rail__logo img { max-height: 64px; width: auto; }

/* Mobile disclosure button */
.rail__toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
}
.rail__toggle:hover { border-color: var(--ink); }

@media (min-width: 900px) {
  .rail__toggle { display: none; }
}

.rail__nav { margin-top: 2rem; }

@media (max-width: 899px) {
  .rail__nav { display: none; margin-top: 1.25rem; }
  .rail__nav.is-open { display: block; }
}


/* --- Menu structure -----------------------------------------
   Top-level menu items render as quiet section labels.
   Child items render as a numbered, indented sequence — the
   numbering is a CSS counter, so reordering the menu in
   Appearance → Menus renumbers everything automatically.
   ------------------------------------------------------------ */

.rail__nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* Top level */
.rail__nav > ul > li {
  margin-bottom: 1.75rem;
}

.rail__nav > ul > li > a {
  display: block;
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: -0.005em;
  color: var(--ink);
  text-decoration: none;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--rule);
}
.rail__nav > ul > li > a:hover { color: var(--accent); border-bottom-color: var(--accent); }

/* Submenu — the numbered spine */
.rail__nav .sub-menu {
  counter-reset: lecture;
  margin-top: 0.6rem;
}

.rail__nav .sub-menu li { counter-increment: lecture; }

.rail__nav .sub-menu a {
  display: grid;
  grid-template-columns: 2ch 1fr;
  gap: 0.6rem;
  align-items: baseline;
  padding: 0.3rem 0;
  font-size: 0.875rem;
  line-height: 1.4;
  color: var(--ink);
  text-decoration: none;
}

.rail__nav .sub-menu a::before {
  content: counter(lecture, decimal-leading-zero);
  font-family: var(--mono);
  font-size: 0.6875rem;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.rail__nav .sub-menu a:hover { color: var(--accent); }
.rail__nav .sub-menu a:hover::before { color: var(--accent); }

/* Current page: a solid block marker rather than a color swap,
   so the position in the sequence stays legible at a glance. */
.rail__nav .current-menu-item > a,
.rail__nav .current_page_item > a {
  font-weight: 600;
  color: var(--ink);
}
.rail__nav .sub-menu .current-menu-item > a::before,
.rail__nav .sub-menu .current_page_item > a::before {
  content: counter(lecture, decimal-leading-zero);
  color: var(--paper);
  background: var(--ink);
  padding: 0.1em 0.3em;
  margin-left: -0.3em;
}

.rail__footer {
  margin-top: 3rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: 0.6875rem;
  line-height: 1.6;
  color: var(--muted);
}
.rail__footer a { color: var(--muted); }
.rail__footer a:hover { color: var(--accent); }


/* ============================================================
   5. RIGHT CONTENT COLUMN
   ============================================================ */

.content {
  padding: var(--gutter);
  min-width: 0;
}

@media (min-width: 900px) {
  .content { padding: 4.5rem var(--gutter) 7rem; }
}

.content__inner { max-width: var(--measure); }

/* Wide blocks escape the measure */
.content__inner .alignwide  { max-width: min(58rem, 100%); width: 100%; }
.content__inner .alignfull  { max-width: none; width: auto; }


/* --- Article head ------------------------------------------- */

.entry__eyebrow {
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 0.9rem;
}

.entry__title {
  margin: 0 0 1.5rem;
  font-size: clamp(1.75rem, 1.2rem + 2.2vw, 2.75rem);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.025em;
  text-wrap: balance;
}

.entry__meta {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--muted);
  margin: 0 0 2.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--rule);
}


/* --- Long-form typography ----------------------------------- */

.entry__body > * + * { margin-top: 1.15em; }

.entry__body h2 {
  margin-top: 2.75rem;
  font-size: 1.375rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.25;
}

.entry__body h3 {
  margin-top: 2rem;
  font-size: 1.0625rem;
  font-weight: 600;
}

.entry__body p { margin-bottom: 0; }

.entry__body ul,
.entry__body ol { padding-left: 1.25rem; }
.entry__body li + li { margin-top: 0.4rem; }

.entry__body blockquote {
  margin-left: 0;
  margin-right: 0;
  padding-left: 1.25rem;
  border-left: 2px solid var(--ink);
  font-size: 1.125rem;
  line-height: 1.45;
}

.entry__body figure { margin-left: 0; margin-right: 0; }

.entry__body figcaption {
  font-family: var(--mono);
  font-size: 0.6875rem;
  line-height: 1.5;
  color: var(--muted);
  margin-top: 0.6rem;
}

.entry__body code {
  font-family: var(--mono);
  font-size: 0.875em;
  background: var(--rail-bg);
  padding: 0.15em 0.35em;
}

.entry__body pre {
  background: var(--rail-bg);
  border: 1px solid var(--rule);
  padding: 1rem;
  overflow-x: auto;
  font-size: 0.8125rem;
  line-height: 1.5;
}
.entry__body pre code { background: none; padding: 0; }

.entry__body hr {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: 3rem 0;
}

.entry__body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
}
.entry__body th,
.entry__body td {
  text-align: left;
  padding: 0.6rem 0.75rem 0.6rem 0;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
}
.entry__body th {
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 400;
}


/* ============================================================
   6. INDEX LISTING (blog / archive)
   ============================================================ */

.listing { list-style: none; margin: 0; padding: 0; }

.listing__item {
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--rule);
}
.listing__item:first-child { padding-top: 0; }

.listing__date {
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  display: block;
  margin-bottom: 0.4rem;
}

.listing__title {
  margin: 0 0 0.5rem;
  font-size: 1.1875rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.25;
}
.listing__title a { color: var(--ink); text-decoration: none; }
.listing__title a:hover { color: var(--accent); text-decoration: underline; }

.listing__excerpt { margin: 0; color: var(--muted); font-size: 0.9375rem; }


/* ============================================================
   7. PAGINATION AND POST NAVIGATION
   ============================================================ */

.pagination,
.post-nav {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
}

.pagination .page-numbers {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  text-decoration: none;
}
.pagination .page-numbers.current {
  background: var(--ink);
  color: var(--paper);
}

.post-nav { display: flex; justify-content: space-between; gap: 1.5rem; }


/* ============================================================
   8. COMMENTS (kept deliberately plain)
   ============================================================ */

.comments { margin-top: 4rem; padding-top: 2rem; border-top: 1px solid var(--rule); }
.comments ol { list-style: none; padding-left: 0; }
.comments .children { padding-left: 1.5rem; }
.comments input[type="text"],
.comments input[type="email"],
.comments input[type="url"],
.comments textarea {
  width: 100%;
  font: inherit;
  padding: 0.5rem;
  border: 1px solid var(--rule);
  background: var(--paper);
  color: var(--ink);
}
.comments input[type="submit"] {
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: var(--ink);
  color: var(--paper);
  border: 0;
  padding: 0.7rem 1.25rem;
  cursor: pointer;
}


/* ============================================================
   9. PRINT AND MOTION
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

@media print {
  .rail { display: none; }
  .frame { display: block; }
  .content { padding: 0; }
  body { font-size: 11pt; }
  a { color: inherit; text-decoration: none; }
}
