/**
 * Xeroxpunk CSS Framework (v1.0.0)
 * A reusable stylesheet for generating low-fidelity, high-contrast,
 * photocopier-inspired web interfaces, documentation, and technical sheets.
 *
 * Designed with CSS Custom Properties for easy theme overrides.
 */

:root {
  /* Color Palette */
  --xp-bg: #f5f2e8;                        /* Warm parchment / aged paper */
  --xp-fg: #0a0808;                        /* High-density photocopier toner black */
  --xp-fg-rgb: 10, 8, 8;
  --xp-fg-muted: rgba(var(--xp-fg-rgb), 0.55);
  --xp-fg-faint: rgba(var(--xp-fg-rgb), 0.22);
  
  /* Borders */
  --xp-border-thick: 3px;
  --xp-border-medium: 2px;
  --xp-border-thin: 1px;
  --xp-border-color: var(--xp-fg);
  --xp-border-muted: rgba(var(--xp-fg-rgb), 0.3);
  --xp-border-faint: rgba(var(--xp-fg-rgb), 0.18);
  
  /* Fonts */
  --xp-font-body: 'Courier New', Courier, monospace;
  --xp-font-display: Impact, Haettenschweiler, 'Arial Narrow Bold', sans-serif;
  
  /* Text Sizes & Line Heights */
  --xp-font-size-base: 13px;
  --xp-line-height-base: 1.55;
  
  /* Textures */
  --xp-grain-opacity: 0.06;
  --xp-grain-svg: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)' opacity='.06'/%3E%3C/svg%3E");
  --xp-vignette: radial-gradient(ellipse at 50% 50%, transparent 68%, rgba(var(--xp-fg-rgb), 0.14) 100%);
}

/*
 * Alternate themes override the three base inputs (--xp-bg, --xp-fg,
 * --xp-fg-rgb). The derived tokens below MUST be re-declared in the same
 * scope: a custom property that references var(--xp-fg-rgb) is resolved
 * where it is *declared*, so leaving them on :root would keep them pinned
 * to the default ink color and render muted text invisible on dark themes.
 */

/* Alternate Theme: Blueprint (Optional utility) */
.theme-blueprint {
  --xp-bg: #1c325c;
  --xp-fg: #f1f4fa;
  --xp-fg-rgb: 241, 244, 250;
  --xp-grain-opacity: 0.12;

  --xp-fg-muted: rgba(var(--xp-fg-rgb), 0.55);
  --xp-fg-faint: rgba(var(--xp-fg-rgb), 0.22);
  --xp-border-color: var(--xp-fg);
  --xp-border-muted: rgba(var(--xp-fg-rgb), 0.3);
  --xp-border-faint: rgba(var(--xp-fg-rgb), 0.18);
  --xp-vignette: radial-gradient(ellipse at 50% 50%, transparent 68%, rgba(var(--xp-fg-rgb), 0.14) 100%);
}

/* Alternate Theme: Terminal Green */
.theme-terminal {
  --xp-bg: #0c100c;
  --xp-fg: #33ff33;
  --xp-fg-rgb: 51, 255, 51;
  --xp-grain-opacity: 0.04;

  --xp-fg-muted: rgba(var(--xp-fg-rgb), 0.55);
  --xp-fg-faint: rgba(var(--xp-fg-rgb), 0.22);
  --xp-border-color: var(--xp-fg);
  --xp-border-muted: rgba(var(--xp-fg-rgb), 0.3);
  --xp-border-faint: rgba(var(--xp-fg-rgb), 0.18);
  --xp-vignette: radial-gradient(ellipse at 50% 50%, transparent 68%, rgba(var(--xp-fg-rgb), 0.14) 100%);
}

/*
 * The colored stamp variants use hard-coded red/blue ink, which disappears
 * against the blue/green alternate backgrounds. Fall back to toned-down
 * foreground ink so stamps stay legible in every theme.
 */
.theme-blueprint .xp-stamp-red,
.theme-blueprint .xp-stamp-blue,
.theme-terminal .xp-stamp-red,
.theme-terminal .xp-stamp-blue {
  border-color: rgba(var(--xp-fg-rgb), 0.30);
  color: rgba(var(--xp-fg-rgb), 0.30);
}

/* ─── BASE RESET & STYLES ─── */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  background-color: var(--xp-bg);
}

