/*
 * Site styles layered on top of Pico CSS v2 (jade theme).
 * Only layout and components Pico does not provide live here; colours come from Pico's variables
 * so light and dark themes work automatically.
 */

:root {
  /* In rem so it grows with Pico's responsive root font size (about 875px to 965px wide). */
  --site-max-width: 46rem;
  --site-timeline-dot: 0.75rem;
  /* Height of the sticky header, used so in-page links don't land underneath it.
     These are fallbacks; site.js sets the measured value. */
  --site-header-offset: 6.5rem;
  /* Body text colour captured at the root: inside links Pico redefines --pico-color as the link colour. */
  --site-text: var(--pico-color);
  /* Section-link pills: neutral on hover, accent-tinted for the current section (needs color-mix()). */
  --site-nav-hover-bg: var(--pico-muted-border-color);
  --site-nav-active-bg: var(--pico-muted-border-color);
}

@media (min-width: 1024px) {
  :root {
    --site-header-offset: 4rem;
  }
}

@supports (background: color-mix(in srgb, red 10%, transparent)) {
  :root {
    --site-nav-hover-bg: color-mix(in srgb, var(--site-text) 8%, transparent);
    --site-nav-active-bg: color-mix(in srgb, var(--pico-primary) 15%, transparent);
  }
}

/* ---------- Layout ---------- */

/* Narrower reading width than Pico's default containers (which grow to 1450px).
   Pico drops the side padding from 576px up, assuming its own max-width leaves a margin; ours is wider
   than the screen until about 830px, so keep the padding at every width (outside the content width). */
.container {
  max-width: calc(var(--site-max-width) + var(--pico-spacing) * 2);
  padding-inline: var(--pico-spacing);
}

html {
  scroll-padding-top: calc(var(--site-header-offset) + 0.5rem);
}

/* ---------- Focus ---------- */

/* Pico draws focus as a translucent box-shadow, which is invisible on nav links, too faint on
   text links, and removed entirely in Windows High Contrast mode. Use one solid outline instead. */
:is(a, button, [role="button"]):focus-visible {
  outline: 2px solid var(--pico-primary);
  outline-offset: 2px;
  box-shadow: none;
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

main > section {
  padding-block: 2.5rem;
  border-top: 1px solid var(--pico-muted-border-color);
}

main > section.hero {
  border-top: 0;
}

h2 {
  font-size: 1.5rem;
  margin-bottom: 1.5rem;
}

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

/* ---------- Icons (Font Awesome SVG sprite) ---------- */

.icon {
  width: 1em;
  height: 1em;
  fill: currentColor;
  vertical-align: -0.125em;
  /* Some Font Awesome 7 icons intentionally draw slightly outside their viewBox. */
  overflow: visible;
  flex-shrink: 0;
}

.icon-ext {
  width: 0.7em;
  height: 0.7em;
  margin-left: 0.25em;
  vertical-align: 0;
}

/* ---------- Skip link ---------- */

.skip-link {
  position: absolute;
  left: 1rem;
  top: -100%;
  z-index: 100;
  padding: 0.5rem 1rem;
  border-radius: var(--pico-border-radius);
  background: var(--pico-primary-background);
  color: var(--pico-primary-inverse);
}

.skip-link:focus {
  top: 1rem;
}

/* ---------- Header / navigation ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  /* Pico pads every top-level <header>; the inner row sets its own spacing. */
  padding-block: 0;
  background: var(--pico-background-color);
  border-bottom: 1px solid var(--pico-muted-border-color);
}

/* Small screens: name + theme toggle on the first row, section links in a second row that
   scrolls sideways. From 1024px everything sits on one row. */
.site-header .header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  column-gap: 1rem;
  padding-block: 0.5rem;
}

.site-header .brand {
  flex-shrink: 0;
  margin-right: auto;
  white-space: nowrap;
  font-weight: 700;
  color: var(--site-text);
  text-decoration: none;
  border-radius: var(--pico-border-radius);
}

.site-header .brand:hover {
  color: var(--pico-primary);
}

