/* Letter pages (signup, sign in, password reset): writing paper, a stamp and, once sent, an envelope. The home page uses the same stationery. */

:root {
  --letter-page: #f6f8f5;
  --letter-paper: #fdfdfb;
  --letter-ink: #141816;
  --letter-muted: #6b7280;
  --letter-rule: #8b93a3;
  --letter-faint: #a3a9b4;
  --letter-navy: #23366f;
  --letter-error: #b4412f;
}

.letter-page {
  margin: 0;
  min-height: 100vh;
  background: var(--letter-page);
  color: var(--letter-ink);
  font-family: "InterVariable", ui-sans-serif, system-ui, sans-serif;
}

.letter-desk {
  box-sizing: border-box;
  max-width: 760px;
  min-height: 100vh;
  margin: 0 auto;
  padding: 56px 16px 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 32px;
}

.letter-desk a {
  color: var(--letter-ink);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.15em;
}

.letter-intro {
  text-align: center;
}

.letter-intro h1 {
  margin: 0;
  font-family: "SourceSerif4Variable", Georgia, serif;
  font-size: 2.5rem;
  font-weight: 600;
  line-height: 1.1;
}

.letter-intro p {
  max-width: 34rem;
  margin: 1rem auto 0;
  color: var(--letter-muted);
  line-height: 1.6;
}

.letter-form {
  width: 100%;
}

/* The letter */

.letter-paper {
  position: relative;
  box-sizing: border-box;
  width: 100%;
  margin-top: 16px;
  padding: 48px clamp(22px, 8vw, 80px) 44px;
  background: var(--letter-paper) url("/assets/letter/paper-light-0d14c02d.jpg") 0 0 / 512px auto;
  box-shadow: 0 34px 60px -28px rgba(28, 38, 35, 0.38);
  color: var(--letter-ink);
  font-family: "SourceSerif4Variable", Georgia, serif;
  font-size: 1.375rem;
  line-height: 2.2;
}

.letter-paper p {
  margin: 0;
}

.letter-paper p + p {
  margin-block-start: 0.5rem;
}

.letter-letterhead {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 4px 0 24px;
  line-height: 1;
}

.letter-letterhead svg {
  width: 34px;
  height: auto;
  color: #f1f2f1;
  filter: drop-shadow(0 1px 0 rgba(255, 255, 255, 0.95)) drop-shadow(0 -1px 0 rgba(40, 50, 70, 0.2));
}

.letter-letterhead span {
  font-family: "InterVariable", sans-serif;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.32em;
  color: var(--letter-faint);
}

.letter-paper .letter-date {
  margin-block-end: 1.25rem;
  font-style: italic;
  font-size: 1rem;
  color: var(--letter-muted);
}

.letter-blank {
  box-sizing: border-box;
  width: 15rem;
  height: 2.2rem;
  padding: 0 6px;
  border: 0;
  border-bottom: 2px dotted var(--letter-rule);
  background: transparent;
  color: var(--letter-ink);
  font: inherit;
  font-weight: 600;
  vertical-align: baseline;
}

.letter-blank::placeholder {
  color: var(--letter-faint);
  font-style: italic;
  font-weight: 400;
}

.letter-blank:focus {
  outline: none;
  box-shadow: none;
  background: rgba(35, 54, 111, 0.06);
  border-bottom-style: solid;
  border-bottom-color: var(--letter-navy);
}

.letter-blank--subdomain { width: 10rem; text-align: end; }
.letter-blank--email { width: 17rem; }

.letter-blank--select {
  width: auto;
  height: auto;
  line-height: normal;
  padding-inline-end: 1.6rem;
  appearance: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 6l4 4 4-4' fill='none' stroke='%23141816' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.3rem center;
  background-size: 0.9rem;
}

.letter-note {
  font-family: "CaveatVariable", cursive;
  font-size: 1.6rem;
  line-height: 1.6;
  color: var(--letter-error);
  transform: rotate(-1deg);
  transform-origin: left;
}

.letter-note:empty {
  display: none;
}

.letter-note a {
  color: inherit;
  white-space: nowrap;
  text-decoration-thickness: 1.5px;
  text-decoration-color: color-mix(in srgb, currentColor 40%, transparent);
}

.letter-note a:hover {
  text-decoration-color: currentColor;
}

.letter-field {
  white-space: nowrap;
}

