/* ============================================================
   Albert Cai — shared design system
   The Plain Index: near-monochrome, body-size-first, still at
   rest. Source Serif 4 reads; Archivo labels the furniture.
   ============================================================ */

:root {
  --font-serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --font-sans: "Archivo", system-ui, -apple-system, sans-serif;

  /* Near-monochrome, light. True off-white at chroma 0, not cream. */
  --bg: oklch(0.985 0 0);
  --bg-sunken: oklch(0.968 0 0);
  --ink: oklch(0.28 0 0);
  --ink-strong: oklch(0.20 0 0);
  --muted: oklch(0.46 0 0);
  --line: oklch(0.90 0 0);
  --line-soft: oklch(0.94 0 0);

  /* The one restrained accent: Crail orange (~#D97757), interaction only.
     --accent holds 3:1 on the page for focus rings and underlines;
     --accent-strong is the 4.5:1 text-safe step for hover and more-links. */
  --accent: oklch(0.67 0.131 38.8);
  --accent-strong: oklch(0.56 0.13 38.8);

  --measure: 64ch;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

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

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

body {
  margin: 0;
  background-color: var(--bg);
  color: var(--ink);
  font-family: var(--font-serif);
  font-optical-sizing: auto;
  font-size: clamp(1rem, 0.96rem + 0.2vw, 1.0625rem);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection {
  background: color-mix(in oklch, var(--accent) 25%, transparent);
}

.page {
  max-width: 42rem;
  margin: 0 auto;
  padding: clamp(1.5rem, 4vw, 2.5rem) clamp(1.25rem, 5vw, 2rem) 4rem;
}

a {
  color: inherit;
  text-decoration: none;
}

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

/* ---- Masthead: lowercase name over a left-aligned nav row ---- */
.masthead { margin-bottom: clamp(2rem, 6vw, 3rem); }

.site-name {
  margin: 0 0 0.4rem;
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.01em;
  color: var(--ink-strong);
}

a.site-name {
  display: inline-block;
  transition: color 0.2s var(--ease);
}

a.site-name:hover { color: var(--accent-strong); }

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.4rem;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: 0.005em;
}

.nav a {
  color: var(--muted);
  padding-block: 0.15rem;
  position: relative;
  transition: color 0.2s var(--ease);
}

.nav a::after {
  content: "";
  position: absolute;
  left: 0;
  right: 100%;
  bottom: -1px;
  height: 1.5px;
  background: var(--ink-strong);
  transition: right 0.28s var(--ease);
}

.nav a:hover { color: var(--ink-strong); }
.nav a:hover::after { right: 0; }

.nav a[aria-current="page"] { color: var(--ink-strong); }
.nav a[aria-current="page"]::after { right: 0; background: var(--line); }

/* ---- Page header (interior pages) ---- */
.page-header { margin-bottom: clamp(1.75rem, 5vw, 2.5rem); }

/* The name is barely larger than prose; hierarchy is weight and tone. */
h1 {
  margin: 0;
  font-weight: 600;
  font-size: clamp(1.35rem, 1.2rem + 0.6vw, 1.6rem);
  line-height: 1.25;
  letter-spacing: -0.01em;
  color: var(--ink-strong);
}

.tagline {
  margin: 0.2rem 0 0;
  max-width: var(--measure);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: 0.005em;
  color: var(--muted);
}

/* ---- Prose ---- */
.prose { max-width: var(--measure); }

.prose p {
  margin: 0 0 1.1em;
  text-wrap: pretty;
}

.prose p:last-child { margin-bottom: 0; }

/* A lead-in like "Now:" sits tight against its list. */
.prose p:has(+ ul) { margin-bottom: 0.35em; }

.prose ul {
  margin: 0 0 1.1em;
  padding-left: 1.15em;
}

.prose li { margin: 0.2em 0; }

.prose li::marker { color: var(--muted); }

/* ---- Inline links (the site's one interactive material) ---- */
.prose a,
.contact a,
.feature-title a {
  color: var(--ink-strong);
  font-weight: 500;
  text-decoration: underline;
  text-decoration-thickness: 0.06em;
  text-underline-offset: 0.18em;
  text-decoration-color: color-mix(in oklch, var(--accent) 42%, transparent);
  transition: color 0.2s var(--ease), text-decoration-color 0.2s var(--ease);
}

.prose a:hover,
.contact a:hover,
.feature-title a:hover {
  color: var(--accent-strong);
  text-decoration-color: var(--accent);
}

/* ---- Section scaffolding ---- */
section + section,
.prose + section { margin-top: clamp(2.25rem, 6vw, 3rem); }

/* Sentence-case serif heading over a hairline; the rule separates,
   the heading just names. Never uppercase, never tracked. */
.section {
  font-family: var(--font-serif);
  font-size: 1.05em;
  font-weight: 600;
  color: var(--ink-strong);
  margin: 0 0 0.9rem;
  padding-top: 1.15rem;
  border-top: 1px solid var(--line);
}

/* ---- Feature / entry titles (body-size, weight does the work) ---- */
.feature-title {
  font-family: var(--font-serif);
  font-size: 1.05em;
  font-weight: 600;
  line-height: 1.35;
  margin: 0;
  max-width: var(--measure);
}

.feature-desc {
  max-width: var(--measure);
  color: var(--muted);
  margin: 0.3rem 0 1rem;
  font-size: 0.95em;
  line-height: 1.55;
}

.more-link {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--accent-strong);
  display: inline-flex;
  align-items: baseline;
  gap: 0.35em;
}

