/* ==========================================================================
   PataNYC — Article Stylesheet
   Tufte-inspired offset layout with sidenotes
   Typography: Libre Baskerville (display) + Source Serif 4 (body)
   With a touch of subversion.
   ========================================================================== */

/* --- CSS Variables --- */
:root {
  --color-green: #2D5F2D;
  --color-green-light: #3A7A3A;
  --color-green-faint: rgba(45, 95, 45, 0.08);
  --color-green-border: rgba(45, 95, 45, 0.25);
  --color-gold: #8B7532;
  --color-gold-faint: rgba(139, 117, 50, 0.12);
  --color-absinthe: #B8C800;
  --color-absinthe-faint: rgba(184, 200, 0, 0.15);
  --color-bg: #EFF3EA;
  --color-bg-warm: #F5F4EF;
  --color-text: #1A1A18;
  --color-text-secondary: #555550;
  --color-text-tertiary: #888883;
  --color-rule: #D4D2C8;
  --color-rule-strong: #B0AEA4;

  --font-display: 'Libre Baskerville', 'Baskerville', 'Georgia', serif;
  --font-body: 'Source Serif 4', 'Source Serif Pro', 'Georgia', serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
  --font-sans: 'Source Sans 3', 'Source Sans Pro', -apple-system, sans-serif;
  --font-stamp: 'Special Elite', 'Courier New', monospace;

  --width-body: 650px;
  --width-sidenote: 250px;
  --gap-sidenote: 40px;
  --margin-left: max(calc((100vw - var(--width-body) - var(--width-sidenote) - var(--gap-sidenote)) / 2.5), 60px);

  --line-height: 1.72;
  --font-size-body: 1.075rem;
}

/* --- Reset & Base --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: var(--font-body);
  font-size: var(--font-size-body);
  line-height: var(--line-height);
  color: var(--color-text);
  background: url("/images/grain.png") repeat, var(--color-bg);
  background-size: 200px 200px, auto;
  position: relative;
}

/* --- Page-level container --- */
.article-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* --- Site Header (minimal) --- */
.site-header {
  padding: 1.5rem var(--margin-left);
  border-bottom: 1px solid var(--color-rule);
}

.site-header-link {
  display: inline-flex;
  align-items: center;
  gap: 0.6em;
  font-family: var(--font-display);
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  color: var(--color-text-secondary);
  text-decoration: none;
  transition: color 0.2s;
}

.site-header-link:hover {
  color: var(--color-absinthe);
}

.site-header-link:hover .site-logo {
  filter: brightness(1.3) saturate(1.5);
}

.site-logo {
  height: 24px;
  width: auto;
  display: block;
}

.site-name {
  position: relative;
  top: 1px;
}

/* --- Article Container --- */
.article-container {
  flex: 1;
  position: relative;
  padding: 4rem 1.5rem 6rem;
  max-width: calc(var(--margin-left) + var(--width-body) + var(--gap-sidenote) + var(--width-sidenote) + 60px);
}

.article-body {
  margin-left: var(--margin-left);
  max-width: var(--width-body);
  position: relative;
}

/* --- Article Header --- */
.article-header {
  margin-bottom: 3.5rem;
}

.article-category {
  display: inline-block;
  font-family: var(--font-stamp);
  font-size: 0.85rem;
  font-weight: 400;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-green);
  margin-bottom: 1rem;
  padding: 0.35em 0.6em 0.15em;
  border: 1.5px solid var(--color-green);
  transform: rotate(-0.8deg);
}

.article-category a {
  color: inherit;
  text-decoration: none;
}

.article-title {
  font-family: var(--font-display);
  font-size: 2.4rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--color-text);
  margin-bottom: 0.3em;
  letter-spacing: -0.01em;
}

.article-subtitle {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 400;
  font-style: italic;
  line-height: 1.45;
  color: var(--color-text-secondary);
  margin-bottom: 1.5rem;
}