body {
  background-color: var(--xp-bg);
  font-family: var(--xp-font-body);
  font-size: var(--xp-font-size-base);
  color: var(--xp-fg);
  line-height: var(--xp-line-height-base);
  position: relative;
  min-height: 100vh;
}

/* Photocopy Grain Texture Overlay */
body.xp-textured::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  background-image: var(--xp-grain-svg);
  opacity: 1; /* Opacity controlled inside SVG baseFrequency or standard mix-blend */
  mix-blend-mode: multiply;
}

/* Photocopy Vignette (edge shading) */
body.xp-textured::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9998;
  background: var(--xp-vignette);
}

/* ─── LAYOUT CONTAINERS ─── */
.xp-wrap {
  max-width: 940px;
  margin: 0 auto;
  padding: 0 28px 64px;
}

.xp-two-col {
  display: flex;
  gap: 36px;
  padding: 12px 0 0;
}

.xp-col {
  flex: 1;
}

.xp-col + .xp-col {
  border-left: var(--xp-border-thin) solid var(--xp-border-faint);
  padding-left: 36px;
}

/* ─── DOCUMENT HEADER ─── */
.xp-doc-hdr {
  position: sticky;
  top: 0;
  z-index: 200;
  background: var(--xp-fg);
  color: var(--xp-bg);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 20px;
  font-size: 10px;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.xp-doc-hdr-left {
  font-weight: 700;
  font-size: 11px;
  letter-spacing: .12em;
}

.xp-doc-hdr-right {
  font-size: 9px;
  letter-spacing: .16em;
}

/*
 * Dim the inactive nav links individually rather than the whole container, so
 * the active chip below can render at full opacity (a parent's opacity caps
 * its children's).
 */
.xp-doc-hdr-right a {
  opacity: .6;
}

/*
 * The active nav link reuses .xp-badge, but two things were off in the header:
 * the display (Impact) font clashed with the monospace header text, and the
 * badge's dark chip (background: --xp-fg) is invisible on the already-dark
 * header. Switch to the body font and flip the chip to paper-on-ink so the
 * active page reads clearly without the display font.
 *
 * The :hover state is pinned to the resting state on purpose. The global
 * ".xp-textured a.xp-badge:hover" rule (0,3,1) would otherwise flip the chip's
 * background to ink while the color !important keeps the text ink too — making
 * the active label vanish on hover. Scoping under .xp-textured lifts this to
 * (0,4,1) so it wins the tie regardless of source order.
 */
.xp-textured .xp-doc-hdr a.xp-badge,
.xp-textured .xp-doc-hdr a.xp-badge:hover {
  font-family: var(--xp-font-body);
  letter-spacing: inherit;
  background: var(--xp-bg);
  /* !important overrides the nav anchor's inline `color: inherit`, which would
     otherwise paint the label paper-on-paper inside the chip. */
  color: var(--xp-fg) !important;
  opacity: 1;
}

/* ─── TITLE BLOCK ─── */
.xp-title-block {
  padding: 28px 0 20px;
  border-bottom: var(--xp-border-thick) solid var(--xp-fg);
  position: relative;
  overflow: hidden;
}

/* Xerox diagonal slashes for misaligned print effect */
.xp-slash {
  position: absolute;
  width: 150%;
  height: 3px;
  background: var(--xp-fg);
  bottom: 22%;
  left: -25%;
  transform: rotate(-1.8deg);
  opacity: .1;
  pointer-events: none;
}

.xp-slash-thin {
  position: absolute;
  width: 150%;
  height: 1px;
  background: var(--xp-fg);
  bottom: 18%;
  left: -25%;
  transform: rotate(-1.8deg);
  opacity: .06;
  pointer-events: none;
}

.xp-title-main {
  display: flex;
  align-items: flex-start;
  gap: 36px;
  position: relative;
  z-index: 5;
}

.xp-title-left {
  flex: 1;
}

.xp-title-part {
  font-family: var(--xp-font-display);
  font-size: 82px;
  letter-spacing: -.02em;
  line-height: .86;
  color: var(--xp-fg);
}

.xp-title-desc {
  font-family: var(--xp-font-display);
  font-size: 19px;
  letter-spacing: .04em;
  text-transform: uppercase;
  margin-top: 8px;
}

.xp-title-subdesc {
  font-size: 11px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--xp-fg-muted);
  margin-top: 3px;
}

