/* ============================================
   DECAY, MY DEAR — Site Stylesheet
   "A bureaucratic archive being gently colonized by a living room"
   ============================================ */

/* ------------ CSS Variables ------------ */
:root {
  /* The Bureaucracy (Gerald's Layer) */
  --manila: #FDF5E6;
  --typewriter-grey: #2F4F4F;
  --stamp-red: #E07A5F;
  --mahogany: #4A2C2A;
  
  /* The Band (Corruption Layer) */
  --royal-purple: #663399;
  --vacuum-amber: #FFBF00;
  --liv-black: #1A1A1A;
  
  /* The Silence (Threat Layer) */
  --erasure-white: #FFFFFF;
  
  /* Utility */
  --body-bg: var(--manila);
  --body-text: var(--typewriter-grey);
  --link-color: var(--mahogany);
  --link-hover: var(--royal-purple);
  
  /* Spacing */
  --content-width: 55rem;
  --sidenote-width: 18rem;
}

/* ------------ Font Imports ------------ */
@import url('https://fonts.googleapis.com/css2?family=Merriweather:ital,wght@0,300;0,400;0,700;1,400&family=Courier+Prime:ital,wght@0,400;0,700;1,400&family=Cinzel:wght@400;600;700&family=Reenie+Beanie&family=Permanent+Marker&display=swap');

/* ------------ Base Styles ------------ */
* {
  box-sizing: border-box;
}

html {
  font-size: 16px;
}

body {
  font-family: 'Merriweather', Georgia, serif;
  font-size: 1.1rem;
  line-height: 1.7;
  color: var(--body-text);
  background-color: var(--body-bg);
  margin: 0;
  padding: 0;
  
  /* Subtle paper texture */
  background-image: 
    linear-gradient(90deg, transparent 0%, rgba(0,0,0,0.02) 50%, transparent 100%),
    linear-gradient(rgba(0,0,0,0.03) 1px, transparent 1px);
  background-size: 100% 100%, 100% 4px;
}

/* ------------ Typography ------------ */
h1, h2, h3, h4, h5, h6 {
  font-family: 'Cinzel', serif;
  font-weight: 600;
  color: var(--mahogany);
  margin-top: 2rem;
  margin-bottom: 1rem;
  line-height: 1.3;
}

h1 { font-size: 2.2rem; }
h2 { font-size: 1.7rem; }
h3 { font-size: 1.4rem; }

p {
  margin: 1rem 0;
}

a {
  color: var(--link-color);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  transition: color 0.2s ease;
}

a:hover {
  color: var(--link-hover);
}

blockquote {
  font-family: 'Courier Prime', monospace;
  font-size: 0.95rem;
  border-left: 3px solid var(--mahogany);
  margin: 1.5rem 0;
  padding: 0.5rem 0 0.5rem 1.5rem;
  background: rgba(74, 44, 42, 0.05);
}

code, pre {
  font-family: 'Courier Prime', monospace;
  font-size: 0.9rem;
}

pre {
  background: rgba(74, 44, 42, 0.08);
  padding: 1rem;
  overflow-x: auto;
  border: 1px solid rgba(74, 44, 42, 0.2);
}

hr {
  border: none;
  border-top: 1px solid var(--mahogany);
  margin: 2rem 0;
  opacity: 0.3;
}

/* ------------ Layout ------------ */
.site-wrapper {
  max-width: calc(var(--content-width) + var(--sidenote-width) + 4rem);
  margin: 0 auto;
  padding: 2rem;
}

.content-area {
  max-width: var(--content-width);
}

/* ------------ Header ------------ */
.site-header {
  border-bottom: 2px solid var(--mahogany);
  padding-bottom: 1.5rem;
  margin-bottom: 3rem;
}

.site-title-row {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.site-logo {
  width: 50px;
  height: 50px;
  opacity: 0.85;
}

.site-title {
  font-family: 'Cinzel', serif;
  font-size: 1.8rem;
  font-weight: 700;
  margin: 0;
  letter-spacing: 0.05em;
}

.site-title a {
  color: var(--mahogany);
  text-decoration: none;
}

.site-subtitle {
  font-family: 'Courier Prime', monospace;
  font-size: 0.85rem;
  color: var(--typewriter-grey);
  margin-top: 0.25rem;
  opacity: 0.8;
}

/* ------------ Navigation ------------ */
.site-nav {
  margin-top: 1rem;
}

.site-nav ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  gap: 2rem;
  flex-wrap: wrap;
}

