/* Scraps of real paper patched together, set like an old archive:
   Garamond for the words, a typewriter for the labels, rubber-stamp buttons. */

:root {
  --ink: #2a2521;
  --muted: #6e665d;
  --red: #a8382a;      /* stamp ink */
  --rule: #c9d4de;
  --sticky: #efe2a8;
  --serif: 'EB Garamond', 'Iowan Old Style', Garamond, Georgia, serif;
  --type: 'Courier Prime', 'Courier New', ui-monospace, monospace;
  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0 24px;
  color: var(--ink);
  /* patchwork.webp tiles seamlessly; swap it for a scan of your own scraps */
  /* with a light wash over it so the small type stays readable */
  background:
    linear-gradient(rgba(247, 242, 231, 0.25), rgba(247, 242, 231, 0.25)),
    #efe7d6 url(/paper/patchwork.webp) center top / 1536px 900px repeat;
  font: 20px/1.45 var(--serif);
}

/* the other backgrounds, picked with BACKGROUND in wrangler.toml */
body.bg-woodchip { background: #ede8de url(/paper/bg-woodchip.webp) 0 0 / 600px repeat; }
body.bg-concrete { background: #e2e0db url(/paper/bg-concrete.webp) 0 0 / 900px repeat; }
body.bg-parchment { background: #f2e6ce url(/paper/bg-parchment.webp) 0 0 / 960px repeat; }
body.bg-drawing { background: #f4f0e8 url(/paper/bg-drawing.webp) 0 0 / 700px repeat; }
body.bg-watercolour { background: #f3eee4 url(/paper/bg-watercolour.webp) 0 0 / 520px repeat; }

a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--red); }

/* tape poking out past a petal never makes the page scroll sideways */
main { max-width: 1100px; margin: 0 auto; overflow-x: clip; overflow-clip-margin: 16px; }
.narrow { max-width: 640px; }

/* typewritten labels */
.masthead, .label, .days, .countdown, .author, .divider, label, legend,
.contents .no, .contents small, footer, button {
  font-family: var(--type);
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

/* ---- header & footer ---- */

.masthead {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  max-width: 1100px;
  margin: 0 auto;
  padding: 18px 0;
  font-size: 13px;
}
.masthead .site { text-decoration: none; font-weight: 700; }
.masthead .tagline { margin: 6px 0 0; font-size: 11px; line-height: 1.7; color: var(--muted); }

footer {
  max-width: 640px;
  margin: 72px auto 40px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}
.designed { margin: 28px 0 0; }
.credits { margin-top: 18px; text-transform: none; letter-spacing: 0.02em; font-size: 11px; }

/* ---- the word ---- */

.word-block { text-align: center; margin: 28px auto 0; }

.label { margin: 0; font-size: 13px; color: var(--muted); }

.word {
  margin: 6px 0 4px;
  font-weight: 400;
  line-height: 0.95;
  letter-spacing: -0.01em;
  /* short words go huge, long ones shrink to fit */
  font-size: clamp(52px, calc(200vw / (var(--letters) + 3)), 190px);
  overflow-wrap: anywhere;
}

.definition {
  max-width: 32em;
  margin: 10px auto 0;
  color: var(--muted);
  font-size: 19px;
  line-height: 1.35;
}
.definition i { color: var(--ink); }

.by { margin: 10px 0 0; color: var(--muted); font-style: italic; font-size: 18px; }

/* ---- the snail race ---- */

.race {
  --snail: 178px;
  max-width: 860px;
  margin: 34px auto 0;
}

.track {
  position: relative;
  height: 76px;
  border-bottom: 1px dashed var(--muted);
  overflow: hidden;
}

/* --p is how far through the week we are (0 to 1), --left the seconds to go. */
.snail {
  position: absolute;
  bottom: 0;
  width: var(--snail);
  left: calc(var(--p) * 100%);
  transform: translateX(calc(var(--p) * -100%));
  animation: crawl var(--left) linear forwards;
}
@keyframes crawl {
  to { left: 100%; transform: translateX(-100%); }
}

/* slime trail */
.snail::before {
  content: '';
  position: absolute;
  right: 95%;
  bottom: 1px;
  width: 2000px;
  border-bottom: 3px dotted rgba(110, 130, 150, 0.4);
}

.snail pre {
  margin: 0;
  font: 13px/1.15 var(--type);
  color: var(--ink);
}
.snail pre:first-child { animation: frame-a 1.8s step-end infinite; }
.snail pre + pre {
  position: absolute;
  left: 0;
  bottom: 0;
  visibility: hidden;
  animation: frame-b 1.8s step-end infinite;
}
@keyframes frame-a { 0% { visibility: visible; } 50% { visibility: hidden; } }
@keyframes frame-b { 0% { visibility: hidden; } 50% { visibility: visible; } }

.days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  margin: 6px calc(var(--snail) / 2) 0;
  padding: 0;
  list-style: none;
  font-size: 11px;
  color: var(--muted);
  text-align: center;
}
.days .today { color: var(--red); font-weight: 700; }

.countdown { margin: 10px 0 0; text-align: center; font-size: 12px; }

/* ---- the wall of poems ---- */

.wall {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-start;
  gap: 44px 36px;
  margin: 52px auto;
}

.empty { margin: 48px 0; text-align: center; color: var(--muted); font-style: italic; }

/* paper grows to fit the poem's longest line, so lines rarely have to wrap */
.poem {
  position: relative;
  width: fit-content;
  min-width: min(270px, 100%);
  max-width: min(520px, 100%);
  transform: rotate(var(--tilt));
  filter: drop-shadow(0 8px 7px rgba(50, 35, 10, 0.22));
}
.poem:target { animation: pinned 0.7s ease-out; }
@keyframes pinned {
  from { transform: rotate(var(--tilt)) scale(1.12); }
}

.sheet {
  position: relative;
  padding: 24px 24px 20px;
  color: var(--ink);
  font-size: 19px;
  line-height: 1.4;
}
.sheet h3 {
  margin: 0 0 8px;
  font: italic 500 22px/1.15 var(--serif);
}
/* The poem exactly as typed (see poemLines in pages.js): spaces, indents and
   blank lines are the poet's. The only spacing the page adds is the hanging
   indent on a line that's too long and has to wrap. */
.lines {
  margin: 0;
  white-space: pre-wrap;
  tab-size: 4;
  overflow-wrap: anywhere;
}
.line { display: block; padding-left: 1.5em; text-indent: -1.5em; }
.author {
  margin: 14px 0 0;
  text-align: right;
  font-size: 11px;
  color: var(--muted);
}
.author::before { content: '— '; }

mark {
  background: none;
  color: inherit;
  text-decoration: underline 1.5px var(--red);
  text-underline-offset: 3px;
}

/* sticky note: faded pastel paper (from a real note's grain), its bottom
   curling off the wall. The picture has room for its shadow on the right and
   at the bottom, so the words sit in from there. */
.poem.sticky { filter: none; }
.sticky .sheet {
  min-height: 250px;
  /* fixed sizes, not %: a % padding stops the note growing to fit the poem's longest line */
  padding: 24px 46px 64px 24px;
  background: url(/paper/sticky-yellow.webp) center / 100% 100% no-repeat;
}
.sticky.tint-1 .sheet { background-image: url(/paper/sticky-pink.webp); }
.sticky.tint-2 .sheet { background-image: url(/paper/sticky-blue.webp); }
.sticky.tint-3 .sheet { background-image: url(/paper/sticky-green.webp); }

/* crumpled paper, smoothed back out */
.crumpled .sheet {
  padding: 32px 30px 28px;
  background: #f6f3ec url(/paper/crumpled.webp) center / 560px;
  clip-path: polygon(
    0 2%, 9% 0, 22% 1.5%, 37% 0, 52% 1%, 68% 0, 83% 1.8%, 100% 0,
    99% 14%, 100% 31%, 98.5% 48%, 100% 66%, 99% 83%, 100% 100%,
    86% 98.5%, 70% 100%, 54% 98.2%, 38% 100%, 21% 98.6%, 6% 100%, 0 99%,
    1.2% 81%, 0 63%, 1.5% 45%, 0 27%, 1% 12%
  );
}

/* a real pressed flower taped onto a card, like a herbarium sheet */
.flower .sheet {
  padding: 20px 24px 22px;
  background: #f5efdf url(/paper/grain.webp) 0 0 / 512px 300px;
  background-blend-mode: multiply;
}
.specimen {
  position: relative;
  display: block;
  width: fit-content;
  margin: 0 auto 16px;
  transform: rotate(calc(var(--tilt) * -3));
}
.specimen img { display: block; max-width: 100%; max-height: 190px; }
/* what holds a crumpled note or a flower card to the page: a piece of tape
   over its top edge, or an old paperclip (picked in pages.js) */
.pin { z-index: 2; }
.tape.pin { height: 24px; }
.clip {
  position: absolute;
  z-index: 2;
  top: -24px;
  height: 74px;
  transform: rotate(var(--turn));
  pointer-events: none;
}

/* pieces of tape sticking the flowers down (placed in pages.js) */
.tape {
  position: absolute;
  width: auto;
  max-width: none;
  transform: translate(-50%, -50%) rotate(var(--turn));
  opacity: 0.92;
  filter: drop-shadow(0 1px 1px rgba(50, 35, 15, 0.22));
  pointer-events: none;
}
.specimen .tape { height: 19px; }


/* damp spots, dried into tea-coloured rings */
/* real dried drops, cut from a scan of old paper */
.damp:is(.sticky, .crumpled, .flower) .sheet::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--stain) no-repeat var(--at) / var(--size) auto;
  mix-blend-mode: multiply;
  opacity: 0.85;
  pointer-events: none;
}
.damp-1 { --stain: url(/paper/stain-1.png); --at: 88% 10%; --size: 120px; }
.damp-2 { --stain: url(/paper/stain-2.png); --at: 6% 92%; --size: 96px; }
.damp-3 { --stain: url(/paper/stain-3.png); --at: 96% 78%; --size: 140px; }
.damp-4 { --stain: url(/paper/stain-4.png); --at: 78% 30%; --size: 46px; }

/* pressed petals and leaves (which one is picked in pages.js), two ways: */
/* leave room either side for the tape sticking out past the petal's edge */
.petal { width: min(var(--width), 100% - 64px); }

/* 1. "strips": each line on its own little strip of paper, cut close round
   the words, so the flower shows everywhere else. The strips follow the
   lines exactly: no staggering, so any indent is the poet's. */
.petal.strips { display: grid; place-items: center; }
.petal.strips .bloom {
  position: relative;
  grid-area: 1 / 1;
  width: 100%;
  aspect-ratio: var(--ratio);
  background: var(--petal) center / contain no-repeat;
  transform: rotate(var(--spin));
  container-type: inline-size;
}
.bloom .tape, .petal.direct .tape { height: 8.5cqw; }
.petal.strips .sheet {
  grid-area: 1 / 1;
  color: #1c140d;
  width: fit-content;
  max-width: 92%;
  padding: 0 0 0 7px;
  font-size: 17px;
  line-height: 1.55;
  transform: rotate(calc(var(--tilt) * -1.2));
}
/* old sellotape: see-through and yellowed, so the petal shows through it,
   with a pale wash under it to keep the words readable */
.petal.strips .text,
.petal.strips h3,
.petal.strips .author {
  padding: 2px 7px 1px;
  background:
    url(/paper/tape.png) var(--tape-at, 0) 0 / 480px 100%,
    rgba(252, 248, 236, 0.66);
  box-shadow: 0 0.5px 1px rgba(40, 25, 10, 0.18);
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}
.petal.strips .line:nth-child(odd) .text { --tape-at: -170px; }
.petal.strips .line:nth-child(3n) .text { --tape-at: -310px; }
.petal.strips .text { margin-left: -7px; }
.petal.strips h3 { display: table; margin: 0 0 6px -7px; font-size: 19px; }
.petal.strips .author { display: table; margin: 8px 0 0 auto; padding: 3px 7px 2px; font-size: 10px; }

/* 2. "direct": written straight onto the petal, with a soft glow of paper
   colour behind the letters so it reads on dark and light petals alike */
.petal.direct .sheet {
  /* the poem's block sits in the middle of the petal, its lines left as typed */
  display: grid;
  align-content: center;
  justify-content: center;
  aspect-ratio: var(--ratio);
  padding: var(--pad);
  background: var(--petal) center / 100% 100% no-repeat;
  color: #1f1610;
  font-size: 19px;
  font-weight: 500;
  text-shadow: 0 0 1px #fff8ec, 0 0 4px #fff8ec, 0 0 9px rgba(255, 248, 236, 0.95), 0 0 18px rgba(255, 248, 236, 0.75);
}
.petal.direct .author { margin-top: 8px; color: #1f1610; font-weight: 700; }
.petal.direct .sheet { position: relative; container-type: inline-size; }
.petal.direct .sheet > :not(.tape) { position: relative; }

/* ---- earlier weeks ---- */

.divider {
  display: flex;
  align-items: center;
  gap: 18px;
  max-width: 640px;
  margin: 88px auto 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 400;
}
.divider::before,
.divider::after { content: ''; flex: 1; border-top: 1px solid rgba(42, 37, 33, 0.3); }

.past-week { margin-top: 48px; }
.word.past { font-size: clamp(44px, calc(110vw / (var(--letters) + 3)), 96px); }
.word.past a { text-decoration: none; }

.more { text-align: center; font: 12px var(--type); text-transform: uppercase; letter-spacing: 0.14em; }

/* ---- forms ---- */

.write { max-width: 560px; margin: 72px auto 0; }

h2, .page-title {
  margin: 24px 0 14px;
  font: 400 40px/1.1 var(--serif);
}

label { display: block; margin: 0 0 18px; font-size: 12px; color: var(--muted); }
label small { font-size: 1em; opacity: 0.8; }

input, select, textarea {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 2px 4px;
  font: 20px var(--serif);
  color: var(--ink);
  letter-spacing: normal;
  text-transform: none;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--muted);
  border-radius: 0;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--red); }

