/* Remembering Ben
   Visual idea: things sent by post. Envelope stock, postal ink, franking marks.
   ------------------------------------------------------------------------- */

:root {
  --paper:      #ece5d8;
  --card:       #fbf8f2;
  --ink:        #22304c;
  --ink-soft:   #5f6b80;
  --postmark:   #9e2b36;
  --airmail:    #2f5d8a;
  --kraft:      #c6b49a;
  --gum:        #e0d3ba;

  --measure: 34rem;
  --step--1: 0.875rem;
  --step-0:  1.0625rem;
  --step-1:  1.375rem;
  --step-2:  1.9rem;
  --step-3:  2.9rem;
  --step-4:  clamp(3.2rem, 12vw, 5.75rem);
}

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

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 var(--step-0)/1.65 Karla, system-ui, sans-serif;
  padding: 0 1.25rem 4rem;
}

/* Faint airmail striping down the left edge of wide screens. */
@media (min-width: 60rem) {
  body::before {
    content: "";
    position: fixed;
    inset: 0 auto 0 0;
    width: 10px;
    background: repeating-linear-gradient(
      -45deg,
      var(--airmail) 0 7px,
      transparent 7px 14px,
      var(--postmark) 14px 21px,
      transparent 21px 28px
    );
    opacity: 0.5;
    pointer-events: none;
  }
}

h1, h2, h3 {
  font-family: Fraunces, Georgia, serif;
  font-weight: 600;
  font-variation-settings: "SOFT" 40, "WONK" 1;
  line-height: 1.1;
  margin: 0 0 0.6em;
  letter-spacing: -0.015em;
}

p { margin: 0 0 1.1em; max-width: var(--measure); }

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

:focus-visible {
  outline: 3px solid var(--postmark);
  outline-offset: 3px;
}

.wrap { max-width: 62rem; margin: 0 auto; }

/* ------------------------------------------------------------------ nav */

.sitenav { border-bottom: 1px solid var(--kraft); margin: 0 auto 3rem; max-width: 62rem; }
.sitenav ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.75rem;
  list-style: none;
  margin: 0;
  padding: 1.5rem 0 1.1rem;
}
.sitenav a {
  color: var(--ink-soft);
  text-decoration: none;
  font-weight: 500;
}
.sitenav a:hover { color: var(--ink); }
.sitenav a.on {
  color: var(--ink);
  box-shadow: inset 0 -2px var(--postmark);
}

/* ----------------------------------------------------------------- hero */

.hero { max-width: 62rem; margin: 0 auto 4.5rem; }

.hero-name {
  font-size: var(--step-4);
  margin: 0;
  font-variation-settings: "SOFT" 60, "WONK" 1, "opsz" 144;
}
.hero-dates {
  font-family: Fraunces, Georgia, serif;
  font-style: italic;
  color: var(--ink-soft);
  font-size: var(--step-1);
  margin: 0.2em 0 1.6em;
}
.hero-intro { font-size: var(--step-1); line-height: 1.5; max-width: 30rem; }

/* A snapshot stuck down with tape. */
.snapshot {
  position: relative;
  background: var(--card);
  padding: 0.75rem;
  box-shadow: 0 1px 0 var(--kraft), 0 14px 28px -18px rgba(34, 48, 76, 0.55);
  transform: rotate(-1.1deg);
  max-width: 26rem;
}
.snapshot img { display: block; width: 100%; height: auto; }
.snapshot figcaption {
  margin: 0.85rem 0.15rem 0.35rem;
  font-family: Fraunces, Georgia, serif;
  font-style: italic;
  color: var(--ink-soft);
  font-size: var(--step--1);
  line-height: 1.35;
}
.snapshot::before {
  content: "";
  position: absolute;
  top: -0.7rem;
  left: 50%;
  translate: -50% 0;
  width: 6.5rem;
  height: 1.5rem;
  background: rgba(224, 211, 186, 0.75);
  border-left: 1px solid rgba(198, 180, 154, 0.9);
  border-right: 1px solid rgba(198, 180, 154, 0.9);
  rotate: -1.5deg;
}
.snapshot .placeholder {
  display: grid;
  place-items: center;
  aspect-ratio: 4 / 3;
  border: 1px dashed var(--kraft);
  color: var(--ink-soft);
  font-size: var(--step--1);
  text-align: center;
  padding: 1.5rem;
}

@media (min-width: 48rem) {
  .hero {
    display: grid;
    grid-template-columns: 1.15fr 1fr;
    gap: 3.5rem;
    align-items: start;
  }
}

/* -------------------------------------------------------------- postmark */