.article-meta {
  font-family: var(--font-sans);
  font-size: 0.82rem;
  color: var(--color-text-tertiary);
  line-height: 1.6;
}

.article-meta .author {
  color: var(--color-text-secondary);
  font-weight: 500;
}

.article-meta .separator {
  margin: 0 0.5em;
  color: var(--color-rule-strong);
}

.article-meta .updated-notice {
  font-style: italic;
  color: var(--color-text-tertiary);
}

.article-header-rule {
  border: none;
  height: 3px;
  background: var(--color-green);
  width: 60px;
  margin-top: 2rem;
}

/* --- Article Content --- */
.article-content {
  position: relative;
}

.article-content p {
  margin-bottom: 1.4em;
}

.article-content > p:first-child::first-letter {
  font-family: var(--font-display);
  font-size: 1.8em;
  float: left;
  line-height: 0.8;
  padding-right: 0.05em;
  padding-top: 0.05em;
  color: var(--color-green);
  font-weight: 700;
}

/* Kill drop caps in footnotes, blockquotes, and lists */
.footnotes p::first-letter,
.article-content blockquote p:first-child::first-letter,
.article-content li p::first-letter {
  font-size: inherit;
  float: none;
  padding: 0;
  color: inherit;
  font-weight: inherit;
  line-height: inherit;
}

.article-content a {
  color: var(--color-green);
  text-decoration: underline;
  text-decoration-color: var(--color-green-border);
  text-underline-offset: 0.15em;
  transition: all 0.2s;
}

.article-content a:hover {
  text-decoration-color: var(--color-absinthe);
  color: var(--color-absinthe);
}

/* Headings within article */
.article-content h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  margin-top: 2.8em;
  margin-bottom: 0.8em;
  color: var(--color-text);
  line-height: 1.3;
}

.article-content h3 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  margin-top: 2.2em;
  margin-bottom: 0.6em;
  color: var(--color-text);
  line-height: 1.4;
}

.article-content h4 {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-top: 2em;
  margin-bottom: 0.6em;
  color: var(--color-text-secondary);
}

/* Blockquotes */
.article-content blockquote {
  margin: 2em 0;
  padding: 1.2em 1.5em 1.2em 1.5em;
  border-left: 3px solid var(--color-green);
  background: var(--color-green-faint);
  color: var(--color-text-secondary);
  font-size: 0.97em;
  line-height: 1.78;
}

.article-content blockquote p {
  margin-bottom: 0.8em;
}

.article-content blockquote p:last-child {
  margin-bottom: 0;
}

.article-content blockquote p:first-child::first-letter {
  font-size: inherit;
  float: none;
  padding: 0;
  color: inherit;
  font-weight: inherit;
}

/* Nested blockquotes (quote within a quote) */
.article-content blockquote blockquote {
  margin: 1em 0;
  padding: 0.8em 1.2em;
  border-left-color: var(--color-green-border);
  background: rgba(45, 95, 45, 0.04);
}

/* Lists */
.article-content ol,
.article-content ul {
  margin: 1.4em 0;
  padding-left: 1.5em;
}

.article-content li {
  margin-bottom: 0.5em;
}

.article-content ol {
  list-style-type: decimal;
}

/* Figures / Images — Size classes */
.article-figure {
  margin: 2em 0;
}

.article-figure img {
  width: 100%;
  height: auto;
  display: block;
}

.article-figure figcaption {
  font-family: var(--font-sans);
  font-size: 0.78rem;
  color: var(--color-text-tertiary);
  margin-top: 0.6em;
  line-height: 1.5;
  font-style: italic;
}

/* Extra small — thumbnail/icon scale */
.article-figure.img-xs {
  max-width: 150px;
}

/* Small — inline/sidebar scale, centered */
.article-figure.img-sm {
  max-width: 300px;
}

/* Medium — standard content image */
.article-figure.img-md {
  max-width: 500px;
}

/* Large — full body width (default) */
.article-figure.img-lg {
  max-width: var(--width-body);
}

