/* Shared theme for evanapplegate.com (main page, design files, map gifts, 404)
   and the blog. Loaded after each page's own layout CSS: change the look here. */

:root {
  --bg-color: #fefaf6;
  --bg-image: url(../img/background.webp);
  /* Background lags the page by this fraction of the scroll. 0 turns it off. */
  --parallax: 0.15;
  /* Optima only ships on Apple devices; everyone else (Windows, Android) gets EB Garamond,
     served from assets/fonts (see the @font-face rules at the end of this file). */
  --font: Optima, 'EB Garamond', Georgia, serif;
  --accent-color: #6e5950;
}
/* phones draw the texture about 390px wide, so they get a 1200px copy of it (94KB instead of 451KB) */
@media (max-width: 767px) {
  :root {
    --bg-image: url(../img/background-1200.webp);
  }
}

html {
  background-color: var(--bg-color);
}
body {
  position: relative;
  min-height: 100vh;
  background: none;
  font-family: var(--font);
}
h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: inherit;
}
a {
  color: var(--accent-color);
  text-decoration-thickness: 1px;
  text-decoration-color: #d1ccc1;
  /* 1px lower than Optima's own underline position (0.075em below the baseline) */
  text-underline-offset: calc(0.075em + 1px);
  transition: color 0.1s;
}
a:hover {
  color: #8c7a73;
}

/* Background image sits on its own layer behind the page so it can drift */
body::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--bg-image) top left / 100% auto repeat;
  image-rendering: pixelated;
  pointer-events: none;
}
@media (prefers-reduced-motion: no-preference) {
  @supports (animation-timeline: scroll()) {
    body::before {
      animation: bg-parallax 1ms linear both;
      animation-timeline: scroll(root block);
    }
  }
}
/* 100% is the page height, so the layer ends up shifted by --parallax x scroll distance */
@keyframes bg-parallax {
  from {
    transform: translateY(calc(var(--parallax) * (100vh - 100%)));
  }
  to {
    transform: translateY(0);
  }
}

/* Audio player (assets/js/audio-player.js builds it from a plain <audio controls>).
   Same box as the form fields; the seek line echoes the link underlines. */
.audio-player {
  display: flex;
  align-items: center;
  gap: 12px;
  box-sizing: border-box;
  min-height: 50px;
  padding: 10px 15px;
  border: 1px solid #d0cbc1;
  border-radius: 5px;
  background-color: #f9f9f8;
  font-size: 14px;
}
.audio-player__toggle {
  flex: none;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  margin: 0 -6px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent-color);
  cursor: pointer;
  transition: color 0.1s;
}
.audio-player__toggle:hover {
  color: #8c7a73;
}
.audio-player__toggle svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
}
.audio-player__pause,
.audio-player.is-playing .audio-player__play {
  display: none;
}
.audio-player.is-playing .audio-player__pause {
  display: block;
}
.audio-player__time {
  flex: none;
  min-width: 2.2em;
  text-align: center;
}
.audio-player__seek {
  --progress: 0%;
  flex: 1;
  min-width: 0;
  height: 20px;
  margin: 0;
  padding: 0;
  background: none;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}
.audio-player__seek::-webkit-slider-runnable-track {
  height: 1px;
  background: linear-gradient(to right, var(--accent-color) var(--progress), #d1ccc1 var(--progress));
}
.audio-player__seek::-moz-range-track {
  height: 1px;
  background: #d1ccc1;
}
.audio-player__seek::-moz-range-progress {
  height: 1px;
  background: var(--accent-color);
}
.audio-player__seek::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 9px;
  height: 9px;
  margin-top: -4px;
  border-radius: 50%;
  background: var(--accent-color);
}
.audio-player__seek::-moz-range-thumb {
  width: 9px;
  height: 9px;
  border: 0;
  border-radius: 50%;
  background: var(--accent-color);
}
.audio-player__toggle:focus-visible,
.audio-player__seek:focus-visible {
  outline: 1px solid var(--accent-color);
  outline-offset: 3px;
}

