/*
  Matthew Capowski — static site
  The layout intentionally stays close to the former matthewcapowski.com page:
  one quiet reading column, portrait first, generous white space, strong headings.
*/

/* 1. Tokens */
:root {
  color-scheme: light dark;

  --font-body: ui-serif, Georgia, Cambria, "Times New Roman", Times, serif;
  --font-heading: Cambria, Georgia, "Times New Roman", Times, serif;
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;

  --text: #111111;
  --muted: #5d5d5d;
  --background: #ffffff;
  --link: #1769aa;
  --link-hover: #111111;
  --focus: #9b4d00;
  --rule: #dedede;

  --step--1: 0.9375rem;
  --step-0: 1.125rem;
  --step-1: clamp(1.35rem, 1.15rem + 0.6vw, 1.6rem);
  --step-2: clamp(2.15rem, 1.65rem + 1.7vw, 2.8125rem);

  --space-1: 0.5rem;
  --space-2: 0.75rem;
  --space-3: 1rem;
  --space-4: 1.5rem;
  --space-5: 2rem;
  --space-6: 3rem;
  --space-7: 3.75rem;

  --measure: 66ch;
  --page-width: 50rem;
  --page-gutter: clamp(1.25rem, 5vw, 3.75rem);
}

@media (prefers-color-scheme: dark) {
  :root {
    --text: #ecebe7;
    --muted: #b8b6b0;
    --background: #1b1c1e;
    --link: #8fc4ee;
    --link-hover: #ffffff;
    --focus: #f0a357;
    --rule: #3b3c3f;
  }
}

/* 2. Small normalization block */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; }
img { display: block; max-width: 100%; height: auto; }

/* 3. Base elements */
body {
  color: var(--text);
  background-color: var(--background);
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: 1.8;
  text-rendering: optimizeLegibility;
  overflow-wrap: break-word;
}

p { margin: 0 0 var(--space-4); max-width: var(--measure); }
strong { font-weight: 700; }

h1, h2, h3 {
  color: var(--text);
  background-color: var(--background);
  font-family: var(--font-heading);
  line-height: 1.16;
  letter-spacing: -0.012em;
}

h2 {
  margin: var(--space-7) 0 var(--space-4);
  font-size: var(--step-2);
  font-weight: 700;
  scroll-margin-top: var(--space-4);
}

h3 {
  margin: var(--space-5) 0 var(--space-2);
  font-size: var(--step-1);
  font-weight: 700;
}

a {
  color: var(--link);
  background-color: var(--background);
  text-decoration-line: underline;
  text-decoration-thickness: 0.06em;
  text-underline-offset: 0.14em;
}

a:hover {
  color: var(--link-hover);
  background-color: var(--background);
  text-decoration-thickness: 0.11em;
}

a:focus-visible {
  color: var(--text);
  background-color: var(--background);
  outline: 0.18rem solid var(--focus);
  outline-offset: 0.18rem;
  border-radius: 0.08rem;
}

/* 4. Layout */
.site-main,
.site-footer {
  width: min(100%, var(--page-width));
  margin-inline: auto;
  padding-inline: var(--page-gutter);
}

.site-main {
  padding-block: var(--page-gutter) var(--space-6);
}

.page { max-width: var(--measure); }

section { margin: 0; }

.portrait {
  width: min(18.75rem, 70vw);
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 50%;
  margin: 0 0 var(--space-5);
}

.site-footer {
  padding-block: var(--space-4) var(--space-6);
  border-top: 1px solid var(--rule);
  font-family: var(--font-ui);
  font-size: var(--step--1);
}

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

.skip-link {
  position: fixed;
  inset-block-start: var(--space-3);
  inset-inline-start: var(--space-3);
  z-index: 1000;
  padding: var(--space-2) var(--space-3);
  color: var(--background);
  background-color: var(--text);
  font-family: var(--font-ui);
  font-size: var(--step--1);
  transform: translateY(-220%);
}

.skip-link:focus {
  color: var(--background);
  background-color: var(--text);
  transform: translateY(0);
}

/* Style-guide-only helpers */
.style-guide-swatch {
  display: inline-block;
  width: 3rem;
  height: 3rem;
  margin-inline-end: var(--space-2);
  border: 1px solid var(--rule);
  vertical-align: middle;
}
.style-guide-swatch--text { background: var(--text); }
.style-guide-swatch--background { background: var(--background); }
.style-guide-swatch--link { background: var(--link); }
.style-guide-swatch--focus { background: var(--focus); }

/* 6. Responsive refinement */
@media (min-width: 48em) {
  .site-main { padding-block-start: var(--space-7); }
}

@media (min-width: 120em) {
  html { font-size: 112.5%; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media print {
  :root {
    --text: #000000;
    --background: #ffffff;
    --link: #000000;
  }
  body { font-size: 11pt; line-height: 1.5; }
  .skip-link, .site-footer { display: none; }
  .site-main { width: auto; max-width: none; padding: 0; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 0.85em; }
}
