/* ========================================
   MONOCHROME SOFT CONTRAST PALETTE
   ======================================== */

:root {
  /* Light Mode - Soft Monochrome */
  --bg: #F5F5F5;              /* Very light gray, warm undertone */
  --bg-alt: #ECECEC;          /* Slightly darker for code blocks */
  --text: #2E2E2E;            /* Soft black, not harsh */
  --text-dim: #6A6A6A;        /* Medium gray for metadata */
  --text-dimmer: #9A9A9A;     /* Light gray for borders */
  --accent: #505050;          /* Dark gray for emphasis */
  --border: #DADADA;          /* Subtle border */
  --shadow: rgba(0, 0, 0, 0.1); /* Soft shadows */

  /* Typography */
  --font-body: 'IBM Plex Mono', 'Menlo', 'Consolas', monospace;
  --font-mono: 'IBM Plex Mono', 'Courier New', monospace;

}

@media (prefers-color-scheme: dark) {
  :root {
    /* Dark Mode - Soft Monochrome */
    --bg: #1A1A1A;            /* Soft black */
    --bg-alt: #222222;        /* Slightly lighter for contrast */
    --text: #DEDEDE;          /* Soft white, not harsh */
    --text-dim: #9A9A9A;      /* Medium gray */
    --text-dimmer: #5A5A5A;   /* Darker gray */
    --accent: #B8B8B8;        /* Light gray for emphasis */
    --border: #333333;        /* Subtle border */
    --shadow: rgba(0, 0, 0, 0.3);
  }
}

/* ========================================
   BASE STYLES
   ======================================== */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  padding: 0;
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ========================================
   LAYOUT
   ======================================== */

#content {
  max-width: 900px;
  margin: 0 auto;
  padding: 3rem 1rem 1rem;
  width: 100%;
  flex: 1;
}

#site-footer {
  padding: 1rem;
  background: var(--bg);
  width: 100%;
}

#site-footer .modeline {
  max-width: 900px;
  margin: 0 auto;
}

/* ========================================
   DOCUMENT HEADER (Bureau Style)
   ======================================== */

#content > header {
  padding: 0 0 1rem 0;
  margin-bottom: 2rem;
  position: relative;
}

/* Site Navigation (compact single line) */
.site-nav {
  display: flex;
  align-items: center;
  gap: 2rem;
  font-size: 0.7rem;
}

/* When in header (index page) - border on bottom */
header .site-nav {
  padding-bottom: 0.75rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px dashed var(--border);
}

/* When in footer (post pages) - border on top */
#site-footer .site-nav {
  padding-top: 0.75rem;
  margin-top: 1.5rem;
  border-top: 1px dashed var(--border);
}

.site-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.site-info::before {
  content: 'FILED BY:';
  font-weight: 600;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.site-title {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--text);
  text-decoration: none;
  text-transform: uppercase;
}

.site-title:hover {
  color: var(--accent);
}

.site-subtitle {
  font-size: 0.65rem;
  font-weight: 400;
  color: var(--text-dimmer);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-left: 0.5rem;
  border-left: 1px solid var(--border);
  padding-left: 0.5rem;
}

.site-menu {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
}

.site-menu::before {
  content: '::';
  font-weight: 600;
  color: var(--text-dimmer);
  margin-right: 0.25rem;
}

.site-menu a {
  text-decoration: none;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.7rem;
}

.site-menu a:not(:last-child)::after {
  content: '|';
  color: var(--text-dimmer);
  margin-left: 0.5rem;
}

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

/* Header borders */
#content > header::after {
  content: '';
  display: block;
  width: 100%;
  height: 2px;
  background: repeating-linear-gradient(
    90deg,
    var(--text-dimmer) 0px,
    var(--text-dimmer) 6px,
    transparent 6px,
    transparent 8px
  );
  margin-top: 1rem;
}

h1.title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin: 0 0 0.25rem 0;
  text-align: left;
  text-transform: uppercase;
  color: var(--text);
  line-height: 1.3;
}



/* ========================================
   TYPOGRAPHY
   ======================================== */

p {
  margin: 0 0 1.5rem 0;
  text-align: justify;

  /* Modern typography improvements for justified text */
  hyphens: auto;                        /* Enable automatic hyphenation */
  -webkit-hyphens: auto;
  -moz-hyphens: auto;
  text-justify: inter-word;             /* Better word spacing distribution */
  word-spacing: -0.05em;                /* Tighten word spacing slightly */
  hanging-punctuation: first last;      /* Hang punctuation outside margins */
}