/* lines inside the box that scroll with the writing */
textarea {
  padding: 0 12px;
  tab-size: 4;
  line-height: 32px;
  border: 1px solid var(--muted);
  background: repeating-linear-gradient(transparent 0 31px, var(--rule) 31px 32px) local, rgba(251, 249, 243, 0.88);
  resize: vertical;
}

fieldset { margin: 0 0 20px; padding: 0; border: 0; }
legend { padding: 0; font-size: 12px; color: var(--muted); }

.choice {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 6px 18px 4px 0;
  font: 19px var(--serif);
  color: var(--ink);
  letter-spacing: normal;
  text-transform: none;
}
.choice input { display: inline; width: auto; margin: 0; accent-color: var(--red); }

.swatch {
  display: inline-block;
  width: 24px;
  height: 24px;
  background: center / 100% 100% no-repeat;
}
.swatch.sticky { background-image: url(/paper/sticky-yellow.webp); }
.swatch.crumpled { background: #eee8da url(/paper/crumpled.webp) center / 400%; background-blend-mode: multiply; }
.swatch.flower { background: url(/flowers/yellow-pansy.webp) center / contain no-repeat; }
.swatch.petal { background: url(/petals/poppy.webp) center / contain no-repeat; }
.swatch.any { border: 1px dashed var(--muted); border-radius: 50%; }

/* buttons are red rubber stamps */
button {
  padding: 10px 18px 9px;
  color: var(--red);
  background: transparent;
  border: 2px solid currentColor;
  outline: 1px solid currentColor;
  outline-offset: 2px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
button:hover { color: #fbf6ec; background: var(--red); }

/* honeypot: hidden from people, bots fill it in */
.hp { position: absolute; left: -9999px; }

.error, .notice { padding: 0 4px; }
.error { color: var(--red); }
.notice { background: linear-gradient(transparent 55%, var(--sticky) 55%); }

/* ---- pick page & archive ---- */

.status { padding-left: 1.1em; }
.status li { margin-bottom: 8px; }

.card { margin: 16px 0 40px; }
.card .choice { display: flex; }

/* notes from the contact page */
.note { margin: 0 0 22px; padding-bottom: 14px; border-bottom: 1px solid rgba(42, 37, 33, 0.15); }
.note p { margin: 0; }
.note .from { font: 12px var(--type); text-transform: uppercase; letter-spacing: 0.14em; color: var(--muted); }
.note .reply { margin-top: 2px; font: 14px var(--type); color: var(--muted); }
.note .said { margin: 8px 0 4px; white-space: pre-wrap; }

.sign-out { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 56px; }

/* the archive is an index */
.contents { margin: 0; padding: 0; list-style: none; border-top: 1px solid rgba(42, 37, 33, 0.3); }
.contents li { padding: 12px 0; border-bottom: 1px solid rgba(42, 37, 33, 0.15); }
.contents a { display: block; text-decoration: none; }
.contents .row { display: flex; align-items: baseline; gap: 14px; margin-top: 2px; }
.contents .no { font-size: 12px; color: var(--muted); }
.contents .w { font-size: 34px; line-height: 1; }
.contents .dots { flex: 1; border-bottom: 1px dotted var(--muted); }
.contents small { font-size: 11px; color: var(--muted); }

code { font: 15px var(--type); }

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

@media (max-width: 600px) {
  body { padding: 0 16px; font-size: 19px; }
  .masthead { font-size: 11px; }
  .race { --snail: 130px; }
  .snail pre { font-size: 9.5px; }
  .days { font-size: 9px; letter-spacing: 0.06em; }
  .wall { gap: 36px; }
  .contents .w { font-size: 26px; }
}

@media (prefers-reduced-motion: reduce) {
  .snail pre:first-child, .snail pre + pre, .poem:target { animation: none; }
}