.site-nav a {
  font-family: 'Courier Prime', monospace;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  text-decoration: none;
  color: var(--typewriter-grey);
  transition: color 0.2s ease;
}

.site-nav a:hover {
  color: var(--stamp-red);
}

/* ------------ Tufte-Style Sidenotes ------------ */
.margin-toggle {
  display: none;
}

.sidenote-number {
  counter-increment: sidenote-counter;
}

.sidenote-number::after {
  content: counter(sidenote-counter);
  font-size: 0.7rem;
  position: relative;
  top: -0.5rem;
  left: 0.1rem;
  color: var(--stamp-red);
  font-weight: bold;
}

.sidenote {
  float: right;
  clear: right;
  margin-right: calc(-1 * var(--sidenote-width) - 2rem);
  width: var(--sidenote-width);
  font-size: 0.85rem;
  line-height: 1.5;
  font-family: 'Courier Prime', monospace;
  color: var(--typewriter-grey);
  opacity: 0.85;
  position: relative;
}

.sidenote::before {
  content: counter(sidenote-counter) ". ";
  color: var(--stamp-red);
  font-weight: bold;
}

/* Mobile sidenotes collapse */
@media (max-width: 1000px) {
  .sidenote {
    display: none;
  }
  
  .margin-toggle:checked + .sidenote {
    display: block;
    float: none;
    width: 100%;
    margin: 1rem 0;
    padding: 0.75rem;
    background: rgba(74, 44, 42, 0.05);
    border-left: 2px solid var(--stamp-red);
  }
  
  .sidenote-number::after {
    cursor: pointer;
  }
}

/* ------------ Gerald's Reports (Typewriter Style) ------------ */
.gerald-report {
  font-family: 'Courier Prime', monospace;
  font-size: 0.95rem;
  background: rgba(253, 245, 230, 0.8);
  border: 1px solid var(--mahogany);
  padding: 1.5rem;
  margin: 2rem 0;
  position: relative;
}

.gerald-report::before {
  content: "DEPT. OF SIGNAL PREDICTABILITY";
  display: block;
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  color: var(--stamp-red);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px dashed var(--mahogany);
}

.gerald-signature {
  margin-top: 1.5rem;
  text-align: right;
  font-style: italic;
}

/* ------------ Stamps & Marks ------------ */
.stamp {
  display: inline-block;
  font-family: 'Courier Prime', monospace;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 0.25rem 0.75rem;
  border: 2px solid;
  transform: rotate(-3deg);
  font-size: 0.75rem;
}

.stamp-deprecated {
  color: var(--stamp-red);
  border-color: var(--stamp-red);
}

.stamp-classified {
  color: var(--mahogany);
  border-color: var(--mahogany);
}

.stamp-uncontained {
  color: var(--royal-purple);
  border-color: var(--royal-purple);
}

/* ------------ Handwritten Notes ------------ */
.handwritten {
  font-family: 'Reenie Beanie', cursive;
  font-size: 1.4rem;
  color: var(--royal-purple);
  transform: rotate(-1deg);
}

.vandalism {
  font-family: 'Permanent Marker', cursive;
  color: var(--liv-black);
}

/* ------------ Document Header (Episode/Entity) ------------ */
.document-header {
  font-family: 'Courier Prime', monospace;
  border: 2px solid var(--mahogany);
  padding: 1.5rem;
  margin-bottom: 2rem;
  background: linear-gradient(to bottom, var(--manila) 0%, rgba(253,245,230,0.5) 100%);
  position: relative;
  overflow: hidden;
}

.document-header::before {
  content: "";
  position: absolute;
  top: 50%;
  right: 1.5rem;
  transform: translateY(-50%) rotate(-15deg);
  width: 120px;
  height: 120px;
  background-image: url('/images/logo.svg');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  opacity: 0.08;
  pointer-events: none;
}

