/* Modern CSS for Big Book of Small Python Projects */

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

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ============================================
   Typography & Body Styles
   ============================================ */

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
               'Ubuntu', 'Cantarell', 'Helvetica Neue', sans-serif;
  font-size: 1.125rem;
  line-height: 1.75;
  color: #2c3e50;
  background-color: #ffffff;
  padding: 2rem 1.5rem;
}

@media (min-width: 768px) {
  body {
    padding: 3rem 2rem;
  }
}

/* ============================================
   Headings
   ============================================ */

h1, h2, h3, h4, h5, h6 {
  font-family: 'Georgia', 'Times New Roman', serif;
  color: #1a202c;
  margin-top: 2rem;
  margin-bottom: 1rem;
  line-height: 1.3;
  font-weight: 600;
}

h1 {
  font-size: 2.5rem;
  margin-top: 0;
  padding-bottom: 1rem;
  border-bottom: 3px solid #3498db;
  color: #2c5282;
}

h2 {
  font-size: 2rem;
  margin-top: 3rem;
  padding-top: 1rem;
  color: #2d3748;
  border-top: 1px solid #e2e8f0;
}

h3 {
  font-size: 1.5rem;
  color: #4a5568;
}

h4 {
  font-size: 1.25rem;
  color: #4a5568;
}

/* ============================================
   Paragraphs & Text
   ============================================ */

p {
  margin-bottom: 1.5rem;
}

/* ============================================
   Code Blocks & Inline Code
   ============================================ */

code {
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  background-color: #f7fafc;
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
  font-size: 0.95em;
  color: #d73a49;
  border: 1px solid #e2e8f0;
}

/* Ensure monospace font for specific code class */
.thesansmonocd_w5regular_ {
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  font-style: normal;
}

pre {
  background-color: #ffffff;
  color: #2c3e50;
  padding: 1.5rem;
  border-radius: 0.5rem;
  overflow-x: auto;
  margin: 1.5rem 0;
  font-size: 0.95rem;
  line-height: 1.5;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  border: 1px solid #e2e8f0;
}

pre code {
  background-color: transparent;
  color: inherit;
  padding: 0;
  border: none;
  font-size: inherit;
}

/* Python shell prompt styling */
pre:has(> code:first-child:contains(">>>")) {
  background-color: #f8f9fa;
  border-left: 4px solid #3498db;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  margin: 2rem 0;
  background-color: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  border-radius: 0.5rem;
  overflow: hidden;
}

thead {
  background-color: #f8f9fa;
  color: #2c3e50;
}

th {
  padding: 1rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

td {
  padding: 1rem;
  border-bottom: 1px solid #e2e8f0;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover {
  background-color: #f7fafc;
  transition: background-color 0.2s ease;
}

/* Zebra striping for better readability */
tbody tr:nth-child(even) {
  background-color: #f8fafc;
}

/* ============================================
   Lists
   ============================================ */

ul, ol {
  margin: 1.5rem 0;
  padding-left: 2rem;
}

li {
  margin-bottom: 0.5rem;
  line-height: 1.8;
}

li::marker {
  color: #3498db;
}

/* Nested lists */
li ul, li ol {
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
}

/* ============================================
   Links
   ============================================ */

a {
  color: #3498db;
  text-decoration: none;
  border-bottom: 2px solid transparent;
  transition: all 0.3s ease;
  font-weight: 500;
}

a:hover {
  color: #2980b9;
  border-bottom-color: #2980b9;
}

a:visited {
  color: #8e44ad;
}

/* ============================================
   Blockquotes & Notes
   ============================================ */

blockquote {
  margin: 2rem 0;
  padding: 1rem 1.5rem;
  background-color: #f0f9ff;
  border-left: 4px solid #3498db;
  color: #4a5568;
  border-radius: 0.25rem;
}

/* Note/Warning boxes */
.note {
  font-size: 1.1rem;
  font-weight: 600;
  color: #2c3e50;
  margin: 1.5rem 0 0.5rem 0;
  padding: 0;
  background: none;
  border: none;
}

.note-txt {
  border: 1px solid #cbd5e1;
  padding: 1rem;
  margin: 0 0 1.5rem 0;
  background-color: #f8fafc;
}

.warning, .tip {
  padding: 1rem 1.5rem;
  margin: 2rem 0;
  border-radius: 0.5rem;
  position: relative;
}

.warning {
  background-color: #fef3c7;
  border-left: 4px solid #f59e0b;
}

.tip {
  background-color: #f0fdf4;
  border-left: 4px solid #22c55e;
}

/* ============================================
   Images & Figures
   ============================================ */

img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 2rem auto;
}

