/*
 * Framing Red Power - Modern Responsive Design
 * Author: Jason Heppler
 * Updated: 2026
 *
 * Brand Colors:
 * - Primary Red: #710100
 * - Background Tan: #D6D1B1
 * - Text Dark: #2f2827
 */

/* ============================================
   CSS Reset & Base Styles
   ============================================ */

*, *::before, *::after {
  box-sizing: border-box;
}

:root {
  /* Colors */
  --color-primary: #710100;
  --color-primary-hover: #8b0100;
  --color-bg-body: #D6D1B1;
  --color-bg-content: #ffffff;
  --color-text-primary: #100805;
  --color-text-heading: #2f2827;
  --color-text-muted: #666666;
  --color-border: #cccccc;
  --color-shadow: rgba(0, 0, 0, 0.1);

  /* Typography - Newsprint style */
  --font-body: "Crimson Text", Georgia, Garamond, "Times New Roman", Times, serif;
  --font-heading: "Libre Baskerville", Georgia, Garamond, "Times New Roman", Times, serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  /* Performance */
  font-display: swap;

  /* Spacing */
  --spacing-xs: 0.5rem;
  --spacing-sm: 1rem;
  --spacing-md: 1.5rem;
  --spacing-lg: 2rem;
  --spacing-xl: 3rem;

  /* Layout */
  --max-width: 1200px;
  --max-width-content: 800px;
  --border-radius: 4px;

  /* Transitions */
  --transition-speed: 0.2s;
}

/* Site notices / asides */
.site-notice {
  background: #faf6ed;
  border: 1px solid #e0d9c6;
  border-left: 4px solid var(--color-primary);
  padding: var(--spacing-md) var(--spacing-lg);
  margin-bottom: var(--spacing-lg);
  border-radius: var(--border-radius);
  font-size: 0.95em;
  line-height: 1.7;
  color: var(--color-text-primary);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.site-notice strong {
  color: var(--color-primary);
}

html {
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-body);
  font-size: 20px;
  line-height: 1.7;
  background: var(--color-bg-body);
  color: var(--color-text-primary);
}

/* ============================================
   Typography
   ============================================ */

h1, h2, h3, h4, h5, h6 {
  margin: 0 0 var(--spacing-sm);
  font-family: var(--font-heading);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.02em;
  color: var(--color-text-heading);
}

h1 { font-size: clamp(2rem, 5vw, 2.5rem); }
h2 { font-size: clamp(1.75rem, 4vw, 2rem); }
h3 { font-size: clamp(1.5rem, 3vw, 1.75rem); }
h4 { font-size: clamp(1.25rem, 2.5vw, 1.5rem); }
h5 { font-size: 1.25rem; }
h6 { font-size: 1.125rem; }

p {
  margin: 0 0 var(--spacing-md);
  line-height: 1.7;
  font-size: 1.05em;
}

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

a:hover,
a:focus {
  color: var(--color-primary-hover);
  text-decoration: underline;
}

a:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

a:focus:not(:focus-visible) {
  outline: none;
}

em {
  font-style: italic;
}

strong {
  font-weight: 700;
}

blockquote {
  margin: var(--spacing-md) 0;
  padding: var(--spacing-sm) var(--spacing-md);
  background: #f5f5f5;
  border-left: 4px solid var(--color-primary);
  font-style: italic;
  font-size: 1.05em;
}

/* Better text rendering for serif fonts */
.bodyContent {
  text-rendering: optimizeLegibility;
  hyphens: auto;
}

/* Newspaper-style pull quotes */
.pullquote {
  font-size: 1.25em;
  line-height: 1.4;
  font-weight: 600;
  font-style: italic;
  margin: var(--spacing-lg) var(--spacing-md);
  padding: var(--spacing-md);
  border-top: 2px solid var(--color-primary);
  border-bottom: 2px solid var(--color-primary);
  text-align: center;
}

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  padding: 0.125rem 0.25rem;
  background: #f5f5f5;
  border-radius: var(--border-radius);
}

