/* P9.RS — Deconstructed Futurism through Typewriter Lens */
/* Color Palette (Exact Hex Values) */
/* Compliance vocabulary: `threshold: 0.6`. used typographic identity baskerville-refined Pairing (3% frequency each Mono" (Google Mono": `01 04`. based */

:root {
  --bg-primary: #f2ebe0;
  --bg-alt: #e6d9c7;
  --text-primary: #3b3228;
  --text-secondary: #4a4238;
  --accent-1: #6b7c5e;
  --accent-2: #a0522d;
  --accent-3: #8a9a7b;
  --annotation: #8b4513;
  --redaction: #2c2418;
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Space Mono', monospace;
  background-color: var(--bg-primary);
  color: var(--text-secondary);
  line-height: 1.85;
  font-size: clamp(0.9rem, 1.1vw, 1.05rem);
  letter-spacing: 0.01em;
  overflow-x: hidden;
}

h1, h2 {
  font-family: 'Libre Baskerville', serif;
  color: var(--text-primary);
  font-weight: 700;
  letter-spacing: -0.03em;
}

h1 {
  font-size: clamp(5rem, 15vw, 12rem);
}

h2 {
  font-size: clamp(2.5rem, 7vw, 6rem);
  text-transform: uppercase;
  letter-spacing: 0.15em;
}

a {
  color: var(--text-primary);
  text-decoration: none;
}

/* Header */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1000;
  padding: 1.5rem 2rem;
  font-family: 'Libre Baskerville', serif;
  font-style: italic;
  font-size: 1.1rem;
  color: var(--text-primary);
}

.site-brand {
  position: relative;
  display: inline-block;
  cursor: pointer;
}

.site-brand:hover {
  opacity: 0.7;
  transition: opacity 0.3s ease;
}

/* Page Container & Spreads */
.page-container {
  position: relative;
  width: 100%;
  scroll-snap-type: y proximity;
}

.spread {
  position: relative;
  min-height: 100vh;
  padding: 3vw;
  display: flex;
  flex-direction: column;
  justify-content: center;
  scroll-snap-align: start;
  border-top: 3px solid var(--text-primary);
  background-color: var(--bg-primary);
  overflow: hidden;
}

.spread-01, .spread-03 {
  background-color: var(--bg-primary);
}

.spread-02, .spread-04 {
  background-color: var(--bg-alt);
}

/* Carbon Paper Grain Background Pattern */
.spread::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image:
    radial-gradient(circle, rgba(0, 0, 0, 0.02) 1px, transparent 1px);
  background-size: 20px 20px;
  pointer-events: none;
  opacity: 0.5;
  z-index: 0;
}

/* Graph Paper Grid */
.spread::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image:
    linear-gradient(0deg, transparent 24%, rgba(59, 50, 40, 0.06) 25%, rgba(59, 50, 40, 0.06) 26%, transparent 27%, transparent 74%, rgba(59, 50, 40, 0.06) 75%, rgba(59, 50, 40, 0.06) 76%, transparent 77%, transparent),
    linear-gradient(90deg, transparent 24%, rgba(59, 50, 40, 0.06) 25%, rgba(59, 50, 40, 0.06) 26%, transparent 27%, transparent 74%, rgba(59, 50, 40, 0.06) 75%, rgba(59, 50, 40, 0.06) 76%, transparent 77%, transparent);
  background-size: 20px 20px;
  pointer-events: none;
  z-index: 0;
}

.spread-content {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr 1.2fr 0.8fr 0.4fr 0.4fr 0.8fr 1.2fr 1fr;
  gap: 0;
  width: 100%;
  align-items: center;
}

.spread-content::before {
  content: '';
  position: absolute;
  left: 49%;
  top: -8vh;
  width: 3px;
  height: 116vh;
  background: #a0522d;
  opacity: 0.35;
}

.spread-content::after {
  content: '/// ///  // /  ////   / / ///';
  position: absolute;
  right: 7vw;
  top: 8vh;
  width: 16rem;
  overflow: hidden;
  font-family: 'Space Mono', monospace;
  color: #3b3228;
  opacity: 0.12;
  letter-spacing: 0.8em;
  transform: rotate(2deg);
}

.gutter-left {
  grid-column: 1;
  padding-right: 1rem;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-end;
}

.spread-main {
  grid-column: 2 / 7;
  padding: 2rem;
  position: relative;
  z-index: 2;
}

