/*
Theme Name: Metze Legacy
Theme URI: https://patrick.metze.us
Author: Eric Metze
Author URI: https://patrick.metze.us
Description: A serif, content-focused classic theme for the published works of Professor Patrick Metze. Pairs with the Metze Papers mu-plugin.
Version: 1.0.0
Requires at least: 6.0
Tested up to: 7.0
Requires PHP: 7.4
License: GPL-2.0-or-later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: metze-legacy
*/

/* ===========================================================================
 * Tokens
 * ======================================================================== */
:root {
  --ml-ink: #2b2b2b;          /* slightly gray, not true black — mimics ink under
                                 real-world lighting and reads softer on the paper-tone background */
  --ml-paper: #fdfcf7;
  --ml-bg: #faf2dd;          /* average color of the paper-bg image, so the image
                                 blends seamlessly with the surrounding canvas on
                                 viewports that extend past the image edges */
  --ml-rule: #ddd9cd;
  --ml-accent: #5a1a1a;
  --ml-muted: #6b6757;

  --ml-serif: Charter, "Iowan Old Style", "Source Serif Pro", Georgia, "Times New Roman", serif;
  --ml-display: var(--ml-serif);
  --ml-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --ml-measure: 38rem;       /* readable line length for prose */
  --ml-content: 64rem;       /* page chrome max width */
}

/* The aged-paper background fills the viewport vertically and stays fixed
 * so the worn top and bottom edges always read. On wide viewports the sides
 * crop; on narrow vertical viewports the sides crop harder but the worn top
 * and bottom remain visible. The cream fills any remaining margin on the
 * sides to keep the backdrop harmonized. */
html {
  background-color: var(--ml-bg);
  background-image: url("assets/paper-bg.webp?v=2");
  background-repeat: no-repeat;
  background-position: center center;
  background-size: auto 100%;
  background-attachment: fixed;
  min-height: 100vh;
}
body { background: transparent; }

/* ===========================================================================
 * Reset (minimal)
 * ======================================================================== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; }
img, video { max-width: 100%; height: auto; }
button { font: inherit; }

/* ===========================================================================
 * Base typography
 * ======================================================================== */
body {
  font-family: var(--ml-serif);
  font-size: 1.0625rem;       /* 17px base, comfortable for serif */
  line-height: 1.65;
  color: var(--ml-ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--ml-display);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.01em;
  margin: 2.5rem 0 0.75rem;
}
h1 { font-size: 2.2rem; }
h2 { font-size: 1.6rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.05rem; }

p, ul, ol, blockquote, pre, figure { margin: 0 0 1.25rem; }
ul, ol { padding-left: 1.25rem; }
li + li { margin-top: 0.25rem; }

a { color: var(--ml-accent); text-underline-offset: 0.18em; }
a:hover { color: var(--ml-ink); }

blockquote {
  border-left: 3px solid var(--ml-accent);
  padding-left: 1rem;
  color: var(--ml-muted);
  font-style: italic;
}

hr {
  border: 0;
  border-top: 1px solid var(--ml-rule);
  margin: 2.5rem 0;
}

::selection { background: var(--ml-accent); color: var(--ml-paper); }

/* ===========================================================================
 * Layout
 * ======================================================================== */
.ml-site { display: flex; flex-direction: column; min-height: 100vh; }
.ml-main { flex: 1 0 auto; }