/* Selectors are scoped under .site-header to outrank Pico's generic `nav` rules. */
.site-header .section-nav {
  order: 3;
  flex: 1 0 100%;
  margin-inline: calc(var(--pico-spacing) * -1);
  overflow-x: auto;
  scrollbar-width: none;
  /* Fade the edges to hint that the row scrolls. */
  -webkit-mask-image: linear-gradient(to right, transparent, #000 var(--pico-spacing), #000 calc(100% - var(--pico-spacing)), transparent);
  mask-image: linear-gradient(to right, transparent, #000 var(--pico-spacing), #000 calc(100% - var(--pico-spacing)), transparent);
}

.site-header .section-nav::-webkit-scrollbar {
  display: none;
}

.site-header .section-nav ul {
  display: flex;
  gap: 0.25rem;
  width: max-content;
  margin: 0;
  /* Vertical room so the focus outline isn't clipped by the scrolling row. */
  padding: 0.375rem var(--pico-spacing);
}

.site-header .section-nav li {
  padding: 0;
}

.site-header .section-nav a {
  display: block;
  margin: 0;
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  font-size: 0.875rem;
  white-space: nowrap;
  color: var(--pico-muted-color);
  background-color: transparent;
  text-decoration: none;
}

.site-header .section-nav a:hover {
  color: var(--site-text);
  background-color: var(--site-nav-hover-bg);
}

.site-header .section-nav a[aria-current="true"] {
  /* Pico's hover shade of the accent: plain --pico-primary is 4.35:1 on the tinted pill in light
     mode (below WCAG AA 4.5:1); this is darker in light mode and lighter in dark mode. */
  color: var(--pico-primary-hover);
  background-color: var(--site-nav-active-bg);
}

@media (prefers-reduced-motion: no-preference) {
  .site-header .section-nav a,
  .site-header .brand,
  .site-header .theme-toggle {
    transition: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
  }
}

@media (min-width: 1024px) {
  .site-header .header-inner {
    flex-wrap: nowrap;
    /* Fixed value: --site-header-offset is measured from this element, so it can't drive its size. */
    min-height: 4rem;
  }

  /* If a wider system font doesn't fit, the links scroll sideways rather than squeezing the name. */
  .site-header .section-nav {
    order: 0;
    flex: 0 1 auto;
    min-width: 0;
    margin-inline: 0;
    -webkit-mask-image: none;
    mask-image: none;
  }

  .site-header .section-nav ul {
    gap: 0.125rem;
    padding-inline: 0.25rem;
  }

  .site-header .section-nav a {
    padding-inline: 0.5rem;
  }
}

/* Scoped under .site-header to outrank Pico's `nav li [type=button]` rules.
   Pico's [hidden] rule (display: none !important) still hides it until site.js runs. */
.site-header .theme-toggle {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  margin: 0;
  border: 1px solid var(--pico-muted-border-color);
  border-radius: 50%;
  background: transparent;
  /* Not var(--pico-color): inside buttons Pico points that at the (white) button text colour. */
  color: var(--pico-muted-color);
}

.site-header .theme-toggle:hover {
  border-color: var(--pico-primary);
  color: var(--pico-primary);
}

/* Show the icon of the theme you would switch to. */
.theme-toggle .icon-sun {
  display: none;
}

[data-theme="dark"] .theme-toggle .icon-sun {
  display: inline;
}

[data-theme="dark"] .theme-toggle .icon-moon {
  display: none;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun {
    display: inline;
  }

  :root:not([data-theme="light"]) .theme-toggle .icon-moon {
    display: none;
  }
}

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

.hero {
  display: grid;
  grid-template-columns: 1fr;
  justify-items: center;
  gap: 1.5rem;
  padding-top: 3rem;
  text-align: center;
}

.avatar {
  display: block;
  width: 9rem;
  height: 9rem;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 0 0 4px var(--pico-background-color), 0 0 0 6px var(--pico-primary);
}

.hero h1 {
  margin-bottom: 0.25rem;
  font-size: 2.25rem;
}

.hero .headline {
  margin-bottom: 0.25rem;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--pico-primary);
}

.hero .location {
  margin-bottom: 1rem;
  color: var(--pico-muted-color);
}

.hero .intro {
  max-width: 38rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.hero .actions {
  justify-content: center;
}

.actions [role="button"] {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

/* Keep the three hero buttons on one row on small phones. */
@media (max-width: 480px) {
  .actions [role="button"] {
    padding: 0.5rem 0.85rem;
    font-size: 0.95rem;
  }
}

@media (min-width: 768px) {
  .hero {
    grid-template-columns: auto 1fr;
    align-items: center;
    justify-items: start;
    gap: 2.5rem;
    text-align: left;
  }

  .avatar {
    width: 11rem;
    height: 11rem;
  }

  .hero .actions {
    justify-content: flex-start;
  }
}

/* ---------- Experience timeline ---------- */

.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
}

.timeline > li.job {
  position: relative;
  list-style: none;
  margin: 0;
  padding: 0 0 2rem 2rem;
  border-left: 2px solid var(--pico-muted-border-color);
}

.timeline > li.job:last-child {
  padding-bottom: 0;
  border-left-color: transparent;
}

.timeline > li.job::before {
  content: "";
  position: absolute;
  top: 0.4rem;
  left: calc(var(--site-timeline-dot) / -2 - 1px);
  width: var(--site-timeline-dot);
  height: var(--site-timeline-dot);
  border-radius: 50%;
  background: var(--pico-background-color);
  border: 2px solid var(--pico-primary);
}

.timeline > li.job:first-child::before {
  background: var(--pico-primary);
}

.job-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  column-gap: 1rem;
}

.job-head h3 {
  margin-bottom: 0.25rem;
  font-size: 1.15rem;
}

.job-meta {
  margin-bottom: 0.25rem;
  font-size: 0.875rem;
  color: var(--pico-muted-color);
}

.timeline ul {
  padding-left: 0;
}

.timeline ul li {
  list-style: none;
}

.roles {
  margin-bottom: 0.75rem;
}

.roles li {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  column-gap: 1rem;
  margin-bottom: 0.15rem;
}

.roles .role {
  font-weight: 600;
}

.roles .dates {
  font-size: 0.875rem;
  color: var(--pico-muted-color);
  font-variant-numeric: tabular-nums;
}

.points {
  margin-bottom: 0;
}

.timeline .points li {
  position: relative;
  padding-left: 1.1rem;
  margin-bottom: 0.4rem;
}

.timeline .points li::before {
  content: "";
  position: absolute;
  left: 0.15rem;
  top: 0.7em;
  width: 0.35rem;
  height: 0.35rem;
  border-radius: 50%;
  background: var(--pico-muted-color);
}

/* ---------- Skills ---------- */

.skill-groups {
  display: grid;
  gap: 1.5rem;
}

@media (min-width: 768px) {
  .skill-groups {
    grid-template-columns: 1fr 1fr;
    column-gap: 2.5rem;
  }
}

.skill-groups h3 {
  margin-bottom: 0.75rem;
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--pico-muted-color);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
}

