/* RFRNT - Typography-first brutalist stylesheet */

/* Valkyrie OT A - Serif (reference/non-technical documentation) */
@font-face {
  font-family: 'Valkyrie';
  font-style: normal;
  font-weight: 400;
  font-display: block;
  src: url('/fonts/valkyrie/valkyrie_ot_a_regular.woff2') format('woff2');
}

@font-face {
  font-family: 'Valkyrie';
  font-style: italic;
  font-weight: 400;
  font-display: block;
  src: url('/fonts/valkyrie/valkyrie_ot_a_italic.woff2') format('woff2');
}

@font-face {
  font-family: 'Valkyrie';
  font-style: normal;
  font-weight: 700;
  font-display: block;
  src: url('/fonts/valkyrie/valkyrie_ot_a_bold.woff2') format('woff2');
}

@font-face {
  font-family: 'Valkyrie';
  font-style: italic;
  font-weight: 700;
  font-display: block;
  src: url('/fonts/valkyrie/valkyrie_ot_a_bold_italic.woff2') format('woff2');
}

/* Iosevka Aile - Sans-serif (technical documentation) */
@font-face {
  font-family: 'Iosevka Aile';
  font-style: normal;
  font-weight: 400;
  font-display: block;
  src: url('/fonts/iosevka-aile/IosevkaAile-Regular.woff2') format('woff2');
}

@font-face {
  font-family: 'Iosevka Aile';
  font-style: italic;
  font-weight: 400;
  font-display: block;
  src: url('/fonts/iosevka-aile/IosevkaAile-Italic.woff2') format('woff2');
}

@font-face {
  font-family: 'Iosevka Aile';
  font-style: normal;
  font-weight: 600;
  font-display: block;
  src: url('/fonts/iosevka-aile/IosevkaAile-SemiBold.woff2') format('woff2');
}

@font-face {
  font-family: 'Iosevka Aile';
  font-style: normal;
  font-weight: 700;
  font-display: block;
  src: url('/fonts/iosevka-aile/IosevkaAile-Bold.woff2') format('woff2');
}

/* Iosevka - Monospace (code, pre blocks) */
@font-face {
  font-family: 'Iosevka';
  font-style: normal;
  font-weight: 400;
  font-display: block;
  src: url('/fonts/iosevka/Iosevka-Regular.woff2') format('woff2');
}

@font-face {
  font-family: 'Iosevka';
  font-style: italic;
  font-weight: 400;
  font-display: block;
  src: url('/fonts/iosevka/Iosevka-Italic.woff2') format('woff2');
}

@font-face {
  font-family: 'Iosevka';
  font-style: normal;
  font-weight: 700;
  font-display: block;
  src: url('/fonts/iosevka/Iosevka-Bold.woff2') format('woff2');
}

@font-face {
  font-family: 'Iosevka';
  font-style: italic;
  font-weight: 700;
  font-display: block;
  src: url('/fonts/iosevka/Iosevka-BoldItalic.woff2') format('woff2');
}

/* Font variables */
:root {
  --font-sans: 'Iosevka Aile', system-ui, sans-serif;
  --font-serif: 'Valkyrie', Georgia, serif;
  --font-mono: 'Iosevka', monospace;
}

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

html {
  font-size: 19px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-serif);
  line-height: 1.55;
  color: #222;
  background: #f4f4f4;
}

/* Typography scale */
h1, h2, h3, h4 {
  font-family: var(--font-sans);
  font-weight: 700;
  line-height: 1.2;
}

h1 {
  font-size: 2.5rem;
  letter-spacing: -0.03em;
}

h2 {
  font-size: 1.75rem;
  letter-spacing: -0.02em;
}

h3 {
  font-size: 1.25rem;
}

h4 {
  font-size: 1rem;
  font-weight: 600;
}

p {
  text-align: justify;
  hyphens: auto;
  -webkit-hyphens: auto;
}