.letter-signature {
  min-height: 3.5rem;
  font-family: "CaveatVariable", cursive;
  font-size: 2.75rem;
  font-weight: 700;
  line-height: 1.3;
}

.letter-signature:empty {
  min-height: 1rem;
}

.letter-paper .letter-ps {
  margin-block-start: 1rem;
  display: flex;
  align-items: baseline;
  gap: 0.35em;
  font-size: 1.125rem;
  white-space: nowrap;
}

.letter-ps .letter-field {
  flex: 1;
  display: flex;
  min-width: 0;
}

.letter-ps .letter-blank {
  width: 100%;
  min-width: 0;
}

.letter-blank--source::placeholder {
  font-size: 0.85em;
}

.letter-consent {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-block-start: 1.5rem;
  font-size: 15px;
  line-height: 1.5;
  color: var(--letter-muted);
}

.letter-consent input {
  flex-shrink: 0;
  width: 1em;
  height: 1em;
  margin-block-start: 0.3em;
  border: 1.5px solid var(--letter-rule);
  border-radius: 2px;
  background-color: transparent;
  cursor: pointer;
}

.letter-consent input:checked,
.letter-consent input:checked:hover,
.letter-consent input:checked:focus {
  border-color: var(--letter-rule);
  background-color: transparent;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 8.5l3 3 6-7' fill='none' stroke='%23141816' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-size: 100%;
}

.letter-consent input:focus {
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--letter-navy) 15%, transparent);
}

.letter-consent label {
  text-wrap: pretty;
  cursor: pointer;
}

.letter-send {
  margin-block-start: 1.75rem;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  font-size: 15px;
  line-height: 1.5;
  color: var(--letter-muted);
  text-align: end;
}

.letter-send .turnstile-widget {
  margin-block-end: 8px;
}

