/* ==========================================================================
   alexcampbell.ie: the site's only stylesheet
   --------------------------------------------------------------------------
   1. Fonts            5. Header & navigation   9. Contact
   2. Design tokens    6. Footer               10. Privacy & 404
   3. Base             7. Home                 11. Motion
   4. Components       8. CV & projects        12. Print (A4)

   All colours, spacing and fonts are custom properties in section 2.
   Contrast (WCAG 2.2 AA) was checked for every text/background pair in
   both themes; re-check if you change a colour.
   ========================================================================== */

/* 1. Fonts: self-hosted JetBrains Mono (SIL OFL, see fonts/OFL.txt) ------- */
@font-face {
  font-family: "JetBrains Mono";
  src: url("../fonts/JetBrainsMono-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("../fonts/JetBrainsMono-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("../fonts/JetBrainsMono-Italic.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

/* 2. Design tokens -------------------------------------------------------- */
:root {
  /* Fonts */
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", "Cascadia Mono", "DejaVu Sans Mono", Menlo, Consolas, monospace;

  /* Type scale */
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-h2: 1.25rem;
  --text-h1: 1.75rem;
  --leading: 1.6;

  /* Spacing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;
  --space-8: 4rem;

  /* Layout */
  --gutter: 1rem;      /* side padding on small screens */
  --wrap: 56rem;       /* max page width */
  --measure: 75ch;     /* max line length for text */
  --radius: 4px;
  --border-width: 1px;

  /* Dark theme (default) */
  color-scheme: dark;
  --bg: #151714;            /* near-black, not #000 */
  --surface: #1d201c;       /* cards, inputs */
  --fg: #e4e1d8;            /* soft off-white text      13.8:1 on bg */
  --muted: #a9a69c;         /* secondary text            7.4:1 */
  --accent: #8fcf8a;        /* main accent: green        9.8:1 */
  --accent-2: #e0b562;      /* secondary accent: amber   9.4:1 */
  --border: #2f332d;        /* decorative dividers */
  --border-strong: #737a6d; /* input borders (UI)        4.1:1 */
  --focus: var(--accent-2);
  --todo-bg: #e0b562;
  --todo-fg: #151714;
}

/* Light theme: warm off-white, darker accents. */
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f7f3ea;
  --surface: #efe9dc;
  --fg: #22241f;            /* 14.2:1 on bg */
  --muted: #57594f;         /*  6.4:1 */
  --accent: #2a6a2e;        /*  5.9:1 */
  --accent-2: #8a5700;      /*  5.5:1 */
  --border: #ddd5c4;
  --border-strong: #85847a; /*  3.4:1 */
  --todo-bg: #8a5700;
  --todo-fg: #f7f3ea;
}

@media (min-width: 48rem) {
  :root {
    --gutter: 2rem;
    --text-h1: 2.25rem;
    --text-h2: 1.375rem;
  }
}

/* 3. Base ----------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: var(--text-base); /* 16px */
  line-height: var(--leading);
  overflow-wrap: break-word;
}

main {
  flex: 1;
  padding-block: var(--space-6) var(--space-8);
}

main:focus {
  outline: none; /* focus target for the skip link only */
}

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

h1,
h2,
h3 {
  line-height: 1.25;
  margin: 0 0 var(--space-4);
}

h1 {
  font-size: var(--text-h1);
}

h2 {
  font-size: var(--text-h2);
  margin-top: var(--space-7);
}

h3 {
  font-size: var(--text-base);
  margin-top: var(--space-5);
  margin-bottom: var(--space-2);
}

p,
ul,
ol,
dl {
  margin: 0 0 var(--space-4);
}

p,
li,
dd,
figcaption {
  max-width: var(--measure);
}

ul {
  padding-left: 2ch;
  list-style-type: "- ";
}

li + li {
  margin-top: var(--space-1);
}

li::marker {
  color: var(--accent);
}

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

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

strong {
  font-weight: 700;
}

/* Visible focus for everything focusable. */
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
  border-radius: 2px;
}