p + p {
  text-indent: 1.5em;
}

a {
  color: #000;
  text-decoration: none;
  font-variant: small-caps;
}

a:hover {
  text-decoration: underline;
}

.toc a {
  font-variant: normal;
}

/* Code and reference numbers */
code, .ref {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: #000;
  color: #fff;
  padding: 0.06em 0.35em 0.14em;
  border-radius: 2px;
  white-space: nowrap;
}

pre {
  background: #000;
  color: #fff;
  padding: 1rem;
  overflow-x: auto;
  margin: 1rem 0;
  border-radius: 2px;
}

pre code {
  background: transparent;
  padding: 0;
  font-size: 0.9rem;
  line-height: 1.5;
  white-space: pre-wrap;
}

/* Syntax highlighted code blocks */
.code-block {
  background: #000;
  border-radius: 2px;
  margin: 1rem 0;
  overflow: hidden;
  display: flex;
  position: relative;
}

.code-block[data-lang]::before {
  content: attr(data-lang);
  position: absolute;
  top: 0;
  right: 0;
  font-size: 0.65rem;
  color: #555;
  padding: 0.35rem 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-family: var(--font-sans);
}

.code-block .line-numbers {
  flex-shrink: 0;
  padding: 1rem 0.75rem;
  margin: 0;
  text-align: right;
  color: #555;
  background: #000;
  border-right: 1px solid #333;
  user-select: none;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.4;
}

.code-block .code-content {
  flex-grow: 1;
  padding: 1rem;
  margin: 0;
  overflow-x: auto;
  background: transparent;
  color: #fff;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.4;
}

.code-block .code-content code {
  background: transparent;
  padding: 0;
  font-size: inherit;
  white-space: pre;
}