.letter-aside {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.letter-aside a {
  font-family: "CaveatVariable", cursive;
  font-size: 1.45em;
  font-weight: 600;
  line-height: 1.35;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 0.2em;
  text-decoration-color: color-mix(in srgb, currentColor 30%, transparent);
}

.letter-aside a:hover {
  text-decoration-color: currentColor;
}

.letter-send .btn-primary {
  font-family: "InterVariable", sans-serif;
  min-height: 48px;
  padding-inline: 22px;
  gap: 10px;
  font-size: 1rem;
}

/* Paper on the home page and marketing pages */

.letter-paper--note,
.letter-paper--long,
.home-envelope__post,
.postcard {
  background: var(--letter-paper) url("/assets/letter/paper-light-0d14c02d.jpg") 0 0 / 512px auto;
  box-shadow: 0 0 22px rgba(28, 38, 35, 0.1), 0 34px 60px -28px rgba(28, 38, 35, 0.38);
}

/* The home page's post by email: a post rising out of an open envelope */

.home-envelope {
  position: relative;
  isolation: isolate;
  width: 100%;
  max-width: 560px;
  margin-inline: auto;
  padding-top: 170px;
}

.home-envelope::before {
  content: "";
  position: absolute;
  z-index: 0;
  inset-inline: 0;
  inset-block-start: 40px;
  height: 130px;
  background: #e4e7e9;
  clip-path: polygon(0 100%, 50% 0, 100% 100%);
}

.home-envelope__post {
  position: absolute;
  z-index: 1;
  inset-inline: 11%;
  inset-block-start: 0;
  height: 300px;
  box-sizing: border-box;
  padding: 30px 32px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background-color: var(--letter-paper);
  color: var(--letter-ink);
  font-family: "SourceSerif4Variable", Georgia, serif;
  animation: home-envelope-rise linear both;
  animation-timeline: view();
  animation-range: entry 25% cover 50%;
}

.home-envelope__post p {
  margin: 4px 0 0;
  font-size: 1.05rem;
  line-height: 1.6;
}

.home-envelope__blog {
  font-family: "InterVariable", sans-serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.22em;
  color: var(--letter-muted);
}

.home-envelope__title {
  font-size: 1.75rem;
  font-weight: 600;
  line-height: 1.15;
}

.home-envelope__date {
  font-family: "InterVariable", sans-serif;
  font-size: 13px;
  color: var(--letter-muted);
}

.home-envelope .letter-envelope {
  z-index: 2;
  margin-top: 0;
  height: 260px;
}

.home-envelope .letter-envelope__address {
  inset-block-end: 40px;
  padding-inline: 16px;
  font-size: clamp(1rem, 4.4vw, 1.6rem);
}

.letter-envelope--open::before {
  display: none;
}

@keyframes home-envelope-rise {
  from { transform: translateY(150px); }
  to { transform: translateY(0); }
}

@supports not (animation-timeline: view()) {
  .home-envelope__post { animation: none; }
}

@media (prefers-reduced-motion: reduce) {
  .home-envelope__post { animation: none; }
}

/* Testimonials on the home page, as postcards */

.postcard {
  position: relative;
  box-sizing: border-box;
  flex: none;
  width: min(440px, 84vw);
  min-height: 280px;
  margin: 0;
  padding: 22px 22px 20px;
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 20px;
  background-color: var(--letter-paper);
  color: var(--letter-ink);
  transform: rotate(-1.4deg);
}

.postcard {
  box-shadow: 0 0 14px rgba(28, 38, 35, 0.08), 0 10px 18px -8px rgba(28, 38, 35, 0.28);
}

.postcard:nth-child(even) {
  transform: rotate(1.2deg);
}

/* --quote-length is the quote's character count, set in home/_postcard */
.postcard blockquote {
  margin: 0;
  font-family: "SourceSerif4Variable", Georgia, serif;
  font-size: clamp(0.875rem, calc(1.2rem - var(--quote-length) * 0.0015rem), 1rem);
  line-height: 1.5;
}

.postcard figcaption {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding-inline-start: 20px;
  border-inline-start: 1px dashed var(--letter-rule);
  font-family: "CaveatVariable", cursive;
}

.postcard .letter-stamp {
  inset-block-start: -8px;
  inset-inline-end: -6px;
  transform: rotate(4deg) scale(0.72);
  transform-origin: top right;
}

.postcard__postmark {
  position: absolute;
  inset-block-start: 8px;
  inset-inline-end: 34px;
  width: 140px;
  height: auto;
  color: rgba(40, 36, 30, 0.45);
  transform: rotate(-8deg);
}

.postcard__name {
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.2;
}

.postcard .postcard__site {
  font-size: 1.3rem;
  line-height: 1.3;
  color: var(--letter-navy);
}

/* The principles page: a long letter */

.letter-paper--long {
  font-size: 1.2rem;
  line-height: 1.75;
}

.letter-paper--long p + p {
  margin-block-start: 1.1em;
}

.letter-paper--long .letter-signature {
  margin-block-start: 0.25em;
}

/* A short letter that starts a signup, on the home page and marketing pages */

.letter-paper--note {
  max-width: 34rem;
  margin-top: 8px;
  padding: 30px 40px 26px;
  font-size: 1.3rem;
  line-height: 1.9;
  transform: rotate(-0.8deg);
}

.letter-paper--note .letter-stamp {
  inset-block-start: 22px;
  inset-inline-end: 26px;
  transform: rotate(4deg) scale(0.75);
  transform-origin: top right;
}

.letter-paper--note .letter-signature,
.letter-paper--note .letter-signature:empty {
  min-height: 3.5rem;
  font-size: 2.6rem;
}

.letter-paper--note .letter-send {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  margin-block-start: 0.5rem;
  font-family: "InterVariable", sans-serif;
  font-size: 14px;
}

.letter-address {
  font-family: "CaveatVariable", cursive;
  font-size: 1.5rem;
  line-height: 1.4;
  color: var(--letter-navy);
}

.letter-address:empty::before {
  content: attr(data-placeholder);
  color: var(--letter-faint);
}

.home-postscript {
  margin: 0;
  font-family: "CaveatVariable", cursive;
  font-size: 2rem;
  line-height: 1.3;
  color: var(--letter-ink);
  transform: rotate(-1deg);
}

.home-postscript a {
  color: inherit;
  font-weight: 600;
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 0.2em;
  text-decoration-color: color-mix(in srgb, currentColor 30%, transparent);
}

.home-postscript a:hover {
  text-decoration-color: currentColor;
}

.home-postscript__signature {
  display: block;
  margin-top: 10px;
  font-size: 2.75rem;
  font-weight: 700;
}

.home-postit {
  position: absolute;
  z-index: 1;
  inset-block-start: -26px;
  inset-inline-end: -18px;
  box-sizing: border-box;
  width: 13rem;
  margin: 0;
  padding: 18px 18px 22px;
  background: linear-gradient(180deg, #fff7a8, #fdec7a);
  box-shadow: 0 1px 1px rgba(60, 50, 0, 0.12), 0 14px 18px -12px rgba(60, 50, 0, 0.45);
  font-family: "CaveatVariable", cursive;
  font-size: 1.5rem;
  line-height: 1.2;
  color: #2b2a1f;
  transform: rotate(3deg);
}

/* The 404 page: an envelope stamped "Return to sender" */

.letter-return {
  position: relative;
  width: 100%;
}

.letter-return .letter-envelope {
  margin-inline: auto;
}

.letter-return .letter-envelope__address {
  padding-inline: 16px;
  font-size: clamp(1.1rem, 5vw, 1.75rem);
}

.letter-return__stamp {
  position: absolute;
  z-index: 3;
  inset-block-start: 55%;
  inset-inline-start: 50%;
  padding: 6px 16px;
  border: 4px double currentColor;
  border-radius: 6px;
  color: var(--letter-error);
  font-family: "InterVariable", sans-serif;
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
  opacity: 0.85;
  transform: translate(-50%, -50%) rotate(-12deg);
}

/* The stamp */

/* Perforations are transparent holes in the background; round fits a whole number of them to each edge */
.letter-stamp {
  --stamp-paper: #ffffff;
  --hole: 4px;
  position: absolute;
  inset-block-start: 34px;
  inset-inline-end: 36px;
  padding: 9px;
  background:
    radial-gradient(var(--hole), transparent 98%, var(--stamp-paper)) calc(var(--hole) * -1.5) calc(var(--hole) * -1.5) / calc(var(--hole) * 3) calc(var(--hole) * 3) round,
    linear-gradient(var(--stamp-paper) 0 0) 50% / calc(100% - var(--hole) * 3) calc(100% - var(--hole) * 3) no-repeat;
  filter: drop-shadow(0 1px 1.5px rgba(30, 40, 60, 0.3));
  transform: rotate(4deg);
}

.letter-stamp__face {
  box-sizing: border-box;
  width: 86px;
  height: 106px;
  padding: 7px 5px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  background: #23366f;
  color: #f4f6fb;
  font-family: "InterVariable", sans-serif;
  font-size: 7px;
  font-weight: 700;
  letter-spacing: 0.2em;
  line-height: 1;
}

.letter-stamp__cameo {
  box-sizing: border-box;
  width: 52px;
  height: 62px;
  border-radius: 50%;
  border: 1px solid currentColor;
  display: flex;
  align-items: center;
  justify-content: center;
}

.letter-stamp__mark {
  width: 30px;
  aspect-ratio: 1094 / 1550;
  background-color: currentColor;
  -webkit-mask: url("/assets/logo-mark-crowned-ade8dd0d.svg") center / contain no-repeat;
  mask: url("/assets/logo-mark-crowned-ade8dd0d.svg") center / contain no-repeat;
}

.letter-postmark {
  display: block;
  aspect-ratio: 600 / 250;
  background-color: currentColor;
  -webkit-mask: url("/assets/icons/stamp-bbaafbf3.svg") center / contain no-repeat;
  mask: url("/assets/icons/stamp-bbaafbf3.svg") center / contain no-repeat;
}

.letter-stamp__code {
  font-size: 8px;
  letter-spacing: 0.08em;
}

.letter-stamp--free .letter-stamp__face {
  background: #2f8f72;
}

#pricing .letter-stamp {
  inset-block-start: 16px;
  inset-inline-end: 16px;
  transform: rotate(4deg) scale(0.62);
  transform-origin: top right;
}

/* Sent */

.letter-envelope {
  position: relative;
  width: 100%;
  max-width: 560px;
  height: 340px;
  margin-top: 40px;
  border-radius: 6px;
  background: var(--letter-paper);
  box-shadow: 0 1px 2px rgba(30, 40, 60, 0.14), 0 34px 60px -26px rgba(30, 40, 60, 0.4);
  overflow: hidden;
}

.letter-envelope::before,
.letter-envelope::after {
  content: "";
  position: absolute;
  inset-inline: 0;
}

.letter-envelope::before {
  inset-block-start: 0;
  height: 180px;
  background: #eceef0;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
}

.letter-envelope::after {
  inset-block-end: 0;
  height: 200px;
  background: #f2f3f5;
  clip-path: polygon(0 100%, 50% 10%, 100% 100%);
}

.letter-envelope .letter-stamp {
  z-index: 1;
  inset-block-start: 22px;
  inset-inline-end: 24px;
}

.letter-envelope__postmark {
  position: absolute;
  z-index: 2;
  inset-block-start: 46px;
  inset-inline-end: 70px;
  width: 190px;
  height: auto;
  color: rgba(40, 36, 30, 0.5);
  transform: rotate(-8deg);
}

.letter-envelope__address {
  position: absolute;
  z-index: 1;
  inset-inline: 0;
  inset-block-end: 64px;
  text-align: center;
  font-family: "CaveatVariable", cursive;
  font-size: 2.25rem;
  font-weight: 700;
  color: var(--letter-ink);
}

.letter-footer {
  margin: auto 0 0;
  padding-top: 24px;
  font-size: 13px;
  color: var(--letter-muted);
}

/* Dark mode: the same stationery, printed dark */

@media (prefers-color-scheme: dark) {
  :root {
    --letter-page: oklch(15% 0.012 262);
    --letter-paper: oklch(25% 0.035 262);
    --letter-ink: oklch(94% 0.005 250);
    --letter-muted: oklch(76% 0.02 262);
    --letter-rule: oklch(60% 0.04 262);
    --letter-faint: oklch(64% 0.03 262);
    --letter-navy: oklch(80% 0.07 265);
    --letter-error: oklch(72% 0.16 18);
  }

  .letter-paper {
    background-image: url("/assets/letter/paper-dark-932f20bf.jpg");
    box-shadow: 0 34px 60px -28px rgba(0, 0, 0, 0.7);
  }

  .letter-letterhead svg {
    color: oklch(33% 0.04 262);
    filter: drop-shadow(0 1px 0 rgba(255, 255, 255, 0.16)) drop-shadow(0 -1px 0 rgba(0, 0, 0, 0.6));
  }

  .letter-blank:focus {
    background: rgba(255, 255, 255, 0.05);
  }

  .letter-stamp {
    --stamp-paper: oklch(86% 0.012 262);
    filter: drop-shadow(0 1px 1.5px rgba(0, 0, 0, 0.6));
  }

  .letter-consent input:checked,
  .letter-consent input:checked:hover,
  .letter-consent input:checked:focus {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 8.5l3 3 6-7' fill='none' stroke='%23eceef2' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  }

  .letter-blank--select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 6l4 4 4-4' fill='none' stroke='%23eceef2' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  }

  .letter-envelope {
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.05), 0 34px 60px -26px rgba(0, 0, 0, 0.7);
  }

  .letter-envelope::before {
    background: oklch(22% 0.035 262);
  }

  .letter-envelope::after {
    background: oklch(23.5% 0.035 262);
  }

  .letter-envelope__postmark {
    color: rgba(255, 255, 255, 0.45);
  }

  .home-envelope::before {
    background: oklch(21% 0.035 262);
  }

  .home-envelope__post {
    background-image: url("/assets/letter/paper-dark-932f20bf.jpg");
  }

  .postcard {
    background-image: url("/assets/letter/paper-dark-932f20bf.jpg");
  }

  .postcard__postmark {
    color: rgba(255, 255, 255, 0.4);
  }
}

@media (max-width: 640px) {
  .letter-return__stamp {
    font-size: 1.1rem;
  }

  .letter-desk {
    padding-top: 32px;
  }

  .letter-intro h1 {
    font-size: 2rem;
  }

  .letter-paper {
    padding-block: 32px 28px;
    font-size: 1.15rem;
    line-height: 1.8;
  }

  .letter-paper p + p {
    margin-block-start: 1rem;
  }

  .letter-trail {
    display: none;
  }

  .letter-paper .letter-ps {
    display: block;
    white-space: normal;
  }

  .letter-send {
    align-items: stretch;
    text-align: center;
  }

  .letter-send .turnstile-widget {
    align-self: center;
  }

  .letter-send .btn-primary {
    justify-content: center;
  }

  .letter-aside {
    align-items: center;
  }

  .letter-field {
    display: flex;
    align-items: baseline;
    gap: 6px;
    width: 100%;
  }

  .letter-field .letter-blank {
    flex: 1;
    min-width: 0;
    width: auto;
  }

  .letter-stamp {
    inset-block-start: 14px;
    inset-inline-end: 12px;
    transform: rotate(4deg) scale(0.62);
    transform-origin: top right;
  }

  .letter-paper--note {
    padding: 26px 22px 22px;
  }

  .letter-paper--note .letter-send {
    flex-direction: column-reverse;
    align-items: stretch;
  }
}

