:root {
  --type-display: clamp(2.6rem, 5vw, 4.6rem);
  --type-section: clamp(1.85rem, 3vw, 3rem);
  --type-section-compact: clamp(1.75rem, 2.6vw, 2.7rem);
  --type-project: clamp(1.35rem, 1.8vw, 1.85rem);
  --type-case-display: clamp(2.45rem, 4.4vw, 4.1rem);
  --type-case-section: clamp(1.7rem, 2.35vw, 2.5rem);
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f0e8;
  --surface: #e8e3d8;
  --surface-strong: #ddd6c8;
  --text: #171714;
  --muted: #6b675f;
  --line: #cbc4b6;
  --accent: #9c4937;
  --accent-soft: #ead7d0;
  --header-bg: rgba(243, 240, 232, 0.94);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #11110f;
  --surface: #191916;
  --surface-strong: #24231f;
  --text: #f1eee6;
  --muted: #aaa49a;
  --line: #323029;
  --accent: #e08a74;
  --accent-soft: #3b2721;
  --header-bg: rgba(17, 17, 15, 0.94);
}

/* Shared type scale. Keep future pages on these sizes instead of inventing page-local display sizes. */
h1 {
  font-size: var(--type-display);
}

h2 {
  font-size: var(--type-section);
}

h3 {
  font-size: var(--type-project);
}

.two-column > header h2,
.about-title h2 {
  font-size: var(--type-section-compact);
}

.editorial-list h3 {
  font-size: 1.45rem;
}

.project-mark span {
  font-size: 3.8rem;
}

.project-featured .project-mark span {
  font-size: 4.4rem;
}

/* Case-study.css is loaded after this file, so these intentionally use a little more specificity. */
html body .case-title {
  font-size: var(--type-case-display);
}

html body .case-copy h2,
html body .case-next h2 {
  font-size: var(--type-case-section);
}

html body .case-deck {
  font-size: clamp(1.05rem, 1.6vw, 1.3rem);
}

html body .case-copy .case-lead {
  font-size: clamp(1.1rem, 1.6vw, 1.35rem);
}

html body .decision h3 {
  font-size: 1.35rem;
}

html body .tradeoff h3 {
  font-size: 1.15rem;
}

::selection {
  background: var(--accent-soft);
  color: var(--text);
}

/* Keyboard focus is intentionally visible site-wide, not only on the theme button. */
a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

.site-header {
  background: var(--header-bg);
}

.header-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 24px;
  min-width: 0;
}

.header-tools {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-inline-start: 20px;
  border-inline-start: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.82rem;
  white-space: nowrap;
}

.site-header nav a[aria-current="page"] {
  color: var(--text);
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 2px;
  text-underline-offset: 6px;
}

.social-link {
  transition: color 160ms ease;
}

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

.theme-toggle {
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: border-color 160ms ease, background-color 160ms ease, color 160ms ease;
}

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

.theme-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

.theme-icon {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.theme-icon-moon {
  fill: currentColor;
  stroke: none;
}

:root[data-theme="light"] .theme-icon-sun,
:root[data-theme="dark"] .theme-icon-moon {
  display: none;
}

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

@media (max-width: 980px) {
  .header-right {
    gap: 16px;
  }

  .header-tools {
    gap: 11px;
    padding-inline-start: 14px;
  }
}

@media (max-width: 760px) {
  :root {
    --type-display: clamp(2.35rem, 10vw, 3.25rem);
    --type-section: clamp(1.7rem, 7vw, 2.35rem);
    --type-section-compact: clamp(1.65rem, 6.5vw, 2.2rem);
    --type-project: clamp(1.25rem, 5.5vw, 1.6rem);
    --type-case-display: clamp(2.2rem, 9vw, 3rem);
    --type-case-section: clamp(1.55rem, 6.5vw, 2.1rem);
  }

  .header-inner {
    flex-wrap: wrap;
  }

  .header-right {
    width: 100%;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 14px 20px;
  }

  .header-tools {
    padding-inline-start: 0;
    border-inline-start: 0;
  }
}

@media (max-width: 520px) {
  .header-right {
    align-items: flex-start;
    flex-direction: column;
  }

  .header-tools {
    width: 100%;
    justify-content: flex-start;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
