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

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

body {
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

/* Cross-fade between pages on same-origin navigation. Browsers without
   support simply navigate normally. */
@view-transition {
  navigation: auto;
}

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

  @view-transition {
    navigation: none;
  }
}

/* === Font Face === */

@font-face {
  font-family: "Atkinson Hyperlegible Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(fonts/AtkinsonHyperlegibleMono-Regular.woff2) format("woff2");
}

@font-face {
  font-family: "Atkinson Hyperlegible Mono";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url(fonts/AtkinsonHyperlegibleMono-Bold.woff2) format("woff2");
}

/* === Color Scheme: Light (default) === */

:root {
  color-scheme: light dark;
  --bg: #ffffff;
  --text: #1f2328;
  --accent: #0969da;
  --accent-hover: #218bff;
  --muted: #6e7781;
  --secondary: #57606a;
  --border: #d0d7de;
  --code-bg: #f6f8fa;
  --red: #cf222e;
  --green: #116329;
  --yellow: #4d2d00;
  --magenta: #8250df;
  --cyan: #1b7c83;
}

/* === Color Scheme: Dark (auto) === */

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #30363d;
    --text: #e6edf3;
    --accent: #58a6ff;
    --accent-hover: #79c0ff;
    --muted: #b1bac4;
    --secondary: #6e7681;
    --border: #484f58;
    --code-bg: #484f58;
    --red: #ff7b72;
    --green: #3fb950;
    --yellow: #d29922;
    --magenta: #bc8cff;
    --cyan: #39c5cf;
  }
}

/* === Manual Theme Overrides === */

html[data-theme="light"] {
  color-scheme: light;
  --bg: #ffffff;
  --text: #1f2328;
  --accent: #0969da;
  --accent-hover: #218bff;
  --muted: #6e7781;
  --secondary: #57606a;
  --border: #d0d7de;
  --code-bg: #f6f8fa;
  --red: #cf222e;
  --green: #116329;
  --yellow: #4d2d00;
  --magenta: #8250df;
  --cyan: #1b7c83;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #30363d;
  --text: #e6edf3;
  --accent: #58a6ff;
  --accent-hover: #79c0ff;
  --muted: #b1bac4;
  --secondary: #6e7681;
  --border: #484f58;
  --code-bg: #484f58;
  --red: #ff7b72;
  --green: #3fb950;
  --yellow: #d29922;
  --magenta: #bc8cff;
  --cyan: #39c5cf;
}

/* === Layout === */

body {
  font-family: "Atkinson Hyperlegible Mono", monospace;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
}

.page-wrapper {
  width: max-content;
  max-width: 95vw;
  margin: 0 auto;
  padding: 0 1rem;
}

.content-wrap {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
}

main {
  width: 65ch;
  flex-shrink: 0;
  padding: 1rem 0;
}

.solar-widget {
  display: flex;
  justify-content: center;
  padding: 0.5rem 0 1rem;
  /* Reserve the column so the page does not reflow when the image arrives. */
  flex: 0 0 155px;
}

.solar-widget img {
  display: block;
  width: 155px;
  height: auto;
  aspect-ratio: 155 / 530;
  max-width: 100%;
}

/* === Typography === */

h1,
h2,
h3 {
  font-weight: 700;
  line-height: 1.3;
}

h1,
h2,
h3 {
  text-wrap: balance;
}

p {
  text-wrap: pretty;
}

h1 {
  font-size: 1.5rem;
  margin-top: 0;
}

h2 {
  font-size: 1.25rem;
}

h3 {
  font-size: 1.1rem;
}

a {
  color: var(--accent);
}

a:hover,
a:focus {
  color: var(--accent-hover);
}

p {
  margin: 1rem 0;
}

/* === Navigation === */

header {
  padding: 1rem 0 0;
}

nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
}

nav a {
  text-decoration: none;
}

nav a:hover,
nav a:focus {
  text-decoration: underline;
}

nav a[aria-current="page"] {
  font-weight: 700;
  text-decoration: none;
  color: var(--text);
}

.theme-toggle {
  background: none;
  border: none;
  color: var(--accent);
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  padding: 0;
  margin-left: auto;
}

.theme-toggle:hover,
.theme-toggle:focus {
  color: var(--accent-hover);
}

/* === Content Elements === */

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}

blockquote {
  border-left: 3px solid var(--border);
  margin: 1rem 0;
  padding: 0.25rem 1rem;
  color: var(--secondary);
}

code {
  background: var(--code-bg);
  padding: 0.15rem 0.3rem;
  font-family: inherit;
  font-size: 0.95em;
}

/* === EchoLink node tooltip === */

.leet-node {
  position: relative;
}

.leet-node::after {
  content: "For l33t :D";
  position: absolute;
  left: 50%;
  bottom: calc(100% + 0.45rem);
  transform: translateX(-50%);
  background: var(--code-bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.75rem;
  line-height: 1.4;
  padding: 0.05rem 0.4rem;
  white-space: nowrap;
  z-index: 1;
}

.leet-node::before,
.leet-node::after {
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.1s ease-out,
    visibility 0.1s;
}

.leet-node:hover::before,
.leet-node:hover::after {
  opacity: 1;
  visibility: visible;
}

.leet-node::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: calc(100% + 0.1rem);
  transform: translateX(-50%);
  border: 0.35rem solid transparent;
  border-bottom-width: 0;
  border-top-color: var(--border);
  z-index: 1;
}

/* === Work Highlights === */

article {
  margin: 2rem 0;
}

article h3 {
  margin-bottom: 0.5rem;
}

article p {
  margin: 0.5rem 0;
}

/* === Projects === */

/* The grouping heading carries the space; the first project under it should
   not add its own on top. */
.project-group + .project-group {
  margin-top: 2.5rem;
}

.project-group > h2 {
  margin-bottom: 0;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--border);
}

.project-group > article:first-of-type {
  margin-top: 1rem;
}

.project-status {
  color: var(--muted);
  font-weight: 400;
  font-size: 0.875rem;
}

/* === Footer === */

footer {
  padding: 1rem 0;
  color: var(--muted);
  font-size: 0.875rem;
}

footer hr {
  margin: 1.5rem 0 1rem;
}

/* === Utility === */

.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;
}

/* The skip link stays hidden until a keyboard user tabs to it. */
.visually-hidden:focus {
  position: fixed;
  top: 0.5rem;
  left: 0.5rem;
  width: auto;
  height: auto;
  padding: 0.25rem 0.5rem;
  margin: 0;
  overflow: visible;
  clip: auto;
  background: var(--bg);
  border: 1px solid var(--border);
  z-index: 10;
}

/* === Print === */

@media print {
  body {
    color: #000;
    background: #fff;
  }

  a {
    color: #000;
    text-decoration: underline;
  }

  nav,
  .theme-toggle {
    display: none;
  }

  .leet-node::before,
  .leet-node::after {
    display: none;
  }
}

/* === Responsive === */

@media (max-width: 768px) {
  h1 {
    font-size: 1.3rem;
  }

  h2 {
    font-size: 1.15rem;
  }

  .page-wrapper {
    width: auto;
    max-width: 100%;
  }

  .content-wrap {
    display: block;
  }

  main {
    width: auto;
    padding: 0.75rem 0;
  }

  header {
    padding: 0.75rem 0 0;
  }

  footer {
    padding: 0.75rem 0;
  }
}