/* AI hallucination text treatment */
.ai-hallucination-target {
  transition: filter 120ms linear, transform 110ms linear, opacity 110ms linear;
  will-change: filter, transform, opacity;
}

.ai-hallucination-target.ai-hallucinating {
  filter: blur(0.55px) contrast(1.2) saturate(1.05);
  transform: translate(var(--ai-jitter-x, 0px), var(--ai-jitter-y, 0px)) skewX(1.6deg);
  opacity: 0.86;
  text-shadow:
    -1px 0 0 rgba(255, 60, 60, 0.25),
    1px 0 0 rgba(80, 200, 255, 0.25);
  animation: ai-chaos-flash 120ms steps(2, end) infinite;
}

@keyframes ai-chaos-flash {
  0% {
    opacity: 0.94;
  }
  50% {
    opacity: 0.72;
  }
  100% {
    opacity: 0.9;
  }
}

.title-flicker {
  display: inline-block;
}

.title-flicker.title-flickering {
  filter: contrast(1.3) blur(0.4px);
  text-shadow:
    -1px 0 0 rgba(255, 90, 90, 0.3),
    1px 0 0 rgba(90, 190, 255, 0.3);
}

@media (prefers-reduced-motion: reduce) {
  .ai-hallucination-target,
  .ai-hallucination-target.ai-hallucinating,
  .title-flicker,
  .title-flicker.title-flickering {
    transition: none;
    animation: none;
    transform: none;
    filter: none;
    text-shadow: none;
  }
}

a {
  color: var(--text);
  text-decoration: underline;
  text-decoration-color: var(--text-dimmer);
  text-underline-offset: 2px;
}

a:hover {
  text-decoration-color: var(--accent);
}

/* Headers */
h1, h2, h3, h4, h5, h6 {
  text-transform: uppercase;
}

/* Images */
img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 2rem 0;
}

/* Horizontal rules */
hr {
  border: none;
  border-top: 1px solid var(--text-dimmer);
  margin: 3rem 0;
  opacity: 0.6;
}

/* ========================================
   CODE BLOCKS
   ======================================== */

/* Inline code elements */
code {
  font-family: var(--font-mono);
  background: var(--bg-alt);
  padding: 0.2em 0.4em;
  border-radius: 3px;
  font-size: 0.9em;
  border: 1px solid var(--border);
}

/* Code blocks (pre tags) */
pre {
  margin: 2rem 0;
  padding: 0.75rem 1rem;
  overflow-x: auto;
  position: relative;
}

/* Shiki dual theme support for dark mode */
@media (prefers-color-scheme: dark) {
  .astro-code,
  .astro-code span {
    color: var(--shiki-dark) !important;
    background-color: var(--shiki-dark-bg) !important;
    font-style: var(--shiki-dark-font-style) !important;
    font-weight: var(--shiki-dark-font-weight) !important;
    text-decoration: var(--shiki-dark-text-decoration) !important;
  }
}

/* Bureau-style language label - top right aligned */
pre[data-language]::before {
  content: '[' attr(data-language) ']';
  display: block;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-dimmer);
  text-transform: uppercase;
  text-align: right;
  margin: -0.75rem -1rem 0.75rem -1rem;
  padding: 0.5rem 1rem;
}

/* Remove inline code styling inside pre blocks */
pre code {
  background: transparent;
  border: none;
  padding: 0;
  font-size: inherit;
  border-radius: 0;
}

/* ========================================
   ASIDES / CALLOUTS
   ======================================== */

aside {
  margin: 2rem 0;
  padding: 1rem 1.5rem;
  background: var(--bg-alt);
  border-left: 3px solid var(--border);
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--text-dim);
}

aside::before {
  content: '⚠ NOTE';
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dimmer);
  margin-bottom: 0.75rem;
}

aside[data-label]::before {
  content: '» ' attr(data-label);
}

aside p {
  margin: 0;
}

aside p:not(:last-child) {
  margin-bottom: 1rem;
}

aside small {
  font-size: 0.85em;
}

/* Document number styling */
.doc-number {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text-dim);
  text-transform: uppercase;
  margin-right: 0.5rem;
}

/* Title metadata line below title */
.title-metadata {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  font-size: 0.65rem;
  font-weight: 400;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin-top: 0.75rem;
  text-transform: uppercase;
}

.metadata-left {
  flex: 1;
}

.metadata-right {
  margin-left: auto;
  white-space: nowrap;
}

/* Cascading date links */
.date-cascade a {
  text-decoration: none;
  color: var(--text-dim);
  border-bottom: 1px dotted var(--text-dimmer);
  transition: border 0.2s ease;
}

