/*
 * Feralism Base Styles
 * Academic, modern, clean, philosophical, e-ink friendly
 * For use across all site pages
 */

:root {
  /* Colors - High contrast for e-ink */
  --pure-black: #000000;
  --charcoal: #1a1a1a;
  --dark-gray: #333333;
  --medium-gray: #595959;  /* Improved from #666666 for WCAG AA (4.5:1) */
  --gray: #767676;          /* Improved from #999999 for WCAG AA (4.54:1) */
  --light-gray: #CCCCCC;
  --pale-gray: #E5E5E5;
  --off-white: #F8F8F8;
  --white: #FFFFFF;

  /* Accent - Restrained gold */
  --gold: #B8860B;
  --gold-dark: #9B7209;
  --gold-light: #D4A637;

  /* Spacing - Dense, academic */
  --space-xs: 0.5rem;
  --space-sm: 0.75rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  --space-3xl: 4rem;

  /* Typography */
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 2rem;
  --text-4xl: 2.5rem;
  --text-5xl: 3rem;

  /* Fonts */
  --font-serif: Georgia, 'Times New Roman', serif;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;

  /* Effects */
  --transition: 200ms ease;
  --radius: 8px;
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
}

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

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

/* Show sr-only content in high contrast mode for e-ink visibility */
@media (prefers-contrast: high), (prefers-contrast: more) {
  .message-content .sr-only {
    position: static;
    width: auto;
    height: auto;
    margin: 0;
    overflow: visible;
    clip: auto;
    white-space: normal;
    font-weight: 600;
  }
}

/* Base Typography */
body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.6;
  color: var(--pure-black);
  background: var(--white);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Headings - Academic serif style */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-serif);
  font-weight: 400;
  line-height: 1.2;
  color: var(--pure-black);
  margin-bottom: var(--space-md);
}

h1 {
  font-size: clamp(var(--text-3xl), 4vw, var(--text-4xl));
  letter-spacing: -0.02em;
}

h2 {
  font-size: clamp(var(--text-2xl), 3vw, var(--text-3xl));
}

h3 {
  font-size: var(--text-2xl);
}

h4 {
  font-size: var(--text-xl);
}

/* Paragraphs */
p {
  margin-bottom: var(--space-md);
  line-height: 1.6;
  color: var(--dark-gray);
}

/* Links */
a {
  color: var(--gold-dark);
  text-decoration: none;
  transition: var(--transition);
}

a:hover {
  color: var(--gold);
}

/* Layout */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-lg);
}

.container-narrow {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 var(--space-lg);
}

.container-wide {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 var(--space-lg);
}

/* Sections */
.section {
  padding: var(--space-2xl) 0;
  position: relative;
}

.section::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 10%;
  right: 10%;
  height: 1px;
  background: var(--pale-gray);
}

.section:last-of-type::after {
  display: none;
}

.section:nth-child(even) {
  background: var(--off-white);
}

.section-white {
  background: var(--white);
}

.section-gray {
  background: var(--off-white);
}

/* Section Headers */
.section-header {
  text-align: center;
  margin-bottom: var(--space-xl);
}

.section-header h2 {
  font-size: var(--text-4xl);
  margin-bottom: var(--space-md);
  position: relative;
  display: inline-block;
}

.section-header h2::after {
  content: '';
  position: absolute;
  bottom: -12px;
  left: 50%;
  transform: translateX(-50%);
  width: 60px;
  height: 2px;
  background: var(--gold);
}

.section-header p {
  font-size: var(--text-lg);
  color: var(--medium-gray);
  max-width: 700px;
  margin: var(--space-lg) auto 0;
  line-height: 1.7;
}

/* Content Blocks */
.content-block {
  max-width: 800px;
  margin: 0 auto var(--space-lg);
}

.content-block p {
  font-size: var(--text-lg);
  line-height: 1.7;
  margin-bottom: var(--space-md);
}

.content-block h3 {
  margin-top: var(--space-xl);
  margin-bottom: var(--space-md);
}

/* Lead paragraph */
.lead {
  font-size: var(--text-xl);
  line-height: 1.7;
  color: var(--dark-gray);
}

/* Emphasis Box */
.emphasis-box {
  background: var(--off-white);
  border-left: 3px solid var(--gold);
  padding: var(--space-md) var(--space-lg);
  margin: var(--space-lg) 0;
}

.emphasis-box p {
  margin: 0;
  font-size: var(--text-lg);
  line-height: 1.7;
  color: var(--charcoal);
}

/* Buttons */
.btn {
  padding: var(--space-sm) var(--space-xl);
  font-size: var(--text-base);
  font-weight: 500;
  text-decoration: none;
  transition: var(--transition);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  border-radius: 6px;
  display: inline-block;
  cursor: pointer;
  border: none;
  font-family: var(--font-sans);
}

.btn-primary {
  background: var(--gold);
  color: var(--white);
  border: 1px solid var(--gold);
}

.btn-primary:hover {
  background: var(--gold-dark);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background: var(--white);
  color: var(--gold-dark);
  border: 1px solid var(--gold);
}

.btn-secondary:hover {
  background: var(--gold);
  color: var(--white);
  transform: translateY(-2px);
}