.postmark {
  display: inline-grid;
  place-items: center;
  width: 6.5rem;
  height: 6.5rem;
  border: 2px solid var(--postmark);
  border-radius: 50%;
  color: var(--postmark);
  font-family: Fraunces, Georgia, serif;
  font-size: var(--step--1);
  line-height: 1.2;
  text-align: center;
  rotate: -8deg;
  opacity: 0.85;
  padding: 0.5rem;
}

/* ----------------------------------------------------------------- cards */

.routes {
  max-width: 62rem;
  margin: 0 auto;
  display: grid;
  gap: 1.25rem;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
}
.route {
  display: block;
  background: var(--card);
  border: 1px solid var(--kraft);
  padding: 1.5rem 1.5rem 1.75rem;
  text-decoration: none;
  color: var(--ink);
}
.route h3 { margin-bottom: 0.35em; font-size: var(--step-1); }
.route p { color: var(--ink-soft); margin: 0; font-size: var(--step--1); max-width: none; }
.route:hover { border-color: var(--ink); }
.route.kids {
  background: #fffdf6;
  border: 2px solid var(--postmark);
  border-radius: 2px;
}
.route.kids h3 { color: var(--postmark); }

/* ---------------------------------------------------------------- gallery */

.photo-grid {
  max-width: 62rem;
  margin: 0 auto;
  display: grid;
  gap: 1.5rem;
  grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
  list-style: none;
  padding: 0;
}
.photo-grid figure { margin: 0; }
.photo-grid button {
  display: block;
  width: 100%;
  padding: 0.5rem;
  background: var(--card);
  border: 1px solid var(--kraft);
  cursor: pointer;
}
.photo-grid img { display: block; width: 100%; height: 13rem; object-fit: cover; }
.photo-grid figcaption {
  font-size: var(--step--1);
  color: var(--ink-soft);
  padding: 0.6rem 0.15rem 0;
  text-align: left;
  font-family: Fraunces, Georgia, serif;
  font-style: italic;
}

dialog.lightbox {
  border: none;
  background: transparent;
  padding: 0;
  max-width: 94vw;
  max-height: 94vh;
}
dialog.lightbox::backdrop { background: rgba(21, 28, 44, 0.9); }
dialog.lightbox img { max-width: 90vw; max-height: 78vh; display: block; background: var(--card); }
dialog.lightbox p { color: var(--gum); margin: 0.9rem 0 0; text-align: center; max-width: none; }
dialog.lightbox .close {
  position: absolute;
  top: -0.5rem;
  right: 0;
  background: none;
  border: none;
  color: var(--gum);
  font-size: 2rem;
  cursor: pointer;
  line-height: 1;
}

/* --------------------------------------------------------------- memories */

.memory-list { max-width: 44rem; margin: 0 auto; list-style: none; padding: 0; }
.memory {
  background: var(--card);
  border: 1px solid var(--kraft);
  border-left: 3px solid var(--gum);
  padding: 1.6rem 1.75rem;
  margin-bottom: 1.5rem;
}
.memory blockquote { margin: 0 0 1rem; font-size: var(--step-1); line-height: 1.5; }
.memory blockquote p { max-width: none; }
.memory cite {
  font-style: normal;
  font-family: Fraunces, Georgia, serif;
  display: block;
}
.memory cite span { color: var(--ink-soft); font-style: italic; }

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

form { max-width: 40rem; }
label { display: block; font-weight: 500; margin: 1.4rem 0 0.35rem; }
.hint { color: var(--ink-soft); font-size: var(--step--1); font-weight: 400; }

input[type=text], input[type=password], textarea, select {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--kraft);
  padding: 0.7rem 0.85rem;
  border-radius: 0;
}
textarea { min-height: 8rem; resize: vertical; line-height: 1.6; }
input:focus, textarea:focus, select:focus { border-color: var(--ink); }

.btn {
  font: 500 var(--step-0) Karla, sans-serif;
  background: var(--ink);
  color: var(--card);
  border: none;
  padding: 0.8rem 1.6rem;
  cursor: pointer;
  margin-top: 1.6rem;
}
.btn:hover { background: var(--postmark); }
.btn.quiet {
  background: none;
  color: var(--ink-soft);
  border: 1px solid var(--kraft);
  padding: 0.5rem 1rem;
  margin: 0;
  font-size: var(--step--1);
}
.btn.quiet:hover { background: none; color: var(--postmark); border-color: var(--postmark); }

.notice {
  max-width: 40rem;
  background: #fffdf6;
  border-left: 3px solid var(--postmark);
  padding: 0.9rem 1.1rem;
  margin: 0 0 2rem;
}
.notice p { margin: 0; }