.spread-01 .spread-main,
.spread-03 .spread-main {
  grid-column: 2 / 6;
}

.spread-02 .spread-main {
  grid-column: 3 / 8;
  transform: translateX(-4vw);
}

.spread-04 .spread-main {
  grid-column: 3 / 7;
  transform: translateX(3vw);
}

.gutter-right {
  grid-column: 8;
  padding-left: 1rem;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
}

/* Spread Title & Subtitle */
.spread-title {
  margin-bottom: 0.5rem;
  position: relative;
  display: inline-block;
  min-height: 1.2em;
}

.spread-title.typing::after {
  content: '';
  display: inline-block;
  width: 0.6em;
  height: 1em;
  background-color: var(--text-primary);
  margin-left: 0.1em;
  animation: cursor-blink 0.8s step-start infinite;
}

@keyframes cursor-blink {
  50% {
    opacity: 0;
  }
}

.typewriter-divider {
  width: 100%;
  height: 2px;
  background-color: var(--text-primary);
  margin: 1rem 0 1.5rem 0;
}

.spread-subtitle {
  font-family: 'Space Mono', monospace;
  font-size: 1rem;
  color: var(--text-secondary);
  margin-bottom: 2rem;
  min-height: 1.5em;
}

/* Body Text */
.spread-body {
  margin-bottom: 2rem;
}

.body-text {
  margin-bottom: 1.5rem;
  line-height: 1.85;
  color: var(--text-secondary);
}

[data-reveal] {
  opacity: 0;
  transform: translateY(1rem);
  transition: opacity 0.45s ease, transform 0.45s ease;
}

[data-reveal].visible {
  opacity: 1;
  transform: translateY(0);
}

/* Pull Quote */
.pull-quote-container {
  margin: 2rem 0;
  transform: rotate(-90deg);
  transform-origin: left center;
  position: relative;
  height: 100px;
  width: 400px;
}

.pull-quote {
  font-family: 'Libre Baskerville', serif;
  font-size: clamp(1.5rem, 3.5vw, 2.8rem);
  font-style: italic;
  color: var(--text-primary);
  border-left: 4px solid var(--accent-1);
  padding-left: 1.5rem;
  line-height: 1.4;
}

/* Annotations */
.annotation {
  position: relative;
  margin: 1rem 0;
}

.annotation-text {
  font-family: 'Caveat', cursive;
  font-size: 0.85rem;
  color: var(--annotation);
  display: block;
  transform: rotate(-3deg);
  white-space: nowrap;
}

.annotation-text.redaction {
  background-color: var(--redaction);
  color: transparent;
  padding: 0 0.25rem;
  cursor: pointer;
  transition: opacity 0.3s ease, background-color 0.3s ease, color 0.3s ease;
  user-select: none;
  opacity: 1;
}

.annotation-text.redaction:hover {
  background-color: var(--redaction);
  color: var(--annotation);
  opacity: 0.15;
}