.xp-title-meta {
  margin-top: 12px;
  padding-top: 8px;
  border-top: var(--xp-border-thin) solid rgba(var(--xp-fg-rgb), 0.22);
  font-size: 10.5px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--xp-fg-muted);
  line-height: 1.7;
}

.xp-title-right {
  flex: 0 0 224px;
}

/* Technical / Packaging Art Box */
.xp-pkg-box {
  border: var(--xp-border-medium) solid var(--xp-fg);
  padding: 12px 14px;
  background: rgba(var(--xp-fg-rgb), 0.02);
}

.xp-pkg-label {
  font-family: var(--xp-font-display);
  font-size: 10px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: rgba(var(--xp-fg-rgb), 0.45);
  margin-bottom: 6px;
  padding-bottom: 4px;
  border-bottom: var(--xp-border-thin) solid rgba(var(--xp-fg-rgb), 0.2);
}

.xp-pkg-art {
  font-family: var(--xp-font-body);
  font-size: 11.5px;
  line-height: 1.38;
  color: var(--xp-fg);
  white-space: pre;
}

/* ─── RUBBER STAMPS ─── */
.xp-stamp {
  position: absolute;
  top: 32px;
  right: 28px;
  border: var(--xp-border-thick) solid rgba(var(--xp-fg-rgb), 0.22);
  padding: 4px 10px;
  font-family: var(--xp-font-display);
  font-size: 22px;
  letter-spacing: .14em;
  color: rgba(var(--xp-fg-rgb), 0.22);
  text-transform: uppercase;
  transform: rotate(-18deg);
  pointer-events: none;
  z-index: 2; /* Sits behind content at z-index 5 */
  white-space: nowrap;
  mix-blend-mode: multiply;
}

.xp-stamp-red {
  border-color: rgba(180, 40, 40, 0.28);
  color: rgba(180, 40, 40, 0.28);
}

.xp-stamp-blue {
  border-color: rgba(30, 80, 180, 0.28);
  color: rgba(30, 80, 180, 0.28);
}

.xp-stamp-inline {
  position: relative;
  top: auto;
  right: auto;
  display: inline-block;
  z-index: auto;
}

/* ─── SECTION HEADERS ─── */
.xp-sec-head {
  background: var(--xp-fg);
  color: var(--xp-bg);
  font-family: var(--xp-font-display);
  font-size: 13px;
  letter-spacing: .14em;
  text-transform: uppercase;
  padding: 5px 12px;
  margin-top: 24px;
  margin-bottom: 0;
}

.xp-sec-head span {
  font-family: var(--xp-font-body);
  font-size: 11px;
  font-weight: normal;
  letter-spacing: .04em;
  text-transform: none;
}

/* ─── TEXT COMPONENT LAYOUTS ─── */
.xp-desc-split {
  display: flex;
  gap: 32px;
  padding: 14px 0;
  border-bottom: var(--xp-border-thin) solid var(--xp-border-faint);
}

.xp-desc-body {
  flex: 1;
  line-height: 1.62;
}

.xp-desc-body p {
  margin-bottom: 9px;
}

/*
 * Project titles. Impact's counters fill in and turn to blobs at heading
 * sizes around 15px, so set them larger with a little tracking to open the
 * letterforms back up while staying in the display font.
 */
.xp-proj-title {
  font-family: var(--xp-font-display);
  font-size: 24px;
  letter-spacing: .05em;
  font-weight: normal;
  line-height: 1.12;
  margin-bottom: 5px;
}

/* Side Info / Feature Block */
.xp-features-box {
  flex: 0 0 228px;
  border: 1.5px solid var(--xp-fg);
  padding: 10px 12px;
  align-self: flex-start;
  background: rgba(var(--xp-fg-rgb), 0.01);
}

.xp-features-title {
  font-family: var(--xp-font-display);
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  margin-bottom: 6px;
  padding-bottom: 4px;
  border-bottom: 1.5px solid var(--xp-fg);
}

.xp-features-list {
  list-style: none;
  font-size: 11.5px;
  line-height: 1.7;
}

.xp-features-list li::before {
  content: '·  ';
}

.xp-features-list li.xp-annot-item {
  font-size: 10px;
  color: var(--xp-fg-muted);
  border-top: var(--xp-border-thin) solid rgba(var(--xp-fg-rgb), 0.15);
  padding-top: 4px;
  margin-top: 3px;
  font-style: italic;
}

