/* ==========================================================================
   Design tokens
   Light is the default theme. Dark is applied by setting data-theme="dark"
   on <html> (see the inline script in each page's <head> and site.js).
   ========================================================================== */

:root {
  color-scheme: light;

  --bg: #f8f4e6;
  --surface: #f1ead5;
  --surface-hover: #ece4ca;
  --text: #28282e;
  --text-strong: #16161a;
  --muted: #5a5a61;
  --primary: #3254a8;
  --primary-hover: #263f80;
  --on-primary: #ffffff;
  --input-border: #8c8169;
  --border: #e5dcbd;
  --error: #b42318;
  --success: #18794e;

  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", "Segoe UI Mono", Menlo, Consolas, monospace;

  --sidebar: 16.25rem; /* 260px */
  --content: 47.5rem; /* 760px */
  --gutter: 1rem;
  --radius: 8px;
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #141a26;
  --surface: #1c2433;
  --surface-hover: #242e42;
  --text: #e7eaf0;
  --text-strong: #ffffff;
  --muted: #a6aebd;
  --primary: #8ea6ee;
  --primary-hover: #b4c4f5;
  --on-primary: #141a26;
  --input-border: #6b7894;
  --border: #2e3850;
  --error: #f97066;
  --success: #4ade80;
}

@media (min-width: 40rem) {
  :root {
    --gutter: 2rem;
  }
}

/* ==========================================================================
   Base
   ========================================================================== */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 1.0625rem/1.65 var(--font-sans);
}

h1,
h2,
h3 {
  color: var(--text-strong);
  line-height: 1.2;
  letter-spacing: -0.015em;
  margin: 0 0 0.75rem;
}

h1 {
  font-size: clamp(2rem, 1.5rem + 2.5vw, 2.75rem);
  letter-spacing: -0.025em;
  margin-bottom: 1rem;
}

h2 {
  font-size: 1.25rem;
}

p,
ul {
  margin: 0 0 1rem;
}

ul {
  padding-left: 1.25rem;
}

li + li {
  margin-top: 0.5rem;
}

img {
  max-width: 100%;
  height: auto;
}

a {
  color: var(--primary);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  transition: color 150ms ease, background-color 150ms ease;
}

a:hover {
  color: var(--primary-hover);
  text-decoration-thickness: 2px;
}

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

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
  }
}

/* ==========================================================================
   Utilities
   ========================================================================== */

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

.meta {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  color: var(--muted);
}

.nowrap {
  white-space: nowrap;
}

/* ==========================================================================
   Skip link
   ========================================================================== */

.skip-link {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  z-index: 10;
  padding: 0.5rem 1rem;
  background: var(--primary);
  color: var(--on-primary);
  border-radius: var(--radius);
  transform: translateY(-200%);
}

.skip-link:focus {
  transform: none;
}

.skip-link:hover {
  color: var(--on-primary);
}

/* ==========================================================================
   Sidebar
   On small screens the sidebar header sits above the content and the
   sidebar footer below it. On wide screens both are fixed to the left
   edge: navigation at the top, profile links at the bottom.
   ========================================================================== */

.sidebar-header,
.sidebar-footer {
  padding: 1rem var(--gutter);
}

.sidebar-header {
  border-bottom: 1px solid var(--border);
}

.sidebar-footer {
  margin-top: 3rem;
  border-top: 1px solid var(--border);
}

.sidebar-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.site-name {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text-strong);
  text-decoration: none;
}

.site-name:hover {
  color: var(--text-strong);
}

.site-name img {
  width: 1.5rem;
  height: 1.5rem;
}

.sidebar-label {
  margin: 1.5rem 0 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.sidebar-links {
  margin: 0 -0.75rem;
  padding: 0;
  list-style: none;
}

.sidebar-links li + li {
  margin-top: 0.125rem;
}

.sidebar-links a {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  min-height: 2.5rem;
  padding: 0.375rem 0.75rem;
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.9375rem;
  font-weight: 500;
  text-decoration: none;
}

.sidebar-links a:hover {
  background: var(--surface-hover);
  color: var(--text-strong);
}

.sidebar-links a[aria-current="page"] {
  background: var(--surface-hover);
  color: var(--primary);
  font-weight: 600;
}

.sidebar-links svg {
  width: 1.125rem;
  height: 1.125rem;
  flex-shrink: 0;
  color: var(--muted);
}

.sidebar-links a:hover svg,
.sidebar-links a[aria-current="page"] svg {
  color: currentColor;
}

/* Small screens: menu and profile links wrap in rows. */
.site-nav .sidebar-links,
.sidebar-footer .sidebar-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.125rem 0.25rem;
}

.site-nav .sidebar-links li + li,
.sidebar-footer .sidebar-links li + li {
  margin-top: 0;
}

