/* Illustrated Santa letter sheets — 8.5x11, shared by preview, print, and the styles gallery. */

@font-face {
  font-family: "Cinzel";
  src: url("../fonts/cinzel.woff2") format("woff2"),
       url("../fonts/cinzel.ttf") format("truetype");
  font-weight: 400 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Great Vibes";
  src: url("../fonts/great-vibes.woff2") format("woff2"),
       url("../fonts/great-vibes.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Bilbo Swash Caps";
  src: url("../fonts/bilbo-swash-caps.woff2") format("woff2"),
       url("../fonts/bilbo-swash-caps.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Short Stack";
  src: url("../fonts/short-stack.woff2") format("woff2"),
       url("../fonts/short-stack.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Libre Baskerville";
  src: url("../fonts/libre-baskerville.woff2") format("woff2"),
       url("../fonts/libre-baskerville.ttf") format("truetype");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Libre Baskerville";
  src: url("../fonts/libre-baskerville-italic.woff2") format("woff2"),
       url("../fonts/libre-baskerville-italic.ttf") format("truetype");
  font-weight: 400 700;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Mountains of Christmas";
  src: url("../fonts/mountains-of-christmas-bold.woff2") format("woff2"),
       url("../fonts/mountains-of-christmas-bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Playfair Display";
  src: url("../fonts/playfair.woff2") format("woff2"),
       url("../fonts/playfair.ttf") format("truetype");
  font-weight: 400 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Playfair Display";
  src: url("../fonts/playfair-italic.woff2") format("woff2"),
       url("../fonts/playfair-italic.ttf") format("truetype");
  font-weight: 400 900;
  font-style: italic;
  font-display: swap;
}

.letter-wrap {
  container-type: inline-size;
  container-name: sheet;
  width: min(100%, 8.5in);
  aspect-ratio: 8.5 / 11;
  overflow: hidden;
  position: relative;
  margin: 0 auto;
  background: #fff;
  box-shadow: 0 10px 28px rgba(42, 28, 18, 0.22);
}

.letter-sheet.letter-illustrated {
  width: 8.5in;
  height: 11in;
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: top left;
  transform: scale(calc(100cqi / 8.5in));
  background-color: #f3ead4;
  background-repeat: no-repeat;
  background-position: center;
  background-size: 100% 100%;
  border: none;
  border-radius: 0;
  padding: 0;
  box-shadow: none;
  color: #2a1c12;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.letter-sheet.letter-illustrated .letter-panel {
  position: absolute;
  top: var(--box-top, 20%);
  left: var(--box-left, 16%);
  right: var(--box-right, 16%);
  bottom: var(--box-bottom, 20%);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: #2a1c12;
  overflow-wrap: break-word;
  word-wrap: break-word;
}

.letter-sheet.letter-illustrated .letter-title {
  display: none;
}

.letter-sheet.letter-illustrated .letter-greet,
.letter-sheet.letter-illustrated .letter-body,
.letter-sheet.letter-illustrated .letter-body p,
.letter-sheet.letter-illustrated .letter-close {
  font-family: "Bilbo Swash Caps", "Palatino Linotype", Palatino, "Times New Roman", cursive;
  font-size: inherit;
  line-height: 1.45;
  margin: 0 0 0.5em;
}

/* The child's own letter uses a bundled kid handwriting face (Short Stack, OFL). */
.letter-sheet.letter-illustrated.letter-from-child .letter-panel {
  justify-content: flex-start;
}
.letter-sheet.letter-illustrated.letter-from-child .letter-greet,
.letter-sheet.letter-illustrated.letter-from-child .letter-body,
.letter-sheet.letter-illustrated.letter-from-child .letter-body p,
.letter-sheet.letter-illustrated.letter-from-child .letter-close,
.letter-sheet.letter-illustrated.letter-from-child .letter-sign {
  font-family: "Short Stack", "Palatino Linotype", Palatino, cursive;
  font-style: normal;
  font-size: var(--body-pt, 16pt);
  line-height: 1.45;
}
.letter-sheet.letter-illustrated.letter-from-child .letter-greet,
.letter-sheet.letter-illustrated.letter-from-child .letter-body p {
  margin: 0 0 0.45em;
}
.letter-sheet.letter-illustrated.letter-from-child .letter-body p:last-child { margin-bottom: 0.2em; }
.letter-sheet.letter-illustrated.letter-from-child .letter-close {
  margin: 0.5em 0 0.02em;
}
.letter-sheet.letter-illustrated.letter-from-child.letter-child-compact .letter-close {
  margin-top: 0;
}
.letter-sheet.letter-illustrated.letter-from-child .letter-sign {
  color: #2a1c12;
  font-size: var(--body-pt, 16pt);
  line-height: 1.25;
  margin: 0;
}

/* The body may shrink (and clip, with the fit warning) but the sign-off and signature
   below it never shrink, so they can never be drawn over the letter text. */
.letter-sheet.letter-illustrated .letter-body {
  font-size: var(--body-pt, 16pt);
  flex: 0 1 auto;
  min-height: 0;
  overflow: hidden;
}
.letter-sheet.letter-illustrated .letter-body p { margin: 0 0 0.5em; }
.letter-sheet.letter-illustrated .letter-body p:last-child { margin-bottom: 0.2em; }
.letter-sheet.letter-illustrated .letter-greet {
  font-style: normal;
  font-size: var(--body-pt, 16pt);
}
.letter-sheet.letter-illustrated .letter-close {
  /* Tight sign-off spacing (no large gap between body and signature). */
  margin: 0.3em 0 0.02em;
  font-size: var(--body-pt, 16pt);
  flex: none;
}
/* The signature sits directly under the sign-off ("Love," / "Warmest wishes..."), lined up with it
   on the left, like a hand-signed letter, in every design (screen and print). */
.letter-sheet.letter-illustrated .letter-sign {
  font-family: "Great Vibes", "Segoe Script", "Apple Chancery", cursive;
  font-size: min(36pt, calc(var(--body-pt, 16pt) * 2.6));
  font-weight: 400;
  line-height: 1.05;
  margin: 0;
  text-align: left;
  flex: none;
  color: #7a1c14;
}

/* Per-template art and title styling.
   Screen uses the smaller -phone.webp; print and the off-screen PDF/print stage use the 2550×3300 JPEG. */
.letter-sheet.look-filigree { background-image: url("../img/letter-filigree-phone.webp"); }
.letter-sheet.look-filigree .letter-title {
  font-family: "Cinzel", "Times New Roman", serif;
  font-size: 20pt;
  font-weight: 700;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: #6b4e0e;
  text-align: center;
  margin-bottom: 0.45em;
}
.letter-sheet.look-filigree .letter-sign { color: #5c1410; }

.letter-sheet.look-candycane { background-image: url("../img/letter-candycane-phone.webp"); }
.letter-sheet.look-candycane .letter-title {
  font-family: "Mountains of Christmas", "Palatino Linotype", serif;
  font-size: 34pt;
  font-weight: 700;
  color: #7a1c14;
  text-align: center;
}
.letter-sheet.look-candycane .letter-sign { color: #7a1c14; }

.letter-sheet.look-snowflake { background-image: url("../img/letter-snowflake-phone.webp"); }
.letter-sheet.look-snowflake .letter-title {
  font-family: "Playfair Display", Georgia, serif;
  font-style: italic;
  font-size: 24pt;
  font-weight: 700;
  color: #5a2e12;
  text-align: center;
}
.letter-sheet.look-snowflake .letter-sign { color: #7a1c14; }

.letter-sheet.look-stars { background-image: url("../img/letter-stars-phone.webp"); }
.letter-sheet.look-stars .letter-title {
  font-family: "Playfair Display", Georgia, serif;
  font-style: italic;
  font-size: 24pt;
  font-weight: 700;
  color: #6b4e0e;
  text-align: center;
}
.letter-sheet.look-stars .letter-sign { color: #7a1c14; }

.letter-sheet.look-gingerbread { background-image: url("../img/letter-gingerbread-phone.webp"); }
.letter-sheet.look-gingerbread .letter-title {
  font-family: "Mountains of Christmas", "Palatino Linotype", serif;
  font-size: 32pt;
  font-weight: 700;
  color: #5c1410;
  text-align: center;
}
.letter-sheet.look-gingerbread .letter-sign { color: #5c1410; }
.letter-sheet.look-kid-candycane { background-image: url("../img/letter-kid-candycane-phone.webp"); }
.letter-sheet.look-kid-icons { background-image: url("../img/letter-kid-icons-phone.webp"); }
.letter-sheet.look-kid-plaid { background-image: url("../img/letter-kid-plaid-phone.webp"); }
.letter-sheet.look-kid-holly { background-image: url("../img/letter-kid-holly-phone.webp"); }
.letter-sheet.look-kid-stars { background-image: url("../img/letter-kid-stars-phone.webp"); }

@media print {
  .letter-sheet.look-filigree { background-image: url("../img/letter-filigree.jpg"); }
  .letter-sheet.look-candycane { background-image: url("../img/letter-candycane.jpg"); }
  .letter-sheet.look-snowflake { background-image: url("../img/letter-snowflake.jpg"); }
  .letter-sheet.look-stars { background-image: url("../img/letter-stars.jpg"); }
  .letter-sheet.look-gingerbread { background-image: url("../img/letter-gingerbread.jpg"); }
  .letter-sheet.look-kid-candycane { background-image: url("../img/letter-kid-candycane.jpg"); }
  .letter-sheet.look-kid-icons { background-image: url("../img/letter-kid-icons.jpg"); }
  .letter-sheet.look-kid-plaid { background-image: url("../img/letter-kid-plaid.jpg"); }
  .letter-sheet.look-kid-holly { background-image: url("../img/letter-kid-holly.jpg"); }
  .letter-sheet.look-kid-stars { background-image: url("../img/letter-kid-stars.jpg"); }
}
.pdf-render .letter-sheet.look-filigree,
#print-stage .letter-sheet.look-filigree { background-image: url("../img/letter-filigree.jpg"); }
.pdf-render .letter-sheet.look-candycane,
#print-stage .letter-sheet.look-candycane { background-image: url("../img/letter-candycane.jpg"); }
.pdf-render .letter-sheet.look-snowflake,
#print-stage .letter-sheet.look-snowflake { background-image: url("../img/letter-snowflake.jpg"); }
.pdf-render .letter-sheet.look-stars,
#print-stage .letter-sheet.look-stars { background-image: url("../img/letter-stars.jpg"); }
.pdf-render .letter-sheet.look-gingerbread,
#print-stage .letter-sheet.look-gingerbread { background-image: url("../img/letter-gingerbread.jpg"); }
.pdf-render .letter-sheet.look-kid-candycane,
#print-stage .letter-sheet.look-kid-candycane { background-image: url("../img/letter-kid-candycane.jpg"); }
.pdf-render .letter-sheet.look-kid-icons,
#print-stage .letter-sheet.look-kid-icons { background-image: url("../img/letter-kid-icons.jpg"); }
.pdf-render .letter-sheet.look-kid-plaid,
#print-stage .letter-sheet.look-kid-plaid { background-image: url("../img/letter-kid-plaid.jpg"); }
.pdf-render .letter-sheet.look-kid-holly,
#print-stage .letter-sheet.look-kid-holly { background-image: url("../img/letter-kid-holly.jpg"); }
.pdf-render .letter-sheet.look-kid-stars,
#print-stage .letter-sheet.look-kid-stars { background-image: url("../img/letter-kid-stars.jpg"); }

/* Style thumbnail picker (kid designs and Santa borders):
   mobile / narrower windows: 2 per row, scroll for more;
   wider desktop: 3 per row, about twice the old 5-across size. */
.style-thumbs,
.style-thumbs-5 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 16px;
  margin: 0 0 16px;
}
@media (min-width: 1100px) {
  .style-thumbs, .style-thumbs-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.style-thumb {
  appearance: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 10px;
  border: 2px solid #e0d0b0;
  border-radius: 12px;
  background: #fffef8;
  color: var(--ink, #2a1c12);
  cursor: pointer;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  text-align: center;
  line-height: 1.25;
}
.style-thumb img {
  width: 100%;
  aspect-ratio: 8.5 / 11;
  object-fit: cover;
  border-radius: 6px;
  background: #f3ead4;
  pointer-events: none;
}
.style-thumb.selected,
.style-thumb[aria-checked="true"] {
  border-color: #b42318;
  background: #fff3e8;
  box-shadow: 0 0 0 2px rgba(180, 35, 24, 0.25);
}
.style-thumb:focus-visible {
  outline: 3px solid #6b4e0e;
  outline-offset: 2px;
}
.fit-warning {
  margin: 0 0 12px;
}


.letter-sheet.letter-illustrated.letter-tight .letter-body,
.letter-sheet.letter-illustrated.letter-tight .letter-greet,
.letter-sheet.letter-illustrated.letter-tight .letter-close {
  line-height: 1.28;
}
.letter-sheet.letter-illustrated.letter-tight .letter-body p { margin: 0 0 0.28em; }
.letter-sheet.letter-illustrated.letter-tight .letter-title { font-size: 28pt; }
.letter-sheet.letter-illustrated.letter-tight .letter-sign { font-size: min(30pt, calc(var(--body-pt, 16pt) * 2.6)); }
.letter-sheet.letter-illustrated.letter-tight.look-filigree .letter-title { font-size: 16pt; }
.letter-sheet.letter-illustrated.letter-tight.look-candycane .letter-title { font-size: 26pt; }
.letter-sheet.letter-illustrated.letter-tight.look-snowflake .letter-title { font-size: 18pt; }
.letter-sheet.letter-illustrated.letter-tight.look-stars .letter-title { font-size: 18pt; }
.letter-sheet.letter-illustrated.letter-tight.look-gingerbread .letter-title { font-size: 24pt; }

@media print {
  @page { size: letter; margin: 0; }
  .letter-wrap {
    width: 8.5in;
    height: 11in;
    aspect-ratio: auto;
    overflow: hidden;
    box-shadow: none;
    margin: 0;
    break-inside: avoid;
    page-break-inside: avoid;
  }
  .letter-sheet.letter-illustrated {
    transform: none;
    box-shadow: none !important;
    border: none !important;
    padding: 0 !important;
    border-radius: 0 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}

/* P.S. sits under the signature and never shrinks, like the sign-off. */
.letter-sheet.letter-illustrated .letter-ps {
  font-family: "Libre Baskerville", "Palatino Linotype", Palatino, "Times New Roman", serif;
  font-style: italic;
  font-size: max(11pt, calc(var(--body-pt, 16pt) * 0.92));
  line-height: 1.35;
  margin: 0.35em 0 0;
  flex: none;
}


/* Full-screen, readable letter preview (grown-up step, phones included).
   This is a typographic reading view, not a scaled US Letter page, so 14–16pt
   body type stays readable at 390px. The print/PDF sheet is unchanged. */
.letter-preview[hidden] { display: none !important; }
.letter-preview {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  flex-direction: column;
  background: #f6edda;
  color: #2a1c12;
}
body.letter-preview-open { overflow: hidden; }
.letter-preview-bar {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  padding-top: max(10px, env(safe-area-inset-top));
  background: #2a1c12;
  color: #f6edda;
}
.letter-preview-heading {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
}
.letter-preview-bar .btn { min-height: 44px; min-width: 88px; }
.letter-preview-scroll {
  flex: 1 1 auto;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 16px 40px;
  padding-bottom: max(40px, env(safe-area-inset-bottom));
}
.letter-preview-page {
  max-width: 36rem;
  margin: 0 auto;
  padding: 8px 4px 24px;
  color: #2a1c12;
}
.letter-preview-page .letter-greet,
.letter-preview-page .letter-body,
.letter-preview-page .letter-body p,
.letter-preview-page .letter-close {
  font-family: "Bilbo Swash Caps", "Palatino Linotype", Palatino, "Times New Roman", cursive;
  font-size: 1.25rem; /* ~20px: readable on a 390px phone */
  line-height: 1.5;
  margin: 0 0 0.7em;
}
.letter-preview-page .letter-body p:last-child { margin-bottom: 0.3em; }
.letter-preview-page .letter-sign {
  font-family: "Great Vibes", "Segoe Script", "Apple Chancery", cursive;
  font-size: 2rem;
  line-height: 1.1;
  margin: 0;
  color: #7a1c14;
}
