/* CSS Reset & Box Sizing */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* CSS Variables */
:root {
  --color-primary: #2F2A6B;
  --color-secondary: #0E6B6A;
  --color-accent: #D6A23A;
  --color-background: #0B0E14;
  --color-surface: #121826;
  --color-text: #E9EEF7;
  --color-text-muted: #A9B4C7;
  --color-border: #26324A;
  
  --rm-bg: var(--color-background);
  --rm-surface: var(--color-surface);
  --rm-text: var(--color-text);
  --rm-muted: var(--color-text-muted);
  --rm-border: var(--color-border);
  --rm-primary: var(--color-primary);
  --rm-secondary: var(--color-secondary);
  --rm-accent: var(--color-accent);
  
  --rm-radius: 0.375rem;
  --rm-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  --rm-maxw: 75ch;
  
  --transition-speed: 0.25s;
}

/* Base Styles */
html {
  font-size: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.6;
  color: var(--rm-text);
  background-color: var(--rm-bg);
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  grid-template-columns: 1fr;
}

/* Typography with clamp() */
h1 {
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  line-height: 1.2;
  margin-bottom: 1rem;
  color: var(--rm-text);
  font-weight: 700;
}

h2 {
  font-size: clamp(1.5rem, 3.5vw, 2rem);
  line-height: 1.3;
  margin-top: 2rem;
  margin-bottom: 0.875rem;
  color: var(--rm-text);
  font-weight: 600;
  border-bottom: 2px solid var(--rm-accent);
  padding-bottom: 0.5rem;
}

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

p {
  margin-bottom: 1rem;
  max-width: var(--rm-maxw);
}