.ml-container {
  max-width: var(--ml-content);
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* ===========================================================================
 * Header
 * ======================================================================== */
.ml-header {
  border-bottom: 1px solid var(--ml-rule);
  background: transparent;
}
.ml-header__inner {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 1rem;
  padding: 1.75rem 1.5rem;
  max-width: var(--ml-content); margin: 0 auto;
}
.ml-site-title {
  margin: 0; font-size: 1.5rem; font-weight: 700; letter-spacing: -0.01em;
}
.ml-site-title a {
  color: var(--ml-ink); text-decoration: none;
}
.ml-site-title a:hover { color: var(--ml-accent); }

.ml-nav { font-size: 1rem; display: flex; align-items: center; }
.ml-nav ul {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-wrap: wrap; align-items: center;
  gap: 1.5rem;
}
.ml-nav li {
  margin: 0; padding: 0;
  display: flex; align-items: center;
}
.ml-nav a {
  display: inline-flex; align-items: center;
  text-decoration: none; color: var(--ml-ink);
  padding: 0.25rem 0;
  line-height: 1.4;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s;
}
.ml-nav a:hover { border-bottom-color: var(--ml-accent); color: var(--ml-accent); }
.ml-nav .current-menu-item > a,
.ml-nav .current_page_item > a { border-bottom-color: var(--ml-accent); }

/* ===========================================================================
 * Content shell
 * ======================================================================== */
.ml-content {
  padding: 1.75rem 0 4rem;
}
.ml-content > .ml-container > *:first-child { margin-top: 0; }

.ml-page-title {
  font-size: 2rem; margin: 0 0 0.5rem;
}
.ml-page-meta {
  color: var(--ml-muted); font-size: 0.95rem;
  margin: 0 0 2rem;
}

/* Prose: constrain line length for the about page and single-paper tiers. */
.ml-prose {
  max-width: var(--ml-measure);
}
.ml-prose p, .ml-prose li { font-size: 1.05rem; line-height: 1.7; }

/* ===========================================================================
 * Home (front page)
 * ======================================================================== */
.ml-hero { padding-top: 0; }
.ml-hero p:first-of-type em {
  display: block;
  font-style: italic; color: var(--ml-muted);
  font-size: 1.1rem; line-height: 1.5;
  margin-bottom: 2.25rem;
  border-bottom: 1px solid var(--ml-rule);
  padding-bottom: 1.5rem;
}
.ml-hero p { max-width: var(--ml-measure); font-size: 1.1rem; }

.cta-row { margin-top: 1rem; }
.cta-button {
  display: inline-block; padding: 0.65rem 1.5rem;
  border: 1px solid var(--ml-accent); color: var(--ml-accent);
  background: transparent; text-decoration: none;
  transition: background 0.15s, color 0.15s;
}
.cta-button:hover { background: var(--ml-accent); color: var(--ml-paper); }

/* ===========================================================================
 * Single paper
 * ======================================================================== */
.ml-paper__header {
  text-align: center;
  padding: 1rem 0 1.5rem;
  margin-bottom: 2rem;
  border-bottom: 1px solid var(--ml-rule);
}
.ml-paper__title {
  font-size: 1.9rem; line-height: 1.25;
  max-width: var(--ml-measure); margin: 0 auto;
}
.ml-paper__byline {
  font-style: italic; color: var(--ml-muted);
  margin-top: 0.75rem; font-size: 1rem;
}

/* ===========================================================================
 * Archive (works index)
 * ======================================================================== */
.ml-archive__header { margin-bottom: 2rem; }
.ml-archive__title { font-size: 2rem; margin: 0 0 0.5rem; }
.ml-archive__intro { color: var(--ml-muted); max-width: var(--ml-measure); }

/* ===========================================================================
 * Letters archive (card-grid layout for clinic newsletters)
 * ======================================================================== */
:root {
  --ml-capital: #5a1a1a;       /* deep red for Capital Punishment Clinic */
  --ml-defense: #2a4a3a;       /* deep green for Criminal Defense Clinic */
}

/* Filter chips */
.letters-filter {
  display: flex; flex-wrap: wrap; gap: 0.6rem;
  margin: 1rem 0 2.5rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--ml-rule);
}
.letters-filter__chip {
  background: transparent; border: 1px solid var(--ml-rule);
  color: var(--ml-muted);
  font-family: inherit; font-size: 0.92rem;
  padding: 0.45rem 1rem; border-radius: 999px;
  cursor: pointer; transition: all 0.15s;
}
.letters-filter__chip:hover { color: var(--ml-ink); border-color: var(--ml-ink); }
.letters-filter__chip.is-active {
  background: var(--ml-ink); color: var(--ml-paper); border-color: var(--ml-ink);
  font-weight: 600;
}
.letters-filter__count { opacity: 0.6; margin-left: 0.2rem; font-weight: 400; }

