/* Self-hosted variable fonts, copied from @fontsource-variable by eleventy.config.js (latin subset) */
@font-face {
  font-family: 'Fraunces';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url('/fonts/fraunces-latin-opsz-normal.woff2') format('woff2-variations');
}

@font-face {
  font-family: 'Urbanist';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url('/fonts/urbanist-latin-wght-normal.woff2') format('woff2-variations');
}

:root {
  --color-primary: #2d6a4f;
  --color-bg: #f9f9f7;
  /* Faint brand-green surface for highlighted sections */
  --color-bg-tint: color-mix(in srgb, var(--color-primary) 8%, var(--color-bg));
  --color-text: #1a1a1a;
  --color-muted: #555;
  --color-white: #fff;
  --color-overlay: rgba(0, 0, 0, 0.5);
  --color-overlay-light: rgba(0, 0, 0, 0.15);
  --color-overlay-dark: rgba(0, 0, 0, 0.6);
  --color-border-light: rgba(255, 255, 255, 0.3);
  --color-hover-light: rgba(226, 232, 206, 0.1);
  /* Translucent dark surface for frosted strips over photos */
  --color-ghost-bg: rgba(0, 0, 0, 0.25);
  --color-shadow: rgba(0, 0, 0, 0.1);
  --color-shadow-strong: rgba(0, 0, 0, 0.3);
  --shadow-card: 0 0.25rem 1rem var(--color-shadow);
  --shadow-card-strong: 0 0.25rem 1rem var(--color-shadow-strong);
  --shadow-raised: 0 0.125rem 0.5rem var(--color-shadow-strong);
  /* Cast downward only, so the fixed header floats above the content */
  --shadow-header: 0 0.125rem 0.75rem -0.125rem var(--color-shadow-strong);
  --radius-sm: 0.25rem;
  --radius-md: 0.5rem;
  --radius-pill: 2rem;
  --tap-target: 2.75rem;
  --flag-width: 1.75rem;
  --font-heading: 'Fraunces', Georgia, serif;
  --font-base: 'Urbanist', system-ui, sans-serif;
  --font-size-xs: 0.75rem;
  --font-size-small: .8rem;
  --font-size-base: 1rem;
  --font-size-title: 1.25rem;
  --font-size-heading: 1.5rem;
  --font-size-icon: 1.5rem;
  --font-size-lead: clamp(1rem, 0.9rem + 0.4vw, 1.3rem);
  --font-size-cta: clamp(1rem, 0.75rem + 0.5vw, 1.25rem);
  --font-size-hero: clamp(1rem, 5vw, 2rem);
  --space-xs: 0.2rem;
  --space-sm: 0.5rem;
  --space-gutter: 1rem;
  --space-md: 1.5rem;
  --space-lg: 3rem;
  --header-height: 3rem;
  --title-rule-width: 3rem;
  /* Shrink on short screens (landscape phones) but never collapse */
  --margin-title: clamp(var(--space-sm), 2vh, var(--space-md));
  --main-padding: clamp(var(--space-gutter), 3vh, 2rem);
  --section-padding: clamp(var(--space-gutter), 3vh, 2rem);
  /* Breakpoints: 400px, 560px, 760px, and 1011px, where the wrapper reaches its 60rem cap (60rem / 95%).
     Media queries can't read custom properties: the `sizes` attributes in layouts/home.njk and
     layouts/projects.njk repeat these values and the slide/column widths; update them together */
  --wrapper-width: min(60rem, 95%);
}

body {
  font-family: var(--font-base);
  background-color: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  padding-top: var(--header-height);
  /* Sticky footer: footer stays at the bottom on short pages */
  min-height: 100dvh;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
}

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

*,
*::before,
*::after {
  margin: 0;
  padding: 0;
}

strong {
  font-weight: bolder;
}

ul {
  list-style: none;
}

address {
  font-style: normal;
}

h1,
h2,
h3 {
  font-family: var(--font-heading);
  font-weight: 400;
  font-optical-sizing: auto;
  line-height: 1.2;
}

/* Section titles; a page title in <main> (outside the hero) looks the same */
main h1:not(.hero h1),
h2 {
  font-size: var(--font-size-heading);
  margin-bottom: var(--margin-title);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

main h1:not(.hero h1)::after,
h2::after {
  content: '';
  display: block;
  width: var(--title-rule-width);
  height: 2px;
  background-color: var(--color-primary);
}

.wrapper {
  width: var(--wrapper-width);
  margin: auto;
}

section {
  padding-block: var(--section-padding);
}

img {
  display: block;
  max-width: 100%;
}

/* Inline SVG icons from the icon shortcode: sized and coloured like the text around them */
.icon {
  display: inline-block;
  height: 1em;
  width: auto;
  overflow: visible;
  vertical-align: -0.125em;
  fill: currentColor;
}

/* Read by screen readers, not shown */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

a {
  color: var(--color-primary);
  text-decoration: none;
}

/* Underline in the link's own colour so it shows on every background; buttons keep their border */
a:not(.cta):hover {
  border-bottom: .1rem solid currentColor;
}

/* Layout */

header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background-color: var(--color-primary);
  box-shadow: var(--shadow-header);
}

