/* issue 3: a villain's commonplace book. One cream page in a dark
   room, and the room takes the mood of whatever is read aloud —
   rose for the loves, absinthe for the hates. */

:root {
  --page: #f7f0e2;
  --page-edge: #d8cbb2;
  --ink: #2b241c;
  --love: #b3125e;
  --hate: #66821a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Crimson Pro', serif;
  font-size: 19px;
  color: var(--ink);
  background: radial-gradient(120% 100% at 50% 0%, #201b16 0%, #151110 55%, #0c0a09 100%) fixed;
  --accent: #8a7c6a;
}

body.love {
  --accent: var(--love);
}

body.hate {
  --accent: var(--hate);
}

/* the room's mood: two tint layers crossfading behind the page */
.atmo {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0;
  transition: opacity 1.2s ease;
}

.atmo-love {
  background: radial-gradient(70% 55% at 50% 30%, rgba(179, 18, 94, 0.3), transparent 72%);
}

.atmo-hate {
  background: radial-gradient(70% 55% at 50% 30%, rgba(122, 156, 31, 0.26), transparent 72%);
}

body.love .atmo-love,
body.hate .atmo-hate {
  opacity: 1;
}

::selection {
  background: var(--ink);
  color: var(--page);
}

/* ---- the page ---------------------------------------------------- */

.page {
  position: relative;
  z-index: 1;
  width: min(42rem, 92%);
  margin: 4rem auto 0;
  padding: 3.2rem 3.4rem 2.8rem;
  background: linear-gradient(180deg, #f9f3e6 0%, var(--page) 60%, #f0e7d3 100%);
  border: 1px solid var(--page-edge);
  outline: 1px solid var(--page-edge);
  outline-offset: 6px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6), 0 4px 12px rgba(0, 0, 0, 0.4);
}

/* ---- bookplate --------------------------------------------------- */

header {
  text-align: center;
  padding-bottom: 1.4rem;
  border-bottom: 1px solid var(--page-edge);
  margin-bottom: 1.6rem;
}

h1 {
  margin: 0 0 0.5rem;
  font-size: 1.5rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.32em;
  text-indent: 0.32em; /* recenter: letter-spacing trails the last glyph */
}

.tagline {
  margin: 0;
  font-style: italic;
  font-size: 1rem;
  color: rgba(43, 36, 28, 0.65);
}

h2 {
  margin: 0 0 1.6rem;
  text-align: center;
  font-size: 1.15rem;
  font-weight: 400;
  font-variant: small-caps;
  letter-spacing: 0.12em;
  color: rgba(43, 36, 28, 0.8);
}

.orn {
  color: var(--accent);
  transition: color 0.9s ease;
  padding: 0 0.4em;
}

/* ---- the passage ------------------------------------------------- */

#lovehate {
  font-size: 1.32rem;
  line-height: 1.55;
}

#lovehate:empty {
  display: none;
}

#lovehate.fresh {
  animation: bloom 0.8s ease-out;
}

@keyframes bloom {
  0% {
    opacity: 0;
    filter: blur(6px);
  }
  100% {
    opacity: 1;
    filter: blur(0);
  }
}

#lovehate p {
  margin: 0 0 1em;
}

#lovehate p:first-child::first-letter {
  float: left;
  font-size: 3.1em;
  line-height: 0.82;
  padding: 0.06em 0.09em 0 0;
  font-weight: 600;
  color: var(--accent);
  transition: color 0.9s ease;
}

#lovehate .love {
  color: var(--love);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

#lovehate .hate {
  color: var(--hate);
  font-weight: 600;
  text-decoration: underline wavy;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

.fin {
  text-align: center;
  font-size: 1.4rem;
  margin: 1.2rem 0 0.4rem;
  color: var(--accent);
  transition: color 0.9s ease;
}

/* ---- the ask ----------------------------------------------------- */

.center {
  text-align: center;
}

#download {
  display: inline-block;
  margin: 1.4rem auto 0;
}

#download input[type='submit'] {
  appearance: none;
  font-family: 'Crimson Pro', serif;
  font-size: 1.2rem;
  font-variant: small-caps;
  letter-spacing: 0.1em;
  color: var(--accent);
  background: transparent;
  border: 1px dotted var(--accent);
  padding: 0.4em 1.8em;
  cursor: pointer;
  transition: color 0.9s ease, border-color 0.9s ease, background 0.25s ease;
}

#download input[type='submit']:hover,
#download input[type='submit']:focus-visible {
  background: var(--accent);
  color: var(--page);
  border-style: solid;
  outline: none;
}

#download input[type='submit']:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* ---- colophon ---------------------------------------------------- */

footer {
  position: relative;
  z-index: 1;
  margin: 2.6rem 0 3rem;
  text-align: center;
  font-style: italic;
  font-size: 1rem;
  color: #9a8c76;
}

footer a {
  color: inherit;
}

footer a:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

/* ---- small screens ----------------------------------------------- */

@media only screen and (max-width: 480px) {
  .page {
    margin-top: 2rem;
    padding: 2rem 1.4rem 1.8rem;
  }

  h1 {
    font-size: 1.15rem;
    letter-spacing: 0.2em;
    text-indent: 0.2em;
  }

  #lovehate {
    font-size: 1.2rem;
  }
}

/* ---- decency ----------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  #lovehate.fresh {
    animation: none;
  }

  .atmo,
  .orn,
  .fin,
  #lovehate p:first-child::first-letter,
  #download input[type='submit'] {
    transition: none;
  }
}
