@font-face {
  font-family: 'Tengwar Parmaite';
  src: url('/fonts/TengwarParmaite-8M2g.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Cormorant Garamond';
  src: url('/fonts/CormorantGaramond-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Cormorant Garamond';
  src: url('/fonts/CormorantGaramond-Italic.ttf') format('truetype');
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: 'Cormorant Garamond';
  src: url('/fonts/CormorantGaramond-SemiBold.ttf') format('truetype');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Cormorant Garamond';
  src: url('/fonts/CormorantGaramond-Bold.ttf') format('truetype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Lora';
  src: url('/fonts/Lora-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Lora';
  src: url('/fonts/Lora-Italic.ttf') format('truetype');
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: 'Lora';
  src: url('/fonts/Lora-Medium.ttf') format('truetype');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Lora';
  src: url('/fonts/Lora-SemiBold.ttf') format('truetype');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'JetBrains Mono';
  src: url('/fonts/JetBrainsMono-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --font-heading: 'Cormorant Garamond', Georgia, serif;
  --font-body: 'Lora', Georgia, serif;
  --font-mono: 'JetBrains Mono', monospace;
}

[data-theme="light"] {
  --bg: #F0EDE4;
  --surface: #F9F7F2;
  --border: #D4CEBC;
  --border-subtle: #E2DDD0;
  --text-primary: #28301E;
  --text-secondary: #555E48;
  --text-tertiary: #77806A;
  --accent: #8B5E34;
  --accent-green: #3D6B45;
  --accent-gold: #A68529;
  --accent-rust: #945A3A;
  --link: #3D6B45;
  --link-hover: #8B5E34;
  --tag-dart: #3D6B45;
  --tag-scala: #945A3A;
  --card-shadow: rgba(40,48,30,0.04);
  --card-shadow-hover: rgba(40,48,30,0.08);
}

[data-theme="dark"] {
  --bg: #1A1D14;
  --surface: #242820;
  --border: #3A3E2E;
  --border-subtle: #2E3226;
  --text-primary: #EAE6D8;
  --text-secondary: #B8B3A0;
  --text-tertiary: #8E8A78;
  --accent: #C8884E;
  --accent-green: #6E9E5C;
  --accent-gold: #C4A240;
  --accent-rust: #B87250;
  --link: #6E9E5C;
  --link-hover: #C8884E;
  --tag-dart: #6E9E5C;
  --tag-scala: #B87250;
  --card-shadow: rgba(10,12,8,0.25);
  --card-shadow-hover: rgba(10,12,8,0.4);
}

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

html {
  font-size: clamp(16px, 1.2vw, 19px);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  color: var(--text-secondary);
  background: var(--bg);
  line-height: 1.6;
  overflow-x: hidden;
}

h1, h2, h3 {
  font-family: var(--font-heading);
  color: var(--text-primary);
  line-height: 1.2;
}

h1 { font-size: clamp(2.4rem, 5vw, 4rem); font-weight: 700; letter-spacing: -0.02em; }
h2 { font-size: clamp(1.5rem, 2.5vw, 1.8rem); font-weight: 600; }
h3 { font-size: clamp(1.2rem, 2vw, 1.4rem); font-weight: 600; }

a {
  color: inherit;
  text-decoration: none;
}

/* Accessibility */
.skip-link {
  position: absolute;
  top: -100%;
  left: 16px;
  z-index: 1000;
  padding: 8px 16px;
  background: var(--surface);
  border: 2px solid var(--accent-green);
  border-radius: 4px;
  font-size: 0.9rem;
  color: var(--accent-green);
}

.skip-link:focus {
  top: 16px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

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

a:focus:not(:focus-visible),
button:focus:not(:focus-visible) {
  outline: none;
}

/* Site layout */
.site {
  max-width: 1400px;
  margin: 0 auto;
  padding: clamp(24px, 4vw, 64px);
  padding-top: clamp(24px, 3vw, 48px);
}

/* Navigation */
.nav {
  display: flex;
  align-items: center;
  gap: clamp(16px, 3vw, 32px);
  margin-bottom: clamp(48px, 8vw, 96px);
}

.nav-logo {
  display: flex;
  align-items: center;
  color: var(--text-primary);
  transition: color 200ms;
}

.logo-tengwar {
  font-family: 'Tengwar Parmaite', serif;
  font-size: clamp(2rem, 4vw, 2.8rem);
  line-height: 1;
}

.nav-title {
  font-family: var(--font-heading);
  font-size: clamp(1rem, 1.5vw, 1.2rem);
  font-weight: 600;
  margin-left: 8px;
}

.nav-logo:hover {
  color: var(--accent-green);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: clamp(16px, 3vw, 32px);
  margin-left: auto;
}

.nav-link {
  font-size: 0.9rem;
  color: var(--text-tertiary);
  transition: color 200ms;
  position: relative;
  white-space: nowrap;
}

.nav-link:hover {
  color: var(--link-hover);
}

.nav-link.active {
  color: var(--text-primary);
  font-weight: 500;
}

.nav-link.active::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 50%;
  transform: translateX(-50%);
  width: 20px;
  height: 1.5px;
  background: var(--accent-green);
  border-radius: 1px;
}

/* Hero */
.hero {
  margin-bottom: clamp(48px, 6vw, 80px);
}

.hero h1 {
  margin-bottom: clamp(16px, 2vw, 24px);
}

.hero-description {
  font-size: clamp(1rem, 1.5vw, 1.2rem);
  max-width: 42em;
  line-height: 1.8;
}

/* Principles */
.principles h2 {
  margin-bottom: clamp(20px, 3vw, 28px);
}

.principles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
  gap: clamp(16px, 2vw, 24px);
}

.principle {
  padding: clamp(16px, 2vw, 24px);
  border-left: 2px solid var(--accent-green);
}

.principle h3 {
  margin-bottom: 8px;
  font-size: clamp(1.1rem, 1.5vw, 1.25rem);
}

.principle p {
  font-size: 0.95rem;
  line-height: 1.7;
}

/* Divider */
.divider {
  border: none;
  height: 1px;
  background: linear-gradient(to right, var(--border), var(--border-subtle), transparent);
  margin: clamp(48px, 6vw, 80px) 0;
}

/* Section headers */
.section-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.section-subtitle {
  color: var(--text-secondary);
  margin-bottom: clamp(20px, 3vw, 28px);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.dot-large {
  width: 10px;
  height: 10px;
}

/* Project grid */
.project-grid, .package-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr));
  gap: clamp(16px, 2vw, 24px);
}

/* Cards */
.card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  padding: clamp(20px, 3vw, 28px);
  transition: transform 250ms ease-out, box-shadow 250ms ease-out, border-color 250ms ease-out;
  box-shadow: 0 2px 8px var(--card-shadow);
}

.card:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 32px var(--card-shadow-hover);
  border-color: var(--border);
}

