:root {
  --midnight: #101b44;
  --midnight-raised: #1a2a5e;
  --parchment: #efe4c8;
  --parchment-raised: #f7f0de;
  --gold: #e2bf62;
  --gold-deep: #7a5a0e;

  --font: Georgia, "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", "Times New Roman", serif;
  --measure: 34rem;
  --gutter: clamp(1rem, 4vw, 2.5rem);
  --radius: 0.5rem;

  /* Dark is the default theme. */
  color-scheme: dark;
  --bg: var(--midnight);
  --raised: var(--midnight-raised);
  --text: var(--parchment);
  --muted: #bdb497;
  --accent: var(--gold);
  --line: rgb(239 228 200 / 0.22);
  --control-line: #6b7699;
  --tree: var(--parchment);
  --shadow: 0 1rem 2.5rem rgb(4 8 26 / 0.55);
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: var(--parchment);
  --raised: var(--parchment-raised);
  --text: var(--midnight);
  --muted: #4a5378;
  --accent: var(--gold-deep);
  --line: rgb(16 27 68 / 0.2);
  --control-line: #8c8163;
  --tree: var(--midnight);
  --shadow: 0 1rem 2.5rem rgb(70 52 12 / 0.18);
}

/* ---------- Base ---------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  background: var(--bg);
  color: var(--text);
  font: 400 1.125rem/1.65 var(--font);
  font-kerning: normal;
  text-rendering: optimizeLegibility;
}

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

a {
  color: inherit;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

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

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

h1 {
  margin: 0 0 1.25rem;
  font-size: clamp(2rem, 1.5rem + 2vw, 3rem);
  font-weight: 400;
  line-height: 1.1;
}

p {
  margin: 0 0 1.1em;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 100;
  padding: 0.5rem 0.9rem;
  background: var(--raised);
  color: var(--text);
  border-radius: var(--radius);
  translate: 0 -200%;
}

.skip-link:focus {
  translate: 0 0;
}

/* ---------- Masthead ---------- */

.masthead {
  padding: 1rem var(--gutter) 0;
}

.masthead--home {
  display: grid;
  justify-items: center;
  gap: 0.6rem;
  padding-top: 1.25rem;
}

.masthead__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  max-width: 72rem;
  margin-inline: auto;
}

.brand {
  display: block;
  border-radius: var(--radius);
}

/* ---------- Light/dark switch ---------- */

