/*
 * Base stylesheet. Everything here must work without JavaScript:
 * the three views are stacked and the nav links act as in-page anchors.
 * Palette values are placeholders until real images are in (design.md, Open Questions).
 */

:root {
  --color-bg: #070b0a;
  --color-text: #e6ece8;
  --color-muted: #a3b0a9;
  --color-accent: #8ff0b8;
  --color-rule: #24302b;
  --color-nav-bg: rgb(7 11 10 / 0.96);

  --font-mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", "Consolas", "Liberation Mono", "Menlo", monospace;

  --nav-height: 3rem;
  --gutter: 1rem;
  --content-width: 38rem;
}

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

/* Keep the hidden attribute effective on elements that set their own display. */
[hidden] {
  display: none !important;
}

html {
  scroll-padding-top: calc(var(--nav-height) + 1rem);
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-mono);
  font-size: 0.9375rem;
  line-height: 1.6;
}

/* ---------- Typography ---------- */

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.25;
  font-weight: 700;
  text-wrap: balance;
}

h1 {
  font-size: 1.75rem;
  letter-spacing: -0.01em;
}

h2 {
  margin-top: 2.25rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--color-rule);
  color: var(--color-accent);
  font-size: 0.8125rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h3 {
  font-size: 1rem;
}

p,
ul,
dl {
  margin: 0.75rem 0 0;
}

ul {
  padding-left: 1.25rem;
}

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

a {
  color: var(--color-accent);
  text-underline-offset: 0.2em;
}

a:hover {
  text-decoration-thickness: 2px;
}

:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 3px;
}

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

/* ---------- Navigation bar ---------- */

.site-nav {
  position: fixed;
  inset: 0 0 auto;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  height: var(--nav-height);
  padding: 0 var(--gutter);
  background: var(--color-nav-bg);
  border-bottom: 1px solid var(--color-rule);
}

.site-nav__links {
  display: flex;
  gap: 0.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-nav__links li + li {
  margin-top: 0;
}

.site-nav a,
.site-nav__toggle {
  display: inline-block;
  padding: 0.4rem 0.6rem;
  border: 1px solid transparent;
  border-radius: 2px;
  color: var(--color-text);
  font: inherit;
  font-size: 0.875rem;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
}

.site-nav a:hover,
.site-nav__toggle:hover {
  color: var(--color-accent);
}

.site-nav a[aria-current="page"] {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.site-nav__toggle {
  background: none;
  border-color: var(--color-rule);
  cursor: pointer;
}

.site-nav__toggle[aria-pressed="true"] {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

/* ---------- Background canvas (created by JavaScript) ---------- */

.background {
  position: fixed;
  inset: 0;
  z-index: -1;
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* ---------- Views (no-JS: stacked) ---------- */

main {
  padding-top: var(--nav-height);
}

.view {
  padding: 3rem var(--gutter) 4rem;
}

.view + .view {
  border-top: 1px solid var(--color-rule);
}

.view__content {
  max-width: var(--content-width);
  margin: 0 auto;
}

/* With JavaScript the router shows one view at a time. */
.js .view {
  display: none;
  border-top: 0;
}

.js .view.is-active {
  display: block;
}

/* Views receive focus from the router after navigation; they are not controls. */
.view:focus {
  outline: none;
}

/* Wide screens: the manifest's contentSide moves the column so the landscape shows beside it. */
@media (min-width: 1024px) {
  .view[data-content-side="left"] .view__content {
    margin-left: clamp(2rem, 7vw, 8rem);
  }

  .view[data-content-side="right"] .view__content {
    margin-right: clamp(2rem, 7vw, 8rem);
  }
}

/* ---------- Content rendered from Markdown (content/*.md) ---------- */

/* The paragraph right under the page heading is the tagline. */
h1 + p {
  color: var(--color-muted);
}

h3 {
  margin-top: 1.25rem;
}

/* An emphasised line under an entry heading holds its dates. */
h3 + p {
  margin-top: 0.15rem;
}

em {
  color: var(--color-muted);
  font-style: normal;
}

h3 + p > em:only-child {
  font-size: 0.8125rem;
}

code {
  font: inherit;
  color: var(--color-accent);
}

.content-error {
  color: var(--color-muted);
}

/* ---------- Contact ---------- */

.contact-list {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.5rem 1.5rem;
  margin-top: 1.5rem;
}

.contact-list dt {
  color: var(--color-muted);
}

.contact-list dd {
  margin: 0;
  overflow-wrap: anywhere;
}

/* ---------- Small screens ---------- */

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

  .view {
    padding-top: 2rem;
    padding-bottom: 3rem;
  }

  .site-nav a,
  .site-nav__toggle {
    padding-inline: 0.45rem;
  }
}

/* ---------- Motion preferences ---------- */

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