/*
 * thisyearwas.com: the front page and the privacy page.
 *
 * The app's tokens (app/src/app.css): paper, ink, the grass green, the
 * sea-teal year color, the system serif and sans. Nothing is fetched from
 * anywhere else: no web fonts, no scripts but the page's own.
 */

:root {
  --paper: #f6f2ea;
  --paper-sunk: #eee8dc;
  --ink: #26231f;
  --ink-soft: #5f5950;
  --ink-faint: #857e73;
  --ink-press: #221a12;
  --rule: #e2dccf;
  --year: #2c6e69;
  --year-deep: #1f4f4b;

  --font-serif: 'Iowan Old Style', 'Palatino Linotype', Palatino, 'Book Antiqua', Georgia, serif;
  --font-sans: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;

  /* How much of each side the grass keeps once it has parted: a quarter on
     a desktop, a sliver on a phone, never into the column. */
  --keep: clamp(26px, calc((100vw - 36rem) / 2 - 1.5rem), 25vw);
  /* The mouse's lean, set by the page's script. */
  --lean: 0deg;

  color-scheme: light;
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--paper);
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 1.0625rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--year);
  text-underline-offset: 0.18em;
  text-decoration-thickness: 1px;
}

a:hover {
  color: var(--year-deep);
}

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

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ------------------------------------------------------------------ */
/* The front page: the grass, then the name.                           */

