/* Canned Emails — one stylesheet, no framework, no dependencies. */

/* ---------------------------------------------------------------- fonts */
/* Archivo Black and IBM Plex Mono, both SIL Open Font License 1.1.
   Self-hosted, latin subset only, ~30KB total. See fonts/LICENSE.txt. */
@font-face {
  font-family: 'Archivo Black';
  src: url('/fonts/ArchivoBlack-400.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'IBM Plex Mono';
  src: url('/fonts/IBMPlexMono-400.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'IBM Plex Mono';
  src: url('/fonts/IBMPlexMono-600.woff2') format('woff2');
  font-weight: 600; font-style: normal; font-display: swap;
}

/* ---------------------------------------------------------------- tokens */
:root {
  --paper:  #e7e9e3;
  --card:   #f6f7f3;
  --ink:    #16181b;
  --muted:  #6b7069;
  --rule:   #c9cdc4;
  --stamp:  #c1402b;

  --display: 'Archivo Black', ui-sans-serif, system-ui, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  --measure: 44rem;
  --step: 0.75rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #141613;
    --card:  #1c1f1b;
    --ink:   #e7e9e3;
    --muted: #8a9086;
    --rule:  #2e332c;
    --stamp: #e4614a;
  }
}

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

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 1rem;
  line-height: 1.6;
  padding: 0 1.25rem;
}

::selection { background: var(--stamp); color: var(--paper); }

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

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  clip-path: inset(50%); overflow: hidden; white-space: nowrap;
}

.skip {
  position: absolute; left: -9999px;
  background: var(--ink); color: var(--paper);
  padding: 0.6rem 1rem; z-index: 10;
}
.skip:focus { left: 1rem; top: 1rem; }

/* ---------------------------------------------------------------- masthead */
/* --------------------------------------------------------- for-sale bar */
/* Full-bleed against the body padding. Reads as a stamped notice on the
   envelope rather than an ad -- same mono, same eyebrow treatment. */
.forsale {
  margin: 0 -1.25rem;
  padding: 0.6rem 1.25rem;
  background: var(--ink);
  color: var(--paper);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.forsale p {
  max-width: var(--measure);
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem 0.9rem;
}


.forsale a {
  color: var(--paper);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  white-space: nowrap;
}
.forsale a:hover { color: var(--stamp); }

.masthead {
  max-width: var(--measure);
  margin: 0 auto;
  padding: clamp(3rem, 12vw, 6rem) 0 clamp(2rem, 6vw, 3.5rem);
}

.eyebrow {
  margin: 0 0 1.75rem;
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.masthead h1 {
  font-family: var(--display);
  font-size: clamp(3.2rem, 15vw, 7rem);
  line-height: 0.86;
  letter-spacing: -0.035em;
  text-transform: uppercase;
  margin: 0 0 1.5rem;
}

.lede {
  margin: 0;
  max-width: 34rem;
  color: var(--muted);
  text-wrap: pretty;
}

/* The bracketed placeholders are the actual interface of these emails —
   they're the part you have to fill in. Mark them as such. */
.bracket {
  color: var(--stamp);
  font-weight: 600;
  white-space: nowrap;
}

/* ---------------------------------------------------------------- controls */
main { max-width: var(--measure); margin: 0 auto; }

.controls {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--paper);
  padding: 0.75rem 0 1rem;
}

.search { position: relative; }

.search input {
  width: 100%;
  font: inherit;
  color: inherit;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 0;
  padding: 0.85rem 3rem 0.85rem 1rem;
}
.search input::placeholder { color: var(--muted); }
.search input:focus-visible { border-color: var(--stamp); outline-offset: 0; }
.search input::-webkit-search-cancel-button { filter: grayscale(1); }

.hint {
  position: absolute;
  right: 0.85rem; top: 50%;
  transform: translateY(-50%);
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--muted);
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 0 0.4rem;
  pointer-events: none;
}
.search input:not(:placeholder-shown) ~ .hint { opacity: 0; }

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.75rem;
}

.chip {
  font: inherit;
  font-size: 0.8rem;
  color: var(--muted);
  background: none;
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 0.2rem 0.75rem;
  cursor: pointer;
}
.chip:hover { color: var(--ink); border-color: var(--ink); }
.chip.is-on {
  color: var(--paper);
  background: var(--ink);
  border-color: var(--ink);
}