/* Screen-reader-only text. */
.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.print-only {
  display: none;
}

.skip-link {
  position: absolute;
  left: var(--space-2);
  top: -100px;
  z-index: 10;
  padding: var(--space-2) var(--space-4);
  background: var(--accent);
  color: var(--bg);
  font-weight: 700;
}

.skip-link:focus {
  top: var(--space-2);
}

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

.lede {
  font-size: var(--text-lg);
}

/* 4. Components ----------------------------------------------------------- */

/* Shell prompt: alex@campbell:~/path$ */
.ps1 {
  font-weight: 700;
  white-space: nowrap;
}
.ps1-user {
  color: var(--accent);
}
.ps1-path {
  color: var(--accent-2);
}

/* Page headings: prompt line above the real title. */
.page-title-prompt {
  display: block;
  margin-bottom: var(--space-2);
  font-size: var(--text-base);
  font-weight: 400;
}

/* "## " marker before section headings. */
.h-mark {
  color: var(--accent);
}

/* Buttons and button-style links. */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 44px;
  padding: var(--space-2) var(--space-4);
  border: var(--border-width) solid var(--accent);
  border-radius: var(--radius);
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}
.btn:hover {
  background: var(--surface);
}
.btn-primary {
  background: var(--accent);
  color: var(--bg);
}
.btn-primary:hover {
  background: var(--accent);
  text-decoration: underline;
}
.btn-small {
  min-height: 36px;
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-sm);
}

/* Tags for stack/tools. */
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding: 0;
  list-style: none;
}
.tags li {
  margin: 0;
  padding: 0 var(--space-2);
  border: var(--border-width) solid var(--border-strong);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: var(--text-sm);
}

/* Unfilled placeholders: deliberately loud until replaced. */
mark.todo {
  background: var(--todo-bg);
  color: var(--todo-fg);
  padding: 0 0.25em;
  border-radius: 2px;
}

/* Key/value lists (skills, languages). */
.kv {
  display: grid;
  gap: var(--space-3);
}
.kv dt {
  font-weight: 700;
  color: var(--accent-2);
}
.kv dd {
  margin: 0;
}

.section {
  margin-top: var(--space-7);
}

.note {
  color: var(--muted);
  font-size: var(--text-base);
}

/* 5. Header & navigation -------------------------------------------------- */
.site-header {
  border-bottom: var(--border-width) solid var(--border);
}

.header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-height: 3.5rem;
}

.brand {
  color: var(--fg);
  text-decoration: none;
  font-size: var(--text-base);
}

.header-tools {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* Theme toggle and menu button need JavaScript: hidden until main.js adds .js */
.theme-toggle,
.menu-toggle,
.copy-btn {
  display: none;
}
.js .theme-toggle,
.js .copy-btn {
  display: inline-flex;
}

.icon-btn,
.menu-toggle {
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-width: 44px;
  min-height: 44px;
  padding: 0 var(--space-2);
  border: var(--border-width) solid var(--border-strong);
  border-radius: var(--radius);
  background: transparent;
  color: var(--fg);
  font: inherit;
  cursor: pointer;
}
.icon-btn:hover,
.menu-toggle:hover {
  background: var(--surface);
}

.icon {
  width: 1.25rem;
  height: 1.25rem;
  flex: none;
}

/* Sun shows in dark mode (switch to light); moon shows in light mode. */
:root[data-theme="light"] .icon-sun,
:root:not([data-theme="light"]) .icon-moon {
  display: none;
}

.site-nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0 var(--space-4);
  margin: 0 auto;
  padding-block: 0 var(--space-2);
  list-style: none;
}
.site-nav li {
  margin: 0;
}
.site-nav a {
  display: inline-block;
  padding: var(--space-2) 0;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
}
.site-nav a:hover {
  color: var(--fg);
}
/* Current page: accent colour, bold, underlined. */
.site-nav a[aria-current="page"] {
  color: var(--accent);
  font-weight: 700;
  border-bottom-color: var(--accent);
}

