/* Confession Note — paper notes pinned to a plaster wall. */

:root {
  --wall: #cfc3b0;
  --ink: #2b2622;
  --ink-soft: #5d544b;
  --pin: #c8402f;
  --hand: 'Caveat', 'Bradley Hand', 'Segoe Print', cursive;
  --type: 'Special Elite', 'Courier New', monospace;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  padding: 0 20px 60px;
  color: var(--ink);
  font-family: var(--type);
  background-color: var(--wall);
  /* plaster grain, then a soft light from above */
  background-image:
    radial-gradient(ellipse at 50% -10%, rgba(255, 250, 240, .55), transparent 60%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .25  0 0 0 0 .2  0 0 0 0 .15  0 0 0 .38 0'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)'/%3E%3C/svg%3E");
  background-attachment: fixed, scroll;
}

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

/* ---------- heading ---------- */

.top { text-align: center; padding: 44px 0 26px; }
.top h1 {
  margin: 0 0 10px;
  font-family: var(--hand); font-weight: 700;
  font-size: clamp(3rem, 9vw, 5rem); line-height: 1;
  transform: rotate(-1.5deg);
}
.top p { margin: 0; font-size: 1.05rem; line-height: 1.6; color: var(--ink-soft); }

/* ---------- a note ---------- */

.note {
  position: relative;
  padding: 30px 22px 16px;
  background: var(--paper);
  border-radius: 2px 2px 3px 14px / 2px 2px 3px 6px;
  box-shadow: 0 1px 1px rgba(0, 0, 0, .16), 0 10px 18px -8px rgba(40, 25, 10, .5);
  transform: rotate(var(--tilt, 0deg));
  opacity: var(--fade, 1);
  filter: sepia(var(--sepia, 0));
  transition: opacity .25s, transform .25s, filter .25s;
}
/* the pin */
.note::before {
  content: '';
  position: absolute; top: 8px; left: 50%;
  width: 16px; height: 16px; margin-left: -8px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff8 0 18%, var(--pin) 22% 100%);
  box-shadow: 1px 3px 3px rgba(0, 0, 0, .4);
}

.c0 { --paper: #fdf1a8; }
.c1 { --paper: #fbcfd6; }
.c2 { --paper: #cfe4f6; }
.c3 { --paper: #d5edc4; }
.c4 { --paper: #faf7f0; }
.p1 { --pin: #2f6fc8; }
.p2 { --pin: #2f9a57; }
.p3 { --pin: #e0a21b; }

.note p.words {
  margin: 0 0 14px;
  font-family: var(--hand); font-weight: 500;
  font-size: 1.7rem; line-height: 1.18;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.note .when {
  display: flex; justify-content: space-between; gap: 10px;
  font-size: .78rem; color: var(--ink-soft);
}

/* a faded note comes back while you read it */
.wall .note:hover, .wall .note:focus {
  opacity: 1; filter: none; outline: none; z-index: 2;
  transform: rotate(0deg) scale(1.03);
}

.note.fresh { animation: drop .5s cubic-bezier(.2, 1.3, .5, 1); }
@keyframes drop {
  from { opacity: 0; transform: translateY(-30px) rotate(calc(var(--tilt, 0deg) - 6deg)) scale(1.12); }
}

/* ---------- the wall ---------- */

.wall {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 34px 30px;
  align-items: start;
  max-width: 1240px; margin: 0 auto;
}

.empty {
  max-width: 420px; margin: 30px auto 0; text-align: center;
  font-size: 1.05rem; line-height: 1.6; color: var(--ink-soft);
}

/* ---------- writing a note ---------- */

.compose {
  display: block;
  max-width: 440px; margin: 0 auto 50px;
  --tilt: -1deg;
}
.compose textarea {
  display: block; width: 100%; min-height: 150px; resize: vertical;
  padding: 0; border: 0; background: transparent; color: var(--ink);
  font-family: var(--hand); font-weight: 500; font-size: 1.8rem; line-height: 1.18;
}
.compose textarea::placeholder { color: rgba(43, 38, 34, .45); }
.compose textarea:focus { outline: none; }
.compose:focus-within { box-shadow: 0 1px 1px rgba(0, 0, 0, .16), 0 16px 26px -8px rgba(40, 25, 10, .6); }

.row {
  display: flex; align-items: center; gap: 12px;
  margin-top: 12px; padding-top: 12px;
  border-top: 1px dashed rgba(43, 38, 34, .3);
}
.papers { display: flex; gap: 8px; margin: 0; padding: 0; border: 0; }
.papers label { cursor: pointer; }
.papers input { position: absolute; opacity: 0; pointer-events: none; }
.swatch {
  display: block; width: 28px; height: 28px; border-radius: 50%;
  background: var(--paper);
  border: 2px solid rgba(43, 38, 34, .35);
}
.papers input:checked + .swatch { border-color: var(--ink); box-shadow: 0 0 0 2px var(--paper), 0 0 0 4px var(--ink); }
.papers input:focus-visible + .swatch { outline: 3px solid #2f6fc8; outline-offset: 3px; }

.count { margin-left: auto; font-size: .85rem; color: var(--ink-soft); }
.count.low { color: #b3261e; }

button {
  padding: 10px 18px; border: 0; border-radius: 4px; cursor: pointer;
  background: var(--ink); color: #fdf8ee;
  font-family: var(--type); font-size: 1rem; letter-spacing: .03em;
}
button:hover { background: #000; }
button:focus-visible { outline: 3px solid #2f6fc8; outline-offset: 3px; }
button:disabled { opacity: .5; cursor: default; }

.msg { min-height: 1.2em; margin: 10px 0 0; font-size: .85rem; color: #b3261e; }
.msg.ok { color: #2c6e3f; }

/* ---------- foot ---------- */

.foot {
  max-width: 520px; margin: 70px auto 0; text-align: center;
  font-size: .82rem; line-height: 1.6; color: var(--ink-soft);
}
.foot p { margin: 0; }

@media (max-width: 560px) {
  body { padding: 0 14px 50px; }
  .top { padding-top: 30px; }
  .top p br { display: none; }
  .wall { grid-template-columns: 1fr; gap: 26px; max-width: 400px; }
  .row { flex-wrap: wrap; }
}

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