/* Design Tokens System */
:root {
  --font-serif: Iowan Old Style, Palatino Linotype, Book Antiqua, Georgia, Cambria, "Times New Roman", Times, serif;
  --font-mono: ui-monospace, "SFMono-Regular", Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  
  /* Light Theme - Technical Cream Notebook */
  --bg-color: #FAF7F2;
  --bg-paper: #FFFFFF;
  --text-color: #1A1C1E;
  --text-muted: #565E66;
  --border-color: #A4ACB5;
  --accent-color: #0E3C66; /* High contrast blueprint blue */
  --accent-glow: #10B981;  /* Live state emerald */
  --accent-glow-bg: rgba(16, 185, 129, 0.15);
  --code-bg: #F0EDE6;
  --grid-color: rgba(14, 60, 102, 0.025);
  --selection-bg: #E1E8F0;
  
  --spacing-unit: 1rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    /* Dark Theme - Blueprint Terminal */
    --bg-color: #0C0F12;
    --bg-paper: #12161B;
    --text-color: #E2E6EA;
    --text-muted: #8E98A2;
    --border-color: #3C444D;
    --accent-color: #58A6FF;
    --accent-glow: #34D399;
    --accent-glow-bg: rgba(52, 211, 153, 0.2);
    --code-bg: #1A1F26;
    --grid-color: rgba(88, 166, 255, 0.025);
    --selection-bg: #21334A;
  }
}

/* Global resets & defaults */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  line-height: 1.6;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-serif);
  color: var(--text-color);
  background-color: var(--bg-color);
  background-image: 
    linear-gradient(var(--grid-color) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-color) 1px, transparent 1px);
  background-size: 24px 24px;
  background-attachment: fixed;
  margin: 0;
  padding: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

/* Text selections */
::selection {
  background-color: var(--selection-bg);
  color: inherit;
}

/* Accessible focus outline */
:focus-visible {
  outline: 3px solid var(--accent-color);
  outline-offset: 4px;
}

/* Skip link for accessibility */
.skip-link {
  position: absolute;
  top: -100px;
  left: 50%;
  transform: translateX(-50%);
  background-color: var(--accent-color);
  color: var(--bg-color) !important;
  padding: 0.75rem 1.5rem;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  font-weight: 500;
  z-index: 100;
  text-decoration: none;
  border: 1px solid var(--border-color);
  border-top: none;
  border-bottom-left-radius: 4px;
  border-bottom-right-radius: 4px;
  transition: top 0.2s ease;
}

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

/* Container & Layout */
.site-header, 
main, 
.site-footer {
  width: 100%;
  max-width: 46rem;
  margin-left: auto;
  margin-right: auto;
  padding-left: 1.5rem;
  padding-right: 1.5rem;
}

/* Header Section */
.site-header {
  margin-top: 3rem;
  margin-bottom: 2.5rem;
}

/* Technical Bulletin Header Block */
.header-bulletin {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background-color: var(--bg-paper);
  padding: 0.75rem 1rem;
  margin-bottom: 2rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.bulletin-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px dashed var(--border-color);
  padding-bottom: 0.5rem;
  margin-bottom: 0.5rem;
}

.bulletin-tag {
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--text-color);
}

.bulletin-status {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background-color: var(--accent-glow-bg);
  color: var(--accent-glow);
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.status-dot {
  width: 6px;
  height: 6px;
  background-color: var(--accent-glow);
  border-radius: 50%;
  display: inline-block;
  animation: pulse 2s infinite ease-in-out;
}

.bulletin-ledger {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.5rem;
}

.ledger-item {
  display: flex;
  flex-direction: column;
}

.ledger-label {
  color: var(--text-muted);
  font-size: 0.65rem;
  letter-spacing: 0.02em;
}

.ledger-val {
  color: var(--text-color);
  font-weight: 500;
}

/* Brand Name */
.header-brand {
  border-bottom: 4px double var(--border-color);
  padding-bottom: 1.25rem;
  margin-bottom: 1.5rem;
}

.site-title {
  font-family: var(--font-serif);
  font-size: 2.25rem;
  font-weight: 700;
  margin: 0 0 0.25rem 0;
  letter-spacing: -0.02em;
  line-height: 1.1;
  text-wrap: balance;
}

.site-title a {
  color: var(--text-color);
  text-decoration: none;
}

.site-title a:hover {
  color: var(--accent-color);
}

.site-tagline {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0;
  letter-spacing: 0.02em;
}

/* Navigation */
.site-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
  font-family: var(--font-mono);
  font-size: 0.875rem;
}

