/* ============================================================
   A personal letter — chichinwanoku.com/note
   The decorative marks are FIXED, so they stay put while the letter
   scrolls over them. Everything else is a single offset column.
   ============================================================ */

:root{
  --cream:      #F7EFE1;
  --cream-art:  #EADBC2;
  --ink:        #102A22;
  --terracotta: #D45A36;
  --teal:       #0B5C5D;

  /* 75%, not 62%. At 62% this measured 3.5:1 against the paper, which fails
     WCAG AA (4.5:1) for the muted lines — the date and the italic sign-up
     prompt. 75% gives 5.3:1 and still reads as secondary. */
  --ink-soft: rgb(74, 91, 82);   /* fallback: color-mix needs Safari 16.2+ */
  --ink-soft: color-mix(in srgb, var(--ink) 75%, var(--cream));
  --rule:     rgba(16, 42, 34, 0.22);
  --rule:     color-mix(in srgb, var(--ink) 22%, transparent);

  --serif: "Cormorant Garamond", "Iowan Old Style", Georgia, serif;
  --sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  --gutter: clamp(1.5rem, 5vw, 4rem);
}

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

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

body{
  margin: 0;
  min-height: 100%;
  position: relative;
  background-color: var(--cream-art);
  /* The artwork carries paper texture, but on phones it scrolls away — without
     this the rest of the page would be flat colour. Tinted to the artwork's
     own cream so the join is invisible. */
  background-image: url("/assets/paper-v3.png");
  background-image: image-set(
    url("/assets/paper-v3.webp") type("image/webp"),
    url("/assets/paper-v3.png")  type("image/png")
  );
  background-size: 512px;
  background-repeat: repeat;
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

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

/* ---------- fixed decorative marks ----------
   These are the "locked" artwork. Fixed elements rather than
   background-attachment: fixed, which iOS Safari handles badly.
--------------------------------------------- */
.decor{
  /* The supplied background, held still while the letter scrolls over it.
     position:fixed rather than background-attachment:fixed, which iOS Safari
     either ignores or stutters on. */
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image: url("/assets/letter-bg-v1.png");
  background-image: image-set(
    url("/assets/letter-bg-v1.webp") type("image/webp"),
    url("/assets/letter-bg-v1.png")  type("image/png")
  );
  background-size: cover;
  /* Anchored to the bottom, not centred. On a wide, short window (a 13" laptop
     at ~1.94) cover scales by width and crops ~36px off the top, which lifts
     the stave lines up into the masthead. Taking the crop off the top instead
     keeps them below it. */
  background-position: center bottom;
  background-repeat: no-repeat;
}

.decor-top{ display: none; }

/* ---------- masthead ---------- */
.masthead{
  position: relative;
  z-index: 2;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: clamp(1.5rem, 3.5vw, 2.5rem) 0 1rem;
  border-bottom: 1px solid var(--rule);
  margin: 0 var(--gutter);
}

/* Indented past the terracotta in the top-left corner. The marks are sized
   by width (see LAYOUT below), so the blob always ends at ~13vw and 16vw
   always clears it. The rule moves with the wordmark, as in the mock. */
@media (min-width: 481px), (min-aspect-ratio: 571/1000){
  .masthead{ margin-left: 16vw; }
}

.masthead__name{
  margin: 0;
  /* a soft paper halo, so the wordmark stays legible whatever part of the
     artwork ends up behind it at a given window size */
  text-shadow: 0 0 6px var(--cream-art), 0 0 14px var(--cream-art),
               0 0 3px var(--cream-art);
  font-family: var(--sans);
  font-size: clamp(.72rem, .9vw, .82rem);
  letter-spacing: .26em;
  text-transform: uppercase;
  font-weight: 500;
}

.masthead__home{
  text-shadow: 0 0 6px var(--cream-art), 0 0 14px var(--cream-art),
               0 0 3px var(--cream-art);
  font-family: var(--serif);
  font-size: 1.05rem;
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}
.masthead__home:hover{ border-bottom-color: var(--ink); }

/* ---------- the letter ---------- */
.letter{
  position: relative;
  z-index: 1;                /* above the fixed marks */
  padding: 0 var(--gutter) clamp(4rem, 10vw, 7rem);
}

.letter__body{
  max-width: 42rem;
  /* offset right of centre so the marks have the left margin to live in,
     as in the mock; centres again once there's no room for that */
  margin: 0 auto;
  padding-top: clamp(3rem, 9vw, 7rem);
}
/* ---------- LAYOUT above phone width ----------
   The artwork is two transparent layers sized by viewport WIDTH only:
     top-left marks  = 52.63vw wide (880 of the original 1672px)
     mustard corner  = 16.27vw wide (272 of 1672)
   so every mark sits at a fixed vw position whatever the window's height.
   Measured from the source, in vw:
     red blob     right edge ~13vw
     staves       y 7.5-14.4vw, x 0-49.6vw   (.decor-top, scrolls)
     spiral+dots  x 26.6-33.8vw, y 14.4-27.5vw (.decor, held still)
   The previous single image used background-size:cover, whose scale and
   crop change with aspect ratio. That is what put the spiral on the
   headline in a ~900px window and the staves through the wordmark on a
   short laptop screen. */
@media (min-width: 481px), (min-aspect-ratio: 571/1000){
  /* Held still (fixed on wide screens): the spiral, plus the mustard corner.
     The spiral is cut from the same source at x435 y235, 140px wide, so it
     sits exactly where it was in the full artwork. */
  .decor{
    background-image:
      url("/assets/letter-spiral-v1.png"),
      url("/assets/letter-marks-br-v1.png");
    background-image:
      image-set(url("/assets/letter-spiral-v1.webp") type("image/webp"),
                url("/assets/letter-spiral-v1.png")  type("image/png")),
      image-set(url("/assets/letter-marks-br-v1.webp") type("image/webp"),
                url("/assets/letter-marks-br-v1.png")  type("image/png"));
    /* mustard trimmed to 12vw and nudged 3vw off the edge: at full size it
       sat under the ends of the text lines on 1000-1100px windows */
    background-size: 8.373vw auto, 12vw auto;
    background-position: left 26.017vw top 14.055vw, right -3vw bottom 0;
    background-repeat: no-repeat, no-repeat;
  }
  /* Scrolls with the page: the staves and the red blob. Held still, the
     staves crossed the headline as soon as the letter moved. */
  .decor-top{
    display: block;
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 28.11vw;                 /* 470 of 1672 */
    pointer-events: none;
    z-index: 0;
    background-image: url("/assets/letter-staves-v1.png");
    background-image: image-set(
      url("/assets/letter-staves-v1.webp") type("image/webp"),
      url("/assets/letter-staves-v1.png")  type("image/png"));
    background-size: 52.63vw auto;
    background-position: left top;
    background-repeat: no-repeat;
  }
}

/* Wide: column to the right of the spiral (ends 33.8vw), marks held still
   while the letter scrolls over them. */
@media (min-width: 1000px){
  .letter__body{
    margin-left: calc(36vw - var(--gutter));
    margin-right: 0;
    max-width: min(42rem, calc(64vw - 2 * var(--gutter)));
    /* the column's top must clear the staves, which sit ~12vw down where
       the column starts; the masthead above is ~4rem tall */
    padding-top: max(clamp(3rem, 9vw, 7rem), calc(14vw - 4rem));
  }
}

/* Mid (tablets, narrow laptop windows): no room beside the spiral, so the
   artwork owns the opening and the letter starts below it, as on phones.
   Not fixed: held still, the staves would cross every line on the way down. */
@media (min-width: 481px) and (max-width: 999px),
       (max-width: 480px) and (min-aspect-ratio: 571/1000){
  .decor{
    position: absolute;
    height: 100svh;
    height: 100dvh;
    /* The marks shrink with the width but the wordmark doesn't, so below
       ~800px the stave ends reach up to it. Drop the marks by the difference
       (0 at 800px, ~22px at 480px); the letter below moves down to match. */
    background-position: left 26.017vw top calc(14.055vw + max(0px, 3.5rem - 7vw)),
                         right -3vw bottom 0;
  }
  .decor-top{
    height: calc(28.11vw + max(0px, 3.5rem - 7vw));
    background-position: left 0 top max(0px, calc(3.5rem - 7vw));
  }
  .letter__body{
    margin-left: calc(16vw - var(--gutter));   /* aligned with the masthead */
    margin-right: 0;
    max-width: min(42rem, calc(84vw - 2 * var(--gutter)));
    /* spiral ends at 27.5vw, plus the drop above */
    padding-top: calc(30vw - 4rem + max(0px, 3.5rem - 7vw));
  }
}

.eyebrow{
  margin: 0 0 .9rem;
  font-family: var(--sans);
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .24em;
  text-transform: uppercase;
  color: var(--terracotta);
}

.letter__title{
  margin: 0 0 .7rem;
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(2.1rem, 1.4rem + 2.4vw, 3.4rem);
  line-height: 1.04;
  letter-spacing: -0.005em;
  text-wrap: balance;
}

.letter__date{
  margin: 0 0 clamp(2rem, 4vw, 2.75rem);
  font-family: var(--serif);
  font-size: 1.05rem;
  color: var(--ink-soft);
}

.letter__prose p{
  font-family: var(--serif);
  /* 500, not 400: Cormorant is a light face and reads faint at body size */
  font-weight: 500;
  font-size: clamp(1.2rem, 1.12rem + 0.45vw, 1.4rem);
  line-height: 1.62;
  margin: 0 0 1.3em;
  text-wrap: pretty;
}
.letter__salutation{ margin-bottom: 1.5em !important; }

/* Sign-off: more air above it than a paragraph break, and the name only a
   little larger than the line above. At 1.9rem against a 1.4rem body it read
   as a size mismatch rather than a signature. */
.letter__signoff{
  font-family: var(--serif); font-weight: 500;
  font-size: clamp(1.2rem, 1.12rem + 0.45vw, 1.4rem);
  margin: 2.2em 0 .35em;
}
.letter__name{
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(1.3rem, 1.16rem + 0.5vw, 1.55rem);
  margin: 0;
}

/* ---------- the ask ---------- */
.after{
  margin-top: clamp(3rem, 8vw, 5rem);
  padding-top: clamp(2rem, 5vw, 2.5rem);
  border-top: 1px solid var(--rule);
}

.after__line{
  margin: 0 0 1.1rem;
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(1.05rem, 1rem + 0.3vw, 1.2rem);
  color: var(--ink-soft);
}

.signup{ position: relative; max-width: 30rem; }
.signup__row{ display: flex; gap: .5rem; flex-wrap: wrap; }

.signup__input{
  flex: 1 1 14rem; min-width: 0;
  padding: .85rem 1rem;
  font: inherit; font-size: .95rem;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.55);
  background: color-mix(in srgb, #fff 55%, transparent);
  border: 1px solid var(--rule);
  border-radius: 2px;
  transition: border-color .18s ease, background .18s ease;
}
.signup__input::placeholder{ color: rgba(74, 91, 82, 0.72);
  color: color-mix(in srgb, var(--ink-soft) 72%, transparent); }
.signup__input:focus-visible{
  outline: none; border-color: var(--ink);
  background: rgba(255, 255, 255, 0.82);
  background: color-mix(in srgb, #fff 82%, transparent);
}
.signup__input[aria-invalid="true"]{ border-color: var(--terracotta); }

/* Safari paints autofilled fields yellow and ignores background-color;
   an oversized inset shadow is the only reliable override. */
.signup__input:-webkit-autofill,
.signup__input:-webkit-autofill:hover,
.signup__input:-webkit-autofill:focus,
.signup__input:autofill{
  -webkit-text-fill-color: var(--ink) !important;
  -webkit-box-shadow: 0 0 0 1000px #F5EFE4 inset !important;
          box-shadow: 0 0 0 1000px #F5EFE4 inset !important;
  caret-color: var(--ink);
  transition: background-color 100000s ease-in-out 0s !important;
}

.signup__btn{
  flex: 0 0 auto;
  padding: .85rem 1.5rem;
  font: inherit; font-size: .9rem;
  color: var(--cream); background: var(--ink);
  border: 1px solid var(--ink); border-radius: 2px;
  cursor: pointer;
  transition: background .18s ease, transform .18s ease;
}
.signup__btn:hover{ background: #12332B; }
.signup__btn:hover{ background: color-mix(in srgb, var(--ink) 82%, var(--teal)); }
.signup__btn:active{ transform: translateY(1px); }
.signup__btn[disabled]{ opacity: .55; cursor: default; transform: none; }

.signup__msg{
  margin: .8rem 0 0; min-height: 1.25em;
  font-size: .82rem; color: var(--ink-soft);
}
.signup__msg[data-state="error"]{ color: var(--terracotta); }
.signup__msg[data-state="ok"]{ color: var(--ink); }

.signup.is-sent{ padding-bottom: calc(0.8rem + 1.25em); }
.signup.is-sent .signup__row{ visibility: hidden; }
.signup.is-sent .signup__msg{
  position: absolute; inset: 0; margin: 0;
  display: flex; align-items: center;
  font-family: var(--serif);
  font-size: clamp(1.15rem, 2.6vw, 1.35rem);
  line-height: 1.3;
}

.hp{ position:absolute; left:-9999px; width:1px; height:1px; overflow:hidden; }

/* ---------- phones ---------- */
@media (max-width: 480px) and (max-aspect-ratio: 57/100){
  /* NOT fixed on phones. Held still, the stave lines sit across the body text
     the whole way down the letter. Absolute + one screen tall means the
     artwork owns the opening and then scrolls away, leaving clean paper.
     Phones keep the single cover image: on a tall screen it crops to the
     staves alone, which is the approved phone look. It only holds while
     the screen is tall: the spiral's dots stay cropped off the left edge
     while width < 0.576 x height, hence the aspect-ratio condition. Wider
     or squatter windows (481px+, short in-app browsers) get the two-layer
     layout above; at 559px and 700px the cover crop put the spiral on the
     headline. */
  .decor{
    position: absolute;
    height: 100svh;
    height: 100dvh;
  }
  /* room for the staves above the copy */
  .letter__body{ padding-top: clamp(9rem, 32vw, 12rem); }
}
@media (max-width: 700px){
  .signup__input, .signup__btn{ flex: 1 1 100%; }
}

@media (prefers-reduced-motion: reduce){
  *, *::before, *::after{ animation: none !important; transition: none !important; }
}

/* "Did you mean …?" typo fix, offered as a link-like button */
.signup__fix{
  font: inherit; color: var(--ink); background: none; border: 0; padding: 0;
  text-decoration: underline; text-underline-offset: .15em; cursor: pointer;
}
