/* Soir - Sparanoid-inspired styling */

:root {
  --fontstack: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  --fontstack-mono: Menlo, Consolas, monospace;
  --font-size: clamp(14px, 1.6vw, 22px);
  --font-scale: 1;
  --font-features: "halt", "cv01", "cv02", "cv03";
  --line-height: 1.428571429;
  --line-height-content: calc(var(--line-height) * 1.2);
  --margin-content: 1.6rem;
  --margin-block: 1.8rem;
  --heading-letter-spacing: -.04em;

  --heading-margin-base: 1rem;
  --opacity-high: .7;
  --opacity-medium: .6;
  --opacity-low: .5;
  --opacity-subtle: .15;

  --hero-height: 60vh;
  --hero-padding-top: 6vmin;
  --hero-padding-bottom: 8vmin;

  --space-lg: 24vw;
  --space-md: 8vw;
  --space-sm: 4vw;
  --space-xs: 1.2vw;
  --space-current: var(--space-xs);
  --space-body: var(--space-lg);
  --space-neg: calc(var(--space-current) * -1);
  --space-body-neg: calc(var(--space-body) * -1);
  --table-width: calc(100% + var(--space-current) * 2);

  --nav-padding: .75vmax;
  --nav-item-space: 1.4vmax;
  --nav-margin-neg: calc(var(--nav-item-space) * -1);
  --nav-item-padding: .5em var(--nav-item-space);

  --text-color: hsl(215, 12%, 75%);
  --text-color-3: hsla(215, 12%, 75%, .03);
  --text-color-5: hsla(215, 12%, 75%, .05);
  --text-color-60: hsla(215, 12%, 75%, .6);

  --link-color: hsl(215, 45%, 65%);
  --bg-color: hsl(215, 20%, 9%);
  --code-color: hsl(245, 50%, 70%);
  --code-color-5: hsla(245, 50%, 70%, .05);

  --border-sm: 1px;
  --border-md: 2px;
}

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

html {
  font-size: 100%;
  text-size-adjust: none;
  text-rendering: optimizelegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background: var(--bg-color);
}

body {
  padding-inline: var(--space-body);
  margin: 0 auto;
  font-family: var(--fontstack);
  font-size: calc(var(--font-size) * var(--font-scale));
  font-feature-settings: var(--font-features);
  line-height: var(--line-height);
  color: var(--text-color);
  transition: all .2s ease;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  font-weight: bold;
  letter-spacing: var(--heading-letter-spacing);
  line-height: 1.1;
}

h1 {
  font-size: 360%;
  margin: 10vmin 0 1rem;
}

small {
    font-size: 60%;
    font-weight: normal;
    opacity: var(--opacity-subtle);
}

/* Header with background */
.content h1:first-child,
.content > h1:first-of-type {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  height: var(--hero-height);
  padding-top: var(--hero-padding-top);
  padding-bottom: var(--hero-padding-bottom);
  padding-inline: var(--space-body);
  margin-top: 0;
  margin-inline: var(--space-body-neg);
  margin-bottom: 0;
  overflow: hidden;
  text-shadow: 0 2px 24px rgba(0, 0, 0, 0.9), 0 0 40px rgba(0, 0, 0, 0.6);
}

.content h1:first-child::before,
.content > h1:first-of-type::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(to bottom, rgba(15, 18, 23, 0.3), rgba(15, 18, 23, 0.4)),
    url('/static/img/header-1.jpg');
  background-size: cover;
  background-position: center 85%;
  transform: scale(1.15);
  z-index: -1;
}

.content h1:first-child small,
.content > h1:first-of-type small {
  opacity: 0.9;
}

.content h1:first-child + *,
.content > h1:first-of-type + * {
  margin-top: 16vmin;
}

/* Progressive heading system */
h2, h3, h4, h5, h6 {
  font-weight: normal;
  margin-bottom: var(--heading-margin-base);
}

h2 {
  font-size: 240%;
  opacity: var(--opacity-high);
  margin-top: 8vmin;
}

h3, h4 {
  opacity: var(--opacity-medium);
}

h3 {
  font-size: 180%;
  margin-top: 6vmin;
}

h4 {
  font-size: 140%;
  margin-top: 4vmin;
}

h5, h6 {
  opacity: var(--opacity-low);
}

h5 {
  font-size: 120%;
  margin-top: 3vmin;
}

h6 {
  font-size: 110%;
  margin-top: 2vmin;
}

