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

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

body {
  /* Fluid side gutter: 20px on phones, growing to 40px on wide screens */
  --gutter: clamp(1.25rem, 0.5rem + 3.5vw, 2.5rem);

  margin: 0;
  /* max() keeps content clear of notches and rounded corners in landscape */
  padding: 0 max(var(--gutter), env(safe-area-inset-right))
    max(clamp(3rem, 2rem + 5vw, 5rem), env(safe-area-inset-bottom))
    max(var(--gutter), env(safe-area-inset-left));
  background: #fff;
  color: #111;
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  font-size: clamp(1.0625rem, 1rem + 0.3vw, 1.1875rem);
  line-height: 1.7;
  text-align: center;
  -webkit-font-smoothing: antialiased;
}

header {
  padding: clamp(2rem, 1.25rem + 4vw, 4rem) 0 clamp(1.5rem, 1rem + 2.5vw, 2.75rem);
}

h1 {
  margin: 0;
  font-size: clamp(1.75rem, 1.4rem + 1.8vw, 2.5rem);
  font-weight: 400;
  line-height: 1.2;
  letter-spacing: 0.04em;
}

main {
  max-width: 56rem;
  margin: 0 auto;
}

.photo {
  display: block;
  /* Fills the column, but never grows taller than the screen, so the whole
     photo stays visible on a phone held sideways (or with a portrait photo) */
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 85vh;
  max-height: 85svh;
  margin: 0 auto;
}

p {
  max-width: 34rem;
  margin: clamp(1.75rem, 1.25rem + 2.5vw, 2.75rem) auto 0;
  text-wrap: pretty;
}

.email {
  margin-top: 0.5rem;
  /* Never let a long address push the page wider than the screen */
  overflow-wrap: anywhere;
}

/* Open book seen straight from above. The image is the flat two-page spread;
   everything that makes it read as a book is drawn around and over it. */
.spreads {
  display: grid;
  gap: clamp(2.5rem, 1.5rem + 5vw, 5rem);
  justify-items: center;
  margin-top: clamp(2.5rem, 1.5rem + 5vw, 5rem);
}

.spread {
  --edge: clamp(2px, 0.6vw, 5px); /* visible thickness of the page block */

  position: relative;
  width: 100%;
  max-width: 48rem;
  margin: 0;
  /* Stacked page edges showing on the left and right of the top pages */
  padding: 0 var(--edge);
  background: repeating-linear-gradient(to right, #fff 0 1px, #d9d9d9 1px 2px);
  box-shadow:
    0 0 0 1px #e4dcb8, /* hairline of the cream cover underneath */
    0 1px 2px rgba(0, 0, 0, 0.12),
    0 1.25rem 2.5rem -1rem rgba(0, 0, 0, 0.28);
}

.spread img {
  display: block;
  width: 100%;
  height: auto;
}

/* Shading of the pages as they curve down into the glued spine */
.spread::after {
  content: "";
  position: absolute;
  inset: 0 var(--edge);
  pointer-events: none;
  background:
    /* the crease itself */
    linear-gradient(
      to right,
      transparent calc(50% - 1px),
      rgba(0, 0, 0, 0.22) 50%,
      transparent calc(50% + 1px)
    ),
    /* pages falling into the gutter */
    linear-gradient(
      to right,
      rgba(0, 0, 0, 0.03) 0%,
      transparent 4%,
      transparent 38%,
      rgba(0, 0, 0, 0.05) 45%,
      rgba(0, 0, 0, 0.2) 50%,
      rgba(0, 0, 0, 0.07) 53%,
      transparent 62%,
      transparent 96%,
      rgba(0, 0, 0, 0.03) 100%
    );
}

a {
  color: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.25em;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0.08);
}

.email a {
  /* Comfortable touch target (about 48px tall) without changing the look */
  display: inline-block;
  padding: 0.75rem 0.5rem;
}

a:hover {
  text-decoration-thickness: 2px;
}

a:focus-visible {
  outline: 2px solid #111;
  outline-offset: 2px;
}