/* ─── TABLES ─── */
.xp-table-wrap {
  overflow-x: auto;
  margin-top: 8px;
}

.xp-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--xp-font-body);
  font-size: 12px;
  margin-top: 0;
}

.xp-table th {
  background: rgba(var(--xp-fg-rgb), 0.1);
  padding: 4px 10px;
  text-align: left;
  border: var(--xp-border-thin) solid var(--xp-fg);
  font-size: 10.5px;
  letter-spacing: .08em;
  text-transform: uppercase;
  font-weight: 700;
}

.xp-table td {
  padding: 4px 10px;
  border: var(--xp-border-thin) solid var(--xp-border-muted);
  vertical-align: top;
}

.xp-table tr:nth-child(even) td {
  background: rgba(var(--xp-fg-rgb), 0.025);
}

/* Alignments */
.xp-table .r { text-align: right; }
.xp-table .c { text-align: center; color: var(--xp-fg-muted); }
.xp-table .nm { font-weight: 700; }
.xp-table .note { font-size: 10px; color: var(--xp-fg-muted); vertical-align: super; }

/* Table Footnotes */
.xp-table-foot {
  font-size: 10.5px;
  color: var(--xp-fg-muted);
  padding: 5px 10px 0;
  border-left: var(--xp-border-medium) solid rgba(var(--xp-fg-rgb), 0.2);
  margin: 4px 0;
  line-height: 1.65;
}

/* Alternate Hover Table (e.g. Ordering info) */
.xp-table-hover tr:hover td {
  background: rgba(var(--xp-fg-rgb), 0.06);
  cursor: default;
}

/* ─── TECHNICAL DIAGRAMS (ASCII CONTAINER) ─── */
.xp-ascii {
  font-family: var(--xp-font-body);
  font-size: 11.5px;
  line-height: 1.55;
  background: rgba(var(--xp-fg-rgb), 0.03);
  border: var(--xp-border-thin) solid rgba(var(--xp-fg-rgb), 0.22);
  padding: 14px 18px;
  margin: 12px 0 0;
  overflow-x: auto;
  white-space: pre;
  color: var(--xp-fg);
}

/* ─── NOTE BOXES ─── */
.xp-note-box {
  border: var(--xp-border-thin) solid var(--xp-fg);
  border-left: 4px solid var(--xp-fg);
  padding: 9px 12px;
  margin: 10px 0 0;
  font-size: 12px;
  background: rgba(var(--xp-fg-rgb), 0.03);
  line-height: 1.6;
}

.xp-note-head {
  font-family: var(--xp-font-display);
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.xp-note-box p {
  margin-bottom: 5px;
}

.xp-note-box p:last-child {
  margin-bottom: 0;
}

/* ─── ANNOTATIONS (handwritten or typewriter alignment) ─── */
.xp-annot {
  display: block;
  font-size: 11px;
  color: var(--xp-fg-muted);
  transform: rotate(-0.4deg);
  border-left: var(--xp-border-medium) solid rgba(var(--xp-fg-rgb), 0.28);
  padding-left: 7px;
  margin: 5px 0;
  letter-spacing: .01em;
}

/* ─── INLINE COMPONENTS ─── */
.xp-badge {
  font-family: var(--xp-font-display);
  font-size: 9px;
  letter-spacing: .1em;
  text-transform: uppercase;
  background: var(--xp-fg);
  color: var(--xp-bg);
  padding: 1px 5px;
  display: inline-block;
}

.xp-badge-outline {
  background: transparent;
  color: var(--xp-fg);
  border: 1px solid var(--xp-fg);
}

/* Stray Ink Artifacts (photocopier crud simulation) */
.xp-ink-spot {
  position: fixed;
  background: rgba(var(--xp-fg-rgb), 0.1);
  border-radius: 50%;
  pointer-events: none;
  z-index: 9997;
}

/* ─── SECTION DIVIDER ─── */
.xp-divider {
  border: none;
  border-top: var(--xp-border-thin) solid var(--xp-border-faint);
  margin: 20px 0 0;
}

/* ─── DOCUMENT FOOTER ─── */
.xp-doc-footer {
  margin-top: 32px;
  padding-top: 12px;
  border-top: var(--xp-border-thick) solid var(--xp-fg);
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  font-size: 10px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--xp-fg-muted);
  gap: 12px;
}

.xp-footer-copy {
  flex: 1;
  line-height: 1.7;
}