p {
  margin-bottom: var(--margin-content);
  line-height: var(--line-height-content);
}

a {
  color: var(--text-color);
  text-decoration: none;
  transition: color .5s ease, border-color .5s ease, background .5s ease, opacity 1.5s ease;
}

a:hover,
a:focus {
  transition: color .1s ease, border-color .1s ease, background .1s ease, opacity .1s ease;
  text-decoration: underline;
}

a:focus-visible {
  outline: 2px solid var(--link-color);
  outline-offset: 2px;
  text-decoration: none;
}

/* Navigation */
.navigation {
  padding-top: var(--nav-padding);
  padding-bottom: var(--nav-padding);
  margin-right: var(--nav-margin-neg);
  margin-left: var(--nav-margin-neg);
  font-size: 90%;
  font-weight: bold;
}

/* Shared container styles */
.nav-container,
.footer-container {
  display: flex;
  flex-wrap: wrap;
}

.nav-link {
  display: inline-block;
  padding: var(--nav-item-padding);
  line-height: 2;
}

.nav-link:hover,
.nav-link:focus {
  color: var(--link-color);
  text-decoration: none;
}

/* Content */
.content {
  margin-bottom: 16vmin;
}

.content a {
  font-weight: bold;
}

.content a:hover,
.content a:focus {
  color: var(--link-color);
}

/* Lists */
.content ul,
.content ol {
  margin-bottom: var(--margin-block);
  list-style: none;
  counter-reset: list;
}

.content ul li,
.content ol li {
  position: relative;
  line-height: var(--line-height-content);
}

/* Shared list pseudo-element styles */
.content ul li::before,
.content ol li::before {
  position: absolute;
  display: flex;
  justify-content: flex-end;
  width: 4em;
  margin-left: -4em;
  text-align: right;
  opacity: var(--opacity-subtle);
  pointer-events: none;
}

/* List type specific styles */
.content ul li::before {
  content: "-";
  padding-right: .5em;
}

.content ol li::before {
  counter-increment: list;
  content: counter(list) ".";
  padding-right: .25em;
}

/* Nested lists */
.content li > ul,
.content li > ol {
  margin-left: 1em;
  margin-bottom: 0;
}

/* Code */
code {
  font-family: var(--fontstack-mono);
  font-size: 92%;
  color: var(--code-color);
  overflow-wrap: break-word;
}

pre {
  padding: var(--space-current);
  margin-inline: var(--space-neg);
  margin-bottom: var(--margin-block);
  overflow-x: auto;
  font-size: 80%;
  line-height: var(--line-height-content);
  background: var(--code-color-5);
}


pre code {
  overflow-wrap: normal;
}

/* Custom scrollbar styling for code blocks */
pre::-webkit-scrollbar {
  height: 8px;
}

pre::-webkit-scrollbar-track {
  background: var(--text-color-3);
  border-radius: 4px;
}

pre::-webkit-scrollbar-thumb {
  background: var(--text-color-5);
  border-radius: 4px;
  transition: background 0.2s ease;
}

pre::-webkit-scrollbar-thumb:hover {
  background: hsla(215, 12%, 75%, .12);
}

/* Firefox scrollbar styling */
pre {
  scrollbar-width: thin;
  scrollbar-color: var(--text-color-5) var(--text-color-3);
}

/* Tables */
table {
  width: var(--table-width);
  margin-inline: var(--space-neg);
  margin-bottom: var(--margin-block);
  border-collapse: collapse;
  border-spacing: 0;
  font-size: 90%;
}

th,
td {
  padding: .6em var(--space-current);
}

th:first-child,
td:first-child {
  padding-left: var(--space-current);
}

th:last-child,
td:last-child {
  padding-right: var(--space-current);
}

th {
  border-bottom: var(--border-md) solid var(--text-color-5);
  text-align: left;
}

td {
  border-top: var(--border-sm) solid var(--text-color-5);
}

/* Blockquote */
blockquote {
  position: relative;
  margin-bottom: 2.8rem;
  margin-inline-start: var(--space-neg);
  font-size: 90%;
}

blockquote > p {
  padding-left: var(--space-current);
  border-left: var(--border-md) solid;
  color: var(--text-color-60);
  padding-bottom: 1.6em;
  margin-bottom: 0;
}

blockquote > p:last-of-type {
  padding-bottom: 0;
  margin-bottom: .4em;
}

