:root {
  --bg: #ffffff;
  --text: #1a1a1a;
  --muted: #5f5f5f;
  --accent: #2563eb;
  --border: #e5e5e5;
  --card-bg: #f8f8f8;
  --danger-bg: #fdeceb;
  --danger-text: #b3261e;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111317;
    --text: #f2f2f2;
    --muted: #a0a0a0;
    --accent: #60a5fa;
    --border: #2a2d33;
    --card-bg: #1a1c20;
    --danger-bg: #3a1f1d;
    --danger-text: #f5a8a2;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  /* Safety net: something (a wide table, a long unbreakable string) can
     always end up a few pixels wider than the viewport on a phone. Rather
     than letting that stretch the whole page sideways, clip it at the body
     level — anything that genuinely needs to scroll horizontally (like a
     wide table) gets its own scroll container instead, see .table-scroll. */
  overflow-x: hidden;
  /* Keeps the footer at the bottom of the window on short pages: the page is at least a
     screen tall and the footer takes any spare space above it. On long pages nothing changes,
     the footer simply follows the content. */
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
/* In a column flex layout an auto-margined block shrinks to its content, so say so explicitly. */
main.container { flex: 1 0 auto; width: 100%; box-sizing: border-box; }
.site-footer { margin-top: auto; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.container {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 24px;
}

/* A wide table (lots of columns, or long unbroken content like an email
   address) won't fit a phone screen no matter how it's laid out — rather
   than letting it stretch the whole page sideways (see body's
   overflow-x: hidden above), it scrolls within its own box instead, so
   the rest of the page stays put. */
.table-scroll { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

nav {
  border-bottom: 1px solid var(--border);
  padding: 20px 0;
}

nav .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

nav a {
  color: var(--text);
  text-decoration: none;
  margin-left: 24px;
  font-size: 14px;
}

nav a.brand {
  margin-left: 0;
  font-weight: 600;
  font-size: 15px;
}

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

.nav-right { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.nav-links { display: flex; align-items: center; }
/* Separates the site's own pages from the account/login area, so it doesn't
   read as just one long undifferentiated row of links. */
.nav-divider { width: 1px; height: 18px; background: var(--border); flex: 0 0 auto; }
.nav-login-btn { margin-left: 0; padding: 8px 16px; font-size: 13px; }
/* Overrides the generic "nav a:hover { color: var(--accent) }" rule, which
   otherwise turned this button's white text the same blue as its own
   background on hover — same colour, invisible text. */
.nav-login-btn:hover { color: #fff; }

.nav-account { position: relative; display: inline-block; }
.nav-account-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--card-bg); border: 1px solid var(--border); border-radius: 6px;
  color: var(--text); font: inherit; font-size: 14px;
  cursor: pointer; padding: 6px 12px;
}
.nav-account-btn:hover { border-color: var(--accent); color: var(--accent); }
.nav-account-menu {
  /* Sits flush against the button (no margin-gap) so there's no dead pixel
     strip for the mouse to fall through on the way down to it — that gap
     used to make the menu vanish if you approached it at an angle. The
     visual breathing room is recreated with padding-top instead, which is
     still part of the menu's own hoverable box. */
  display: none; position: absolute; right: 0; top: 100%; margin-top: 0;
  background: var(--card-bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 14px 6px 6px; min-width: 120px; box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15); z-index: 30;
}
.nav-account:focus-within .nav-account-menu,
.nav-account.hover-show .nav-account-menu,
.nav-account.pinned .nav-account-menu {
  display: block;
}
.nav-account-menu a, .nav-account-menu button {
  display: block; width: 100%; text-align: left; background: none; border: none;
  color: var(--text); font-size: 13px; padding: 6px 8px; margin: 0; cursor: pointer;
  text-decoration: none; border-radius: 4px; font-family: inherit;
}
.nav-account-menu a:hover, .nav-account-menu button:hover { background: var(--bg); color: var(--accent); }

.nav-toggle { display: none; }

/* On a phone the whole nav collapses to one slim bar — brand on the left,
   a hamburger on the right — and the links plus the account area open as a
   panel beneath it only when asked for, instead of permanently taking up
   the top third of the screen. */
@media (max-width: 640px) {
  nav { padding: 10px 0; position: relative; }
  nav .container { flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0; }
  .nav-toggle {
    display: inline-flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; margin-right: -8px;
    background: none; border: none; color: var(--text); cursor: pointer; border-radius: 8px;
  }
  .nav-toggle svg { width: 24px; height: 24px; }
  .nav-right {
    display: none; width: 100%; flex-direction: column; align-items: stretch; gap: 0;
    margin-top: 8px; padding-top: 6px; border-top: 1px solid var(--border);
  }
  nav.open .nav-right { display: flex; }
  .nav-links { flex-direction: column; align-items: stretch; }
  .nav-links a, .nav-right > a { margin-left: 0; padding: 12px 4px; font-size: 16px; border-bottom: 1px solid var(--border); }
  .nav-divider { display: none; }
  .nav-right > .nav-login-btn { margin: 12px 0 4px; text-align: center; border-bottom: none; padding: 11px 16px; font-size: 15px; }
  /* The account dropdown has no hover on a touch screen — list its entries
     straight into the panel instead of hiding them behind another tap. */
  .nav-account { display: block; }
  .nav-account-btn { display: none; }
  .nav-account-menu {
    display: block; position: static; box-shadow: none; border: none; background: none;
    padding: 0; min-width: 0;
  }
  .nav-account-menu a, .nav-account-menu button {
    margin: 0; padding: 12px 4px; font-size: 16px; border-radius: 0; border-bottom: 1px solid var(--border);
  }
}

/* Space below the last thing on every page. This has to be main.container, not
   just main: .container sets its own padding and, being a class, beat the plain
   "main" rule that used to be here, so most pages had no bottom space at all.
   The footer (partials/footer.ejs) supplies most of the space below the content;
   on phones it also clears the browser's floating address bar. */
main.container { padding-bottom: 40px; }
.site-footer { padding: 24px 0 120px; font-size: 13px; color: var(--muted); text-align: center; }
.site-footer p { margin: 0; }
@media (max-width: 640px) {
  main.container { padding-bottom: 32px; }
  .site-footer { padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px)); }
}

h1 { font-size: 32px; margin: 0 0 8px; }
h2 { font-size: 22px; margin: 40px 0 16px; }
h3 { font-size: 17px; margin: 0 0 6px; }

.tagline {
  color: var(--muted);
  font-size: 18px;
  margin: 0 0 32px;
}

.contact-line {
  margin: 0 0 32px;
  font-size: 15px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.contact-line a {
  color: var(--accent); text-decoration: none;
  display: inline-flex; align-items: center; gap: 6px;
}
.contact-line a:hover { text-decoration: underline; }
.contact-line a svg { width: 16px; height: 16px; flex: 0 0 auto; }
.contact-line .dot { color: var(--muted); }

.bio { margin-bottom: 40px; max-width: 60ch; }

.card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 16px;
  background: var(--card-bg);
}

.card p { margin: 0 0 10px; color: var(--muted); font-size: 15px; }
.card .tags { font-size: 13px; color: var(--muted); }

.links a {
  color: var(--accent);
  text-decoration: none;
  font-size: 14px;
  margin-right: 16px;
}
.links a:hover { text-decoration: underline; }

.btn {
  display: inline-block;
  padding: 10px 18px;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  font-size: 14px;
}

ul.plain { list-style: none; padding: 0; margin: 0; }
ul.plain li { margin-bottom: 8px; }

.entries { display: flex; flex-direction: column; gap: 12px; }

.entry {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 20px;
  background: var(--card-bg);
}

.entry-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

/* flex-basis 0 with flex-grow makes long titles wrap onto their own extra
   line rather than pushing the date onto a separate, badly-aligned one */
.entry-header h3 { margin: 0; flex: 1 1 0; min-width: 0; }

.entry-date {
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  flex: 0 0 auto;
}

.entry-sub {
  color: var(--muted);
  font-size: 14px;
  font-style: italic;
  margin: 2px 0 10px;
}

.entry-details {
  margin: 0;
  padding-left: 18px;
  font-size: 14px;
}
.entry-details li { margin-bottom: 4px; }
.entry-details li:last-child { margin-bottom: 0; }

.skills-group { margin-bottom: 20px; }
.skills-group h3 { font-size: 15px; color: var(--muted); font-weight: 500; margin-bottom: 8px; }

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.photo-grid .placeholder {
  aspect-ratio: 1;
  background: var(--card-bg);
  border: 1px dashed var(--border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  padding: 12px;
}

.note {
  font-size: 13px;
  color: var(--muted);
  margin-top: 24px;
}