.chips li {
  list-style: none;
  margin: 0;
  padding: 0.2rem 0.7rem;
  font-size: 0.875rem;
  border: 1px solid var(--pico-muted-border-color);
  border-radius: 999px;
  background: var(--pico-card-sectioning-background-color);
}

/* ---------- Certifications ---------- */

.cert-groups {
  display: grid;
  gap: 1rem;
  align-items: start;
}

@media (min-width: 768px) {
  .cert-groups {
    grid-template-columns: 3fr 2fr;
  }
}

.cert-groups article {
  margin-bottom: 0;
}

.cert-groups header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.cert-groups header h3,
.cert-groups header p {
  margin-bottom: 0;
}

.cert-groups header h3 {
  font-size: 1.05rem;
}

.cert-groups header p {
  font-size: 0.875rem;
  /* Muted grey fails WCAG AA on Pico's darker card-header background in dark mode. */
  color: var(--pico-color);
}

.cert-groups ul {
  margin-bottom: 0;
}

.cert-groups ul li {
  margin-bottom: 0.25rem;
}

/* ---------- Speaking & recognition ---------- */

.plain-list {
  margin: 0;
  padding: 0;
}

.plain-list li {
  display: grid;
  grid-template-columns: 3.5rem 1fr;
  gap: 1rem;
  list-style: none;
  margin-bottom: 0.6rem;
}

.plain-list .year {
  font-weight: 600;
  color: var(--pico-primary);
  font-variant-numeric: tabular-nums;
}

/* ---------- Education ---------- */

.education {
  margin-bottom: 0;
}

.education h3 {
  margin-bottom: 0.5rem;
  font-size: 1.15rem;
}

.education p {
  margin-bottom: 0.25rem;
}

/* ---------- Contact & footer ---------- */

.contact .actions {
  margin-bottom: 1rem;
}

.site-footer {
  padding-block: 2rem;
  border-top: 1px solid var(--pico-muted-border-color);
  font-size: 0.8rem;
  color: var(--pico-muted-color);
}

.site-footer p {
  margin: 0;
}

.site-footer a {
  color: inherit;
}
