/* =====================================================================
   STYLE.CSS  -  how this file is organised

   1. SETTINGS      <- the only part you normally need to edit
        1a. Text sizes and fonts
        1b. Spacing (every gap on the site, one named setting each)
        1c. Layout (widths, columns)
        1d. Resources map
        1e. Phone settings (screens narrower than 820px)
   2. BASE          headings, links, lists, images, text spacing
   3. MENU AND FOOTER
   4. PAGES         Home, About, Experience, Contact, Work, Projects, Resources, 404
   5. EXTRAS        cursor, sliding panel, accessibility helpers
   6. PHONE LAYOUT  how everything rearranges on small screens

   Units: "rem" = a multiple of the browser's text size (1rem = 16px by default,
   so 0.75rem = 12px, 1.25rem = 20px, 3.75rem = 60px). Using rem lets people who
   enlarge their browser text get a bigger site. Handy conversions:
   8px = 0.5rem, 10px = 0.625rem, 12px = 0.75rem, 16px = 1rem, 20px = 1.25rem,
   24px = 1.5rem, 30px = 1.875rem, 40px = 2.5rem, 50px = 3.125rem, 60px = 3.75rem
   ===================================================================== */


/* =====================================================================
   1. SETTINGS
   ===================================================================== */
:root {
  --font: Arial, Helvetica, sans-serif;

  /* ---------- 1a. Text ---------- */
  --text: 0.75rem;                 /* ALL body text (12px) */
  --menu-text: var(--text);        /* menu links and your name in the menu */
  --h1: clamp(1.625rem, 1.45rem + 0.9vw, 1.875rem);
                                   /* H1 = page titles and your name on the home page.
                                      Grows smoothly from 26px on small phones to 30px on desktop.
                                      Format: clamp(smallest, preferred, largest) */
  --h2: 1.25rem;                   /* H2 = subtitles and section titles (20px) */
  --h3: 0.94rem;                   /* H3 = sub-subtitles: roles, degrees, project names (15px) */
  --lh: 1.7;                       /* line height for all text */
  --line: calc(var(--text) * var(--lh));   /* the height of ONE line of text (don't edit) */

  /* ---------- 1b. Spacing ---------- */
  /* Under the page title */
  --space-title-subtitle: 1.25rem; /* H1 -> subtitle directly under it (20px) */
  --space-heading-text: 3.75rem;   /* H1 -> the content of the page (60px) */

  /* Inside text (the same on every page) */
  --space-paragraph: 0.625rem;     /* between paragraphs and list lines (10px) */
  --space-h2-text: 1.25rem;        /* H2 -> the text under it (20px) */
  --space-h3-text: 0.625rem;       /* H3 -> the text under it (10px) */
  --space-before-h2: 1.875rem;     /* text -> an H2 that follows it (30px) */
  --space-before-h3: 1.875rem;     /* text -> an H3 that follows it (30px) */
  --space-image: var(--line);      /* above AND below every image = one line of text */

  /* Between blocks */
  --space-section: 3.75rem;        /* between sections on Work and Project pages (60px) */
  --space-meta: 1.875rem;          /* project details (position, organisation) -> project text (30px) */
  --space-contact: var(--line);    /* Contact page: blurb -> email on phones; email -> social links (one line) */
  --space-stack: 1.875rem;         /* gap between the two columns once they stack on phones (30px) */
  --space-page-end: 3.75rem;       /* page content -> the "You can view my work here." line (60px) */

  /* Top and bottom of the page */
  --top: clamp(2.25rem, 1.5rem + 3vw, 4.5rem);  /* space above the page title (36px to 72px) */
  --space-footer: 3.75rem;         /* minimum space above the footer (60px) */
  --foot-pad: 1.875rem;            /* space above and below the footer text (30px) */

  /* Home page only (separate from the other pages) */
  --home-space-heading-text: 1.875rem;  /* your name -> the intro text (30px) */
  --home-space-paragraph: 0rem;         /* intro text -> email link (0 = directly underneath) */
  --home-colgap: var(--colgap);         /* text -> photo */

  /* ---------- 1c. Layout ---------- */
  --max: 65rem;                    /* widest the site gets on big screens (1040px) */
  --pad: 3.125rem;                 /* space either side of the page (50px) */
  --side: 15.625rem;               /* width of the left column on two-column pages (250px) */
  --colgap: clamp(2rem, 1rem + 4vw, 4.5rem);   /* gap between columns (32px to 72px) */
  --sticky-top: 1.5rem;            /* how far from the top of the screen sticky headings stop (24px) */
  --logo-h: 1.75rem;               /* height of your logo image in the menu (28px) */
  --cursor-size: 0.875rem;         /* the black dot cursor (14px) */
  --panel-width: 100%;             /* panel that slides in (Work projects; Resources categories on phones). 100% = whole screen, or try 85% */
  --panel-speed: 0.4s;             /* how long the panel takes to slide in and out */

  /* ---------- 1d. Resources map (desktop only) ---------- */
  --map-height: clamp(26rem, 62vh, 40rem);   /* roughly how tall the area things float in is (the map then fits itself to what's on it) */
  --map-speed: 0.7s;               /* how long each zoom takes */
  --map-float: 1.5rem;             /* how far things drift as the mouse moves (24px; 0 = still) */
  --map-thumb: 5rem;               /* width of the pictures on the map (80px) */
  --map-label: 11rem;              /* widest a resource title gets before it wraps (176px) */

  /* ---------- Colours ---------- */
  --bg: #fff;
  --ink: #000;

  color-scheme: light;
}