.document-header h1 {
  font-family: 'Cinzel', serif;
  font-size: 1.3rem;
  margin: 0 0 1rem 0;
  color: var(--mahogany);
}

.document-filing {
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  color: var(--stamp-red);
  margin: 0 0 0.5rem 0;
  text-transform: uppercase;
}

.document-meta {
  font-size: 0.85rem;
  color: var(--typewriter-grey);
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.25rem 1rem;
}

.document-meta dt {
  font-weight: bold;
}

.document-meta dd {
  margin: 0;
}

/* ------------ Threat Tiers ------------ */
.threat-tier {
  display: inline-block;
  font-family: 'Courier Prime', monospace;
  font-size: 0.75rem;
  font-weight: bold;
  padding: 0.2rem 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.threat-cardboard { background: #d4c5a9; color: var(--mahogany); }
.threat-ceramic { background: #c9b896; color: var(--mahogany); }
.threat-stone { background: #a89880; color: white; }
.threat-cathedral { background: var(--mahogany); color: white; }
.threat-dynasty { background: var(--royal-purple); color: white; }
.threat-scripture { background: var(--stamp-red); color: white; }
.threat-megiddo { background: var(--liv-black); color: var(--stamp-red); }

/* ------------ Silence Effects ------------ */
.deprecated {
  text-decoration: line-through;
  opacity: 0.5;
}

.redacted {
  background: var(--liv-black);
  color: var(--liv-black);
  padding: 0 0.25rem;
  cursor: pointer;
  transition: all 0.3s ease;
}

.redacted:hover {
  background: var(--typewriter-grey);
  color: var(--manila);
}

.silence-gap {
  display: block;
  height: 3rem;
  background: linear-gradient(to bottom, var(--manila), var(--erasure-white), var(--manila));
  margin: 1rem 0;
  position: relative;
}

.silence-gap::after {
  content: "THIS DATE HAS BEEN ARCHIVED";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: 'Courier Prime', monospace;
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  color: rgba(47, 79, 79, 0.3);
}

/* ------------ Episode List / Timeline ------------ */
.incident-list {
  list-style: none;
  padding: 0;
  margin: 0;
  border-left: 2px solid var(--mahogany);
  padding-left: 2rem;
}

.incident-item {
  position: relative;
  margin-bottom: 2rem;
  padding-bottom: 2rem;
  border-bottom: 1px dashed rgba(74, 44, 42, 0.2);
}

.incident-item::before {
  content: "";
  position: absolute;
  left: -2.4rem;
  top: 0.5rem;
  width: 12px;
  height: 12px;
  background: var(--manila);
  border: 2px solid var(--mahogany);
  border-radius: 50%;
}

.incident-date {
  font-family: 'Courier Prime', monospace;
  font-size: 0.85rem;
  color: var(--stamp-red);
  letter-spacing: 0.1em;
}

.incident-title {
  font-family: 'Cinzel', serif;
  font-size: 1.3rem;
  margin: 0.25rem 0;
}

.incident-title a {
  color: var(--mahogany);
  text-decoration: none;
}

.incident-title a:hover {
  color: var(--royal-purple);
}

.incident-synopsis {
  font-size: 0.95rem;
  margin-top: 0.5rem;
  color: var(--typewriter-grey);
}

/* ------------ Entity Cards ------------ */
.entity-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-top: 2rem;
}

.entity-card {
  border: 1px solid var(--mahogany);
  padding: 1rem;
  background: var(--manila);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.entity-card:hover {
  transform: translateY(-2px);
  box-shadow: 4px 4px 0 rgba(74, 44, 42, 0.2);
}

.entity-designation {
  font-family: 'Courier Prime', monospace;
  font-size: 0.75rem;
  color: var(--stamp-red);
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.entity-name {
  font-family: 'Cinzel', serif;
  font-size: 1.2rem;
  margin: 0.25rem 0;
  color: var(--mahogany);
}

.entity-role {
  font-family: 'Courier Prime', monospace;
  font-size: 0.85rem;
  color: var(--typewriter-grey);
}

/* ------------ Box Catalog ------------ */
.box-entry {
  font-family: 'Courier Prime', monospace;
  border: 1px dashed var(--mahogany);
  padding: 1rem;
  margin-bottom: 1rem;
  background: rgba(253, 245, 230, 0.5);
}

.box-label {
  font-family: 'Reenie Beanie', cursive;
  font-size: 1.5rem;
  color: var(--royal-purple);
  margin-bottom: 0.5rem;
}

.box-contents {
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

.box-status {
  font-size: 0.8rem;
  color: var(--stamp-red);
}

/* ------------ Footer ------------ */
.site-footer {
  margin-top: 4rem;
  padding-top: 2rem;
  border-top: 1px solid rgba(74, 44, 42, 0.3);
  font-family: 'Courier Prime', monospace;
  font-size: 0.8rem;
  color: var(--typewriter-grey);
  opacity: 0.8;
}

.sandwich-status {
  margin-bottom: 0.5rem;
}

.footer-note {
  font-style: italic;
}

/* ------------ 404 Page ------------ */
.error-page {
  text-align: center;
  padding: 4rem 2rem;
}

.error-code {
  font-family: 'Courier Prime', monospace;
  font-size: 4rem;
  color: var(--stamp-red);
  margin-bottom: 0;
}

.error-message {
  font-family: 'Courier Prime', monospace;
  font-size: 1.1rem;
  margin-top: 0.5rem;
}

/* ------------ Coffee Stain Decorations ------------ */
.coffee-stain {
  position: relative;
}

.coffee-stain::after {
  content: "";
  position: absolute;
  width: 60px;
  height: 60px;
  background: radial-gradient(ellipse at center, 
    rgba(139, 90, 43, 0.15) 0%, 
    rgba(139, 90, 43, 0.08) 40%,
    transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}

.coffee-stain-tr::after {
  top: -10px;
  right: -10px;
}

.coffee-stain-bl::after {
  bottom: -10px;
  left: 20px;
}

/* ------------ Responsive ------------ */
@media (max-width: 768px) {
  html {
    font-size: 15px;
  }
  
  .site-wrapper {
    padding: 1rem;
  }
  
  .site-nav ul {
    gap: 1rem;
  }
  
  .document-header {
    padding: 1rem;
  }
  
  h1 { font-size: 1.8rem; }
  h2 { font-size: 1.4rem; }
}

/* ------------ Tippy.js Gerald Theme ------------ */
.tippy-box[data-theme~='gerald'] {
  background: var(--mahogany);
  color: var(--manila);
  font-family: 'Courier Prime', monospace;
  font-size: 0.85rem;
  line-height: 1.5;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}

.tippy-box[data-theme~='gerald'] .tippy-content {
  padding: 0.6rem 0.8rem;
}

.tippy-box[data-theme~='gerald'] .tippy-arrow {
  color: var(--mahogany);
}

.tippy-box[data-theme~='gerald'] p {
  margin: 0 0 0.5rem 0;
}

.tippy-box[data-theme~='gerald'] p:last-child {
  margin-bottom: 0;
}

.tippy-box[data-theme~='gerald'] em {
  font-style: italic;
}

.tippy-box[data-theme~='gerald'] strong {
  font-weight: bold;
}

/* ------------ Footnotes (Gerald's Notes) ------------ */
.footnotes {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px dashed var(--mahogany);
  font-family: 'Courier Prime', monospace;
  font-size: 0.85rem;
}

.footnotes::before {
  content: "AUDITOR'S ANNOTATIONS";
  display: block;
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  color: var(--stamp-red);
  margin-bottom: 1rem;
}

.footnotes ol {
  padding-left: 1.5rem;
}

.footnotes li {
  margin-bottom: 0.75rem;
}

.footnotes li p {
  margin: 0;
}

.footnote-ref {
  font-size: 0.75rem;
  color: var(--stamp-red);
  font-weight: bold;
  text-decoration: none;
  vertical-align: super;
}

.footnote-backref {
  color: var(--stamp-red);
  text-decoration: none;
  margin-left: 0.25rem;
}

/* ------------ Print Styles ------------ */
@media print {
  .site-nav,
  .site-footer {
    display: none;
  }
  
  body {
    background: white;
  }
  
  .sidenote {
    float: none;
    display: block;
    margin: 0.5rem 0;
    margin-left: 2rem;
    width: auto;
  }
}