.card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
}

.card-title {
  font-size: clamp(1.2rem, 2vw, 1.4rem);
  flex: 1;
}

.card-title-link {
  flex: 1;
  transition: color 200ms;
}

.card-title-link:hover .card-title {
  color: var(--accent-green);
}

.version {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-tertiary);
}

.version-large {
  font-size: 0.8rem;
}

.tagline {
  font-family: var(--font-heading);
  font-style: italic;
  color: var(--accent-green);
  font-size: 1rem;
  margin-bottom: 16px;
  padding-left: 20px;
}

.tagline-large {
  font-size: 1.1rem;
  padding-left: 0;
  margin-bottom: 24px;
  color: var(--accent-green);
}

.description {
  margin-bottom: 20px;
}

.description-wide {
  max-width: 42em;
}

.features {
  list-style: none;
  margin-bottom: 18px;
}

.features li {
  position: relative;
  padding-left: 16px;
  margin-bottom: 6px;
}

.features li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.75em;
  width: 5px;
  height: 1.5px;
  background: var(--text-tertiary);
}

.card-footer {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  margin-top: auto;
}

.package-count {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-tertiary);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  transition: color 200ms;
}

.package-count:hover {
  color: var(--link-hover);
}

.package-count svg {
  vertical-align: middle;
}

/* Section title links */
.section-title-link {
  transition: color 200ms;
}

.section-title-link:hover h2 {
  color: var(--accent-green);
}

/* Package cards */
.package-name {
  font-size: clamp(1.2rem, 2vw, 1.4rem);
  font-weight: 600;
  margin-bottom: 4px;
}

