/* ============================================================
   SCREED — style.css
   A counterculture document drop.
   ============================================================ */

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

/* --- Custom Properties ------------------------------------- */
:root,
[data-theme="dark"] {
  --bg:             #0a0a0a;
  --bg-elevated:    #111111;
  --bg-card:        #161616;
  --bg-card-hover:  #1c1c1c;
  --text:           #b8b0a4;
  --text-bright:    #e8e0d4;
  --text-muted:     #6a6358;
  --accent:         #c41e3a;
  --accent-hover:   #e02548;
  --accent-dim:     #7a1425;
  --accent-gold:    #c9a227;
  --rule:           #222;
  --rule-bright:    #333;
  --code-bg:        #1a1a1a;
  --selection-bg:   #c41e3a40;
  --shadow:         0 2px 20px rgba(0,0,0,.5);
}

[data-theme="light"] {
  --bg:             #eae2d0;
  --bg-elevated:    #f2ebdb;
  --bg-card:        #f8f4ec;
  --bg-card-hover:  #fff;
  --text:           #3a352e;
  --text-bright:    #1a1510;
  --text-muted:     #8a7e6e;
  --accent:         #8b0000;
  --accent-hover:   #a51010;
  --accent-dim:     #c41e3a;
  --accent-gold:    #8b6914;
  --rule:           #d0c4ae;
  --rule-bright:    #b0a48e;
  --code-bg:        #ddd6c4;
  --selection-bg:   #c41e3a30;
  --shadow:         0 2px 20px rgba(0,0,0,.1);
}

/* --- Typography Setup -------------------------------------- */
:root {
  --font-display:  "Special Elite", "Courier New", Courier, monospace;
  --font-mono:     "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  --font-body:     Georgia, "Times New Roman", Times, serif;
  --font-ui:       -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --measure:       65ch;
  --leading:       1.72;
  --scale-ratio:   1.25;
}

/* --- Base -------------------------------------------------- */
html {
  font-size: 100%;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  font-size: 1.05rem;
  line-height: var(--leading);
  color: var(--text);
  background-color: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color .3s ease, color .3s ease;
}

::selection {
  background: var(--selection-bg);
}

/* --- Links ------------------------------------------------- */
a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: .15em;
  transition: color .2s ease;
}
a:hover,
a:focus-visible {
  color: var(--accent-hover);
}

/* --- Headings ---------------------------------------------- */
h1, h2, h3, h4 {
  font-family: var(--font-mono);
  color: var(--text-bright);
  letter-spacing: -.01em;
  line-height: 1.2;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.2rem; }

/* --- Rules ------------------------------------------------- */
hr,
.rule {
  border: none;
  height: 2px;
  background: repeating-linear-gradient(
    90deg,
    var(--accent) 0,
    var(--accent) 4px,
    transparent 4px,
    transparent 8px
  );
  margin: 2rem 0;
}

/* --- Code -------------------------------------------------- */
code {
  font-family: var(--font-mono);
  font-size: .88em;
  background: var(--code-bg);
  padding: .15em .35em;
  border-radius: 3px;
}

pre {
  background: var(--code-bg);
  padding: 1.25rem;
  border-radius: 4px;
  overflow-x: auto;
  border-left: 3px solid var(--accent);
  margin: 1.5rem 0;
}

pre code {
  background: none;
  padding: 0;
}

/* --- Blockquotes ------------------------------------------- */
blockquote {
  border-left: 3px solid var(--accent);
  padding: .75rem 1.25rem;
  margin: 1.5rem 0;
  color: var(--text-muted);
  font-style: italic;
}

blockquote p + p {
  margin-top: .5rem;
}

/* --- Lists ------------------------------------------------- */
ul, ol {
  padding-left: 1.5rem;
}

li + li {
  margin-top: .35rem;
}

/* --- Images ------------------------------------------------ */
img {
  max-width: 100%;
  height: auto;
  display: block;
  border-radius: 4px;
}

/* ============================================================
   SITE HEADER
   ============================================================ */
.site-header {
  border-bottom: 2px solid var(--rule);
  padding: 1rem 0;
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  transition: background-color .3s ease;
}