/* Year groups */
.letters-stream__year-group { margin-bottom: 2rem; }
.letters-stream__year-rule {
  display: flex; align-items: center; gap: 1rem;
  margin: 1.25rem 0 1.5rem;
}
.letters-stream__year-rule::before,
.letters-stream__year-rule::after {
  content: ""; flex: 1; height: 1px; background: var(--ml-rule);
}
.letters-stream__year-rule span {
  font-family: var(--ml-display);
  font-size: 2.2rem; font-weight: 700;
  color: var(--ml-ink); letter-spacing: -0.02em;
  padding: 0 0.5rem;
}

/* Two-column layout per year: Fall left, Spring right */
.letters-stream__columns {
  display: grid; gap: 1.5rem;
  grid-template-columns: 1fr 1fr;
  align-items: start;
}
.letters-stream__column {
  display: flex; flex-direction: column; gap: 1.5rem;
}
@media (max-width: 768px) {
  .letters-stream__columns { grid-template-columns: 1fr; }
}

/* Legacy class kept for any other contexts that may still emit it. */
.letters-stream__cards {
  display: grid; gap: 1.5rem;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
}

/* Card */
.letter-card {
  display: flex; flex-direction: column;
  padding: 1.5rem 1.5rem 1.25rem;
  background: var(--ml-paper);
  border: 1px solid var(--ml-rule);
  border-top: 4px solid var(--ml-defense);
  text-decoration: none; color: var(--ml-ink);
  transition: transform 0.18s, box-shadow 0.18s, border-color 0.18s;
  position: relative;
}
.letter-card--capital { border-top-color: var(--ml-capital); }
.letter-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 28px -12px rgba(0,0,0,0.18);
}

.letter-card__tag {
  display: inline-block; align-self: flex-start;
  font-variant: small-caps; letter-spacing: 0.12em;
  font-size: 0.72rem; font-weight: 600;
  padding: 0.25rem 0.65rem;
  background: var(--ml-defense); color: var(--ml-paper);
  border-radius: 3px;
  margin-bottom: 1rem;
}
.letter-card__tag--capital { background: var(--ml-capital); }

.letter-card__heading {
  margin: 0 0 0.85rem;
  font-family: var(--ml-display);
  display: flex; align-items: baseline; gap: 0.5rem;
  line-height: 1;
}
.letter-card__season {
  font-size: 1.5rem; font-weight: 700;
}
.letter-card__year {
  font-size: 1.1rem; font-weight: 400;
  color: var(--ml-muted);
}

.letter-card__excerpt {
  font-size: 0.97rem; line-height: 1.55;
  color: var(--ml-ink); margin: 0 0 1rem;
  flex-grow: 1;
}

.letter-card__cta {
  display: inline-block;
  font-size: 0.88rem; font-weight: 600;
  color: var(--ml-accent);
  border-bottom: 1px solid transparent;
  align-self: flex-start;
}
.letter-card:hover .letter-card__cta { border-bottom-color: currentColor; }

/* ===========================================================================
 * Single letter (newsletter column) with archive sidebar
 * ======================================================================== */
.ml-container.ml-container--wide { max-width: 78rem; }

.ml-letter__layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 13rem;
  gap: 3rem;
  align-items: start;
}

.ml-letter__archive {
  position: sticky;
  top: 1.5rem;
  font-size: 0.9rem;
  max-height: calc(100vh - 3rem);
  overflow-y: auto;
  padding-right: 0.5rem;
  /* Subtle scrollbar treatment */
  scrollbar-width: thin;
  scrollbar-color: var(--ml-rule) transparent;
}
.ml-archive__heading {
  font-size: 0.78rem;
  font-variant: small-caps; letter-spacing: 0.14em;
  color: var(--ml-muted);
  margin: 0 0 1rem;
  font-weight: 600;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--ml-rule);
}
.ml-archive__year { margin-bottom: 1.2rem; }
.ml-archive__year-label {
  font-family: var(--ml-display);
  font-size: 1rem; font-weight: 700;
  color: var(--ml-accent);
  margin: 0 0 0.3rem;
  letter-spacing: -0.01em;
}
.ml-archive__list ul { list-style: none; padding: 0; margin: 0; }
.ml-archive__list li { margin: 0.15rem 0; }
.ml-archive__list a {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 0.5rem;
  color: var(--ml-ink);
  text-decoration: none;
  padding: 0.18rem 0;
  border-left: 2px solid transparent;
  padding-left: 0.4rem;
  margin-left: -0.4rem;
  transition: color 0.12s, border-color 0.12s;
}
.ml-archive__list a:hover {
  color: var(--ml-accent);
  border-left-color: var(--ml-rule);
}
.ml-archive__list .is-current a {
  font-weight: 700;
  color: var(--ml-accent);
  border-left-color: var(--ml-accent);
}
.ml-archive__season { font-size: 0.92rem; }
.ml-archive__tag {
  font-size: 0.66rem;
  font-variant: small-caps; letter-spacing: 0.08em;
  color: var(--ml-muted);
  font-weight: 600;
  flex-shrink: 0;
}
.ml-archive__list .is-current .ml-archive__tag {
  color: var(--ml-accent);
}