.more-link .arrow { transition: transform 0.25s var(--ease); }
.more-link:hover .arrow { transform: translateX(3px); }

/* ---- Writing index (list of entries) ---- */
.entries {
  list-style: none;
  margin: 0;
  padding: 0;
}

.entry {
  padding: clamp(1.25rem, 3.5vw, 1.6rem) 0;
  border-top: 1px solid var(--line);
}

.entry:first-child {
  padding-top: 0;
  border-top: none;
}

.entry .feature-desc { margin-bottom: 0.5rem; }

.entry .meta {
  font-family: var(--font-sans);
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0;
}

.entry .meta em { font-style: italic; }

.note {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  color: var(--muted);
  margin: clamp(1.5rem, 4vw, 2rem) 0 0;
}

/* ---- Elsewhere index (home) ---- */
.index {
  list-style: none;
  margin: 0;
  padding: 0;
}

.index li {
  display: grid;
  grid-template-columns: 11rem 1fr;
  align-items: baseline;
  gap: 0.2rem 1.5rem;
  padding: 0.7rem 0;
  border-top: 1px solid var(--line-soft);
}

.index li:first-child { border-top: none; }

.index .term {
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: 0.95rem;
  color: var(--ink-strong);
  position: relative;
  width: max-content;
}

.index .term::after {
  content: "";
  position: absolute;
  left: 0;
  right: 100%;
  bottom: -2px;
  height: 1.5px;
  background: var(--accent);
  transition: right 0.28s var(--ease);
}

.index .term:hover { color: var(--accent-strong); }
.index .term:hover::after { right: 0; }

.index .gloss {
  font-family: var(--font-sans);
  font-size: 0.875rem;
  line-height: 1.4;
  color: var(--muted);
}

/* ---- Contact ---- */
.contact {
  color: var(--muted);
  font-size: 0.95em;
}

.contact p {
  max-width: var(--measure);
  margin: 0;
}

/* ---- Footer ---- */
footer {
  margin-top: clamp(2.75rem, 7vw, 4rem);
  padding-top: 1.15rem;
  border-top: 1px solid var(--line);
  font-family: var(--font-sans);
  font-size: 0.8rem;
  color: var(--muted);
}

/* ---- Motion ----
   Still at rest and still on load: no entrance animation, no reveal
   choreography. The whole motion budget is the hover transitions
   declared above (color shifts and grow-from-left underlines). */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

/* ---- Narrow viewports ---- */
@media (max-width: 34rem) {
  .index li {
    grid-template-columns: 1fr;
    gap: 0.25rem;
  }
}