/* ---------- 1e. Phone settings (screens narrower than 820px = 51.25rem) ---------- */
@media (max-width: 51.25rem) {
  :root {
    --pad: 1.25rem;                /* space either side of the page (20px) */
    --top: 1.75rem;                /* space above the page title (28px) */
    --space-title-subtitle: 1rem;  /* (16px) */
    --space-heading-text: 3.75rem; /* (60px) */
    --space-h2-text: 1.25rem;      /* (20px) */
    --space-before-h2: 1.5rem;     /* (24px) */
    --space-section: 2.5rem;       /* (40px) */
    --space-stack: 1.5rem;         /* (24px) */
    --space-page-end: 2.5rem;      /* (40px) */
  }
}


/* =====================================================================
   2. BASE
   ===================================================================== */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font: 400 var(--text) / var(--lh) var(--font);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--ink); text-decoration: underline; text-underline-offset: 0.25em; }
button { font: inherit; color: inherit; }

/* Buttons that look like links ("View as a list", "Close", the map's "All resources" line, phone category names) */
.mm-crumbs button, .mm-toggle, .panel-close, .mm-cat-btn { background: none; border: 0; padding: 0; text-align: left; cursor: pointer; text-decoration: underline; text-underline-offset: 0.25em; }
[hidden] { display: none !important; }

/* Headings: H1 page titles, H2 subtitles, H3 sub-subtitles. Same Arial, regular weight. */
h1, h2, h3, p, figure, dl, dd, ul, ol, address { margin: 0; }
h1 { font: 400 var(--h1) / 1.1 var(--font); letter-spacing: -0.03em; overflow-wrap: break-word; }
h2 { font: 400 var(--h2) / 1.2 var(--font); letter-spacing: -0.02em; }
h3 { font: 400 var(--h3) / 1.3 var(--font); letter-spacing: -0.01em; }

address { font-style: normal; }
hr { border: 0; margin: var(--space-section) 0; }     /* --- in a .md file adds space, never a line */

/* Lists with no bullets (used for skills, social links) */
.plain { list-style: none; padding: 0; }

/* Images keep their own shape: landscape, portrait or square */
img { display: block; max-width: 100%; height: auto; }
.photo { width: 100%; height: auto; }
.figure figcaption { margin-top: var(--space-paragraph); }

/* ---------- Spacing inside any block of text ("flow") ----------
   Rules lower down win over rules higher up. Do not reorder. */
