/* ==========================================================================
   pamphlet.css: shared print-ready pamphlet styles

   Used by the single-sheet Letter pamphlets: setup.html (Quick Start) and
   features.html (Features). Each page links this file, then adds only its own
   page-specific bits inline (setup: QR codes; features: none). Screen shows a
   simulated Letter sheet; @media print flattens it to real paper.
   ========================================================================== */

/* ==========================================
   1. DESIGN SYSTEM & VARIABLE DEFINITIONS
   ========================================== */
:root {
  --bg-color: #ece9e3;
  --card-bg: #ffffff;
  --border-color: #e5e7eb;
  --text-primary: #111827;
  --text-secondary: #4b5563;
  --text-muted: #9ca3af;

  --accent-color: #dc2626;
  /* LED Matrix Red */

  --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'Space Mono', monospace;

  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.1);

  --page-width: 8.5in;
  --page-height: 11in;
  --transition-speed: 0.2s;
}

/* ==========================================
   2. SCREEN/INTERACTIVE MODE BASICS
   ========================================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-color);
  color: var(--text-primary);
  font-family: var(--font-sans);
  line-height: 1.5;
  padding: 40px 20px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: background-color var(--transition-speed) ease, color var(--transition-speed) ease;
}

/* Dark mode: only the surrounding page background follows the system
   preference (matching index.html's --bg). The pamphlet itself is a
   printed sheet and stays light, so we override body's background
   directly rather than the --bg-color token (which the content SVGs
   also use). Print backgrounds win via later !important rules and higher
   specificity, so this doesn't touch either. */
@media (prefers-color-scheme: dark) {
  body {
    background-color: #0a0a0b;
  }
}

/* Print Preview Wrapper (simulates Letter page on screen) */
.pamphlet-container {
  width: var(--page-width);
  min-height: var(--page-height);
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 0.3in;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
  transition: all var(--transition-speed) ease;
}

/* ==========================================
   3. PAMPHLET CONTENT LAYOUT & TYPOGRAPHY
   ========================================== */
.header {
  border-bottom: 2px solid var(--accent-color);
  padding-bottom: 15px;
  margin-bottom: 20px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}

.header-left h1 {
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  text-transform: uppercase;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-left h1 span.accent {
  color: var(--accent-color);
}

.header-left p {
  font-size: 1rem;
  color: var(--text-secondary);
  font-weight: 400;
  margin-top: 2px;
}

.header-right {
  text-align: right;
}

.header-right a {
  color: var(--accent-color);
  text-decoration: none;
  font-weight: 500;
}

.header-right a:hover {
  text-decoration: underline;
}

.header-right .model-badge {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid var(--accent-color);
  color: var(--accent-color);
  padding: 3px 8px;
  border-radius: 4px;
  font-weight: bold;
}

/* 2-Column grid of cards to fit cleanly on one page. Cards are numbered
   .step-card items, the same primitive whether they hold a setup step or a
   feature. */
.steps-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  margin-bottom: 20px;
}

.step-card {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 15px;
  display: flex;
  flex-direction: column;
  background: rgba(255, 255, 255, 0.01);
  position: relative;
}

.step-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.step-number {
  background: var(--accent-color);
  color: #ffffff;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.step-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
}

.step-desc {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.45;
  margin-bottom: 12px;
  flex-grow: 1;
}

.step-desc code {
  font-family: var(--font-mono);
  font-size: 0.80rem;
  background: rgba(0, 0, 0, 0.04);
  border: 1px solid var(--border-color);
  padding: 1px 4px;
  border-radius: 3px;
  color: var(--accent-color);
}

/* Illustration containers inside cards */
.step-ill {
  height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.015);
  overflow: hidden;
  margin-top: auto;
  padding: 6px;
}

.step-ill img {
  max-height: 100%;
  max-width: 100%;
  object-fit: contain;
}

.step-ill svg {
  max-height: 100%;
  max-width: 100%;
  color: var(--text-primary);
}

/* Reset & troubleshooting / system notes section, styled as a bordered card to
   match the step cards. */
.footer-section {
  margin-top: auto;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 15px;
  display: flex;
  align-items: center;
  gap: 24px;
}

.reset-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.reset-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.reset-title svg {
  width: 16px;
  height: 16px;
  fill: var(--accent-color);
}

