/*
  Shared styles for every page (index.html, project.html, ...).
  Page-specific styles live in each page's own <style> block.

  Grid system
  -----------
  Spacing: everything is a multiple of 8px (0.5rem).
  Baseline: 24px (1.5rem). Every line of text sits in a 24px line box,
    and rows are 32px (24px line + 4px padding top and bottom).
  Type: two sizes only. 18px for the name and section titles, 14px for
    everything else.
  Columns: 1/3 and 2/3 with a 32px gutter.
*/
:root {
  --bg: #fbfbfa;
  --text: #1a1a1a;
  --muted: #686864;                    /* 5.4:1 on --bg */
  --hl-bg: rgba(37, 99, 235, 0.13);    /* hover highlight */

  --u: 0.5rem;                         /* base unit, 8px */
  --line: 1.5rem;                      /* baseline, 24px */
  --gutter: 2rem;                      /* 32px */
  --row-pad-x: 0.5rem;                 /* highlight reaches 8px past text */
}
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  padding: 6rem 1.5rem 6rem;
  background: var(--bg);
  color: var(--text);
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 0.875rem;                 /* 14px */
  line-height: var(--line);
  -webkit-font-smoothing: antialiased;
}

/* Centered container. Change max-width to taste. */
main { max-width: 46rem; margin: 0 auto; }

/* Two columns: headings and menu on the left (1/3), content on the right (2/3). */
section, .layout {
  display: grid;
  grid-template-columns: 1fr 2fr;
  column-gap: var(--gutter);
}

h1, h2 {
  margin: 0;
  font-size: 1.125rem;                 /* 18px */
  font-weight: 400;
  line-height: var(--line);
}

p { margin: 0 0 var(--line); }
.role { margin: 0; color: var(--muted); }

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

/* Your name, when it's a link back home */
h1 a {
  padding: 0.1em 0.25em;
  margin: 0 -0.25em;
  border-radius: 0.3em;
  transition: background-color 0.15s;
}
h1 a:hover { background: var(--hl-bg); }

/* Keyboard focus: a real outline, plus the same highlight as hover */
h1 a:focus-visible,
.menu summary:focus-visible,
.menu a:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

/* ---------- Menu with dropdowns ---------- */
.menu { margin-top: var(--line); }
.menu ul { list-style: none; margin: 0; padding: 0; }

.menu summary,
.menu > ul > li > a {
  display: flex;
  align-items: center;
  gap: var(--u);
  padding: 0.25rem var(--row-pad-x);
  margin: 0 calc(var(--row-pad-x) * -1);
  border-radius: var(--u);
  color: var(--muted);
  cursor: pointer;
  list-style: none;
  transition: background-color 0.15s, color 0.15s;
}
.menu summary::-webkit-details-marker { display: none; }
.menu summary:hover,
.menu > ul > li > a:hover,
.menu summary:focus-visible,
.menu a:focus-visible { background: var(--hl-bg); color: var(--text); }
.menu details[open] > summary { color: var(--text); }

/* Triangle: 8px box, turns down when open */
.menu summary::before {
  content: "";
  flex: none;
  width: var(--u);
  height: var(--u);
  background: currentColor;
  clip-path: polygon(0 0, 100% 50%, 0 100%);
  transition: transform 0.15s;
}
.menu details[open] > summary::before { transform: rotate(90deg); }

/* Dropdown items: text lines up under the section name (triangle 8px +
   gap 8px = 16px in). Extra left padding keeps the highlight's left edge
   the same as the section name's. */
.menu details ul { margin: 0 0 var(--u); padding: 0; }
.menu details li a {
  display: block;
  padding: 0.25rem var(--row-pad-x) 0.25rem calc(var(--row-pad-x) + 1rem);
  margin: 0 calc(var(--row-pad-x) * -1);
  border-radius: var(--u);
  color: var(--muted);
  transition: background-color 0.15s, color 0.15s;
}
.menu details li a:hover,
.menu details li a:focus-visible { background: var(--hl-bg); color: var(--text); }

/* The page you're on, shown in black in the dropdown */
.menu details li a[aria-current] { color: var(--text); }

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

/* ---------- Narrow screens: single column ---------- */
@media (max-width: 40rem) {
  body { padding-top: 3rem; }
  section, .layout { grid-template-columns: 1fr; }
}