.meadow {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.bank {
  position: absolute;
  bottom: 0;
  height: 100%;
  width: auto;
  aspect-ratio: 6 / 5;
  overflow: visible;
}

/* Parted is the resting state: with no script, and with reduced motion,
   the page is simply this. */
.bank.left {
  right: calc(100% - var(--keep));
}

.bank.right {
  left: calc(100% - var(--keep));
}

.p,
.l,
.w,
.o {
  transform-box: view-box;
  transform-origin: var(--o);
}

/* The mouse leans the blades a touch, smoothly; taller ones more. */
.l {
  transform: rotate(calc(var(--lean) * var(--s)));
  transition: transform 1.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* With the script on, the grass starts closed over the page and parts half
   a second in, stepping at 12 frames a second like the app's, inner blades
   first. The breeze runs smooth, a 12 second loop with no seam. */
.js .bank.left {
  animation: part-left 1000ms step-end 500ms both;
}

.js .bank.right {
  animation: part-right 1000ms step-end 500ms both;
}

.js .p {
  animation-name: part;
  animation-duration: 1000ms;
  animation-timing-function: step-end;
  animation-fill-mode: both;
}

.js .w {
  animation: sway 3s ease-in-out infinite alternate;
}

.js .o {
  animation-name: sway;
  animation-timing-function: ease-in-out;
  animation-iteration-count: infinite;
  animation-direction: alternate;
}

/* From the rest pose outward and back: --a is signed per bank, away from
   the words. */
@keyframes sway {
  from {
    transform: none;
  }
  to {
    transform: rotate(var(--a));
  }
}

/* parting:start */
@keyframes part {
  0% { transform: rotate(calc(var(--c) * 1)); }
  8.33% { transform: rotate(calc(var(--c) * 0.99)); }
  16.67% { transform: rotate(calc(var(--c) * 0.95)); }
  25% { transform: rotate(calc(var(--c) * 0.86)); }
  33.33% { transform: rotate(calc(var(--c) * 0.7)); }
  41.67% { transform: rotate(calc(var(--c) * 0.47)); }
  50% { transform: rotate(calc(var(--c) * 0.29)); }
  58.33% { transform: rotate(calc(var(--c) * 0.17)); }
  66.67% { transform: rotate(calc(var(--c) * 0.1)); }
  75% { transform: rotate(calc(var(--c) * 0.05)); }
  83.33% { transform: rotate(calc(var(--c) * 0.02)); }
  91.67% { transform: rotate(calc(var(--c) * 0)); }
  100% { transform: rotate(calc(var(--c) * 0)); }
}

@keyframes part-left {
  0% { right: calc(50% * 1 + (100% - var(--keep)) * 0); }
  8.33% { right: calc(50% * 0.99 + (100% - var(--keep)) * 0.01); }
  16.67% { right: calc(50% * 0.95 + (100% - var(--keep)) * 0.05); }
  25% { right: calc(50% * 0.86 + (100% - var(--keep)) * 0.14); }
  33.33% { right: calc(50% * 0.7 + (100% - var(--keep)) * 0.3); }
  41.67% { right: calc(50% * 0.47 + (100% - var(--keep)) * 0.53); }
  50% { right: calc(50% * 0.29 + (100% - var(--keep)) * 0.71); }
  58.33% { right: calc(50% * 0.17 + (100% - var(--keep)) * 0.83); }
  66.67% { right: calc(50% * 0.1 + (100% - var(--keep)) * 0.9); }
  75% { right: calc(50% * 0.05 + (100% - var(--keep)) * 0.95); }
  83.33% { right: calc(50% * 0.02 + (100% - var(--keep)) * 0.98); }
  91.67% { right: calc(50% * 0 + (100% - var(--keep)) * 1); }
  100% { right: calc(50% * 0 + (100% - var(--keep)) * 1); }
}

@keyframes part-right {
  0% { left: calc(50% * 1 + (100% - var(--keep)) * 0); }
  8.33% { left: calc(50% * 0.99 + (100% - var(--keep)) * 0.01); }
  16.67% { left: calc(50% * 0.95 + (100% - var(--keep)) * 0.05); }
  25% { left: calc(50% * 0.86 + (100% - var(--keep)) * 0.14); }
  33.33% { left: calc(50% * 0.7 + (100% - var(--keep)) * 0.3); }
  41.67% { left: calc(50% * 0.47 + (100% - var(--keep)) * 0.53); }
  50% { left: calc(50% * 0.29 + (100% - var(--keep)) * 0.71); }
  58.33% { left: calc(50% * 0.17 + (100% - var(--keep)) * 0.83); }
  66.67% { left: calc(50% * 0.1 + (100% - var(--keep)) * 0.9); }
  75% { left: calc(50% * 0.05 + (100% - var(--keep)) * 0.95); }
  83.33% { left: calc(50% * 0.02 + (100% - var(--keep)) * 0.98); }
  91.67% { left: calc(50% * 0 + (100% - var(--keep)) * 1); }
  100% { left: calc(50% * 0 + (100% - var(--keep)) * 1); }
}
/* parting:end */

.door {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 0;
  padding: 3rem calc(var(--keep) + 1.25rem) 2.5rem;
  text-align: center;
}

.door h1 {
  margin: 0 0 1.75rem;
  line-height: 0;
}

.door h1 svg {
  display: block;
  width: min(26rem, 100%);
  height: auto;
  fill: var(--ink-press);
  overflow: visible;
}

.pitch {
  max-width: 28rem;
  margin: 0 0 1.5rem;
  font-family: var(--font-serif);
  font-size: clamp(1.1875rem, 1rem + 0.8vw, 1.4375rem);
  line-height: 1.4;
  color: var(--ink);
}

.soon {
  margin: 0 0 2.75rem;
  font-size: 1rem;
  color: var(--ink-soft);
}

.door .small {
  margin: 0;
  font-size: 0.875rem;
  color: var(--ink-faint);
}

/* The words come forward once the grass has parted, on the same 12 fps steps. */
.js .enter {
  animation: forward 500ms step-end both;
  animation-delay: var(--at);
}

@keyframes forward {
  0% { opacity: 0; transform: translateY(10px); }
  16.67% { opacity: 0.55; transform: translateY(4.5px); }
  33.33% { opacity: 0.8; transform: translateY(2px); }
  50% { opacity: 0.91; transform: translateY(0.9px); }
  66.67% { opacity: 0.97; transform: translateY(0.3px); }
  83.33% { opacity: 0.99; transform: none; }
  100% { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .js .bank,
  .js .p,
  .js .w,
  .js .o,
  .js .enter {
    animation: none;
  }

  .l {
    transition: none;
    transform: none;
  }
}

/* ------------------------------------------------------------------ */
/* The privacy page: one column of plain reading.                      */

.page {
  max-width: 38rem;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
}

.page header {
  margin-bottom: 3rem;
}

.page header a {
  display: inline-block;
}

.page header svg {
  display: block;
  width: 11rem;
  height: auto;
  fill: var(--ink-press);
}

.page h1,
.page h2 {
  font-family: var(--font-serif);
  font-weight: 400;
  color: var(--ink);
  line-height: 1.2;
}

.page h1 {
  margin: 0 0 0.5rem;
  font-size: clamp(1.875rem, 1.4rem + 2.2vw, 2.5rem);
}

.page h2 {
  margin: 2.5rem 0 0.75rem;
  font-size: 1.375rem;
}

.page p,
.page li {
  max-width: 34rem;
}

.page ul {
  padding-left: 1.2rem;
}

.page li {
  margin-bottom: 0.75rem;
}

.page li::marker {
  color: var(--ink-faint);
}

.updated {
  margin: 0 0 2rem;
  font-size: 0.875rem;
  color: var(--ink-faint);
}

.lede {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  line-height: 1.45;
}

.page footer {
  margin-top: 3.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
  font-size: 0.875rem;
  color: var(--ink-faint);
}

.page footer p {
  margin: 0.25rem 0;
}