/* Contact form states (Formspree AJAX toggles data-fs-active / aria-*) */
[data-fs-success],
[data-fs-error] {
  display: none;
}
[data-fs-success][data-fs-active],
[data-fs-error][data-fs-active] {
  display: block;
}
/* "Thanks" message in the body text colour instead of Dorik's green */
.success-message {
  color: #696464;
}
span[data-fs-error] {
  color: #ff3a28;
  font-size: 12px;
  margin: -6px 0 10px;
}
[data-fs-field][aria-invalid='true'] {
  border-color: #ff3a28 !important;
}
#contact-form .form-control {
  box-sizing: border-box;
}
#contact-form button[type='submit'] {
  cursor: pointer;
}
#contact-form button[disabled] {
  opacity: 0.7;
  cursor: default;
}
#contact-form[aria-busy='true'] button[type='submit']::after {
  content: '';
  display: inline-block;
  width: 0.8em;
  height: 0.8em;
  margin-left: 8px;
  vertical-align: -0.1em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: fs-spin 0.7s linear infinite;
}
@keyframes fs-spin {
  to {
    transform: rotate(360deg);
  }
}

/* Phones: keep long bare URLs and deeply nested outlines on screen */
@media (max-width: 767px) {
  body {
    overflow-wrap: break-word;
  }
  :is(ul, ol) :is(ul, ol) {
    padding-left: 18px;
  }
  :is(ul, ol) :is(ul, ol) :is(ul, ol) :is(ul, ol) :is(ul, ol) :is(ul, ol) {
    padding-left: 8px;
  }
}

/* EB Garamond (SIL Open Font License), weights 400-800, regular and italic.
   Browsers only download the files they need, and none at all where Optima is installed. */
@font-face {
  font-family: 'EB Garamond';
  font-style: italic;
  font-weight: 400 800;
  font-display: swap;
  src: url(../fonts/eb-garamond-italic-cyrillic-ext.woff2) format('woff2');
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
@font-face {
  font-family: 'EB Garamond';
  font-style: italic;
  font-weight: 400 800;
  font-display: swap;
  src: url(../fonts/eb-garamond-italic-cyrillic.woff2) format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'EB Garamond';
  font-style: italic;
  font-weight: 400 800;
  font-display: swap;
  src: url(../fonts/eb-garamond-italic-greek-ext.woff2) format('woff2');
  unicode-range: U+1F00-1FFF;
}
@font-face {
  font-family: 'EB Garamond';
  font-style: italic;
  font-weight: 400 800;
  font-display: swap;
  src: url(../fonts/eb-garamond-italic-greek.woff2) format('woff2');
  unicode-range: U+0370-0377, U+037A-037F, U+0384-038A, U+038C, U+038E-03A1, U+03A3-03FF;
}
@font-face {
  font-family: 'EB Garamond';
  font-style: italic;
  font-weight: 400 800;
  font-display: swap;
  src: url(../fonts/eb-garamond-italic-vietnamese.woff2) format('woff2');
  unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}
@font-face {
  font-family: 'EB Garamond';
  font-style: italic;
  font-weight: 400 800;
  font-display: swap;
  src: url(../fonts/eb-garamond-italic-latin-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'EB Garamond';
  font-style: italic;
  font-weight: 400 800;
  font-display: swap;
  src: url(../fonts/eb-garamond-italic-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'EB Garamond';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url(../fonts/eb-garamond-normal-cyrillic-ext.woff2) format('woff2');
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
@font-face {
  font-family: 'EB Garamond';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url(../fonts/eb-garamond-normal-cyrillic.woff2) format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'EB Garamond';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url(../fonts/eb-garamond-normal-greek-ext.woff2) format('woff2');
  unicode-range: U+1F00-1FFF;
}
@font-face {
  font-family: 'EB Garamond';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url(../fonts/eb-garamond-normal-greek.woff2) format('woff2');
  unicode-range: U+0370-0377, U+037A-037F, U+0384-038A, U+038C, U+038E-03A1, U+03A3-03FF;
}
@font-face {
  font-family: 'EB Garamond';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url(../fonts/eb-garamond-normal-vietnamese.woff2) format('woff2');
  unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}
@font-face {
  font-family: 'EB Garamond';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url(../fonts/eb-garamond-normal-latin-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'EB Garamond';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url(../fonts/eb-garamond-normal-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