@media (max-width: 900px) {
  .ml-letter__layout {
    grid-template-columns: 1fr;
    gap: 2rem;
  }
  .ml-letter__archive {
    position: static;
    max-height: none;
    overflow-y: visible;
    padding-right: 0;
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--ml-rule);
  }
}

/* ===========================================================================
 * Single letter (newsletter column)
 * ======================================================================== */
.ml-letter__header {
  padding: 1rem 0 1.5rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--ml-rule);
}
.ml-letter__title {
  font-size: 1.9rem; line-height: 1.25;
  max-width: var(--ml-measure); margin: 0;
}
.ml-letter__byline {
  font-style: italic; color: var(--ml-muted);
  margin-top: 0.6rem; font-size: 0.95rem;
}

.ml-letter__gallery {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  margin: 0 0 2rem;
}
.ml-letter__photo {
  display: block; overflow: hidden;
  border: 1px solid var(--ml-rule);
  aspect-ratio: 4 / 3;
  background: #f0ece2;
  transition: transform 0.18s, box-shadow 0.18s;
}
.ml-letter__photo:hover {
  transform: scale(1.02);
  box-shadow: 0 8px 18px -8px rgba(0,0,0,0.25);
}
.ml-letter__photo img {
  width: 100%; height: 100%;
  object-fit: cover; object-position: center;
  display: block;
}

/* ===========================================================================
 * Private mode splash (page-private.php)
 * ======================================================================== */
body.ml-private-splash { min-height: 100vh; }

.ml-private {
  min-height: 100vh;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 2rem 1.5rem 1rem;
  position: relative;
}
.ml-private__inner {
  max-width: 34rem; width: 100%;
  text-align: center;
  background: rgba(253, 252, 247, 0.85);
  padding: 2.5rem 2rem;
  border: 1px solid var(--ml-rule);
  box-shadow: 0 8px 30px -12px rgba(0,0,0,0.18);
}
.ml-private__header { margin-bottom: 1.5rem; }
.ml-private__title {
  font-family: var(--ml-display);
  font-size: 1.8rem; font-weight: 700;
  margin: 0; letter-spacing: -0.01em;
  color: var(--ml-ink);
}
.ml-private__article {
  font-size: 1.05rem; line-height: 1.65;
  color: var(--ml-ink);
  text-align: left;
}
.ml-private__article p { margin: 0 0 1rem; }
.ml-private__article p:last-child { margin-bottom: 0; }
.ml-private__article a { color: var(--ml-accent); }

.ml-private__login {
  margin-top: 2rem;
  font-size: 0.85rem;
  color: var(--ml-muted);
}
.ml-private__login a {
  color: var(--ml-muted);
  text-decoration: none;
  border-bottom: 1px dotted currentColor;
  padding-bottom: 1px;
}
.ml-private__login a:hover { color: var(--ml-accent); }

/* ===========================================================================
 * Footer
 * ======================================================================== */
.ml-footer {
  border-top: 1px solid var(--ml-rule);
  padding: 2.5rem 1.5rem;
  text-align: center;
  color: var(--ml-muted);
  font-size: 0.9rem;
  background: transparent;
}
.ml-footer p { margin: 0; }

/* ===========================================================================
 * Skip link (a11y)
 * ======================================================================== */
.skip-link {
  position: absolute; left: -9999px; top: 0;
  background: var(--ml-ink); color: var(--ml-paper);
  padding: 0.5rem 1rem; z-index: 100;
}
.skip-link:focus { left: 1rem; top: 1rem; }