.header-inner {
  max-width: 56rem;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.site-logo {
  font-family: var(--font-display);
  font-size: 1.75rem;
  color: var(--text-bright);
  text-decoration: none;
  letter-spacing: .08em;
  transition: color .2s ease;
}

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

/* --- Theme Toggle ------------------------------------------ */
.theme-toggle {
  appearance: none;
  border: 1px solid var(--rule-bright);
  background: var(--bg-elevated);
  color: var(--text);
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
  display: grid;
  place-items: center;
  transition: border-color .2s ease, background .2s ease;
}

.theme-toggle:hover {
  border-color: var(--accent);
}

.toggle-icon::after {
  content: "◐";
}

[data-theme="light"] .toggle-icon::after {
  content: "◑";
}

/* ============================================================
   MAIN
   ============================================================ */
.site-main {
  flex: 1;
  max-width: 56rem;
  width: 100%;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

/* ============================================================
   INDEX PAGE
   ============================================================ */
.index-hero {
  padding: 3rem 0 1rem;
  text-align: center;
}

.index-tagline {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 4vw, 2.5rem);
  color: var(--text-bright);
  letter-spacing: .04em;
  margin-bottom: .5rem;
}

.index-sub {
  color: var(--text-muted);
  font-size: .95rem;
  line-height: 1.6;
}

/* --- Section Headings -------------------------------------- */
.section-heading {
  font-family: var(--font-mono);
  font-size: .8rem;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  padding-bottom: .5rem;
  border-bottom: 1px solid var(--rule);
}

/* --- Document List ----------------------------------------- */
.doc-list {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: .75rem;
}

.doc-card {
  border-left: 3px solid var(--accent-dim);
  transition: border-color .2s ease;
}

.doc-card:hover {
  border-color: var(--accent);
}

.doc-card-link {
  display: block;
  padding: 1.25rem 1.5rem;
  background: var(--bg-card);
  text-decoration: none;
  transition: background .2s ease, box-shadow .2s ease;
  border-radius: 0 4px 4px 0;
}

.doc-card-link:hover {
  background: var(--bg-card-hover);
  box-shadow: var(--shadow);
}

.doc-card-title {
  font-family: var(--font-mono);
  font-size: 1.15rem;
  color: var(--text-bright);
  margin-bottom: .35rem;
  line-height: 1.3;
}

.doc-card-meta {
  font-family: var(--font-ui);
  font-size: .78rem;
  color: var(--text-muted);
  letter-spacing: .02em;
  margin-bottom: .4rem;
}

.doc-card-desc {
  color: var(--text);
  font-size: .92rem;
  line-height: 1.55;
}

.no-docs {
  color: var(--text-muted);
  font-style: italic;
  padding: 2rem 0;
  text-align: center;
}

/* ============================================================
   DOCUMENT PAGE
   ============================================================ */
.doc {
  max-width: var(--measure);
  margin: 0 auto;
}

.doc-header {
  margin-bottom: 2rem;
}

.doc-title {
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  line-height: 1.15;
  margin-bottom: .5rem;
}

.doc-meta {
  font-family: var(--font-ui);
  font-size: .82rem;
  color: var(--text-muted);
  letter-spacing: .02em;
}

.doc-description {
  margin-top: .75rem;
  color: var(--text-muted);
  font-style: italic;
  font-size: 1.05rem;
}

/* --- Document Content -------------------------------------- */
.doc-content p {
  margin-bottom: 1.25rem;
}

.doc-content h2 {
  margin-top: 2.5rem;
  margin-bottom: .75rem;
  padding-bottom: .3rem;
  border-bottom: 1px solid var(--rule);
}

.doc-content h3 {
  margin-top: 2rem;
  margin-bottom: .5rem;
}

.doc-content ul,
.doc-content ol {
  margin-bottom: 1.25rem;
}

.doc-content strong {
  color: var(--text-bright);
}

.doc-content em {
  color: var(--text);
}

/* --- Document Footer --------------------------------------- */
.doc-footer {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
}

.back-link {
  font-family: var(--font-mono);
  font-size: .85rem;
}

/* ============================================================
   404 PAGE
   ============================================================ */
.four-oh-four {
  text-align: center;
  padding: 4rem 0;
  max-width: 36rem;
  margin: 0 auto;
}

.error-code {
  font-family: var(--font-display);
  font-size: clamp(5rem, 15vw, 10rem);
  line-height: 1;
  color: var(--accent);
  opacity: .35;
  margin-bottom: .5rem;
}

.error-title {
  font-family: var(--font-mono);
  font-size: 1.3rem;
  letter-spacing: .15em;
  margin-bottom: 1rem;
}

.error-message {
  color: var(--text-muted);
  font-size: .95rem;
  line-height: 1.6;
}

.error-action {
  font-family: var(--font-mono);
  font-size: .85rem;
  margin-top: 1rem;
}

/* ============================================================
   FOOTER
   ============================================================ */
.site-footer {
  border-top: 2px solid var(--rule);
  padding: 1.5rem 0;
  margin-top: auto;
}

.footer-inner {
  max-width: 56rem;
  margin: 0 auto;
  padding: 0 1.5rem;
  text-align: center;
}

.footer-text {
  font-family: var(--font-ui);
  font-size: .75rem;
  color: var(--text-muted);
  letter-spacing: .03em;
}

.footer-text a {
  color: var(--text-muted);
}

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

.footer-sub {
  font-family: var(--font-mono);
  font-size: .65rem;
  color: var(--text-muted);
  opacity: .6;
  margin-top: .35rem;
  letter-spacing: .05em;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 640px) {
  .site-main {
    padding: 1.25rem 1rem 3rem;
  }

  .index-hero {
    padding: 2rem 0 .5rem;
  }

  .doc-card-link {
    padding: 1rem 1.15rem;
  }

  .site-logo {
    font-size: 1.4rem;
  }
}

/* ============================================================
   PRINT
   ============================================================ */
@media print {
  :root {
    --bg: #fff;
    --text: #000;
    --text-bright: #000;
    --text-muted: #555;
    --accent: #000;
    --rule: #ccc;
  }

  .site-header,
  .site-footer,
  .theme-toggle,
  .back-link {
    display: none;
  }

  .site-main {
    max-width: none;
    padding: 0;
  }

  body {
    font-size: 11pt;
  }
}

/* ============================================================
   REDUCED MOTION
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  * {
    transition-duration: 0.01ms !important;
  }

  html {
    scroll-behavior: auto;
  }
}