.theme-switch {
  display: inline-block;
  margin: 0;
  padding: 0.4rem;
  border: 0;
  border-radius: 999px;
  background: none;
  color: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.theme-switch__track {
  position: relative;
  display: block;
  width: 3.6rem;
  height: 1.9rem;
  border: 1px solid var(--control-line);
  border-radius: 999px;
  background: var(--raised);
}

.theme-switch__thumb {
  position: absolute;
  top: calc(0.2rem - 1px);
  left: calc(0.2rem - 1px);
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background: var(--accent);
}

.theme-switch[aria-checked="true"] .theme-switch__thumb {
  translate: 1.7rem 0;
}

.theme-switch__icon {
  position: absolute;
  top: 50%;
  width: 0.95rem;
  height: 0.95rem;
  translate: 0 -50%;
  color: var(--muted);
}

.theme-switch__icon--sun {
  left: calc(0.475rem - 1px);
}

.theme-switch__icon--moon {
  right: calc(0.475rem - 1px);
}

.theme-switch[aria-checked="true"] .theme-switch__icon--moon,
.theme-switch[aria-checked="false"] .theme-switch__icon--sun {
  color: var(--bg);
}

.theme-switch:hover .theme-switch__track {
  border-color: var(--accent);
}

/* Without JavaScript the switch can't do anything, so hide it. */
html:not(.js) .theme-switch {
  visibility: hidden;
}

/* ---------- Navigation ---------- */

.nav__list {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: clamp(1.5rem, 7vw, 3.75rem);
  margin: 0;
  padding: 0;
  list-style: none;
}

.nav__link {
  display: flex;
  align-items: center;
  gap: 0.3em;
  padding: 0.55rem 0.1rem;
  color: var(--text);
  font-size: 1.1875rem;
  line-height: 1.4;
  text-decoration: none;
  cursor: pointer;
}

.nav__link:hover,
.menu[open] > .nav__link {
  color: var(--accent);
}

.nav__link[aria-current="page"],
.menu.is-current > .nav__link {
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.35em;
}

/* Metal menu (a native <details>, enhanced by site.js) */

.menu {
  position: relative;
}

.menu > summary {
  list-style: none;
}

.menu > summary::-webkit-details-marker {
  display: none;
}

.menu__chevron {
  width: 0.7em;
  height: 0.7em;
  margin-top: 0.1em;
}

.menu[open] .menu__chevron {
  rotate: 180deg;
}

.menu__list {
  position: absolute;
  z-index: 10;
  top: calc(100% + 0.35rem);
  left: 50%;
  translate: -50% 0;
  min-width: 13rem;
  margin: 0;
  padding: 0.4rem;
  list-style: none;
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* Invisible bridge so the pointer can cross the gap without the menu closing. */
.menu__list::before {
  content: "";
  position: absolute;
  inset: -0.5rem 0 100%;
}

.menu__list a {
  display: block;
  padding: 0.5rem 0.85rem;
  border-radius: calc(var(--radius) - 0.15rem);
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}

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

.menu__list a[aria-current="page"] {
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-underline-offset: 0.3em;
}

/* ---------- Emblem: the crown over the tree ---------- */

.emblem {
  display: grid;
  justify-items: center;
}

.emblem__crown {
  display: block;
  width: 56%;
  aspect-ratio: 2 / 1;
}

.emblem__tree {
  display: block;
  width: 100%;
  aspect-ratio: 1480 / 1009;
  background: var(--tree);
  -webkit-mask: url("/assets/img/tree.webp") center / contain no-repeat;
  mask: url("/assets/img/tree.webp") center / contain no-repeat;
}

/* Flat crown for browsers without JavaScript or WebGL. */
html:not(.js) .emblem__crown,
.emblem__crown.is-fallback {
  background: url("/assets/img/crown.svg") center / 84% auto no-repeat;
}

/* As wide as the screen allows, while the menu, emblem and name still fit in one screen. */
.emblem--hero {
  width: max(14rem, min(88vw, 46rem, calc((100vh - 20rem) * 1.05)));
  width: max(14rem, min(88vw, 46rem, calc((100svh - 20rem) * 1.05)));
}

.emblem--hero .emblem__crown {
  margin-bottom: -1%;
}

.emblem--mark {
  width: clamp(4.75rem, 3.5rem + 4vw, 6.5rem);
}

.emblem--mark .emblem__crown {
  width: 62%;
}

/* ---------- Home ---------- */

/* The emblem sits in the space below the menu, a little above center. */
.home {
  display: grid;
  grid-template-rows: auto 1fr;
}

.hero {
  display: grid;
  justify-items: center;
  align-content: center;
  padding: clamp(1rem, 4vh, 2.75rem) var(--gutter) clamp(2rem, 8vh, 5rem);
}

.wordmark {
  margin: 0.35em 0 0;
  font-size: clamp(2.25rem, 1.4rem + 3.6vw, 4rem);
  font-weight: 400;
  line-height: 1.05;
  letter-spacing: 0.01em;
  text-align: center;
}

/* ---------- Inner pages ---------- */

.page {
  max-width: 72rem;
  margin: 0 auto;
  padding: clamp(2rem, 6vh, 4rem) var(--gutter) 5rem;
}

.prose {
  max-width: var(--measure);
}

.page--prose .prose {
  margin-inline: auto;
}

.prose a:hover {
  text-decoration-color: currentColor;
}

.product {
  display: grid;
  gap: clamp(1.75rem, 4vw, 4rem);
  align-items: center;
}

.product__image {
  width: 100%;
  border-radius: var(--radius);
}

@media (min-width: 54rem) {
  .product {
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  }
}

/* ---------- Motion ---------- */

@media (prefers-reduced-motion: no-preference) {
  .theme-switch__thumb {
    transition: translate 0.25s ease;
  }

  .menu__chevron {
    transition: rotate 0.2s ease;
  }

  .menu[open] .menu__list {
    transition: opacity 0.15s ease, translate 0.15s ease;
  }

  @starting-style {
    .menu[open] .menu__list {
      opacity: 0;
      translate: -50% -0.3rem;
    }
  }

  .emblem__crown.is-ready {
    animation: crown-in 0.7s ease-out;
  }

  @keyframes crown-in {
    from {
      opacity: 0;
    }
  }
}
