/* === Custom Properties === */
:root {
  --bg: #ffffff;
  --fg: #000000;
  --muted: #888888;
  --max-width: 900px;
  --px: clamp(1.5rem, 5vw, 3rem);
}

html[data-theme="dark"] {
  --bg: #000000;
  --fg: #ffffff;
  --muted: #999999;
}

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

/* === Base === */
html {
  font-size: 18px;
}

body {
  font-family: 'Crimson Pro', Georgia, serif;
  font-weight: 400;
  background-color: var(--bg);
  color: var(--muted);
  line-height: 1.6;
  transition: background-color 0.3s ease, color 0.3s ease;
  -webkit-font-smoothing: antialiased;
}

/* === Layout === */
.container {
  max-width: var(--max-width);
  margin-inline: auto;
  padding-inline: var(--px);
}

/* === Navigation === */
nav {
  display: flex;
  align-items: center;
  gap: 2rem;
  padding-block: 1.75rem;
}

.nav-brand {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  color: var(--fg);
  font-size: 0.875rem;
  letter-spacing: 0.015em;
  flex-shrink: 0;
  transition: opacity 0.2s ease;
}

.nav-brand:hover {
  opacity: 0.6;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 2rem;
  margin-left: auto;
}

.nav-link {
  text-decoration: none;
  color: var(--fg);
  font-size: 0.875rem;
  letter-spacing: 0.015em;
  position: relative;
  transition: opacity 0.2s ease;
}

.nav-link::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  height: 1px;
  width: 0;
  background-color: var(--fg);
  transition: width 0.25s ease;
}

.nav-link:hover {
  opacity: 0.55;
}

.nav-link:hover::after {
  width: 100%;
}

/* === Dropdown === */
.nav-dropdown-wrapper {
  position: relative;
}

.nav-dropdown-trigger {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  user-select: none;
}

.nav-chevron {
  opacity: 0.5;
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.nav-dropdown {
  position: absolute;
  top: 100%;
  left: -0.75rem;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  padding-top: 0.75rem;
  padding-bottom: 0.5rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  white-space: nowrap;
  z-index: 100;
}

.nav-dropdown-link {
  display: block;
  padding: 0.3rem 0.75rem;
  text-decoration: none;
  color: var(--fg);
  font-size: 0.875rem;
  letter-spacing: 0.015em;
  transition: opacity 0.2s ease;
}

.nav-dropdown-link:hover {
  opacity: 0.55;
}

.nav-dropdown-wrapper:hover .nav-dropdown,
.nav-dropdown-wrapper:focus-within .nav-dropdown {
  opacity: 1;
  pointer-events: auto;
}

.nav-dropdown-wrapper:hover .nav-chevron,
.nav-dropdown-wrapper:focus-within .nav-chevron {
  transform: rotate(180deg);
}

/* === Theme Toggle === */
.theme-toggle {
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--fg);
  opacity: 0.6;
  transition: opacity 0.2s ease;
  padding: 0;
}

.theme-toggle:hover {
  opacity: 1;
}

/* Default: show moon (dark mode toggle), hide sun */
.icon-sun { display: none; }
.icon-moon { display: flex; }

/* Dark mode: show sun (light mode toggle), hide moon */
html[data-theme="dark"] .icon-sun { display: flex; }
html[data-theme="dark"] .icon-moon { display: none; }

/* No-JS fallback: respect OS preference */
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) .icon-sun { display: flex; }
  html:not([data-theme="light"]) .icon-moon { display: none; }
}

/* === Main Content === */
main {
  padding-top: 8rem;
  padding-bottom: 6rem;
}

/* === Home === */
.home-heading {
  font-size: clamp(2.75rem, 6vw, 4.25rem);
  font-weight: 200;
  line-height: 1.12;
  letter-spacing: -0.025em;
  color: var(--fg);
  margin-bottom: 2.75rem;
}

.home-body p {
  font-size: 1.15rem;
  line-height: 1.7;
  margin-bottom: 1rem;
  max-width: 620px;
}

.home-body p:last-child {
  margin-bottom: 0;
}

/* === Article / Single === */
.article-header {
  margin-bottom: 4rem;
}

.article-heading {
  font-size: clamp(2.25rem, 5vw, 3.75rem);
  font-weight: 200;
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: var(--fg);
}

.article-meta {
  margin-top: 1rem;
  font-size: 0.875rem;
  letter-spacing: 0.01em;
  color: var(--muted);
}

.article-body {
  font-size: 1.1rem;
  line-height: 1.7;
}

.article-body h2 {
  font-size: 1.7rem;
  font-weight: 300;
  color: var(--fg);
  line-height: 1.25;
  letter-spacing: -0.015em;
  margin-top: 3.5rem;
  margin-bottom: 1rem;
}

.article-body h3 {
  font-size: 1.3rem;
  font-weight: 400;
  color: var(--fg);
  line-height: 1.3;
  margin-top: 2.5rem;
  margin-bottom: 0.9rem;
}

.article-body p {
  margin-bottom: 0.9rem;
}

.article-body p:last-child {
  margin-bottom: 0;
}

.article-body a,
.home-body a {
  color: var(--fg);
  text-decoration: none;
  position: relative;
  transition: opacity 0.2s ease;
}

.article-body a::after,
.home-body a::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  height: 1px;
  width: 0;
  background-color: var(--fg);
  transition: width 0.25s ease;
}

.article-body a:hover,
.home-body a:hover {
  opacity: 0.55;
}

.article-body a:hover::after,
.home-body a:hover::after {
  width: 100%;
}

.article-body ul,
.article-body ol {
  padding-left: 1.5rem;
  margin-bottom: 0.9rem;
}

.article-body li {
  margin-bottom: 0.5rem;
}

.article-body hr {
  border: none;
  border-top: 1px solid currentColor;
  opacity: 0.12;
  margin: 3rem 0;
}

/* === List Page === */
.list-heading {
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 200;
  color: var(--fg);
  letter-spacing: -0.015em;
  margin-bottom: 3rem;
}

.list-items {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.list-item a {
  text-decoration: none;
  color: var(--fg);
  font-size: 1.15rem;
  transition: opacity 0.2s ease;
}

.list-item a:hover {
  opacity: 0.55;
}

/* === Responsive === */
@media (max-width: 600px) {
  main {
    padding-top: 4rem;
  }

  nav {
    flex-wrap: wrap;
    gap: 0;
    padding-block: 1.25rem;
  }

  .nav-brand {
    flex: 1;
  }

  .theme-toggle {
    order: 2;
  }

  .nav-links {
    order: 3;
    width: 100%;
    margin-left: 0;
    gap: 1.25rem;
    padding-top: 0.75rem;
  }
}
