/* What every page shares: the colours, the type, the header with the theme
   toggle and the footer. Each page keeps its own layout in its <style>. */

:root {
  color-scheme: light dark;
  --gutter: clamp(16px, 4.5vw, 72px);
  --bg: light-dark(#eef0f6, #141938);
  --ink: light-dark(#161b3d, #f6ecda);
  --ink-2: light-dark(#555c82, #9ca1cc);
  --line: color-mix(in srgb, var(--ink) 12%, transparent);
  --sun: none;
  --moon: block;
}

/* The colours follow color-scheme, and the visitor's pick overrides it. The
   toggle's icon is not a colour, so its dark value is named for both ways
   into the dark. */
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; --sun: block; --moon: none; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --sun: block; --moon: none; }
}

* { box-sizing: border-box; }

body {
  display: flex;
  flex-direction: column;
  min-height: 100svh;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 18px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-underline-offset: 0.2em; }

:focus-visible { outline: 2px solid light-dark(#e2582f, #ff8a3d); outline-offset: 3px; border-radius: 6px; }

.wrap {
  width: 100%;
  max-width: 1560px;
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* Header */

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: clamp(20px, 3.2vh, 44px);
  padding-bottom: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.brand img { width: 52px; height: 52px; margin: -4px 0 -4px -4px; }

.top nav { display: flex; align-items: center; gap: 12px; }

.top nav a {
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--ink-2);
  font-size: 17px;
  text-decoration: none;
}

.top nav a:hover { color: var(--ink); }

.theme {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
}

.theme:hover { color: var(--ink); background: var(--line); }
.theme:active { transform: scale(0.94); }
.theme .sun { display: var(--sun); }
.theme .moon { display: var(--moon); }

/* Footer */

footer { padding-bottom: 32px; }

.foot {
  margin: 0;
  padding-top: 28px;
  border-top: 1px solid var(--line);
  color: var(--ink-2);
  font-size: 15px;
}

.foot a { text-decoration: none; }
.foot a:hover { color: var(--ink); text-decoration: underline; }

@media (max-width: 600px) {
  .top nav { gap: 4px; }
  .top nav a { padding-inline: 6px; }
  .brand { font-size: 20px; }
  .brand img { width: 40px; height: 40px; }
}

/* Under 360 px the header runs out of room: the brand keeps its icon, and
   its name stays in the link for screen readers. */
@media (max-width: 359px) {
  .brand { gap: 0; font-size: 0; }
}