figure {
  margin: 2rem 0;
  text-align: center;
}

figcaption {
  margin-top: 0.75rem;
  font-size: 0.95rem;
  color: #718096;
}

/* ============================================
   Utility Classes
   ============================================ */

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

.text-muted {
  color: #718096;
}

.mb-0 {
  margin-bottom: 0;
}

.mt-0 {
  margin-top: 0;
}

/* Box class with simple border */
.box {
  border: 1px solid #cbd5e1;
  padding: 1rem;
  margin: 1rem 0;
}

/* ============================================
   Responsive Design
   ============================================ */

@media (max-width: 768px) {
  body {
    font-size: 1rem;
  }

  h1 {
    font-size: 2rem;
  }

  h2 {
    font-size: 1.5rem;
  }

  h3 {
    font-size: 1.25rem;
  }

  pre {
    padding: 1rem;
    font-size: 0.875rem;
  }

  table {
    font-size: 0.875rem;
  }

  th, td {
    padding: 0.75rem 0.5rem;
  }
}

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

@media print {
  body {
    color: #000;
    background: #fff;
    font-size: 12pt;
    line-height: 1.5;
  }

  h1, h2, h3, h4, h5, h6 {
    page-break-after: avoid;
    color: #000;
  }

  pre, blockquote {
    page-break-inside: avoid;
  }

  a {
    color: #000;
    text-decoration: underline;
  }

  a[href^="http"]:after {
    content: " (" attr(href) ")";
  }

  pre {
    border: 1px solid #999;
    background: #f5f5f5;
  }
}

/* ============================================
   Animations & Transitions
   ============================================ */

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Apply subtle animation to main content */
body > * {
  animation: fadeIn 0.6s ease-out;
}

/* ============================================
   Accessibility Improvements
   ============================================ */

/* Focus styles for keyboard navigation */
*:focus {
  outline: 3px solid #3498db;
  outline-offset: 2px;
}

/* Skip link for screen readers */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: #000;
  color: #fff;
  padding: 0.5rem 1rem;
  text-decoration: none;
  border-radius: 0 0 0.25rem 0;
}

.skip-link:focus {
  top: 0;
}

/* Ensure sufficient color contrast */
.low-vision-mode {
  filter: contrast(1.2);
}

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

@media (prefers-color-scheme: dark) {
  body {
    background-color: #1a202c;
    color: #e2e8f0;
  }

  h1, h2, h3, h4, h5, h6 {
    color: #f7fafc;
  }

  code {
    background-color: #2d3748;
    color: #fbbf24;
    border-color: #4a5568;
  }

  pre {
    background-color: #0f172a;
    color: #e2e8f0;
  }

  table {
    background-color: #2d3748;
  }

  thead {
    background-color: #374151;
  }

  tbody tr:hover {
    background-color: #374151;
  }

  tbody tr:nth-child(even) {
    background-color: #1f2937;
  }

  td {
    border-color: #4a5568;
  }

  a {
    color: #60a5fa;
  }

  a:hover {
    color: #93bbfc;
    border-bottom-color: #93bbfc;
  }

  a:visited {
    color: #a78bfa;
  }

  blockquote {
    background-color: #1e293b;
    border-left-color: #3b82f6;
    color: #cbd5e1;
  }

  .note {
    color: #e2e8f0;
  }

  .note-txt {
    background-color: #2d3748;
    border-color: #4a5568;
  }

  .box {
    border-color: #4a5568;
  }

  .warning {
    background-color: #451a03;
  }

  .tip {
    background-color: #14532d;
  }
}