/* Syntax highlighting */
.keyword { color: #f5a9b8; }
.variable { color: #f5f5a9; }
.string { color: #a8d8a8; }
.comment { color: #8899aa; font-style: italic; }
.constant { color: #f5d0a9; }
.entity { color: #c9b8f5; }
.support { color: #a9c8f5; }
.punctuation { color: #888; }

/* Layout */
.container {
  max-width: 44rem;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* Page structure */
header {
  padding: 3rem 0 2rem;
  border-bottom: 1px solid #000;
}

.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 1.5rem;
  letter-spacing: 0.1em;
  text-decoration: none;
}

nav a {
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-variant-caps: normal;
  text-decoration: none;
  margin-left: 1.5rem;
}

nav a:hover {
  text-decoration: underline;
}

/* Nav dropdown (CSS-only, matches server pattern) */
.nav-dropdown {
  position: relative;
  display: inline-block;
  margin-left: 1.5rem;
}

.nav-dropdown-toggle {
  font-family: var(--font-sans);
  font-size: 0.9rem;
  cursor: pointer;
}

.nav-dropdown-toggle::after {
  content: ' \25BE';
  font-size: 0.7em;
}

.nav-dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 0.5rem;
  min-width: 200px;
  background: #fff;
  border: 1px solid #000;
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.1s ease, visibility 0s linear 0.1s;
}

/* Invisible expanded hit area to prevent flickering */
.nav-dropdown-menu::before {
  content: '';
  position: absolute;
  top: -1rem;
  left: -1rem;
  right: -1rem;
  bottom: -1rem;
  z-index: -1;
}

.nav-dropdown:hover .nav-dropdown-menu {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity 0.1s ease, visibility 0s linear 0s;
}

.dropdown-item {
  display: block;
  padding: 0.4rem 0.75rem;
  color: #000;
  text-decoration: none;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-variant: normal;
  white-space: nowrap;
}

.dropdown-item:hover {
  background: #f5f5f5;
  text-decoration: none;
}

main {
  padding: 4rem 0;
}

section {
  margin-bottom: 2rem;
}

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

section + section h2 {
  margin-top: 0.5rem;
}

section h2 {
  margin-bottom: 1.5rem;
}

section h3 {
  margin-top: 1.25rem;
  margin-bottom: 0.75rem;
}

footer {
  padding: 2rem 0;
  border-top: 1px solid #000;
  font-size: 0.875rem;
}

footer p {
  text-align: center;
}

.footer-links {
  margin-top: 0.5rem;
  letter-spacing: 0.05em;
}

.footer-links a {
  font-variant: small-caps;
  margin: 0 0.4em;
}

/* Legal pages */
.legal h2, .legal h3 {
  font-family: var(--font-serif);
}

.legal h2 {
  font-size: 1.5rem;
  margin-bottom: 1.5rem;
}

.legal h3 {
  font-size: 1.1rem;
  margin-top: 2rem;
  margin-bottom: 1rem;
}

.legal p {
  margin-bottom: 1rem;
  text-indent: 0;
}

.legal p + p {
  text-indent: 0;
}

.legal ul, .legal ol {
  margin-bottom: 1rem;
}

.legal .effective-date {
  font-style: italic;
  margin-bottom: 1.5rem;
}

/* Hero */
.hero {
  margin-bottom: 2.5rem;
}

.hero h1 {
  margin-bottom: 1.5rem;
}

.hero p {
  font-size: 1.25rem;
  line-height: 1.5;
}

/* Features */
.features {
  display: grid;
  gap: 1.75rem;
}

.feature h3 {
  margin-bottom: 0.5rem;
}

.feature p {
  color: #000;
}

/* Typography preview - breaks out of container, centered */
.preview-wrapper {
  width: 100vw;
  position: relative;
  left: 50%;
  right: 50%;
  margin-left: -50vw;
  margin-right: -50vw;
  display: flex;
  justify-content: center;
  padding: 0 1.5rem;
  margin-top: 1.25rem;
}

.preview {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  width: 100%;
  max-width: 56rem;
}

@media (max-width: 1100px) {
  .preview {
    grid-template-columns: 1fr;
    max-width: 32rem;
  }
}

.preview-box {
  border: 1px solid #000;
  padding: 1.5rem;
}

.preview-box h4 {
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #000;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
}

.preview-box h5 {
  font-size: 1.1rem;
  margin-bottom: 0.75rem;
}

.preview-box p {
  margin-bottom: 0.75rem;
  font-size: 0.95rem;
  line-height: 1.5;
}

.preview-box p:last-child {
  margin-bottom: 0;
}

.preview-box ul {
  margin: 0 0 0.75rem 1.25rem;
  font-size: 0.95rem;
}

.preview-box li {
  margin-bottom: 0.25rem;
}

.preview-box pre {
  background: #000;
  color: #fff;
  padding: 1rem;
  margin-bottom: 0.75rem;
  overflow-x: auto;
  font-size: 0.8rem;
  line-height: 1.4;
}

.preview-box pre code {
  background: none;
  padding: 0;
  color: #fff;
  font-size: inherit;
}

.preview-box blockquote {
  border-left: 2px solid #000;
  padding-left: 1rem;
  margin: 1rem 0;
  font-style: italic;
}

.preview-box blockquote p {
  margin-bottom: 0;
}

.preview-serif {
  font-family: var(--font-serif);
}

.preview-serif h5 {
  font-family: var(--font-serif);
  font-weight: 700;
}

.preview-sans {
  font-family: var(--font-sans);
}

.preview-sans h5 {
  font-family: var(--font-sans);
  font-weight: 600;
}

/* Philosophy section */
.philosophy {
  border-left: 3px solid #000;
  padding-left: 1.5rem;
}

/* Pricing */
.pricing-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  margin-top: 1rem;
}

@media (max-width: 700px) {
  .pricing-grid {
    grid-template-columns: 1fr;
  }
}

.pricing-card {
  border: 1px solid #000;
  padding: 2rem;
}

.pricing-card h2 {
  font-size: 1.25rem;
  margin-bottom: 0.25rem;
}

.pricing-for {
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

.pricing-amount {
  font-family: var(--font-sans);
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  line-height: 1;
  text-indent: 0;
}

.pricing-period {
  font-size: 1rem;
  font-weight: 400;
}

.pricing-features {
  list-style: none;
  margin: 0;
  padding: 0;
}

.pricing-features li {
  padding: 0.5rem 0;
  border-top: 1px solid #000;
}

.pricing-features li:last-child {
  padding-bottom: 0;
}

.pricing-note {
  margin-top: 2rem;
  font-size: 0.95rem;
}

#eaddr, #eaddr2 {
  hyphens: none;
  white-space: nowrap;
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
}

th, td {
  text-align: left;
  padding: 0.75rem;
  border: 1px solid #000;
}

th {
  font-family: var(--font-sans);
  font-weight: 600;
}

/* Lists */
ul {
  margin: 1rem 0 1rem 1.5rem;
}

ol {
  margin: 1.25rem 0;
  padding: 0;
  list-style: none;
  counter-reset: ol-counter;
}

li {
  margin-bottom: 0.5rem;
}

ul li {
  margin-bottom: 0.5rem;
}

ol > li {
  counter-increment: ol-counter;
  position: relative;
  padding-left: 2.5rem;
  margin-bottom: 1rem;
}

ol > li::before {
  content: counter(ol-counter);
  position: absolute;
  left: 0;
  top: 0.1em;
  width: 1.5rem;
  height: 1.5rem;
  background: transparent;
  color: #000;
  border: 1px solid #000;
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

ol > li > pre {
  margin-top: 0.5rem;
  margin-bottom: 0;
}

/* Table of Contents (gwern-inspired) */
.toc {
  border: 1px solid #000;
  padding: 1.25rem 1.5rem;
  margin-bottom: 2.5rem;
  background: #fafafa;
}

.toc h2 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #000;
}

.toc ul {
  list-style: none;
  margin: 0;
  padding: 0;
  column-count: 2;
  column-gap: 2rem;
}

@media (max-width: 600px) {
  .toc ul {
    column-count: 1;
  }
}

.toc li {
  margin-bottom: 0.35rem;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  line-height: 1.35;
  break-inside: avoid;
}

.toc li::before {
  content: counter(toc-item) ".";
  counter-increment: toc-item;
  display: inline-block;
  width: 1.5em;
  margin-right: 0.5em;
  font-weight: 600;
  color: #000;
}

.toc ul {
  counter-reset: toc-item;
}

.toc a {
  text-decoration: none;
}

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

/* Utility classes */
.sans {
  font-family: var(--font-sans);
}

.serif {
  font-family: var(--font-serif);
}

.small {
  font-size: 0.875rem;
}

.caps {
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.8rem;
}

.sc {
  font-variant: small-caps;
  font-size: 1.05em;
}

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

/* Dark mode */
html[data-theme="dark"] {
  filter: invert(1) hue-rotate(180deg);
}

html[data-theme="dark"] img,
html[data-theme="dark"] video,
html[data-theme="dark"] iframe,
html[data-theme="dark"] pre,
html[data-theme="dark"] code,
html[data-theme="dark"] .code-block {
  filter: invert(1) hue-rotate(180deg);
}

html[data-theme="dark"] pre code,
html[data-theme="dark"] .code-block pre,
html[data-theme="dark"] .code-block code {
  filter: none;
}

/* Theme toggle button */
.theme-toggle {
  position: fixed;
  top: 1rem;
  right: 1rem;
  background: transparent;
  border: none;
  font-family: var(--font-sans);
  font-size: 0.75rem;
  cursor: pointer;
  z-index: 1000;
  color: inherit;
  text-decoration: underline;
}

@media (max-width: 768px) {
  .theme-toggle {
    position: static;
  }
}
