/* ===========================
   CSS Variables (Color Palette)
   =========================== */
:root {
  --color-bg: #F7F7F2;
  --color-surface: #FFFFFF;
  --color-text: #111827;
  --color-muted: #4B5563;
  --color-border: #D1D5DB;
  --color-primary: #2B3A67;
  --color-secondary: #1F7A8C;
  --color-accent: #F4D35E;
  --radius: 2px;
  --space: 1.5rem;
  --maxw: 56rem;
}

/* ===========================
   Reset and Base Styles
   =========================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 100%;
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.6;
  color: var(--color-text);
  background-color: var(--color-bg);
  font-size: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
}

/* ===========================
   Typography
   =========================== */
h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 1rem;
  color: var(--color-primary);
}

h1 {
  font-size: clamp(1.75rem, 1.5rem + 1.25vw, 2.5rem);
  margin-bottom: 1.5rem;
}

h2 {
  font-size: clamp(1.5rem, 1.25rem + 1vw, 2rem);
  margin-top: 2.5rem;
  margin-bottom: 1rem;
}

h3 {
  font-size: clamp(1.25rem, 1.125rem + 0.5vw, 1.5rem);
  margin-top: 2rem;
  margin-bottom: 0.75rem;
}

p, ul, ol, table, blockquote {
  margin-bottom: 1.5rem;
}

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

li {
  margin-bottom: 0.5rem;
}

a {
  color: var(--color-secondary);
  text-decoration: underline;
  transition: color 0.2s ease;
}

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

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

strong {
  font-weight: 700;
}

/* ===========================
   Layout: Grid and Container
   =========================== */
.container {
  max-width: var(--maxw);
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--space);
  padding-right: var(--space);
}

main {
  padding-top: 2rem;
  padding-bottom: 3rem;
}

/* ===========================
   Header and Navigation
   =========================== */
header {
  background-color: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding-top: 1rem;
  padding-bottom: 1rem;
}

header .container {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.site-name {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0;
}

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

.site-name a:hover {
  color: var(--color-secondary);
}

header nav {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
}

header nav a {
  color: var(--color-text);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s ease;
}

header nav a:hover {
  color: var(--color-secondary);
}

header nav a:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
  border-radius: var(--radius);
}

/* ===========================
   Breadcrumbs
   =========================== */
.breadcrumbs {
  font-size: 0.875rem;
  color: var(--color-muted);
  margin-bottom: 1.5rem;
}

.breadcrumbs a {
  color: var(--color-secondary);
  text-decoration: none;
}

.breadcrumbs a:hover {
  text-decoration: underline;
}

/* ===========================
   Article and Sections
   =========================== */
article {
  background-color: var(--color-surface);
  padding: 2rem;
  border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

@media (max-width: 767px) {
  article {
    padding: 1.5rem;
  }
}

section {
  margin-bottom: 2.5rem;
}

section:last-child {
  margin-bottom: 0;
}

/* ===========================
   Blockquote
   =========================== */
blockquote {
  border-left: 4px solid var(--color-secondary);
  padding-left: 1.5rem;
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
  background-color: rgba(31, 122, 140, 0.05);
  font-style: italic;
  color: var(--color-text);
  margin-left: 0;
  margin-right: 0;
}

blockquote p {
  margin-bottom: 0.5rem;
}

blockquote p:last-child {
  margin-bottom: 0;
}

/* ===========================
   Tables
   =========================== */
.table-wrapper {
  overflow-x: auto;
  margin-bottom: 1.5rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  background-color: var(--color-surface);
  font-size: 0.9375rem;
}

table caption {
  font-weight: 700;
  text-align: left;
  margin-bottom: 0.75rem;
  color: var(--color-primary);
  font-size: 1rem;
}

thead {
  background-color: var(--color-primary);
  color: var(--color-surface);
}

thead th {
  padding: 0.75rem;
  text-align: left;
  font-weight: 700;
}

tbody tr {
  border-bottom: 1px solid var(--color-border);
  transition: background-color 0.2s ease;
}

tbody tr:nth-child(even) {
  background-color: rgba(247, 247, 242, 0.5);
}

tbody tr:hover {
  background-color: rgba(244, 211, 94, 0.1);
}

tbody td {
  padding: 0.75rem;
}

@media (min-width: 1024px) {
  thead {
    position: sticky;
    top: 0;
    z-index: 10;
  }
}

/* ===========================
   Details / Summary (Accordion)
   =========================== */
details {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
  background-color: var(--color-surface);
  transition: box-shadow 0.2s ease;
}

details:hover {
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

details[open] {
  border-color: var(--color-secondary);
}

summary {
  font-weight: 700;
  cursor: pointer;
  color: var(--color-primary);
  list-style: none;
  display: flex;
  align-items: center;
  transition: color 0.2s ease;
}

summary::-webkit-details-marker {
  display: none;
}

summary::before {
  content: '▸';
  display: inline-block;
  margin-right: 0.5rem;
  transition: transform 0.2s ease;
  color: var(--color-secondary);
}

details[open] summary::before {
  transform: rotate(90deg);
}

summary:hover {
  color: var(--color-secondary);
}

summary:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
  border-radius: var(--radius);
}

.details-content {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--color-border);
}

.details-content p {
  margin-bottom: 1rem;
}

.details-content p:last-child {
  margin-bottom: 0;
}

/* ===========================
   Aside
   =========================== */
aside {
  background-color: rgba(31, 122, 140, 0.05);
  border-left: 4px solid var(--color-secondary);
  padding: 1.5rem;
  margin-top: 2.5rem;
  margin-bottom: 2.5rem;
  border-radius: var(--radius);
}

aside h2, aside h3 {
  margin-top: 0;
}

/* ===========================
   Footer
   =========================== */
footer {
  background-color: var(--color-surface);
  border-top: 1px solid var(--color-border);
  padding-top: 1.5rem;
  padding-bottom: 1.5rem;
  text-align: center;
  font-size: 0.875rem;
  color: var(--color-muted);
}

footer p {
  margin: 0;
}

/* ===========================
   Responsive Breakpoints
   =========================== */
@media (min-width: 768px) {
  :root {
    --space: 2rem;
  }
  main {
    padding-top: 3rem;
    padding-bottom: 4rem;
  }
}

@media (min-width: 1024px) {
  :root {
    --space: 2.5rem;
  }
}

/* ===========================
   Focus-Visible Enhancements
   =========================== */
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* ===========================
   Utility: Smooth Transitions
   =========================== */
a, summary, tbody tr, details {
  transition: all 0.2s ease;
}

@media (prefers-reduced-motion: reduce) {
  a, summary, tbody tr, details {
    transition: none;
  }
}