/* ---------------------------------------------------------------- list */
.drafts { border-top: 1px solid var(--rule); }

.draft { border-bottom: 1px solid var(--rule); }
.draft[hidden] { display: none; }

summary {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 0;
  cursor: pointer;
  list-style: none;
}
summary::-webkit-details-marker { display: none; }
summary:hover .draft-name { color: var(--stamp); }

.draft-name { font-weight: 600; }

.draft-tag {
  flex: none;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

details[open] .draft-name { color: var(--stamp); }

/* ---------------------------------------------------------------- panel */
.draft-panel {
  position: relative;
  background: var(--card);
  border: 1px solid var(--rule);
  padding: 1.25rem;
  margin-bottom: 1.1rem;
  /* Contains the stamp: it's scaled up at the start of its animation and
     would otherwise widen the page on narrow screens. */
  overflow: hidden;
}

.draft-subject {
  margin: 0 0 1rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px dashed var(--rule);
  font-weight: 600;
}

.label {
  display: inline-block;
  margin-right: 0.6rem;
  font-size: 0.7rem;
  font-weight: 400;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.draft-text {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.9375rem;
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

.draft-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1.25rem;
}

.btn {
  font: inherit;
  font-size: 0.85rem;
  color: var(--ink);
  background: none;
  border: 1px solid var(--ink);
  border-radius: 0;
  padding: 0.45rem 0.9rem;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: var(--ink); color: var(--paper); }

.btn-primary { background: var(--ink); color: var(--paper); }
.btn-primary:hover { background: var(--stamp); border-color: var(--stamp); color: #fff; }

.btn-quiet { border-color: var(--rule); color: var(--muted); }
.btn-quiet:hover { background: none; border-color: var(--ink); color: var(--ink); }

/* ------------------------------------------------------- the copied stamp */
/* The one flourish on the page: hitting Copy stamps the draft like a file
   that's been processed and put back in the drawer. */
.stamp {
  position: absolute;
  left: 50%;
  top: 45%;
  font-family: var(--display);
  font-size: clamp(1.4rem, 6vw, 2.25rem);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--stamp);
  border: 3px solid var(--stamp);
  border-radius: 4px;
  padding: 0.1em 0.35em;
  opacity: 0;
  transform: translate(-50%, -50%) rotate(-11deg) scale(1.6);
  pointer-events: none;
}

.is-copied .stamp {
  animation: stamp 1.4s ease-out forwards;
}

@keyframes stamp {
  0%   { opacity: 0;    transform: translate(-50%, -50%) rotate(-11deg) scale(1.6); }
  18%  { opacity: 0.92; transform: translate(-50%, -50%) rotate(-11deg) scale(1); }
  70%  { opacity: 0.92; transform: translate(-50%, -50%) rotate(-11deg) scale(1); }
  100% { opacity: 0;    transform: translate(-50%, -50%) rotate(-11deg) scale(1); }
}

/* ---------------------------------------------------------------- misc */
.no-results {
  padding: 2.5rem 0;
  color: var(--muted);
  text-align: center;
}

.linkish {
  font: inherit;
  color: var(--stamp);
  background: none;
  border: 0;
  padding: 0;
  text-decoration: underline;
  cursor: pointer;
}

.colophon {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 3.5rem 0 4rem;
  border-top: 1px solid var(--rule);
  margin-top: 3rem;
  font-size: 0.8rem;
  color: var(--muted);
}
.colophon p { margin: 0 0 0.5rem; }
.colophon a { color: var(--ink); text-decoration-color: var(--rule); }
.colophon a:hover { color: var(--stamp); }
.fine { color: var(--muted); }

.live {
  position: absolute; width: 1px; height: 1px;
  margin: -1px; clip-path: inset(50%); overflow: hidden;
}

/* ---------------------------------------------------------------- motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .is-copied .stamp { animation: stamp-plain 1.4s steps(1) forwards; }
  @keyframes stamp-plain {
    0%, 92% { opacity: 0.92; transform: translate(-50%, -50%) rotate(-11deg); }
    100%    { opacity: 0;    transform: translate(-50%, -50%) rotate(-11deg); }
  }
}

/* ---------------------------------------------------------------- print */
@media print {
  .forsale, .controls, .skip, .draft-actions, .stamp, .colophon { display: none; }
  .draft details { display: block; }
  body { background: #fff; color: #000; }
}