/* Full — breaks out into the sidenote margin */
.article-figure.img-full {
  max-width: calc(var(--width-body) + var(--gap-sidenote) + var(--width-sidenote));
}

/* Alignment — default is left-aligned (no class needed) */
.article-figure.img-center {
  margin-left: auto;
  margin-right: auto;
}

.article-figure.img-right {
  margin-left: auto;
  margin-right: 0;
}

/* --- Sidenotes (Tufte-style) --- */
.sidenote-number {
  counter-increment: sidenote-counter;
  font-size: 0.7em;
  vertical-align: super;
  line-height: 0;
  color: var(--color-green);
  font-family: var(--font-sans);
  font-weight: 600;
  cursor: pointer;
  position: relative;
}

.sidenote-number::after {
  content: counter(sidenote-counter);
}

.sidenote {
  float: right;
  clear: right;
  width: var(--width-sidenote);
  margin-right: calc(-1 * (var(--width-sidenote) + var(--gap-sidenote)));
  margin-bottom: 1.2em;
  font-family: var(--font-sans);
  font-size: 0.78rem;
  line-height: 1.55;
  color: var(--color-text-secondary);
  position: relative;
  padding-top: 0.1em;
}

.sidenote::before {
  content: counter(sidenote-counter) ".";
  font-weight: 600;
  color: var(--color-green);
  margin-right: 0.4em;
  font-size: 0.85em;
}

.sidenote-checkbox {
  display: none;
}

/* --- Labels / Tags --- */
.article-labels {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--color-rule);
}

.article-labels span,
.article-labels a {
  display: inline-block;
  font-family: var(--font-stamp);
  font-size: 0.78rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--color-text-secondary);
  background: var(--color-green-faint);
  padding: 0.35em 0.6em 0.15em;
  margin-right: 0.4em;
  margin-bottom: 0.4em;
  border: 1px solid var(--color-green-border);
  border-radius: 0;
  text-decoration: none;
  transition: all 0.15s;
}

.article-labels a:hover {
  color: var(--color-absinthe);
  border-color: var(--color-absinthe);
}

/* --- Ampersand Closing Mark --- */
.article-closing {
  text-align: center;
  margin-top: 3rem;
  font-family: var(--font-stamp);
  font-size: 1.8rem;
  color: var(--color-green);
  letter-spacing: 0.2em;
  transition: transform 0.3s ease;
  cursor: default;
}

.article-closing:hover {
  transform: rotate(2.5deg);
  color: var(--color-absinthe);
}

/* --- Footnotes section (Hugo's built-in footnotes) --- */
.footnotes,
section.footnotes {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--color-rule);
  font-family: var(--font-sans);
  font-size: 0.82rem;
  line-height: 1.6;
  color: var(--color-text-secondary);
  counter-reset: none;
}

.footnotes ol,
section.footnotes ol {
  padding-left: 1.5em;
}

.footnotes li,
section.footnotes li {
  margin-bottom: 0.8em;
}

.footnotes li p,
section.footnotes li p {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.6;
}

.footnotes a.footnote-backref,
section.footnotes a.footnote-backref {
  color: var(--color-green);
  text-decoration: none;
  margin-left: 0.3em;
  transition: color 0.2s;
}

.footnotes a.footnote-backref:hover,
section.footnotes a.footnote-backref:hover {
  color: var(--color-absinthe);
}

.footnotes hr {
  display: none;
}