.reset-desc {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.reset-desc strong {
  color: var(--text-primary);
}

.reset-desc code {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  background: rgba(0, 0, 0, 0.04);
  border: 1px solid var(--border-color);
  padding: 1px 4px;
  border-radius: 3px;
  color: var(--accent-color);
}

/* Subtitle footer elements */
.pamphlet-footer {
  border-top: 1px solid var(--border-color);
  padding-top: 10px;
  margin-top: 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.pamphlet-footer a {
  color: var(--accent-color);
  text-decoration: none;
  font-weight: 500;
}

.pamphlet-footer a:hover {
  text-decoration: underline;
}

/* ==========================================
   4. MOBILE / NARROW SCREEN REFLOW
   Screen-only. The pamphlet is a fixed Letter sheet by design; on a
   phone we drop the inch geometry and collapse to a single column so
   it reads without horizontal scrolling. Print + preview untouched.
   ========================================== */
@media screen and (max-width: 768px) {
  body {
    padding: 20px 12px;
  }

  .pamphlet-container {
    width: 100%;
    min-height: auto;
    padding: 20px;
  }

  .header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .header-right {
    text-align: left;
  }

  .steps-grid {
    grid-template-columns: 1fr;
  }

  .footer-section {
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
  }

  .pamphlet-footer {
    align-items: flex-start;
  }

  /* Halve the row so the blocks hug opposite edges once the labels wrap. */
  .pamphlet-footer > div {
    flex: 1 1 0;
    min-width: 0;
  }

  /* Force label-over-link on both sides so neither block wraps unevenly. */
  .pamphlet-footer a {
    display: block;
  }

  .pamphlet-footer > div:last-child {
    text-align: right;
  }
}

/* ==========================================
   5. PRINT MODE DIRECT STYLES (@media print)
   ========================================== */
@media print {
  @page {
    size: letter;
    margin: 0.2in;
  }

  html,
  body {
    background: #ffffff !important;
    color: #000000 !important;
    width: 100% !important;
    /* Full printable height so the container can center within it.
       min-height:0 clears the base min-height:100vh (which Safari would
       resolve to the full 11in paper and overflow to a blank page). */
    height: 100% !important;
    min-height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  .pamphlet-container {
    width: 100% !important;
    /* Fill the printable page and center the content block so the empty
       space is split evenly top and bottom. */
    height: 100% !important;
    min-height: 0 !important;
    overflow: visible !important;
    padding: 0 !important;
    border: none !important;
    box-shadow: none !important;
    background: transparent !important;
    color: #000000 !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
  }

  /* Force monochrome/grayscale elements for print */
  * {
    color: #000000 !important;
    border-color: #666666 !important;
    background-color: transparent !important;
    text-shadow: none !important;
    box-shadow: none !important;
  }

  .header {
    border-bottom: 2.5px solid #000000 !important;
    padding-bottom: 6px !important;
    margin-bottom: 10px !important;
  }

  .header-left h1 {
    font-size: 2rem !important;
  }

  /* Middle-ground print: body text stays black for legibility, but the
     LED-red accent prints in color on the headline and step numbers. */
  .header-left h1 span.accent {
    color: #dc2626 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .header-right .model-badge {
    border: 1px solid #000000 !important;
    color: #000000 !important;
    background: transparent !important;
  }

  /* Vertical budget is tight: 4-line card copy only fits one page if the
     interior padding is trimmed too, not just the row gap. */
  .steps-grid {
    gap: 9px !important;
    margin-bottom: 6px !important;
  }

  .step-card {
    border: 1px solid #666666 !important;
    padding: 6px !important;
    background: transparent !important;
  }

  .step-header {
    margin-bottom: 4px !important;
  }

  .step-desc {
    margin-bottom: 6px !important;
  }

  .step-number {
    background: #dc2626 !important;
    color: #ffffff !important;
    border-color: #dc2626 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .step-ill {
    border: 1px solid #999999 !important;
    background: #fafafa !important;
    height: 72px !important;
    margin-top: 4px !important;
    padding: 4px !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .step-desc code {
    background: #f0f0f0 !important;
    border: 1px solid #cccccc !important;
    color: #000000 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .footer-section {
    border: 1px solid #666666 !important;
    padding: 8px !important;
    margin-top: 4px !important;
  }

  .reset-title svg {
    fill: #000000 !important;
  }

  .reset-desc code {
    background: #f0f0f0 !important;
    border: 1px solid #cccccc !important;
    color: #000000 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .pamphlet-footer {
    border-top: 1px solid #666666 !important;
    padding-top: 4px !important;
    margin-top: 6px !important;
  }
}