.site-nav a {
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.5rem 0;
  display: inline-block;
  min-height: 2.75rem; /* Touch target minimum height */
  display: flex;
  align-items: center;
  transition: color 0.15s ease;
}

.site-nav a:hover,
.site-nav a:focus {
  color: var(--accent-color);
}

.site-nav a.active {
  color: var(--accent-color);
  font-weight: 600;
}

/* Main Content Area */
main {
  flex: 1 0 auto;
  margin-bottom: 4rem;
}

/* Notebook Entry style (articles) */
.notebook-entry {
  background-color: var(--bg-paper);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 2.25rem 2.5rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.02);
}

@media (max-width: 600px) {
  .notebook-entry {
    padding: 1.5rem;
  }
}

.entry-header {
  border-bottom: 1px dashed var(--border-color);
  padding-bottom: 1.25rem;
  margin-bottom: 2rem;
}

.entry-title {
  font-family: var(--font-serif);
  font-size: 1.85rem;
  font-weight: 600;
  margin: 0 0 0.75rem 0;
  line-height: 1.2;
  color: var(--text-color);
  text-wrap: balance;
}

.entry-title-main {
  font-family: var(--font-mono);
  font-size: 1.15rem;
  font-weight: 600;
  margin: 0 0 0.75rem 0;
  line-height: 1.3;
  color: var(--accent-color);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-wrap: balance;
}

.entry-meta {
  font-family: var(--font-mono);
  font-size: 0.725rem;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
}

.meta-item {
  display: inline-flex;
  gap: 0.25rem;
}

.meta-label {
  color: var(--text-muted);
  font-weight: 500;
}

/* Typography elements within pages */
.entry-content p {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  line-height: 1.65;
  margin-top: 0;
  margin-bottom: 1.5rem;
  color: var(--text-color);
  text-wrap: pretty;
}

.entry-content h2,
.entry-content h3,
.entry-content h4 {
  font-family: var(--font-serif);
  color: var(--text-color);
  margin-top: 2rem;
  margin-bottom: 1rem;
  line-height: 1.3;
  text-wrap: balance;
}

.entry-content h2 {
  font-size: 1.45rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.4rem;
}

.entry-content h3 {
  font-size: 1.25rem;
}

.entry-content ul,
.entry-content ol {
  margin-top: 0;
  margin-bottom: 1.5rem;
  padding-left: 2rem;
}

.entry-content li {
  margin-bottom: 0.5rem;
  font-size: 1.05rem;
  line-height: 1.6;
  text-wrap: pretty;
}

.entry-content li::marker {
  color: var(--accent-color);
}

.entry-content code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background-color: var(--code-bg);
  padding: 0.15rem 0.35rem;
  border-radius: 3px;
  word-break: break-all;
}

.entry-content pre {
  background-color: var(--code-bg);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 1rem;
  overflow-x: auto;
  margin-bottom: 1.5rem;
}

.entry-content pre code {
  background-color: transparent;
  padding: 0;
  border-radius: 0;
  font-size: 0.85rem;
  word-break: normal;
}

.entry-content strong {
  font-weight: 700;
  color: var(--text-color);
}

.entry-content a {
  color: var(--accent-color);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: color 0.1s ease;
}

.entry-content a:hover {
  color: var(--text-color);
  text-decoration-thickness: 2px;
}

/* Footer Section */
.site-footer {
  border-top: 1px solid var(--border-color);
  padding-top: 1.5rem;
  padding-bottom: 3rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.footer-meta {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
  border-bottom: 1px dashed var(--border-color);
  padding-bottom: 0.75rem;
}

.footer-copyright {
  margin: 0;
}

.footer-copyright p {
  margin: 0;
  line-height: 1.5;
}

/* Animations */
@keyframes pulse {
  0% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4);
  }
  70% {
    transform: scale(1);
    box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
  }
  100% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .status-dot {
    animation: none;
  }
  html {
    scroll-behavior: auto;
  }
}
