/* ============================================================
   Cici Liu — research papers
   Palette and structure drawn from audit's own materials:
   ledger paper, pen, pencil, ruled lines, red pencil for exceptions.
   ============================================================ */

:root {
  --paper:     #fcf7e3;   /* legal pad */
  --sheet:     #fefbf1;   /* a fresh sheet */
  --ink:       #1a1813;   /* pen */
  --ink-soft:  #5f5a4c;   /* pencil — metadata, annotation */
  --rule:      #ddd4b2;   /* ruled line */
  --exception: #9c3b2a;   /* red pencil — used sparingly, on purpose */

  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --mono:  "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --measure: 34rem;
  --margin-rail: 6rem;
}

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

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-optical-sizing: auto;
  font-size: 1.0625rem;
  line-height: 1.62;
  font-weight: 380;
}

::selection { background: var(--exception); color: var(--sheet); }

a { color: inherit; text-decoration-color: var(--rule); text-underline-offset: 0.18em; }
a:hover { text-decoration-color: var(--exception); }

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

/* ---------- shared shell ---------- */

.shell {
  max-width: calc(var(--measure) + var(--margin-rail) + 4rem);
  margin: 0 auto;
  padding: 0 1.5rem;
}

.label {
  font-family: var(--mono);
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

/* ---------- masthead ---------- */

.masthead {
  padding: 3.25rem 0 0;
}

.masthead__name {
  font-family: var(--serif);
  font-size: clamp(1.75rem, 1.3rem + 1.9vw, 2.5rem);
  font-weight: 500;
  letter-spacing: -0.018em;
  line-height: 1.1;
  margin: 0;
}

.masthead__role {
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0.85rem 0 0;
}

/* thesis — the standard the papers are written to */
.thesis {
  margin: 3.5rem 0 0;
  padding: 0 0 0 1.25rem;
  border-left: 2px solid var(--exception);
  max-width: 30rem;
}

.thesis p {
  margin: 0;
  font-size: clamp(1.125rem, 1rem + 0.5vw, 1.375rem);
  line-height: 1.44;
  font-weight: 380;
  letter-spacing: -0.008em;
}

.thesis footer {
  margin-top: 0.7rem;
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
}

.masthead__note {
  margin: 2rem 0 0;
  max-width: 30rem;
  color: var(--ink-soft);
  font-size: 0.9375rem;
}

/* ---------- the schedule (paper index) ---------- */

.schedule {
  margin: 4.5rem 0 0;
  border-top: 1px solid var(--ink);
}

.schedule__head {
  display: grid;
  grid-template-columns: 5rem 1fr 5rem;
  gap: 1.5rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--rule);
}

.schedule__head span:last-child { text-align: right; }

.entry {
  display: grid;
  grid-template-columns: 5rem 1fr 5rem;
  gap: 1.5rem;
  padding: 1.75rem 0;
  border-bottom: 1px solid var(--rule);
  text-decoration: none;
  color: inherit;
  transition: background 140ms ease;
}

.entry:hover { background: rgba(255,255,255,0.5); }
.entry:hover .entry__title { text-decoration-color: var(--exception); }

.entry__ref {
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--exception);
  padding-top: 0.3rem;
}

.entry__title {
  font-size: 1.1875rem;
  font-weight: 500;
  letter-spacing: -0.012em;
  line-height: 1.28;
  margin: 0;
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 0.2em;
  transition: text-decoration-color 140ms ease;
}

.entry__sub {
  margin: 0.4rem 0 0;
  color: var(--ink-soft);
  font-size: 0.9375rem;
  line-height: 1.5;
}

.entry__tags {
  margin: 0.75rem 0 0;
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
}

.entry__date {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--ink-soft);
  text-align: right;
  padding-top: 0.3rem;
  white-space: nowrap;
}

/* footed, the way a schedule should be */
.foot {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 0 0;
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.foot__tick { color: var(--exception); }

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

.site-foot {
  margin: 5rem 0 0;
  padding: 1.75rem 0 4rem;
  border-top: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.75rem;
}

/* ============================================================
   Paper pages
   ============================================================ */

.paper-shell {
  max-width: calc(var(--measure) + var(--margin-rail) + 4rem);
  margin: 0 auto;
  padding: 0 1.5rem;
}

.nav {
  display: flex;
  gap: 1.75rem;
  padding: 2.5rem 0 0;
}

.nav a {
  font-family: var(--mono);
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
  text-decoration: none;
  padding-bottom: 0.2rem;
  border-bottom: 1px solid transparent;
}

.nav a:hover { color: var(--ink); border-bottom-color: var(--rule); }
.nav a[aria-current] { color: var(--exception); border-bottom-color: var(--exception); }

.paper-head {
  margin: 3rem 0 0;
  padding-left: var(--margin-rail);
}

.paper-head__ref {
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  color: var(--exception);
  margin: 0 0 1rem;
}

.paper-head__title {
  font-size: clamp(1.875rem, 1.4rem + 2.1vw, 2.75rem);
  font-weight: 500;
  letter-spacing: -0.022em;
  line-height: 1.08;
  margin: 0;
  max-width: 20ch;
}

.paper-head__sub {
  margin: 1rem 0 0;
  font-size: 1.125rem;
  line-height: 1.4;
  color: var(--ink-soft);
  max-width: 34ch;
  font-weight: 380;
}

/* document control block — mirrors the front matter of the paper itself */
.control {
  margin: 2.5rem 0 0;
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--rule);
}