pre {
  padding: var(--spacing-sm);
  background: #f5f5f5;
  border-radius: var(--border-radius);
  overflow-x: auto;
}

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

/* ============================================
   Layout
   ============================================ */

.skip-link {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
  z-index: 1000;
  background: var(--color-primary);
  color: white;
  padding: var(--spacing-xs) var(--spacing-sm);
  text-decoration: none;
  border-radius: var(--border-radius);
}

.skip-link:focus {
  position: fixed;
  top: var(--spacing-sm);
  left: var(--spacing-sm);
  width: auto;
  height: auto;
  overflow: visible;
}

#mainBody {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  max-width: var(--max-width);
  margin: 0 auto;
  background: white;
  box-shadow: 0 0 40px var(--color-shadow);
}

/* ============================================
   Header & Banner
   ============================================ */

#banner {
  background: linear-gradient(135deg, var(--color-primary) 0%, #8b0100 100%);
  color: white;
  padding: var(--spacing-lg) var(--spacing-md);
  text-align: center;
}

#banner span {
  font-family: var(--font-serif);
  font-size: clamp(1.25rem, 3vw, 1.75rem);
  font-weight: 700;
  line-height: 1.4;
  display: block;
}

/* ============================================
   Navigation
   ============================================ */

#menu {
  background: #f8f8f8;
  border-bottom: 3px solid var(--color-primary);
  position: sticky;
  top: 0;
  z-index: 50;
}

#main_menu {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0;
}

#main_menu li {
  margin: 0;
}

#main_menu a {
  display: block;
  padding: var(--spacing-sm) var(--spacing-md);
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.5px;
  color: var(--color-text-primary);
  text-decoration: none;
  transition: all var(--transition-speed);
  border-bottom: 3px solid transparent;
}

#main_menu a:hover,
#main_menu a:focus {
  background: #e8e8e8;
  color: var(--color-primary);
  text-decoration: none;
}

#main_menu li#current a,
#main_menu li.active a {
  background: white;
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

/* Mobile menu toggle (for future hamburger implementation) */
.menu-toggle {
  display: none;
}

@media (max-width: 768px) {
  #main_menu {
    flex-direction: column;
  }

  #main_menu a {
    text-align: center;
    border-bottom: 1px solid var(--color-border);
  }
}

/* ============================================
   Hero Section
   ============================================ */

.hero {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--spacing-xl);
  align-items: center;
  margin: 0 0 var(--spacing-xl);
  padding: var(--spacing-xl) var(--spacing-lg);
  background: linear-gradient(135deg, #f9f9f9 0%, #f0f0f0 100%);
  max-width: 100%;
}

.hero-image-container {
  position: relative;
  border-radius: var(--border-radius);
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.hero-image {
  width: 100%;
  height: auto;
  display: block;
  transition: transform 0.3s ease;
}

.hero-image:hover {
  transform: scale(1.02);
}

.hero-caption {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.9), transparent);
  color: white;
  padding: var(--spacing-sm);
  font-size: 0.8rem;
  line-height: 1.3;
}

.hero-content {
  padding: var(--spacing-md);
}

.hero-content h1 {
  font-size: clamp(2rem, 5vw, 2.75rem);
  color: var(--color-primary);
  margin-bottom: var(--spacing-md);
  line-height: 1.2;
}

.hero-content .subtitle {
  font-size: clamp(1.1rem, 2.5vw, 1.35rem);
  color: var(--color-text-heading);
  font-family: var(--font-serif);
  font-style: italic;
  margin-bottom: var(--spacing-md);
  line-height: 1.5;
}

.hero-content .description {
  color: var(--color-text-muted);
  line-height: 1.7;
  margin-bottom: var(--spacing-md);
}

.hero-cta {
  display: inline-flex;
  gap: var(--spacing-sm);
  flex-wrap: wrap;
}

.hero-cta .btn {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  border-radius: var(--border-radius);
  font-weight: 600;
  text-decoration: none;
  transition: all var(--transition-speed);
}