header {
  color: var(--color-bg);
}

header a {
  color: inherit;
}

/* Every flex row of the header centres its items vertically */
header .wrapper,
header #navbar-right-side,
header nav,
header nav a:not(.cta),
header address,
header address a,
.lang-selector button,
.lang-selector li a {
  align-items: center;
}

header .wrapper {
  height: var(--header-height);
  display: flex;
  justify-content: space-between;
  font-size: var(--font-size-small);
}

@media (min-width: 400px) {
  header .wrapper {
    font-size: var(--font-size-base);
  }
}

header .cta {
  border: 1px solid var(--color-bg);
  padding-block: var(--space-xs);
  padding-inline: var(--space-sm);
  border-radius: var(--radius-sm);
  transition: background-color 0.2s ease, color 0.2s ease;
}

header .cta:hover,
header .cta:focus-visible {
  background-color: var(--color-bg);
  color: var(--color-primary);
}

/* Enlarge the touch area of bordered header controls without changing their look */
header .cta,
.lang-selector button {
  position: relative;
}

header .cta::after,
.lang-selector button::after {
  content: '';
  position: absolute;
  inset-block: calc((100% - var(--tap-target)) / 2);
  inset-inline: 0;
}

header #navbar-right-side {
  display: flex;
  gap: var(--space-sm);
}

header nav {
  display: flex;
  gap: var(--space-sm);
  font-style: normal;
  white-space: nowrap;
}

header nav a:not(.cta) {
  display: flex;
  min-height: var(--tap-target);
}

@media (min-width: 760px) {
  header #navbar-right-side,
  header nav {
    gap: var(--space-md);
  }
}

header address {
  display: flex;
}

header address a {
  display: flex;
  justify-content: center;
  gap: var(--space-sm);
  /* WCAG AA minimum width on the smallest phones, full touch size from 400px */
  min-width: 1.5rem;
  min-height: var(--tap-target);
  white-space: nowrap;
  color: var(--color-bg);
}

@media (min-width: 400px) {
  header address a {
    min-width: var(--tap-target);
  }
}

header address a>span {
  display: none;
}

@media (min-width: 760px) {
  header address a>span {
    display: inline-block;
  }
}

/* Language Selector */
.lang-selector button {
  anchor-name: --lang-selector;
  display: flex;
  gap: var(--space-sm);
  padding-block: var(--space-xs);
  padding-inline: var(--space-sm);
  font: inherit;
  color: inherit;
  background-color: transparent;
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-md);
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.2s ease;
}

/* Focus ring for keyboard navigation only, not after a mouse click */
.lang-selector button:focus {
  outline: none;
}

.lang-selector button:focus-visible {
  outline: 2px solid var(--color-bg);
  outline-offset: 2px;
}

.lang-selector button:hover,
.lang-selector:has(:popover-open) button {
  background-color: var(--color-overlay-light);
}

/* Flag and chevron only on the smallest phones, the language code once the header has room for it */
.lang-selector button span {
  display: none;
}

@media (min-width: 400px) {
  .lang-selector button span {
    display: inline;
  }
}

.lang-selector button .icon {
  font-size: var(--font-size-xs);
}

.lang-selector:has(:popover-open) button .icon {
  rotate: 180deg;
}

/* The hairline keeps the white stripes of the flags distinct from any background */
.lang-selector img {
  display: block;
  width: var(--flag-width);
  height: auto;
  border-radius: calc(var(--radius-sm) / 2);
  box-shadow: 0 0 0 1px var(--color-overlay-light);
}

/* The popover sits in the top layer: placed under the button, right edges aligned.
   It resets the browser's centred-dialog defaults (inset, margin, colours) */
.lang-selector ul {
  position-anchor: --lang-selector;
  position-area: bottom span-left;
  inset: auto;
  margin: var(--space-xs) 0 0;
  padding: var(--space-xs);
  list-style: none;
  color: inherit;
  background-color: var(--color-primary);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-raised);
}

/* Only when open: a display value on the closed popover would override the browser's hiding */
.lang-selector ul:popover-open {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

/* Browsers without anchor positioning: the header is fixed, so pin the list under its right edge */
@supports not (anchor-name: --lang-selector) {
  .lang-selector ul {
    position: fixed;
    top: var(--header-height);
    right: calc((100% - var(--wrapper-width)) / 2);
  }
}

.lang-selector li a {
  display: flex;
  gap: var(--space-sm);
  min-height: var(--tap-target);
  padding-inline: var(--space-sm);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

/* Background instead of the default link underline */
.lang-selector li a:hover {
  border-color: transparent;
  background-color: var(--color-hover-light);
}

/* No light fill on the current language: it would swallow the white stripes of its flag */
.lang-selector a[aria-current="page"] {
  background-color: var(--color-overlay-light);
  border-color: var(--color-border-light);
}

footer {
  background-color: var(--color-primary);
  font-size: var(--font-size-small);
  padding-block: var(--space-sm);
  color: var(--color-bg);
  text-align: center;
}

footer a {
  color: var(--color-bg);
}