.flow > * + * { margin-top: var(--space-paragraph); }
.flow > figure, .flow > .photo { margin-block: var(--space-image); }
.flow > h2 + * { margin-top: var(--space-h2-text); }
.flow > h3 + * { margin-top: var(--space-h3-text); }
.flow > * + h2 { margin-top: var(--space-before-h2); }
.flow > * + h3 { margin-top: var(--space-before-h3); }
.flow > h2 + h3 { margin-top: var(--space-h2-text); }
.flow > :first-child { margin-top: 0; }
.flow > :last-child { margin-bottom: 0; }
.flow ul, .flow ol { padding-left: 1.25em; }
.flow ul.plain { padding-left: 0; }
.flow blockquote { margin-inline: 0; padding-left: 1.25em; }

/* Every page uses the same centred column. The footer sits at the bottom of short pages. */
.top, main, .foot { width: 100%; max-width: var(--max); margin-inline: auto; }
main { flex: 1 0 auto; display: flex; flex-direction: column; padding: 0 var(--pad); }
main:focus { outline: none; }
.page { padding-top: var(--top); }
.page-head { margin-bottom: var(--space-heading-text); }
.page-end { margin-top: var(--space-page-end); padding-left: calc(var(--side) + var(--colgap)); }


/* =====================================================================
   3. MENU AND FOOTER
   ===================================================================== */
.top {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.5rem;
  padding: 1.5rem var(--pad);
  font-size: var(--menu-text);
}
.top a { text-decoration: none; }
.top a:hover, .top a:focus-visible, .top a[aria-current="page"] { text-decoration: underline; text-underline-offset: 0.25em; }
.top nav { display: flex; gap: 1.75rem; }
.logo { display: block; height: var(--logo-h); width: auto; }

.menu-btn { display: none; background: none; border: 0; padding: 0.5rem 0 0.5rem 0.5rem; cursor: pointer; flex-direction: column; gap: 0.3125rem; }
.menu-btn span { display: block; width: 1.375rem; height: 1.5px; background: var(--ink); }

.foot {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  width: calc(100% - 2 * var(--pad));
  max-width: calc(var(--max) - 2 * var(--pad));
  padding: var(--foot-pad) 0;
  margin-top: var(--space-footer);
  font-size: 0.625rem;
}


/* =====================================================================
   4. PAGES
   ===================================================================== */

/* ---------- Home: text left, photo right, centred between menu and footer ---------- */
.home {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr);
  grid-template-rows: 1fr 1fr;
  grid-template-areas: "head img" "body img";
  column-gap: var(--home-colgap);
  padding-block: var(--top);
}
.home-head { grid-area: head; align-self: end; padding-bottom: calc(var(--home-space-heading-text) / 2); }
.home-body { grid-area: body; align-self: start; padding-top: calc(var(--home-space-heading-text) / 2); max-width: 44ch; }
.home-body > * + * { margin-top: var(--home-space-paragraph); }
.home > .photo { grid-area: img; align-self: center; }

/* ---------- Two columns: left column (--side) and right column ---------- */
.cols2 { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); column-gap: var(--colgap); align-items: start; }

/* ---------- About: photo left; subtitle and text right ---------- */
.about {
  display: grid;
  grid-template-columns: var(--side) minmax(0, 1fr);
  grid-template-rows: auto 1fr;
  grid-template-areas: "img sub" "img body";
  column-gap: var(--colgap);
  align-items: start;
}
.about > .photo { grid-area: img; }
.about-sub { grid-area: sub; margin-bottom: var(--space-h2-text); }
.about-body { grid-area: body; }

/* ---------- Experience ---------- */
/* nothing extra: uses .cols2 and .flow */

/* ---------- Contact ---------- */
.contact-links > * + * { margin-top: var(--space-contact); }

/* ---------- Sections: H2 in the left column, sticky beside its text (Work, Project and Resources pages) ---------- */
.sec { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); column-gap: var(--colgap); align-items: start; }
.sec + .sec { margin-top: var(--space-section); }
.sec > h2 { grid-column: 1; grid-row: 1; position: sticky; top: var(--sticky-top); }
.sec > .sec-body { grid-column: 2; grid-row: 1; min-width: 0; }
.sec > .meta { grid-column: 1; grid-row: 1; }   /* project pages: position, organisation and date in the left column */

/* ---------- Work (and the Resources list): spacing between the projects inside a section ---------- */
.work .sec-body > * + * { margin-top: var(--space-before-h3); }