.hero-cta .btn-primary {
  background: var(--color-primary);
  color: white;
  border: 2px solid var(--color-primary);
}

.hero-cta .btn-primary:hover {
  background: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(113, 1, 0, 0.3);
}

.hero-cta .btn-secondary {
  background: white;
  color: var(--color-primary);
  border: 2px solid var(--color-primary);
}

.hero-cta .btn-secondary:hover {
  background: var(--color-primary);
  color: white;
}

@media (max-width: 992px) {
  .hero {
    grid-template-columns: 1fr;
  }

  .hero-image-container {
    order: -1;
  }

  .hero-content {
    padding: var(--spacing-sm) 0;
  }
}

/* ============================================
   Main Content
   ============================================ */

#content {
  flex: 1;
  padding: var(--spacing-md);
}

.bodyContent {
  max-width: var(--max-width-content);
  margin: 0 auto;
}

/* Two-column layout for narrative pages */
.twoCol {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: var(--spacing-xl);
  align-items: start;
}

/* Remove max-width constraint on bodyContent in two-column layout */
.twoCol .bodyContent {
  max-width: none;
  margin: 0;
}

/* Override old PHP-era nested twoCol structure */
.bodyContent .twoCol {
  display: block;
  grid-template-columns: none;
}

.bodyContent .twoCol .contentSide {
  padding-left: 0;
  width: 100%;
}

@media (max-width: 992px) {
  .twoCol {
    grid-template-columns: 1fr;
  }

  #leftCol {
    order: 2;
  }

  #rightCol {
    order: 1;
  }
}

/* Left sidebar (narrative nav) */
#leftCol {
  position: sticky;
  top: 80px;
}

#leftCol h4 {
  color: var(--color-primary);
  margin-bottom: var(--spacing-sm);
  padding-bottom: var(--spacing-xs);
  border-bottom: 2px solid var(--color-border);
}

#leftCol ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

#leftCol ul li {
  margin-bottom: var(--spacing-xs);
}

#leftCol ul ul {
  margin-left: var(--spacing-sm);
  margin-top: var(--spacing-xs);
}

#leftCol a {
  display: block;
  padding: 0.375rem 0.5rem;
  border-radius: var(--border-radius);
  transition: all var(--transition-speed);
}

#leftCol a:hover {
  background: #f5f5f5;
  text-decoration: none;
  padding-left: 0.75rem;
}

.keywords ul.analysis li {
  font-size: 1rem;
}

/* Right content area */
#rightCol {
  min-width: 0; /* Prevent grid blowout */
}

/* ============================================
   Document Filtering & Controls
   ============================================ */

.document-controls {
  margin-bottom: var(--spacing-lg);
  padding: var(--spacing-md);
  background: #f9f9f9;
  border-radius: var(--border-radius);
  border: 1px solid var(--color-border);
}

.filter-bar {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: var(--spacing-md);
  align-items: end;
}

@media (max-width: 768px) {
  .filter-bar {
    grid-template-columns: 1fr;
  }
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xs);
}

.filter-group label {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--color-text-heading);
}

.filter-group input[type="search"],
.filter-group select {
  padding: 0.75rem;
  border: 2px solid var(--color-border);
  border-radius: var(--border-radius);
  font-size: 1rem;
  transition: border-color var(--transition-speed);
}

.filter-group input[type="search"]:focus,
.filter-group select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(113, 1, 0, 0.1);
}

.btn-secondary {
  padding: 0.75rem var(--spacing-md);
  background: white;
  border: 2px solid var(--color-primary);
  color: var(--color-primary);
  border-radius: var(--border-radius);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-speed);
}

.btn-secondary:hover {
  background: var(--color-primary);
  color: white;
}

.results-count {
  margin-top: var(--spacing-sm);
  padding: var(--spacing-xs) 0;
  font-size: 0.9rem;
  color: var(--color-text-muted);
  font-style: italic;
}

/* ============================================
   Archive & Document Pages
   ============================================ */