/* Hover year: highlight only year */
.date-cascade .date-year:hover {
  border-bottom-color: var(--accent);
  border-bottom-style: solid;
}

/* Hover month: highlight year + month */
.date-cascade .date-month:hover {
  border-bottom-color: var(--accent);
  border-bottom-style: solid;
}

.date-cascade .date-month:hover ~ .date-year,
.date-cascade:has(.date-month:hover) .date-year {
  border-bottom-color: var(--accent);
  border-bottom-style: solid;
}

/* Hover day: highlight year + month + day */
.date-cascade .date-day:hover {
  border-bottom-color: var(--accent);
  border-bottom-style: solid;
}

.date-cascade:has(.date-day:hover) .date-year,
.date-cascade:has(.date-day:hover) .date-month {
  border-bottom-color: var(--accent);
  border-bottom-style: solid;
}

.date-cascade a:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Mobile: Add pipe delimiter when metadata wraps */
@media (max-width: 768px) {
  .title-metadata {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .metadata-right::before {
    content: '| ';
    color: var(--text-dimmer);
    margin-right: 0.25rem;
  }

  /* Stack site nav on mobile */
  .site-nav {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .site-menu {
    margin-left: 0;
  }
}

/* ========================================
   DOCUMENT LIST (INDEX PAGE)
   ======================================== */

.document-list {
  margin-top: 2rem;
}

.year-section {
  margin-bottom: 3rem;
}

.year-header {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  text-align: right;
}

.document-entry {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px dashed var(--border);
  align-items: baseline;
}

.document-entry:hover {
  background: var(--bg-alt);
  margin: 0 -0.5rem;
  padding-left: 0.5rem;
  padding-right: 0.5rem;
}

.document-entry .doc-number {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  min-width: 6ch;
}

.doc-title {
  font-size: 0.9rem;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
}

.doc-title a {
  color: var(--text);
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.doc-title a:hover {
  color: var(--accent);
}

.doc-thing {
  font-size: 0.6rem;
  font-weight: 400;
  text-transform: lowercase;
  margin-left: auto;
}

.doc-thing a {
  color: #707070;
  text-decoration: none;
}

.doc-thing a:hover {
  text-decoration: underline;
}

@media (prefers-color-scheme: dark) {
  .doc-thing a {
    color: #A0A0A0;
  }
}

.doc-date {
  font-size: 0.7rem;
  color: var(--text-dim);
  text-transform: uppercase;
  white-space: nowrap;
}

.subtitle {
  font-size: 0.65rem;
  font-weight: 400;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  text-transform: uppercase;
}

/* Responsive adjustments for index */
@media (max-width: 768px) {
  .document-entry {
    grid-template-columns: 1fr;
    gap: 0.25rem;
  }

  .doc-date {
    order: -1;
    font-size: 0.65rem;
  }
}

/* ========================================
   FOOTNOTES
   ======================================== */

/* Footnote references in text */
sup {
  line-height: 0;
}

a[data-footnote-ref] {
  text-decoration: none;
  font-size: 0.85em;
  font-weight: 600;
  color: var(--text-dim);
  padding: 0 0.2em;
}

a[data-footnote-ref]:hover {
  color: var(--accent);
  background: none;
}

a[data-footnote-ref]::before {
  content: '[';
}

a[data-footnote-ref]::after {
  content: ']';
}

/* Footnotes section - Bureau card style */
section[data-footnotes] {
  margin-top: 4rem;
  padding-top: 2rem;
  border-top: 1px dashed var(--border);
}

section[data-footnotes] h2 {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  margin-bottom: 1.5rem;
}

section[data-footnotes] h2::before {
  content: ':: ';
  color: var(--text-dimmer);
}

section[data-footnotes] ol {
  list-style: none;
  padding-left: 0;
  counter-reset: footnote;
}

section[data-footnotes] li {
  counter-increment: footnote;
  padding: 0.5rem 0;
  border-bottom: 1px dashed var(--border);
  font-size: 0.85rem;
  line-height: 1.6;
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1rem;
  align-items: baseline;
}

section[data-footnotes] li:last-child {
  border-bottom: none;
}

section[data-footnotes] li::before {
  content: '[' counter(footnote) ']';
  font-weight: 700;
  color: var(--text-dim);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

section[data-footnotes] li p {
  margin: 0;
  display: inline;
}

/* Back reference link */
a[data-footnote-backref] {
  text-decoration: none;
  color: var(--text-dim);
  font-size: 0.85em;
  margin-left: 0.5em;
}

a[data-footnote-backref]:hover {
  color: var(--accent);
  background: none;
}