/* ------------------------------------------------------- kids: the postbox */

body.kids { background: #f4eee1; }
body.kids .sitenav { margin-bottom: 2rem; }

.kids h1 { font-size: var(--step-3); }
.kids .lede { font-size: var(--step-1); line-height: 1.55; max-width: 32rem; }

.pillarbox { display: block; width: 8rem; height: auto; margin: 0 0 1.5rem; }

.who {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  list-style: none;
  padding: 0;
  margin: 2rem 0 0;
}
.who a {
  display: block;
  background: var(--card);
  border: 2px solid var(--ink);
  padding: 1.4rem 2.2rem;
  font-family: Fraunces, Georgia, serif;
  font-size: var(--step-2);
  text-decoration: none;
  color: var(--ink);
}
.who a:hover { background: var(--postmark); border-color: var(--postmark); color: var(--card); }

.pad {
  background: var(--card);
  border: 1px solid var(--kraft);
  padding: 1.5rem;
  max-width: 44rem;
  box-shadow: 0 12px 24px -20px rgba(34, 48, 76, 0.6);
}
.pad textarea {
  font-size: var(--step-1);
  min-height: 7rem;
  border: none;
  background:
    repeating-linear-gradient(var(--card) 0 2.55rem, var(--gum) 2.55rem 2.6rem);
  line-height: 2.6rem;
  padding: 0;
}
.pad textarea:focus { outline-offset: 6px; }

.canvas-wrap { margin-top: 1.5rem; }
canvas#doodle {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 3 / 2;
  background: #fff;
  border: 1px solid var(--kraft);
  touch-action: none;
  cursor: crosshair;
}
.tools { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; margin-top: 0.85rem; }
.swatch {
  width: 2.6rem;
  height: 2.6rem;
  border: 2px solid var(--kraft);
  border-radius: 50%;
  cursor: pointer;
  padding: 0;
}
.swatch[aria-pressed="true"] { border-color: var(--ink); transform: scale(1.12); }

.btn.post {
  font-family: Fraunces, Georgia, serif;
  font-size: var(--step-2);
  background: var(--postmark);
  padding: 0.9rem 2.4rem;
}
.btn.post:hover { background: var(--ink); }

/* One orchestrated moment: the letter folds and goes. */
@keyframes post-away {
  0%   { transform: none; opacity: 1; }
  35%  { transform: rotate(-3deg) scale(0.94); opacity: 1; }
  100% { transform: translate(38vw, -85vh) rotate(28deg) scale(0.12); opacity: 0; }
}
.sending { animation: post-away 1.15s cubic-bezier(0.5, 0, 0.75, 0) forwards; }

@media (prefers-reduced-motion: reduce) {
  .sending { animation: none; opacity: 0; }
  * { scroll-behavior: auto; }
}

/* -------------------------------------------------------- letters back */

.thread { max-width: 44rem; list-style: none; padding: 0; }
.thread > li { margin-bottom: 3rem; }

.sent {
  background: var(--card);
  border: 1px solid var(--kraft);
  padding: 1.4rem 1.6rem;
}
.sent .stamp {
  font-family: Fraunces, Georgia, serif;
  font-style: italic;
  color: var(--ink-soft);
  font-size: var(--step--1);
  margin: 0 0 0.8rem;
}
.sent p.words { font-size: var(--step-1); margin: 0; white-space: pre-wrap; }
.sent img { display: block; max-width: 100%; margin-top: 1rem; border: 1px solid var(--kraft); }

.reply {
  margin: 1.25rem 0 0 1.5rem;
  background: #fffdf6;
  border: 2px solid var(--postmark);
  padding: 1.4rem 1.6rem;
}
.reply h3 {
  color: var(--postmark);
  font-size: var(--step-1);
  margin-bottom: 0.5em;
}
.reply p { font-size: var(--step-1); white-space: pre-wrap; margin: 0; max-width: none; }

.waiting {
  margin: 1.25rem 0 0 1.5rem;
  color: var(--ink-soft);
  font-family: Fraunces, Georgia, serif;
  font-style: italic;
}

/* ------------------------------------------------------------------ admin */

.admin-grid { display: grid; gap: 3rem; max-width: 62rem; margin: 0 auto; }
.admin-grid section { border-top: 1px solid var(--kraft); padding-top: 1.75rem; }
.admin-grid h2 { font-size: var(--step-2); }