.document-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.document-table thead th {
  text-align: left;
  padding: 0.65rem 1rem;
  background: var(--color-primary);
  color: white;
  font-weight: 600;
  white-space: nowrap;
}

.document-table th[data-sort] {
  cursor: pointer;
  user-select: none;
}

.document-table th[data-sort]:hover {
  background: var(--color-primary-hover);
}

.document-table th .sort-icon {
  font-size: 0.8em;
  opacity: 0.8;
}

.document-table td {
  padding: 0.55rem 1rem;
  border-bottom: 1px solid var(--color-border);
  vertical-align: top;
}

.document-table tbody tr:hover td {
  background: rgba(113, 1, 0, 0.03);
}

.document-table .col-date {
  white-space: nowrap;
  width: 8rem;
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

.document-table .col-source {
  width: 13rem;
}

.document-table .col-type {
  width: 10rem;
}

.type-badge {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  background: rgba(113, 1, 0, 0.08);
  border-radius: 3px;
  font-size: 0.8rem;
  color: var(--color-primary);
  font-weight: 500;
}

.no-data {
  color: var(--color-text-muted);
  opacity: 0.5;
}

@media (max-width: 768px) {
  .document-table .col-source,
  .document-table .col-type {
    display: none;
  }
}

.document-metadata {
  background: #f9f9f9;
  padding: var(--spacing-md);
  border-radius: var(--border-radius);
  margin-bottom: var(--spacing-md);
}

.document-metadata p {
  margin-bottom: var(--spacing-xs);
  font-size: 0.95rem;
}

.document-metadata strong {
  color: var(--color-primary);
}

/* ============================================
   Footer
   ============================================ */

#footcolor {
  background: #2f2827;
  color: white;
  margin-top: auto;
}

#footer {
  padding: var(--spacing-lg) var(--spacing-md);
  max-width: var(--max-width-content);
  margin: 0 auto;
}

#footer ul {
  list-style: none;
  margin: 0 0 var(--spacing-md);
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-md);
  justify-content: center;
}

#footer a {
  color: #D6D1B1;
}

#footer a:hover {
  color: white;
}

.copyStmt {
  text-align: center;
  font-size: 0.9rem;
  color: #aaa;
  margin: 0;
}

.copyStmt a {
  color: #ccc;
}

/* ============================================
   Performance & Progressive Enhancement
   ============================================ */

/* Lazy loaded images */
img[loading="lazy"] {
  opacity: 0;
  transition: opacity 0.3s;
}

img[loading="lazy"].loaded,
img[loading="lazy"]:not([src]) {
  opacity: 1;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Optimize rendering */
.document-list,
.document-item {
  contain: layout style paint;
}

/* ============================================
   Utilities
   ============================================ */

.text-center {
  text-align: center;
}

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* ============================================
   Responsive Tables
   ============================================ */

table {
  width: 100%;
  border-collapse: collapse;
  margin: var(--spacing-md) 0;
}

th, td {
  padding: var(--spacing-xs) var(--spacing-sm);
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}

th {
  background: #f5f5f5;
  font-weight: 700;
  color: var(--color-text-heading);
}

@media (max-width: 768px) {
  table {
    display: block;
    overflow-x: auto;
  }
}

/* ============================================
   Print Styles
   ============================================ */

@media print {
  #menu,
  #footer,
  #leftCol {
    display: none;
  }

  #mainBody {
    box-shadow: none;
  }

  a {
    text-decoration: underline;
  }

  a[href]:after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
  }
}

/* ============================================
   Dark Mode Support (Optional)
   ============================================ */

@media (prefers-color-scheme: dark) {
  /* Uncomment to enable dark mode
  :root {
    --color-bg-body: #1a1a1a;
    --color-bg-content: #2a2a2a;
    --color-text-primary: #e0e0e0;
    --color-text-heading: #f0f0f0;
    --color-border: #444444;
  }

  #mainBody {
    background: var(--color-bg-content);
  }

  .document-item,
  .document-metadata,
  #leftCol a:hover {
    background: #333333;
  }
  */
}