/* Haiku integration in H1 */
.haiku-container {
  margin-top: 3rem;
  font-size: 28%;
  font-weight: normal;
  letter-spacing: normal;
}

/* Reference layout - TOC outside on left */
.reference-content {
  position: relative;
}

/* Table of Contents - Shared styles */
.toc ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.toc li {
  margin: 0 0 0.4em 0;
  line-height: 1.5;
}

.toc li::before {
  content: none !important;
  display: none !important;
}

.toc a {
  color: var(--text-color);
  font-weight: normal;
  opacity: var(--opacity-high);
}

.toc a:hover {
  opacity: 1;
  color: var(--link-color);
}

/* Desktop TOC - sticky sidebar */
.toc-inline {
  position: sticky;
  top: 25px;
  float: left;
  width: 200px;
  margin-top: 8vmin !important;
  margin-left: calc(-220px - 3rem);
  margin-right: 3rem;
  padding-left: 1.5rem;
  border-left: 4px solid var(--text-color-5);
  font-size: 70%;
  max-height: 100vh;
  overflow-y: auto;
}

@media (max-width: 1400px) {
  .toc-inline {
    display: none;
  }
}

.toc-section {
  margin-bottom: 1.5rem;
}

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

.toc-section h4 {
  font-size: 100%;
  font-weight: normal;
  margin: 0 0 0.5rem 0;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.toc-section h4 a {
  opacity: var(--opacity-low);
  text-decoration: none;
}

.toc-section h4 a:hover {
  opacity: var(--opacity-high);
  text-decoration: none;
}

/* Back to TOC link */
.back-to-toc {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: var(--border-sm) solid var(--text-color-5);
  text-align: right;
}

.back-to-toc a {
  font-size: 85%;
  font-weight: normal;
  opacity: var(--opacity-subtle);
  transition: opacity 0.2s;
}

.back-to-toc a:hover {
  opacity: 1;
  color: var(--link-color);
  text-decoration: none;
}

/* Member sections */
.member-section {
  scroll-margin-top: 2rem;
}

.section-header {
  margin-top: 8vmin;
  margin-bottom: 4vmin;
  font-size: 200%;
  opacity: var(--opacity-high);
  scroll-margin-top: 2rem;
}

.member {
  margin-bottom: 6vmin;
  scroll-margin-top: 2rem;
}

/* Footer */
.footer {
  padding: 0 0 16vmin;
  margin-right: var(--nav-margin-neg);
  margin-left: var(--nav-margin-neg);
  font-size: 80%;
  text-transform: lowercase;
}

.footer-container p {
  display: inline-block;
  padding: var(--nav-item-padding);
  line-height: 1.8;
}

/* Responsive */
@media (max-width: 1080px) {
  :root {
    --space-current: var(--space-md);
    --space-body: var(--space-md);
    --font-scale: 1.4;
    --hero-padding-top: 8vmin;
    --hero-padding-bottom: 10vmin;
  }
}

@media (max-width: 640px) {
  :root {
    --space-current: var(--space-sm);
    --space-body: var(--space-sm);
    --font-scale: 2.4;
    --hero-height: 55vh;
  }

  h1 {
    font-size: 280%;
  }

  .content ul,
  .content ol {
    margin-left: 1em;
  }

  blockquote {
    margin-left: 0;
  }

  blockquote > p {
    padding-left: calc(var(--space-body) - var(--border-md));
    padding-right: var(--space-body);
    margin-inline: var(--space-body-neg);
  }
}

@media (max-width: 400px) {
  :root {
    --font-scale: 3.2;
  }
}

/* Reduced motion for users who prefer it */
@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;
  }
}

/* Skip link - visually hidden until focused */
.skip-link {
  position: absolute;
  top: -100%;
  left: 0;
  z-index: 1000;
  padding: 1em var(--space-body);
  background: var(--bg-color);
  color: var(--link-color);
  font-weight: bold;
  text-decoration: none;
  transition: top 0.1s ease;
}

.skip-link:focus {
  top: 0;
  outline: 2px solid var(--link-color);
  outline-offset: -2px;
}

/* Mobile TOC - visible on smaller screens */
.toc-mobile {
  display: none;
}

@media (max-width: 1400px) {
  .toc-mobile {
    display: block;
    margin: 6vmin 0 4vmin;
    border-left: 4px solid var(--text-color-5);
    padding-left: 1.5rem;
    font-size: 90%;
  }
}