/* ---------- Resources (the map itself is built by static/js/mindmap.js) ---------- */
/* Intro line under the title, with "View as a list" on the right */
.intro-row { display: flex; justify-content: space-between; align-items: baseline; gap: 0 1.5rem; margin-top: var(--space-heading-text); }
.page-intro { max-width: 44rem; }
.resources .page-head { margin-bottom: var(--space-h2-text); }   /* intro -> map (20px) */
.mm-toggle { flex: none; }

/* "Select a category to zoom in." only shows with the map */
.mm-hint { display: none; }
.mm-ready .mm-hint { display: inline; }
.mm-list-mode .mm-hint { display: none; }

/* List view (also what phones and Google see) */
.mm-list { margin-top: var(--space-section); }
.mm-list .mm-img { display: none; }                             /* no pictures in the list */
.resources .project h3 + .source { margin-top: var(--space-h3-text); }
.mm-ready .mm-list { display: none; }                           /* with the map: list hidden... */
.mm-ready.mm-list-mode .mm-list { display: block; }             /* ...until "View as a list" */
.mm-list-mode .mm, .mm-list-mode .mm-tools { display: none; }

/* The "All resources / Category" line above the map */
.mm-tools { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; min-height: var(--line); }
.mm-crumbs { display: flex; flex-wrap: wrap; gap: 0 0.5em; }

/* The map: categories and resources floating on it */
.mm { position: relative; height: var(--map-height); overflow: hidden; }
.mm-node {
  position: absolute; left: 0; top: 0;
  margin: 0; padding: 0; border: 0; background: none;
  color: var(--ink); text-align: left; cursor: pointer;
  transform-origin: center;
  will-change: transform; backface-visibility: hidden;   /* each on its own layer, so moving leaves no trails */
}
.mm-node:hover, .mm-node:focus-visible { z-index: 2; }
.mm-node.mm-off { pointer-events: none; }                        /* things that are faded out can't be clicked */
.mm-group { font-size: var(--h2); line-height: 1.2; letter-spacing: -0.02em; white-space: nowrap; }   /* categories */
.mm-item { display: flex; flex-direction: column; align-items: flex-start; gap: 0.375rem; line-height: var(--lh); text-decoration: none; }   /* resources: picture, then title */
.mm-item .mm-label { max-width: var(--map-label); }
.mm-thumb { display: block; width: var(--map-thumb); height: auto; }
.mm-group:hover .mm-label, .mm-item:hover .mm-label { text-decoration: underline; text-underline-offset: 0.25em; }

/* ---------- 404: centred between menu and footer, like the home page ---------- */
.page-center { flex: 1; display: flex; flex-direction: column; justify-content: center; padding-block: var(--top); }


/* =====================================================================
   5. EXTRAS
   ===================================================================== */

/* Cursor: black dot, becomes an outlined circle (same size) over links */
.has-cursor, .has-cursor * { cursor: none !important; }
.cursor { position: fixed; left: 0; top: 0; z-index: 9999; width: var(--cursor-size); height: var(--cursor-size); border: 1.5px solid var(--ink); border-radius: 50%; background: var(--ink); pointer-events: none; opacity: 0; transition: background-color 0.15s, opacity 0.15s; }
.cursor.on { opacity: 1; }
.cursor.hover { background: transparent; }

/* Sliding panel: Work projects (site.js) and, on phones, Resources categories (mindmap.js) */
.panel { position: fixed; inset: 0; z-index: 200; visibility: hidden; transition: visibility 0s linear var(--panel-speed); }
.panel.open { visibility: visible; transition-delay: 0s; }
.panel-shade { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.25); opacity: 0; transition: opacity var(--panel-speed); }
.panel.open .panel-shade { opacity: 1; }
.panel-sheet { position: absolute; top: 0; right: 0; bottom: 0; width: var(--panel-width); overflow-y: auto; overscroll-behavior: contain; background: var(--bg); transform: translateX(100%); transition: transform var(--panel-speed) cubic-bezier(0.22, 0.61, 0.36, 1); }
.panel.open .panel-sheet { transform: none; }
.panel-sheet:focus { outline: none; }
.panel-inner { max-width: var(--max); margin-inline: auto; padding: 0 var(--pad) var(--top); }
.panel-bar { position: sticky; top: 0; z-index: 1; display: flex; justify-content: flex-end; padding: 1.5rem 0; background: var(--bg); font-size: var(--menu-text); }
html.panel-open { overflow: hidden; }