/* Small screens with JavaScript: collapsible menu. */
@media (max-width: 47.99rem) {
  .js .menu-toggle {
    display: inline-flex;
  }
  .js .site-nav {
    display: none;
  }
  .js .site-nav.is-open {
    display: block;
  }
  .js .site-nav ul {
    flex-direction: column;
    padding-block: var(--space-2) var(--space-3);
  }
  .js .site-nav a {
    display: block;
  }
}

/* 6. Footer --------------------------------------------------------------- */
.site-footer {
  border-top: var(--border-width) solid var(--border);
  color: var(--muted);
}

.footer-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2) var(--space-5);
  padding-block: var(--space-5);
}

.footer-bar p {
  margin: 0;
}

.footer-links {
  display: flex;
  gap: var(--space-5);
  margin: 0;
  padding: 0;
  list-style: none;
}
.footer-links li {
  margin: 0;
}
.footer-links a[aria-current="page"] {
  font-weight: 700;
}

/* 7. Home ----------------------------------------------------------------- */
.prompt-line {
  margin-bottom: var(--space-2);
}

.hero-name {
  font-size: calc(var(--text-h1) * 1.15);
}

.status {
  padding: var(--space-3) var(--space-4);
  border-left: 2px solid var(--accent-2);
  background: var(--surface);
}
.status-label {
  display: block;
  color: var(--accent-2);
  font-weight: 700;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-top: var(--space-5);
  padding: 0;
  list-style: none;
}
.actions li {
  margin: 0;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}

.card {
  padding: var(--space-4);
  border: var(--border-width) solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.card h3 {
  margin-top: 0;
}
.card .tags {
  margin-bottom: 0;
}

/* 8. CV & projects -------------------------------------------------------- */
.cv-sub {
  color: var(--muted);
  margin-bottom: var(--space-2);
}

.cv-contact {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-5);
  padding: 0;
  list-style: none;
}
.cv-contact li {
  margin: 0;
}

.entry + .entry {
  margin-top: var(--space-5);
}
.entry h3 {
  margin-top: 0;
}
.entry-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0 var(--space-4);
  margin-bottom: var(--space-2);
  color: var(--muted);
}
.entry-dates {
  color: var(--accent-2);
}

.project {
  margin-top: var(--space-7);
  padding-top: var(--space-5);
  border-top: var(--border-width) solid var(--border);
}
.project h2 {
  margin-top: 0;
}
/* Featured (first) project: larger, framed. */
.project-featured {
  padding: var(--space-5) var(--space-4);
  border: var(--border-width) solid var(--border-strong);
  border-radius: var(--radius);
}
@media (min-width: 48rem) {
  .project-featured {
    padding: var(--space-6);
  }
  .project-featured h2 {
    font-size: var(--text-h1);
  }
}

.outcomes {
  list-style-type: "→ ";
  padding-left: 2ch;
}

/* Homelab architecture diagram: colours follow the theme. */
.diagram {
  margin: 0 0 var(--space-5);
}
.diagram svg {
  display: block;
  width: 100%;
  max-width: 30rem;
  height: auto;
  margin-bottom: var(--space-3);
}
.diagram figcaption {
  color: var(--muted);
}
.d-box {
  fill: var(--surface);
  stroke: var(--border-strong);
  stroke-width: 1;
}
.d-accent {
  stroke: var(--accent);
}
.d-accent2 {
  stroke: var(--accent-2);
}
.d-strong {
  stroke: var(--fg);
}
.d-label,
.d-sub {
  font-family: var(--font-mono);
  text-anchor: middle;
}
.d-label {
  fill: var(--fg);
  font-size: 13px;
  font-weight: 700;
}
.d-sub {
  fill: var(--muted);
  font-size: 12px;
}
.d-line {
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.5;
}
.d-dashed {
  stroke-dasharray: 4 3;
}
.d-arrowhead {
  fill: var(--muted);
}