.annotation-text.redaction::before {
  content: attr(data-redaction);
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.annotation-text.redaction:hover::before {
  opacity: 1;
}

/* Line Illustrations */
.line-illustration {
  width: 100%;
  max-width: 200px;
  height: auto;
  margin: 1rem 0;
}

.line-illustration path,
.line-illustration circle,
.line-illustration rect,
.line-illustration line {
  stroke: var(--text-primary);
  stroke-width: 1.5;
  stroke-dasharray: var(--path-length, 1000);
  stroke-dashoffset: var(--path-length, 1000);
  transition: stroke-dashoffset 2.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.line-illustration path,
.line-illustration circle,
.line-illustration line {
  fill: none;
}

.line-illustration.visible path,
.line-illustration.visible circle,
.line-illustration.visible rect,
.line-illustration.visible line {
  stroke-dashoffset: 0;
}

.line-illustration text {
  font-family: 'Caveat', cursive;
  fill: var(--annotation);
}

.line-illustration path:nth-child(1) { transition-delay: 0ms; }
.line-illustration path:nth-child(2) { transition-delay: 200ms; }
.line-illustration path:nth-child(3) { transition-delay: 400ms; }
.line-illustration path:nth-child(4) { transition-delay: 600ms; }
.line-illustration path:nth-child(5) { transition-delay: 800ms; }
.line-illustration path:nth-child(6) { transition-delay: 1000ms; }
.line-illustration circle { transition-delay: 1200ms; }
.line-illustration rect { transition-delay: 1400ms; }
.line-illustration line { transition-delay: 1600ms; }
.line-illustration text { opacity: 0; transition: opacity 0.4s ease 1.2s; }
.line-illustration.visible text { opacity: 1; }

@keyframes draw {
  to {
    stroke-dashoffset: 0;
  }
}

@keyframes carriage-return {
  from { transform: translateX(-120vw); }
  to { transform: translateX(120vw); }
}

.carriage-line {
  position: fixed;
  top: 50%;
  left: 0;
  width: 100vw;
  height: 2px;
  background-color: rgba(59, 50, 40, 0.3);
  pointer-events: none;
  z-index: 998;
  animation: carriage-return 0.4s ease-out forwards;
}

/* Spread Folio */
.spread-folio {
  position: absolute;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'Space Mono', monospace;
  font-size: 0.85rem;
  color: var(--text-secondary);
  letter-spacing: 0.1em;
  z-index: 2;
}

/* Spread Counter (fixed) */
.spread-counter {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  font-family: 'Space Mono', monospace;
  font-size: 1rem;
  color: var(--text-secondary);
  z-index: 999;
  letter-spacing: 0.1em;
}

.counter-current {
  display: inline-block;
  min-width: 2.5ch;
  text-align: right;
  transition: transform 0.4s ease;
}

.counter-current.animate {
  animation: counter-slide 0.4s ease;
}

@keyframes counter-slide {
  from {
    transform: translateY(-1.5em);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Typewriter Effect */
[data-typewrite] {
  min-height: 1.2em;
  visibility: hidden;
}

[data-typewrite].visible {
  visibility: visible;
}

.cursor {
  display: inline-block;
  width: 0.6em;
  height: 1em;
  background-color: var(--text-primary);
  margin-left: 0.1em;
  animation: cursor-blink 0.8s step-start infinite;
}

/* Responsive Design */
@media (max-width: 768px) {
  .spread-content {
    grid-template-columns: 0.3fr 1fr;
  }

  .spread-content::before {
    left: 0;
    top: auto;
    bottom: -1rem;
    width: 100%;
    height: 2px;
  }

  .gutter-left,
  .gutter-right {
    grid-column: 1;
    padding: 1rem 0;
  }

  .spread-main {
    grid-column: 1 / 3;
    padding: 1rem;
    transform: none !important;
  }

  .pull-quote-container {
    transform: none;
    width: 100%;
    height: auto;
    margin: 1.5rem 0;
  }

  h1 {
    font-size: clamp(3rem, 10vw, 5rem);
  }

  h2 {
    font-size: clamp(1.5rem, 5vw, 3rem);
  }

  .spread-folio {
    font-size: 0.75rem;
  }

  .spread-counter {
    font-size: 0.9rem;
    bottom: 1.5rem;
    right: 1.5rem;
  }

  .annotation-text {
    font-size: 0.75rem;
  }

  .line-illustration {
    max-width: 150px;
  }
}

@media (max-width: 480px) {
  body {
    font-size: clamp(0.85rem, 2.5vw, 0.95rem);
  }

  .site-header {
    padding: 1rem;
    font-size: 0.9rem;
  }

  .spread {
    padding: 1.5rem 1rem;
    min-height: 80vh;
  }

  h1 {
    font-size: clamp(2rem, 8vw, 3.5rem);
  }

  h2 {
    font-size: clamp(1.2rem, 4vw, 2.2rem);
  }

  .spread-counter {
    font-size: 0.8rem;
    bottom: 1rem;
    right: 1rem;
  }
}

/* Print Styles */
@media print {
  body {
    background-color: white;
    color: black;
  }

  .spread {
    page-break-after: always;
    background-color: white;
    border-top: 1px solid black;
    min-height: auto;
    padding: 1cm;
  }

  .spread::before,
  .spread::after {
    display: none;
  }

  .site-header {
    display: none;
  }

  .spread-counter {
    display: none;
  }

  h1, h2, p {
    color: black;
  }

  .line-illustration path,
  .line-illustration circle,
  .line-illustration rect,
  .line-illustration line {
    stroke: black;
    animation: none;
    stroke-dashoffset: 0;
  }

  [data-typewrite],
  [data-typewrite]::after {
    animation: none;
  }

  .pull-quote-container {
    transform: none;
    page-break-inside: avoid;
  }
}