.xp-footer-docnum {
  font-family: var(--xp-font-display);
  font-size: 12px;
  letter-spacing: .14em;
  color: var(--xp-fg-muted);
  text-align: right;
}

.xp-footer-bar {
  height: 6px;
  background: var(--xp-fg);
  margin-top: 6px;
}

.xp-footer-barcode {
  font-family: var(--xp-font-body);
  font-size: 24px;
  letter-spacing: .45em;
  color: var(--xp-fg);
  line-height: 1;
  opacity: .7;
}

/* ─── RESPONSIVE LAYOUTS ─── */
@media(max-width: 700px) {
  .xp-title-main, 
  .xp-desc-split, 
  .xp-two-col {
    flex-direction: column;
  }
  
  .xp-title-right, 
  .xp-col + .xp-col {
    border-left: none;
    padding-left: 0;
  }
  
  .xp-title-part {
    font-size: 56px;
  }
  
  .xp-stamp {
    top: 14px;
    right: 10px;
    font-size: 16px;
  }
}

/* ─── PRINT RULES ─── */
@media print {
  body::before, 
  body::after, 
  .xp-ink-spot {
    display: none !important;
  }
  
  .xp-doc-hdr {
    position: static;
  }
  
  body {
    background: #ffffff !important;
    color: #000000 !important;
  }
}

/* ─── CUSTOM RE-THEMING COMPATIBILITY MAPPINGS ─── */

.xp-textured a {
  color: var(--xp-fg);
  text-decoration: underline;
}

.xp-textured a:hover {
  background: var(--xp-fg);
  color: var(--xp-bg);
}

/*
 * Badges rendered as links (e.g. clickable project statuses) must keep the
 * badge's own colors. Without this, the global ".xp-textured a" rule above
 * wins on specificity and paints the label in foreground ink on a
 * foreground-ink background — invisible until hover flips it.
 */
.xp-textured a.xp-badge {
  color: var(--xp-bg);
  text-decoration: none;
}

.xp-textured a.xp-badge.xp-badge-outline {
  color: var(--xp-fg);
}

.xp-textured a.xp-badge:hover {
  background: var(--xp-fg);
  color: var(--xp-bg);
  opacity: .8;
}

.xp-textured a.xp-badge.xp-badge-outline:hover {
  opacity: 1;
}

.xp-textured .project-box {
  border: var(--xp-border-thin) solid var(--xp-fg);
  border-left: 4px solid var(--xp-fg);
  padding: 12px;
  margin: 16px 0;
  background: rgba(var(--xp-fg-rgb), 0.02);
}

.xp-textured .project-name {
  font-family: var(--xp-font-display);
  font-size: 18px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--xp-fg);
  border-bottom: var(--xp-border-medium) solid var(--xp-fg);
  display: inline-block;
  margin-bottom: 8px;
  text-decoration: none;
}

.xp-textured .project-name:hover {
  background: var(--xp-fg);
  color: var(--xp-bg);
}

.xp-textured .project-thumbnail img,
.xp-textured .project-image img,
.xp-textured .project-image-fullwide img {
  border: var(--xp-border-medium) solid var(--xp-fg);
  padding: 4px;
  filter: grayscale(1) contrast(1.2);
  max-width: 100%;
  height: auto;
  margin-top: 8px;
  display: block;
}

.xp-textured input[type="text"], 
.xp-textured input[type="email"], 
.xp-textured textarea {
  width: 100%;
  background: transparent;
  border: var(--xp-border-medium) solid var(--xp-fg);
  color: var(--xp-fg);
  font-family: var(--xp-font-body);
  font-size: var(--xp-font-size-base);
  padding: 10px;
  margin-top: 6px;
  margin-bottom: 16px;
  outline: none;
  transition: background 0.2s, color 0.2s;
}

.xp-textured input[type="text"]:focus, 
.xp-textured input[type="email"]:focus, 
.xp-textured textarea:focus {
  background: var(--xp-fg);
  color: var(--xp-bg);
}

.xp-textured input[type="submit"] {
  background: var(--xp-fg);
  color: var(--xp-bg);
  border: var(--xp-border-medium) solid var(--xp-fg);
  font-family: var(--xp-font-display);
  font-size: 13px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 8px 20px;
  cursor: pointer;
  outline: none;
  transition: opacity 0.2s;
}

.xp-textured input[type="submit"]:hover {
  opacity: 0.8;
}