.sidebar-footer .sidebar-label {
  margin-top: 0;
}

.theme-toggle {
  display: inline-grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--input-border);
  border-radius: var(--radius);
  cursor: pointer;
}

/* Hidden until site.js enables it, but keeps its space so nothing shifts. */
.theme-toggle[hidden] {
  display: inline-grid;
  visibility: hidden;
}

.theme-toggle:hover {
  background: var(--surface-hover);
  color: var(--text-strong);
}

.theme-toggle svg {
  width: 1.125rem;
  height: 1.125rem;
}

/* Show the moon in light mode (switch to dark) and the sun in dark mode. */
.icon-sun,
[data-theme="dark"] .icon-moon {
  display: none;
}

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

/* Wide screens: fixed sidebar. The height condition keeps the top and
   bottom parts from overlapping in short windows (or when zoomed in). */
@media (min-width: 64rem) and (min-height: 36rem) {
  body::before {
    content: "";
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar);
    border-right: 1px solid var(--border);
    pointer-events: none;
  }

  .sidebar-header,
  .sidebar-footer {
    position: fixed;
    left: 0;
    width: var(--sidebar);
    margin: 0;
    padding: 1.5rem;
    border: 0;
  }

  .sidebar-header {
    top: 0;
  }

  .sidebar-footer {
    bottom: 0;
  }

  .site-nav .sidebar-links,
  .sidebar-footer .sidebar-links {
    display: block;
  }

  .site-nav .sidebar-links li + li,
  .sidebar-footer .sidebar-links li + li {
    margin-top: 0.125rem;
  }

  main {
    margin-left: var(--sidebar);
  }

}

/* ==========================================================================
   Main content
   ========================================================================== */

.content {
  max-width: calc(var(--content) + 7rem);
  padding: 2.5rem var(--gutter) 1rem;
}

@media (min-width: 64rem) and (min-height: 36rem) {
  .content {
    padding: 5rem 3rem 3rem 4rem;
  }
}

.lead {
  font-size: 1.1875rem;
  color: var(--muted);
}

@media (min-width: 40rem) {
  .lead {
    font-size: 1.25rem;
  }
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 2rem;
}

.entry {
  padding: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.entry h2 {
  margin-bottom: 0.25rem;
}

.entry .meta {
  margin-bottom: 1rem;
}

.entry + .entry {
  margin-top: 1.5rem;
}

.entry h2 a {
  color: inherit;
}

.entry h2 a:hover {
  color: var(--primary);
}

.entry > :last-child {
  margin-bottom: 0;
}

.subsection {
  margin-top: 3rem;
}

.subsection > :last-child {
  margin-bottom: 0;
}


/* ==========================================================================
   Buttons
   ========================================================================== */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  padding: 0.5rem 1.25rem;
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  border: 2px solid var(--primary);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease;
}

.button-primary {
  background: var(--primary);
  color: var(--on-primary);
}

.button-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  color: var(--on-primary);
}

.button-secondary {
  background: transparent;
  color: var(--primary);
}

.button-secondary:hover {
  background: var(--surface-hover);
  color: var(--primary-hover);
}

.button:disabled {
  opacity: 0.6;
  cursor: progress;
}

/* ==========================================================================
   Contact form
   ========================================================================== */

.field {
  margin-bottom: 1.25rem;
}

.field label {
  display: block;
  margin-bottom: 0.375rem;
  font-weight: 600;
}

.field input,
.field textarea {
  display: block;
  width: 100%;
  min-height: 2.75rem;
  padding: 0.625rem 0.75rem;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--input-border);
  border-radius: var(--radius);
}

.field textarea {
  min-height: 10rem;
  resize: vertical;
}

.field [aria-invalid="true"] {
  border: 2px solid var(--error);
}

.hint,
.field-error {
  margin: 0.375rem 0 0;
  font-size: 0.9375rem;
}

.hint {
  color: var(--muted);
}

.field-error {
  color: var(--error);
  font-weight: 600;
}

.honeypot {
  display: none;
}

.form-status:empty {
  display: none;
}

.form-status {
  margin-top: 1.25rem;
  padding: 0.75rem 1rem;
  border-left: 4px solid var(--input-border);
  background: var(--surface);
}

.form-status[data-state="success"] {
  border-color: var(--success);
}

.form-status[data-state="error"] {
  border-color: var(--error);
}

.form-note {
  margin-top: 1.25rem;
  font-size: 0.9375rem;
  color: var(--muted);
}

/* ==========================================================================
   About page
   ========================================================================== */

.portrait {
  display: block;
  width: 10rem;
  height: 10rem;
  margin-bottom: 2rem;
  border-radius: 50%;
  object-fit: cover;
}