/* 9. Contact -------------------------------------------------------------- */
.contact-list {
  padding: 0;
  list-style: none;
}
.contact-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
  padding-block: var(--space-3);
  border-bottom: var(--border-width) solid var(--border);
  margin: 0;
}
.contact-list .icon {
  color: var(--accent);
}
.contact-label {
  min-width: 9ch;
  color: var(--muted);
}
.copy-status {
  color: var(--accent);
  font-weight: 700;
}

.mail-form {
  max-width: 40rem;
}
.field {
  margin-bottom: var(--space-4);
}
.field label {
  display: block;
  margin-bottom: var(--space-1);
  font-weight: 700;
}
.field input,
.field textarea {
  width: 100%;
  min-height: 44px;
  padding: var(--space-2) var(--space-3);
  border: var(--border-width) solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--fg);
  font: inherit;
}
.field textarea {
  resize: vertical;
}
.field input:focus-visible,
.field textarea:focus-visible {
  outline-offset: 1px;
}

/* 10. Privacy & 404 ------------------------------------------------------- */
.updated {
  margin-top: var(--space-7);
}

/* Terminal block on the 404 page (one of the few box-drawing touches). */
.terminal {
  margin-bottom: var(--space-6);
  padding: var(--space-4);
  border: var(--border-width) solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
}
.terminal::before {
  content: "┌─ bash ─────";
  display: block;
  margin-bottom: var(--space-2);
  color: var(--muted);
}
.terminal p {
  margin: 0;
}
.terminal .error {
  color: var(--accent-2);
}

/* 11. Motion: blinking cursor on the home prompt -------------------------- */
.cursor {
  display: inline-block;
  width: 0.6em;
  height: 1.1em;
  margin-left: 2px;
  vertical-align: text-bottom;
  background: var(--accent);
}

@media (prefers-reduced-motion: no-preference) {
  .cursor {
    animation: blink 1.1s steps(1) infinite;
  }
  html {
    scroll-behavior: smooth;
  }
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

/* 12. Print: clean A4 CV (and any other page) ----------------------------- */
@media print {
  @page {
    size: A4;
    margin: 16mm 15mm;
  }

  /* Force light colours whatever theme is active. */
  :root,
  :root[data-theme] {
    color-scheme: light;
    --bg: #fff;
    --surface: #fff;
    --fg: #111;
    --muted: #444;
    --accent: #1f4f22;
    --accent-2: #5a3a00;
    --border: #bbb;
    --border-strong: #888;
  }

  body {
    display: block;
    font-size: 10pt;
    line-height: 1.45;
  }

  .site-header,
  .site-footer,
  .skip-link,
  .theme-toggle,
  .menu-toggle,
  .copy-btn,
  .copy-status,
  .page-title-prompt,
  .prompt-line,
  .h-mark {
    display: none !important;
  }

  .print-only {
    display: block;
  }

  main {
    padding: 0;
  }

  .wrap {
    max-width: none;
    padding: 0;
  }

  h1 {
    font-size: 18pt;
    margin-bottom: 2pt;
  }
  h2 {
    font-size: 12pt;
    margin-top: 14pt;
    margin-bottom: 6pt;
    padding-bottom: 2pt;
    border-bottom: 1px solid var(--border);
    break-after: avoid;
  }
  h3 {
    font-size: 10.5pt;
    break-after: avoid;
  }

  p,
  li,
  dd {
    max-width: none;
    orphans: 3;
    widows: 3;
  }

  p,
  ul,
  dl {
    margin-bottom: 5pt;
  }

  a {
    color: inherit;
    text-decoration: none;
  }

  /* Page breaks: keep short sections and individual entries together. */
  .cv-section-keep,
  .entry,
  .kv > div,
  .card,
  .diagram {
    break-inside: avoid;
  }

  .entry + .entry {
    margin-top: 8pt;
  }

  .kv {
    gap: 4pt;
  }

  .status,
  .card,
  .project-featured {
    background: none;
    border-color: var(--border);
  }
}