.control dl {
  margin: 0;
  display: grid;
  grid-template-columns: 9rem 1fr;
}

.control dt {
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--rule);
}

.control dd {
  margin: 0;
  padding: 0.55rem 0;
  font-size: 0.9375rem;
  border-bottom: 1px solid var(--rule);
}

.control dl > dt:last-of-type,
.control dl > dd:last-of-type { border-bottom: 0; }

/* ---------- the document body ---------- */

.doc {
  padding-left: var(--margin-rail);
  padding-bottom: 5rem;
  max-width: calc(var(--measure) + var(--margin-rail));
}

.doc > * { max-width: var(--measure); }

.doc h2, .doc h3, .doc h4 {
  position: relative;
  font-weight: 500;
  letter-spacing: -0.014em;
  line-height: 1.18;
}

.doc h2 {
  font-size: 1.5rem;
  margin: 3.75rem 0 1rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--rule);
}

.doc h3 {
  font-size: 1.1875rem;
  margin: 2.5rem 0 0.75rem;
}

.doc h4 {
  font-size: 1.0625rem;
  margin: 2rem 0 0.5rem;
}

/* section reference pulled into the margin, workpaper-style */
.secref {
  position: absolute;
  left: calc(-1 * var(--margin-rail));
  top: 1.35rem;
  width: calc(var(--margin-rail) - 1.25rem);
  text-align: right;
  font-family: var(--mono);
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--exception);
  line-height: 1.4;
}

.doc h3 .secref, .doc h4 .secref { top: 0.28rem; }

.doc p { margin: 0 0 1.15rem; }

.doc strong { font-weight: 600; }

.doc ul, .doc ol { margin: 0 0 1.15rem; padding-left: 1.15rem; }
.doc li { margin: 0 0 0.42rem; }
.doc li::marker { color: var(--ink-soft); }

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

.doc code {
  font-family: var(--mono);
  font-size: 0.875em;
  background: rgba(26,24,19,0.06);
  padding: 0.1em 0.32em;
  border-radius: 2px;
}

/* the one place red pencil is allowed to be loud */
.doc blockquote {
  margin: 2.25rem 0;
  padding: 0 0 0 1.25rem;
  border-left: 2px solid var(--exception);
}

.doc blockquote p {
  font-size: 1.1875rem;
  line-height: 1.44;
  margin: 0;
  letter-spacing: -0.008em;
}

/* ---------- tables as schedules ---------- */

.table-wrap {
  margin: 1.9rem 0 2.25rem;
  overflow-x: auto;
  max-width: calc(var(--measure) + 5rem);
}

.doc table {
  border-collapse: collapse;
  width: 100%;
  min-width: 32rem;
  font-size: 0.875rem;
  line-height: 1.5;
}

.doc thead th {
  font-family: var(--mono);
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
  text-align: left;
  padding: 0 0.9rem 0.5rem 0;
  border-bottom: 1px solid var(--ink);
  vertical-align: bottom;
}

.doc tbody td {
  padding: 0.7rem 0.9rem 0.7rem 0;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
}

.doc tbody tr:last-child td { border-bottom: 1px solid var(--ink); }

.doc tbody td:first-child { font-weight: 500; padding-right: 1.1rem; }

.doc thead th:last-child, .doc tbody td:last-child { padding-right: 0; }

/* ---------- checklist ---------- */

.doc .checklist { list-style: none; padding-left: 0; }

.doc .checklist li {
  position: relative;
  padding-left: 1.6rem;
  margin-bottom: 0.5rem;
}

.doc .checklist li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.42em;
  width: 0.72rem;
  height: 0.72rem;
  border: 1px solid var(--ink-soft);
}


/* what the series is — the line a stranger needs */
.masthead__series {
  margin: 1.5rem 0 0;
  max-width: 30rem;
  font-size: 1.0625rem;
  line-height: 1.5;
  color: var(--ink);
}

/* about page */
.doc--page { padding-bottom: 2.5rem; }

.doc--page p {
  font-size: 1.125rem;
  line-height: 1.6;
  margin-bottom: 1.35rem;
}

.control--about { margin-bottom: 1rem; }

/* ---------- responsive ---------- */

@media (max-width: 46rem) {
  :root { --margin-rail: 0rem; }

  .masthead { padding-top: 2.25rem; }
  .nav { gap: 1.25rem; padding-top: 2rem; }

  .paper-head, .doc { padding-left: 0; }

  .secref {
    position: static;
    display: block;
    width: auto;
    text-align: left;
    margin-bottom: 0.3rem;
  }

  .schedule__head { display: none; }

  .entry {
    grid-template-columns: 1fr;
    gap: 0.4rem;
    padding: 1.4rem 0;
  }

  .entry__ref { padding-top: 0; }
  .entry__date { text-align: left; padding-top: 0.25rem; }

  .control dl { grid-template-columns: 1fr; }
  .control dt { padding-bottom: 0; border-bottom: 0; }
  .control dd { padding-top: 0.15rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

@media print {
  body { background: #fff; }
  .nav, .site-foot { display: none; }
  .doc { padding-left: 0; }
  .secref { position: static; }
}