.btn-link {
  background: transparent;
  color: var(--dark-gray);
  border: none;
  padding: 0;
  text-transform: none;
  letter-spacing: normal;
  text-decoration: underline;
  font-weight: 400;
}

.btn-link:hover {
  color: var(--gold-dark);
  transform: none;
}

/* Cards */
.card {
  background: var(--white);
  border: 1px solid var(--pale-gray);
  border-radius: var(--radius);
  overflow: hidden;
}

.card-header {
  padding: var(--space-lg);
  border-bottom: 1px solid var(--pale-gray);
}

.card-body {
  padding: var(--space-lg);
}

.card-footer {
  padding: var(--space-lg);
  border-top: 1px solid var(--pale-gray);
  background: var(--off-white);
}

/* Grid Layouts */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: var(--space-xl);
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-xl);
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--space-lg);
}

/* Separators */
.separator {
  height: 1px;
  background: var(--pale-gray);
  margin: var(--space-xl) 0;
}

.separator-thick {
  height: 2px;
  background: var(--charcoal);
  margin: var(--space-2xl) 0;
}

/* Lists */
ul, ol {
  margin-left: var(--space-lg);
  margin-bottom: var(--space-md);
}

li {
  margin-bottom: var(--space-xs);
  line-height: 1.7;
}

/* Blockquotes */
blockquote {
  border-left: 3px solid var(--gold);
  padding-left: var(--space-lg);
  margin: var(--space-xl) 0;
  font-style: italic;
  color: var(--medium-gray);
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  margin: var(--space-xl) 0;
}

th, td {
  padding: var(--space-sm) var(--space-md);
  text-align: left;
  border-bottom: 1px solid var(--pale-gray);
}

th {
  font-weight: 600;
  background: var(--off-white);
}

/* Responsive */
@media (max-width: 768px) {
  :root {
    --space-3xl: 3rem;
    --space-2xl: 2rem;
    --space-xl: 1.5rem;
  }

  .section {
    padding: var(--space-xl) 0;
  }

  .grid-2, .grid-3, .grid-4 {
    grid-template-columns: 1fr;
  }

  .container, .container-narrow, .container-wide {
    padding: 0 var(--space-md);
  }
}

/* ===========================================
   E-INK & HIGH CONTRAST OPTIMIZATIONS
   Supports both monochrome and color e-ink displays
   =========================================== */

/* Improved contrast for secondary text (base styles) */
/* --gray changed from #999999 to #595959 for WCAG AA compliance */

/* Print & E-ink optimizations */
@media print {
  :root {
    --gold: #000000;
    --gold-dark: #000000;
    --gold-light: #000000;
    --medium-gray: #333333;
    --gray: #333333;
  }

  body {
    background: white !important;
    color: black !important;
  }

  * {
    box-shadow: none !important;
    text-shadow: none !important;
  }

  a {
    color: black !important;
    text-decoration: underline !important;
  }
}

/* High contrast mode - preserves colors but removes effects */
@media (prefers-contrast: high) {
  :root {
    /* Boost contrast for all text */
    --medium-gray: #4a4a4a;
    --gray: #595959;
    --dark-gray: #1a1a1a;
  }

  body {
    background: white;
  }

  .section:nth-child(even) {
    background: white;
  }

  /* Remove all transforms on interaction */
  .card:hover, .btn:hover, a:hover {
    transform: none !important;
    box-shadow: none !important;
  }

  /* Remove gradients - use solid backgrounds */
  .main-content,
  .project-header,
  .dropdown-content,
  .sidebar,
  .sidebar .item,
  footer,
  .server-message-container {
    background-image: none !important;
  }
}

/* E-ink specific optimizations */
@media (prefers-contrast: more),
       (prefers-reduced-motion: reduce),
       (color-gamut: srgb) and (prefers-contrast: high) {

  /* Disable all animations */
  *, *::before, *::after {
    animation: none !important;
    animation-duration: 0s !important;
    transition: none !important;
    transition-duration: 0s !important;
  }

  /* Remove all gradients - e-ink dithers them even with color */
  * {
    background-image: none !important;
  }

  /* Remove shadows - cause ghosting on e-ink */
  * {
    box-shadow: none !important;
    text-shadow: none !important;
  }

  /* Remove transforms - cause refresh artifacts */
  *:hover, *:focus, *:active {
    transform: none !important;
  }

  /* Use underline for links instead of color change */
  a:hover, a:focus {
    text-decoration: underline !important;
  }

  /* Simplify borders */
  .card, .btn, input, textarea, select {
    border-radius: 2px !important;
  }

  /* Ensure solid backgrounds for alternating sections */
  .section:nth-child(even) {
    background: #f0f0f0 !important;
  }

  .section:nth-child(odd) {
    background: #ffffff !important;
  }
}

/* Reduced motion - respects user preference */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  /* Remove pulsing, bouncing, sliding effects */
  .notification-badge,
  .icon-messages,
  .ping-indicator {
    animation: none !important;
  }

  /* Static hover states */
  .btn:hover,
  .card:hover,
  .account-icon:hover,
  .social-icons li a:hover {
    transform: none !important;
  }
}
