/* CSS Variables: Ouroboros Nightglass palette */
:root {
  --bg: #0B0F14;
  --surface: #121A23;
  --text: #E7EEF7;
  --muted: #A7B3C2;
  --border: #243244;
  --primary: #2FD6A6;
  --secondary: #7B5CFF;
  --accent: #FFB454;
  --shadow: rgba(0, 0, 0, 0.5);
  --radius: 0.5rem;
  --maxw: 1200px;
}

/* Reset and base styles */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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, Oxygen, Ubuntu, Cantarell, sans-serif;
  line-height: 1.6;
  color: var(--text);
  background-color: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Responsive typography using clamp() */
h1 {
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  line-height: 1.2;
  margin-bottom: 1.5rem;
  color: var(--primary);
  font-weight: 700;
}

h2 {
  font-size: clamp(1.5rem, 3vw, 2rem);
  line-height: 1.3;
  margin-top: 2.5rem;
  margin-bottom: 1rem;
  color: var(--secondary);
  font-weight: 600;
}

h3 {
  font-size: clamp(1.25rem, 2.5vw, 1.5rem);
  line-height: 1.4;
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
  color: var(--accent);
  font-weight: 600;
}

p {
  margin-bottom: 1rem;
}

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

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

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

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

li {
  margin-bottom: 0.5rem;
}

strong {
  color: var(--primary);
  font-weight: 600;
}

/* Container and layout */
.container {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 1rem;
}

@media (min-width: 768px) {
  .container {
    padding: 0 2rem;
  }
}

main {
  flex: 1;
  padding: 2rem 0;
}

/* Header and navigation */
header {
  background-color: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 1rem 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px var(--shadow);
}

header .container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: center;
}

@media (min-width: 768px) {
  header .container {
    flex-direction: row;
    justify-content: space-between;
  }
}

.site-name {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 0.5px;
}

header nav ul {
  list-style: none;
  display: flex;
  gap: 1.5rem;
  padding: 0;
  margin: 0;
}

header nav a {
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s ease;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius);
}

header nav a:hover {
  color: var(--primary);
  background-color: rgba(47, 214, 166, 0.1);
}

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

header nav a[aria-current="page"] {
  color: var(--primary);
  font-weight: 600;
}

/* Breadcrumbs */
.breadcrumbs {
  margin-bottom: 1.5rem;
}

.breadcrumbs ol {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0;
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.breadcrumbs li:not(:last-child)::after {
  content: '/';
  margin-left: 0.5rem;
  color: var(--border);
}

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

.breadcrumbs a:hover {
  color: var(--primary);
  text-decoration: underline;
}

/* Aside */
aside {
  background-color: var(--surface);
  border-left: 4px solid var(--secondary);
  padding: 1rem;
  margin: 1.5rem 0;
  border-radius: var(--radius);
}

aside p {
  margin-bottom: 0;
}

/* Blockquote with gradient border and glow */
blockquote {
  background-color: var(--surface);
  padding: 1.5rem;
  margin: 2rem 0;
  border-radius: var(--radius);
  border-left: 4px solid var(--primary);
  position: relative;
  font-style: italic;
  color: var(--muted);
  box-shadow: 0 0 12px rgba(47, 214, 166, 0.2);
}

blockquote p {
  margin-bottom: 0;
}

/* Tables with sticky header */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 2rem 0;
  background-color: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 2px 8px var(--shadow);
}

caption {
  font-weight: 600;
  color: var(--primary);
  text-align: left;
  padding: 1rem;
  background-color: var(--surface);
  font-size: 1.1rem;
}

thead {
  background-color: var(--border);
}

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

th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-weight: 600;
  color: var(--primary);
  border-bottom: 2px solid var(--primary);
}

td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}

tbody tr:hover {
  background-color: rgba(47, 214, 166, 0.05);
}

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

/* Responsive table wrapper */
@media (max-width: 767px) {
  table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
}

/* Details/Summary accordion with animated marker */
details {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1rem;
  padding: 1rem;
  transition: background-color 0.2s ease;
}

details:hover {
  background-color: rgba(47, 214, 166, 0.05);
}

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

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

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

summary::before {
  content: '▶';
  display: inline-block;
  transition: transform 0.2s ease;
  color: var(--secondary);
}

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

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

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

details p {
  margin-top: 1rem;
  color: var(--text);
}

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

footer p {
  margin: 0;
}

/* Section spacing */
section {
  margin-bottom: 3rem;
}

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

/* Navigation lists inside sections */
section nav ul {
  list-style: none;
  padding: 0;
}

section nav li {
  margin-bottom: 0.75rem;
}

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

section nav a:hover {
  color: var(--accent);
  text-decoration: underline;
}

/* External link styling */
a[target="_blank"]::after {
  content: ' ↗';
  font-size: 0.85em;
  color: var(--muted);
}

/* Accessibility: focus-visible for all interactive elements */
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* High contrast text for readability */
body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Reduced motion: disable transitions and animations */
@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
  summary::before {
    transition: none !important;
  }
}

/* Article wrapper */
article {
  background-color: var(--surface);
  padding: 2rem;
  border-radius: var(--radius);
  box-shadow: 0 4px 12px var(--shadow);
}

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

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

/* Hover states for all links */
a {
  position: relative;
}

a:hover {
  text-decoration-thickness: 2px;
}

/* Grid-based page shell */
body {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 100vh;
}

header,
main,
footer {
  width: 100%;
}

/* Flex navigation clusters */
header nav ul,
section nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

@media (max-width: 767px) {
  header nav ul {
    flex-direction: column;
    gap: 0.5rem;
  }
}