/* Links */
a {
  color: var(--rm-accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  transition: color var(--transition-speed) ease, text-decoration-color var(--transition-speed) ease;
}

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

a:focus-visible {
  outline: 2px solid var(--rm-accent);
  outline-offset: 3px;
  box-shadow: 0 0 0 4px rgba(214, 162, 58, 0.3);
  border-radius: 2px;
}

/* Header */
header {
  background-color: var(--rm-surface);
  border-bottom: 1px solid var(--rm-border);
  padding: 1rem;
  box-shadow: var(--rm-shadow);
}

header .header-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

header .site-name {
  font-size: clamp(1.25rem, 3vw, 1.75rem);
  font-weight: 700;
  color: var(--rm-accent);
  text-decoration: none;
}

header .site-name:hover {
  color: var(--rm-text);
}

/* Navigation */
nav ul {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

nav a {
  color: var(--rm-text);
  text-decoration: none;
  padding: 0.5rem 0.75rem;
  border-radius: var(--rm-radius);
  transition: background-color var(--transition-speed) ease, color var(--transition-speed) ease;
  display: block;
}

nav a:hover {
  background-color: var(--rm-primary);
  color: var(--rm-accent);
}

nav a:focus-visible {
  outline: 2px solid var(--rm-accent);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(214, 162, 58, 0.2);
}

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

.breadcrumbs ul {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.breadcrumbs li {
  display: inline-flex;
  align-items: center;
}

.breadcrumbs li:not(:first-child)::before {
  content: "›";
  margin-right: 0.5rem;
  color: var(--rm-muted);
  font-weight: bold;
}

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

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

/* Main Content */
main {
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem 1rem;
}

article, section {
  margin-bottom: 2.5rem;
}

/* Blockquotes */
blockquote {
  background-color: var(--rm-surface);
  border-left: 4px solid var(--rm-accent);
  padding: 1rem 1.25rem;
  margin: 1.5rem 0;
  border-radius: var(--rm-radius);
  font-style: italic;
  color: var(--rm-muted);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

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

/* Aside */
aside {
  background-color: var(--rm-surface);
  border: 1px solid var(--rm-border);
  border-radius: var(--rm-radius);
  padding: 1.25rem;
  margin: 1.5rem 0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

aside h3 {
  margin-top: 0;
  color: var(--rm-accent);
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  background-color: var(--rm-surface);
  border-radius: var(--rm-radius);
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

caption {
  caption-side: top;
  padding: 0.75rem;
  font-weight: 600;
  text-align: left;
  background-color: var(--rm-primary);
  color: var(--rm-text);
  font-size: 1.125rem;
}

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

th {
  padding: 0.875rem;
  text-align: left;
  font-weight: 600;
  border-bottom: 2px solid var(--rm-border);
}

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

tbody tr {
  transition: background-color var(--transition-speed) ease;
}

tbody tr:nth-child(odd) {
  background-color: rgba(255, 255, 255, 0.02);
}

tbody tr:hover {
  background-color: rgba(214, 162, 58, 0.1);
}

/* Sticky table header at >=768px */
@media (min-width: 768px) {
  thead th {
    position: sticky;
    top: 0;
    background-color: var(--rm-primary);
    z-index: 10;
  }
}

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

/* Details/Summary Accordion */
details {
  background-color: var(--rm-surface);
  border: 1px solid var(--rm-border);
  border-radius: var(--rm-radius);
  margin-bottom: 1rem;
  overflow: hidden;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

summary {
  padding: 1rem 1.25rem;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: background-color var(--transition-speed) ease, color var(--transition-speed) ease;
  color: var(--rm-text);
  position: relative;
}

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

summary::after {
  content: "▼";
  font-size: 0.75rem;
  color: var(--rm-accent);
  transition: transform var(--transition-speed) ease;
  flex-shrink: 0;
  margin-left: 1rem;
}

details[open] summary::after {
  transform: rotate(-180deg);
}

summary:hover {
  background-color: rgba(214, 162, 58, 0.1);
  color: var(--rm-accent);
}

summary:focus-visible {
  outline: 2px solid var(--rm-accent);
  outline-offset: -2px;
  box-shadow: inset 0 0 0 3px rgba(214, 162, 58, 0.3);
}

details[open] summary {
  border-bottom: 1px solid var(--rm-border);
  background-color: rgba(47, 42, 107, 0.3);
}

details p {
  padding: 1rem 1.25rem;
  margin-bottom: 0;
}

details div {
  padding: 1rem 1.25rem;
}

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

li {
  margin-bottom: 0.5rem;
}

ul[role="list"], ol[role="list"] {
  list-style: none;
  padding-left: 0;
}

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

footer .footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: center;
}

/* Focus-visible support */
*:focus {
  outline: none;
}

*:focus-visible {
  outline: 2px solid var(--rm-accent);
  outline-offset: 2px;
}

button:focus-visible, 
input:focus-visible, 
textarea:focus-visible, 
select:focus-visible {
  box-shadow: 0 0 0 3px rgba(214, 162, 58, 0.3);
}

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

/* Responsive breakpoints */
@media (min-width: 768px) {
  header .header-inner {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
  
  nav ul {
    gap: 1.5rem;
  }
  
  main {
    padding: 3rem 2rem;
  }
  
  aside {
    float: right;
    width: 40%;
    margin-left: 2rem;
    margin-top: 0.5rem;
  }
}

@media (min-width: 1024px) {
  main {
    padding: 4rem 2rem;
  }
  
  nav ul {
    gap: 2rem;
  }
  
  aside {
    width: 35%;
  }
}

/* Print Styles */
@media print {
  body {
    background-color: white;
    color: black;
  }
  
  header, footer, nav, aside {
    display: none;
  }
  
  main {
    max-width: 100%;
    padding: 0;
  }
  
  a {
    text-decoration: underline;
    color: black;
  }
  
  a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
  }
  
  table {
    border: 1px solid black;
    box-shadow: none;
  }
  
  thead {
    background-color: #f0f0f0;
  }
  
  th, td {
    border: 1px solid black;
  }
  
  details[open] summary ~ * {
    display: block;
  }
  
  summary::after {
    display: none;
  }
  
  blockquote {
    border-left: 4px solid black;
    background-color: #f9f9f9;
  }
  
  h2 {
    page-break-after: avoid;
  }
  
  table, figure, img {
    page-break-inside: avoid;
  }
}