/* Keyboard focus ring */
a:focus-visible, button:focus-visible { outline: 2px solid var(--ink); outline-offset: 0.2em; }

/* Text only for screen readers */
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* "Skip to main content" link: appears when you press Tab */
.skip-link { position: absolute; left: var(--pad); top: -5rem; z-index: 100; padding: 0.5rem 0.75rem; background: var(--bg); }
.skip-link:focus { top: 0.5rem; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .cursor, .panel, .panel-sheet, .panel-shade { transition: none; }
}


/* =====================================================================
   6. PHONE LAYOUT (screens narrower than 820px = 51.25rem)
   ===================================================================== */
@media (max-width: 51.25rem) {

  /* Menu: name on the left, button on the right. Links drop down OVER the page, aligned right. */
  .top { display: grid; grid-template-columns: 1fr auto; gap: 0 1rem; }
  .top .name { grid-column: 1; justify-self: start; }
  .menu-btn { display: flex; grid-column: 2; justify-self: end; }
  .top nav { grid-column: 1 / -1; grid-row: 2; flex-wrap: wrap; justify-content: flex-end; gap: 1rem 1.5rem; padding-top: 1rem; }       /* without JavaScript */
  .js .top nav { display: none; position: absolute; top: 100%; left: 0; right: 0; z-index: 50; flex-direction: column; align-items: flex-end; gap: 1rem; margin-inline: calc(-1 * var(--pad)); padding: 0.5rem var(--pad) 1.5rem; background: var(--bg); }
  .js .top.open nav { display: flex; }

  /* Home: title, photo, text. Everything centred between menu and footer. */
  .home { flex: 1 0 auto; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto; grid-template-areas: "head" "img" "body"; row-gap: var(--home-space-heading-text); align-content: center; }
  .home-head, .home-body { padding: 0; }

  /* Two-column pages stack. Experience shows roles first; Contact shows the blurb first. */
  .cols2 { grid-template-columns: minmax(0, 1fr); row-gap: var(--space-stack); }
  .experience .col-main { order: -1; }
  .contact { row-gap: var(--space-contact); }
  .contact .blurb { order: -1; }
  .page-end { padding-left: 0; }

  /* About: title, photo, subtitle (H2), text. The photo starts where content starts on other pages. */
  .page-head--tight { margin-bottom: var(--space-title-subtitle); }   /* project pages: details sit directly under the title */
  .about { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto; grid-template-areas: "img" "sub" "body"; row-gap: 0; }
  .about-sub { margin: var(--space-before-h2) 0 0; }       /* photo -> subtitle */
  .about-body { margin-top: var(--space-before-h2); }      /* photo -> text (when there is no subtitle) */
  .about.has-sub .about-body { margin-top: var(--space-h2-text); }   /* subtitle -> text */

  /* Work and Project pages: H2 sits above its text instead of beside it */
  .sec { display: block; }
  .sec > h2 { position: static; }
  .sec > h2 + .sec-body { margin-top: var(--space-h2-text); }
  .sec > .meta { margin-bottom: var(--space-meta); }   /* directly under the title, then a gap before the text */

  /* Resources: phones get a list of the categories; tapping one slides its resources in (like Work projects) */
  .mm-ready .mm-list { display: block; }
  .mm, .mm-tools, .mm-toggle, .mm-ready .mm-hint { display: none; }
  .mm-ready .mm-list .sec-body { display: none; }                       /* resources show in the panel instead */
  .mm-ready .mm-list .sec.mm-open .sec-body { display: block; }          /* (safety net if the panel can't load) */
  .mm-ready .mm-list .sec + .sec { margin-top: var(--space-h2-text); }  /* gap between category names (20px) */
  .mm-cat-btn { letter-spacing: inherit; text-decoration-thickness: 1px; text-underline-offset: 0.2em; }   /* category names, as links */
}