/* Links */
.link-row {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

.link-chip {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  display: inline-flex;
  align-items: center;
  gap: 3px;
  transition: color 200ms;
}

.link-chip:hover {
  color: var(--link-hover);
}

.link-chip svg {
  vertical-align: middle;
}

/* Project page */
.project-hero {
  margin-bottom: clamp(40px, 5vw, 64px);
}

.project-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.packages-section h2 {
  margin-bottom: 8px;
}

.packages-section .section-subtitle {
  margin-bottom: 28px;
}

/* Theme toggle */
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-tertiary);
  transition: color 200ms, border-color 200ms, background 200ms;
  padding: 0;
  margin-left: 8px;
  flex-shrink: 0;
}

.theme-toggle:hover {
  color: var(--accent-green);
  border-color: var(--accent-green);
  background: var(--surface);
}

.theme-toggle .icon-sun,
.theme-toggle .icon-moon {
  display: none;
}

[data-theme="light"] .theme-toggle .icon-moon { display: block; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }

/* Mobile nav */
.nav-checkbox {
  display: none;
}

.nav-hamburger {
  display: none;
}

@media (max-width: 640px) {
  .nav {
    flex-wrap: wrap;
  }

  .nav-hamburger {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 32px;
    height: 32px;
    margin-left: auto;
    cursor: pointer;
    padding: 6px 4px;
  }

  .hamburger-line {
    display: block;
    width: 100%;
    height: 1.5px;
    background: var(--text-tertiary);
    border-radius: 1px;
    transition: background 200ms;
  }

  .nav-hamburger:hover .hamburger-line {
    background: var(--accent-green);
  }

  .nav-links {
    display: none;
    flex-direction: column;
    align-items: flex-end;
    width: 100%;
    gap: 0;
    margin-left: 0;
    padding-top: 16px;
  }

  .nav-checkbox:checked ~ .nav-links {
    display: flex;
  }

  .nav-link {
    padding: 10px 0;
  }

  .nav-link.active::after {
    display: none;
  }

  .theme-toggle {
    margin-left: 0;
    margin-top: 8px;
    align-self: flex-end;
  }
}

/* Theme transition */
body, .card, .nav-logo, .nav-link, .link-chip, .tagline, .site-footer {
  transition: color 300ms ease, background-color 300ms ease,
              border-color 300ms ease, box-shadow 300ms ease;
}

/* Footer */
.site-footer {
  margin-top: clamp(64px, 10vw, 120px);
  color: var(--text-tertiary);
  font-size: 0.8rem;
}

.site-footer .divider {
  margin-bottom: clamp(24px, 4vw, 40px);
}

.footer-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  margin-bottom: clamp(20px, 3vw, 32px);
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-primary);
  transition: color 200ms;
}

.footer-brand:hover {
  color: var(--accent-green);
}

.footer-logo {
  font-size: 1.6rem;
}

.footer-title {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 600;
}

.footer-nav {
  display: flex;
  gap: clamp(16px, 3vw, 24px);
}

.footer-link {
  color: var(--text-tertiary);
  font-size: 0.8rem;
  transition: color 200ms;
}

.footer-link:hover {
  color: var(--link-hover);
}

.footer-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
}

/* Code blocks */
.code-block {
  background: var(--bg);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: clamp(16px, 2vw, 20px);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.7;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.code-block code {
  font-family: inherit;
  font-size: inherit;
}

.code-block-card {
  font-size: 0.75rem;
  margin-top: 4px;
}

.example-section {
  margin-bottom: clamp(40px, 5vw, 64px);
  max-width: 42em;
}

.example-caption {
  font-size: 0.9rem;
  color: var(--text-tertiary);
  font-style: italic;
}

/* 404 */
.not-found {
  text-align: center;
  padding: clamp(80px, 15vw, 200px) 0;
}

.not-found h1 {
  font-size: clamp(4rem, 10vw, 8rem);
  color: var(--text-tertiary);
  margin-bottom: 16px;
}

.not-found p {
  font-size: 1.1rem;
}

.not-found-quote {
  font-family: var(--font-heading);
  font-style: italic;
  font-size: clamp(1.2rem, 2vw, 1.5rem);
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.not-found a {
  color: var(--link);
  transition: color 200ms;
}

.not-found a:hover {
  color: var(--link-hover);
}
