/* ==========================================================================
   madskunk.co.uk
   One stylesheet, no build step. Edit the tokens; the rest derives from them.
   ========================================================================== */

/* --- Theme tokens ---------------------------------------------------------
   Dark is the base, so an absent or unknown preference gets dark.
   Light is declared in TWO places and they must stay in sync:
     1. @media (prefers-color-scheme: light)  — visitor's OS says light
     2. :root[data-theme="light"]             — visitor used the toggle
   The :not([data-theme="dark"]) guard lets an explicit dark choice win over
   an OS that says light.
   -------------------------------------------------------------------------- */

:root {
  color-scheme: dark;

  --bg: #000;
  --surface: #0e0e0e;
  --border: #232323;
  --border-strong: #3a3a3a;
  --text: #ededed;
  --muted: #8a8a8a;
  --accent: #d9a441;

  /* Set --accent to var(--text) if you ever want it fully monochrome. */

  --measure: 68ch;     /* comfortable line length for prose */
  --gap: clamp(1rem, 3vw, 2rem);
  --pad-page: clamp(1.25rem, 5vw, 4rem);
  --radius: 10px;
}

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

    --bg: #f7f7f6;
    --surface: #fff;
    --border: #e2e2de;
    --border-strong: #c6c6c0;
    --text: #16161a;
    --muted: #5f5f66;
    --accent: #8a5300;
  }
}

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

  --bg: #f7f7f6;
  --surface: #fff;
  --border: #e2e2de;
  --border-strong: #c6c6c0;
  --text: #16161a;
  --muted: #5f5f66;
  --accent: #8a5300;
}

/* --- Reset-ish ----------------------------------------------------------- */

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

body,
h1, h2, h3, p, ul, ol, figure, blockquote { margin: 0; }

img, svg { display: block; max-width: 100%; height: auto; }

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

body {
  background: var(--bg);
  color: var(--text);
  font: 400 clamp(1rem, 0.95rem + 0.2vw, 1.0625rem)/1.65
        system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

/* --- Shared layout ------------------------------------------------------- */

.wrap {
  width: 100%;
  max-width: 62rem;
  margin-inline: auto;
  padding-inline: var(--pad-page);
}

main { flex: 1 0 auto; }

.skip-link {
  position: absolute;
  left: -9999px;
}
.skip-link:focus {
  left: var(--pad-page);
  top: 0.5rem;
  z-index: 10;
  padding: 0.5rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
}

/* --- Links --------------------------------------------------------------- */

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

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

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

/* --- Site header --------------------------------------------------------- */

.site-header {
  display: flex;
  align-items: center;
  gap: var(--gap);
  padding-block: 1.25rem;
  border-bottom: 1px solid var(--border);
}

.site-header nav {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: clamp(0.75rem, 2vw, 1.5rem);
}

.site-header nav a {
  color: var(--muted);
  text-decoration: none;
}

.site-header nav a:hover,
.site-header nav a[aria-current="page"] { color: var(--text); }

.wordmark {
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
  text-decoration: none;
}

/* --- The mark -----------------------------------------------------------
   The logo PNG has an opaque black background, so it always sits on its own
   dark plinth — in the light theme too. Swap for a transparent SVG and you can
   delete the background/padding here.
   ------------------------------------------------------------------------ */

.mark {
  background: #000;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem;
  flex: none;
  line-height: 0;
}

.mark img { border-radius: calc(var(--radius) - 4px); }

.mark--sm img { width: 32px; }
.mark--lg img { width: clamp(96px, 22vw, 148px); }

/* --- Hero ---------------------------------------------------------------- */

.hero {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--gap);
  padding-block: clamp(2.5rem, 8vw, 5rem);
}

.hero-copy { flex: 1 1 22rem; }

.hero h1 {
  font-size: clamp(1.75rem, 1.2rem + 3vw, 3rem);
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-weight: 650;
}

.hero p {
  margin-top: 0.875rem;
  max-width: var(--measure);
  color: var(--muted);
  font-size: 1.0625em;
}

/* --- Sections ------------------------------------------------------------ */

.section { padding-block: clamp(2rem, 6vw, 3.5rem); }

.section > h2 {
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  font-weight: 600;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--gap);
}

/* --- Project cards ------------------------------------------------------- */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr));
  gap: var(--gap);
}

/* Whole card is one link — keep it to a single link per card so the target
   stays unambiguous. Extra project links belong on the project page. */
.card {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: clamp(1rem, 3vw, 1.5rem);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: inherit;
  text-decoration: none;
  transition: border-color 0.18s ease, transform 0.18s ease;
}

.card:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
}

.card h3 {
  font-size: 1.0625rem;
  font-weight: 620;
  letter-spacing: -0.01em;
}

.card p {
  color: var(--muted);
  font-size: 0.9375rem;
  flex: 1 0 auto;
}

.card-more {
  color: var(--accent);
  font-size: 0.875rem;
  font-weight: 550;
}

/* --- Tags & status ------------------------------------------------------- */

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  list-style: none;
  padding: 0;
}

.tags li {
  font-size: 0.75rem;
  letter-spacing: 0.02em;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.125rem 0.5rem;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.status::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.status--live { color: var(--accent); }

/* --- Prose (project pages) ---------------------------------------------- */

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

.prose > * + * { margin-top: 1.1em; }

.prose h2 {
  margin-top: 2.25em;
  font-size: 1.25rem;
  letter-spacing: -0.01em;
}

.prose h3 {
  margin-top: 1.75em;
  font-size: 1.0625rem;
}

.prose ul, .prose ol { padding-left: 1.25em; }

.prose li + li { margin-top: 0.4em; }

.prose code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.1em 0.35em;
}

.prose pre {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  overflow-x: auto;   /* long lines scroll in the block, not the page */
}

.prose pre code { background: none; border: 0; padding: 0; }

/* --- Project page header ------------------------------------------------ */

.page-head { padding-block: clamp(2rem, 6vw, 3.5rem) var(--gap); }

.page-head h1 {
  font-size: clamp(1.625rem, 1.2rem + 2.4vw, 2.5rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin-top: 0.5rem;
}

.page-head .lede {
  margin-top: 0.75rem;
  color: var(--muted);
  font-size: 1.0625em;
  max-width: var(--measure);
}

.back {
  font-size: 0.875rem;
  color: var(--muted);
  text-decoration: none;
}

.back:hover { color: var(--text); }

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  align-items: center;
  margin-top: var(--gap);
  padding-top: var(--gap);
  border-top: 1px solid var(--border);
  font-size: 0.875rem;
  color: var(--muted);
}

.meta dl { display: flex; gap: 0.4rem; margin: 0; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; color: var(--text); }

/* --- Theme toggle ------------------------------------------------------- */

.theme-toggle {
  font: inherit;
  font-size: 0.8125rem;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.3rem 0.7rem;
  cursor: pointer;
  min-height: 2rem;
}

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

/* No-JS visitors can't switch, so don't show a dead control. */
.no-js .theme-toggle { display: none; }

/* --- Footer ------------------------------------------------------------- */

.site-footer {
  margin-top: clamp(3rem, 8vw, 5rem);
  padding-block: var(--gap);
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.875rem;
}

.site-footer .wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem var(--gap);
  align-items: center;
}

.site-footer ul {
  list-style: none;
  padding: 0;
  margin-left: auto;
  display: flex;
  flex-wrap: wrap;
  gap: clamp(0.75rem, 2vw, 1.25rem);
}

.site-footer a { color: var(--muted); }

.site-footer a:hover { color: var(--text); }

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

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