.footnotes {
  border-top: 1px solid var(--color-rule, #ccc);
  margin-top: 2rem;
  padding-top: 1.5rem;
}

/* Hugo footnote reference links in body text */
.article-content a[href^="#fn"],
.article-content sup a {
  color: var(--color-green);
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.75em;
  text-decoration: none;
}

/* --- Site Footer --- */
.site-footer {
  max-width: 100%;
  padding: 3rem 1.5rem;
  border-top: 1px solid var(--color-rule);
}

.site-footer-inner {
  display: flex;
  justify-content: center;
  align-items: baseline;
}

.site-footer .footer-text {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  color: var(--color-text-tertiary);
}

.site-footer .footer-text a {
  color: var(--color-text-secondary);
  text-decoration: none;
  transition: color 0.2s;
}

.site-footer .footer-text a:hover {
  color: var(--color-absinthe);
}

/* --- Table (for the matrix figure) --- */
.article-content table {
  border-collapse: collapse;
  margin: 2em 0;
  font-family: var(--font-sans);
  font-size: 0.88rem;
  width: 100%;
}

.article-content th,
.article-content td {
  padding: 0.6em 1em;
  text-align: left;
  border: 1px solid var(--color-rule);
}

.article-content th {
  background: var(--color-green-faint);
  font-weight: 600;
  font-size: 0.82rem;
  letter-spacing: 0.03em;
}

.article-content td {
  vertical-align: top;
}

/* --- Horizontal rule in content --- */
.article-content hr {
  border: none;
  height: 1px;
  background: var(--color-rule);
  margin: 3em 0;
}

/* --- Code --- */
.article-content code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--color-green-faint);
  padding: 0.15em 0.35em;
  border-radius: 3px;
  color: var(--color-text);
}

.article-content pre {
  margin: 2em 0;
  padding: 1.2em 1.4em;
  background: #1e1e1e;
  border-radius: 4px;
  overflow-x: auto;
  max-width: 100%;
  line-height: 1.55;
}

.article-content pre code {
  font-size: 0.82rem;
  background: none;
  padding: 0;
  border-radius: 0;
  color: #d4d4d4;
}

/* --- Strong and emphasis --- */
.article-content strong {
  font-weight: 700;
  color: var(--color-text);
}

.article-content em {
  font-style: italic;
}

/* --- Responsive --- */
@media (max-width: 1100px) {
  :root {
    --margin-left: 40px;
  }

  .sidenote {
    display: none;
  }

  /* Show inline fallback footnotes on narrow screens */
  .sidenote-checkbox:checked + .sidenote {
    display: block;
    float: none;
    width: 100%;
    margin: 0.5em 0 1em 1em;
    padding: 0.8em 1em;
    background: var(--color-green-faint);
    border-left: 2px solid var(--color-green-border);
    border-radius: 0 2px 2px 0;
  }

  .sidenote-number {
    cursor: pointer;
  }

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

  .article-figure.img-full {
    max-width: 100%;
  }
}

@media (max-width: 768px) {
  :root {
    --margin-left: 1.25rem;
    --font-size-body: 1.02rem;
  }

  .site-header {
    padding-left: 1.25rem;
    padding-right: 1.25rem;
  }

  .article-container {
    padding: 2.5rem 1.25rem 4rem;
  }

  .article-title {
    font-size: 1.85rem;
  }

  .article-subtitle {
    font-size: 1.1rem;
  }

  .site-footer {
    margin-left: 1.25rem;
    padding-right: 1.25rem;
  }

  .article-content p:first-child::first-letter {
    font-size: 2em;
  }
}

@media (max-width: 480px) {
  .article-title {
    font-size: 1.55rem;
  }

  .article-subtitle {
    font-size: 1rem;
  }
}

/* --- List content (no drop caps) --- */
.list-content p {
  margin-bottom: 1.4em;
}

.list-content a {
  color: var(--color-green);
  text-decoration: underline;
  text-decoration-color: var(--color-green-border);
  text-underline-offset: 0.15em;
  transition: text-decoration-color 0.2s;
}

.list-content a:hover {
  text-decoration-color: var(--color-absinthe);
  color: var(--color-absinthe);
}

/* --- Print styles --- */
@media print {
  .site-header, .site-footer {
    display: none;
  }

  .article-container {
    padding: 0;
  }

  .article-body {
    margin-left: 0;
    max-width: 100%;
  }

  .sidenote {
    display: none;
  }

  .footnotes {
    display: block;
  }

  body {
    font-size: 11pt;
    color: #000;
    background: #fff;
  }
}