table.rows { width: 100%; border-collapse: collapse; font-size: var(--step--1); }
table.rows th, table.rows td {
  text-align: left;
  padding: 0.7rem 0.6rem;
  border-bottom: 1px solid var(--gum);
  vertical-align: top;
}
table.rows th { font-weight: 700; color: var(--ink-soft); }
table.rows img { max-width: 5rem; height: auto; display: block; }
table.rows form { margin: 0; max-width: none; display: inline; }

.pending { color: var(--postmark); font-weight: 700; }

/* ----------------------------------------------------------------- footer */

.sitefoot {
  max-width: 62rem;
  margin: 5rem auto 0;
  padding-top: 1.25rem;
  border-top: 1px solid var(--kraft);
  color: var(--ink-soft);
  font-size: var(--step--1);
}
.sitefoot p { margin: 0; max-width: none; }

/* --------------------------------------------------------------- utility */

.center-narrow { max-width: 26rem; margin: 4rem auto; }
.stack-lg > * + * { margin-top: 2.5rem; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ------------------------------------------------------------- slideshow */

.slideshow { position: relative; }

.slideshow .frames {
  position: relative;
  display: grid;
  background: #e6e0d4;
  overflow: hidden;
}
.slideshow .frames img {
  grid-area: 1 / 1;
  width: 100%;
  display: block;
  opacity: 0;
  transition: opacity 900ms ease-in-out;
}
.slideshow .frames img.on { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  .slideshow .frames img { transition: none; }
}

/* In the taped snapshot on the home page: fill the frame, crop as needed. */
.slideshow.in-frame .frames { aspect-ratio: 4 / 3; }
.slideshow.in-frame .frames img { height: 100%; object-fit: cover; }

.slideshow.in-frame .slide-caption {
  margin: 0.85rem 0.15rem 0;
  max-width: none;
  min-height: 1.4em;
  font-family: Fraunces, Georgia, serif;
  font-style: italic;
  color: var(--ink-soft);
  font-size: var(--step--1);
  line-height: 1.35;
}

/* Full size, in the gallery dialog: show the whole photo. */
.slideshow.full .frames {
  aspect-ratio: auto;
  height: 76vh;
  background: transparent;
}
.slideshow.full .frames img { height: 76vh; object-fit: contain; }
.slideshow.full .slide-caption {
  color: var(--gum);
  text-align: center;
  margin: 1rem 0 0;
  max-width: none;
  font-family: Fraunces, Georgia, serif;
  font-style: italic;
}

.slide-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.6rem;
}
.slide-controls button {
  font: 500 var(--step--1) Karla, sans-serif;
  background: none;
  border: 1px solid var(--kraft);
  color: var(--ink-soft);
  padding: 0.3rem 0.7rem;
  cursor: pointer;
  min-width: 2.2rem;
}
.slide-controls button:hover { color: var(--postmark); border-color: var(--postmark); }
.slide-count { font-size: var(--step--1); color: var(--ink-soft); margin-left: auto; }

.slideshow.in-frame .slide-controls { margin-top: 0.7rem; }

.slideshow.full .slide-controls { justify-content: center; margin-top: 1rem; }
.slideshow.full .slide-controls button { border-color: var(--ink-soft); color: var(--gum); }
.slideshow.full .slide-controls button:hover { color: #fff; border-color: var(--gum); }
.slideshow.full .slide-count { color: var(--ink-soft); margin-left: 1rem; }

dialog.lightbox.show-all { width: min(92vw, 68rem); }

/* --------------------------------------------------------- upload dropzone */

.dropzone {
  display: grid;
  gap: 0.4rem;
  place-items: center;
  text-align: center;
  padding: 2.75rem 1.5rem;
  margin-top: 0.5rem;
  border: 2px dashed var(--kraft);
  background: var(--card);
  cursor: pointer;
  font-weight: 400;
}
.dropzone:hover { border-color: var(--ink-soft); }
.dropzone.dragging { border-color: var(--postmark); background: #fffdf6; }
.dropzone-main {
  font-family: Fraunces, Georgia, serif;
  font-size: var(--step-1);
  color: var(--ink);
}
.dropzone input[type=file] {
  position: absolute;
  width: 1px; height: 1px;
  opacity: 0;
  pointer-events: none;
}
.dropzone:focus-within { outline: 3px solid var(--postmark); outline-offset: 3px; }

ul.chosen {
  list-style: none;
  padding: 0;
  margin: 1rem 0 0;
  font-size: var(--step--1);
  color: var(--ink-soft);
}
ul.chosen li {
  padding: 0.3rem 0;
  border-bottom: 1px solid var(--gum);
}
ul.chosen li.over { color: var(--postmark); }
