/* One foreground paper system, sampled from the approved homepage material.
   Photograph, crop, camera, screenshots and live text remain untouched. */
:root {
  --sheet-fibre: url('assets/desk/paper-fibre-v4.webp');
  --sheet-contour: url('assets/desk/paper-contour-v28.svg');
}

html body :is(.home-story, .desk-examples, .section:where(#availability), .footer,
  .feature-section, .support-main, .legal-main, .product-hero > div,
  .buy-card:where(#product-purchase > .buy-card), .product-detail-grid article, .use-cases,
  .support-card, .support-contact, .faq details, .feature-section details,
  .audio-column .audio-track, .reviews-section, .review-form, .review-card, .reviews-empty) {
  --sheet-edge: 14px;
  --sheet-wash: transparent;
  position: relative;
  isolation: isolate;
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
  filter: drop-shadow(0 1px .7px #704b2770) drop-shadow(2px 9px 9px #49301c38);
}

html body :is(.home-story, .desk-examples, .section:where(#availability), .footer,
  .feature-section, .support-main, .legal-main, .product-hero > div,
  .buy-card:where(#product-purchase > .buy-card), .product-detail-grid article, .use-cases,
  .support-card, .support-contact, .faq details, .feature-section details,
  .audio-column .audio-track, .reviews-section, .review-form, .review-card, .reviews-empty)::before,
html body:not(.reference-home) .header::before {
  content: '';
  display: block;
  position: absolute;
  inset: -3px;
  width: auto;
  height: auto;
  z-index: -1;
  box-sizing: border-box;
  border: 0;
  border-image: none;
  border-radius: 0;
  background: linear-gradient(var(--sheet-wash), var(--sheet-wash)), #f3e4c6 var(--sheet-fibre) center top / 560px auto repeat;
  background-clip: border-box;
  box-shadow: inset 0 1px 1px #fff8e6d9, inset -1px -2px 2px #a6834c38;
  opacity: 1;
  transform: none;
  filter: none;
  clip-path: none;
  mask: var(--sheet-contour) center / 100% 100% no-repeat;
  -webkit-mask-box-image: var(--sheet-contour) 24 fill / var(--sheet-edge) / 0 stretch;
  pointer-events: none;
}
/* Nine-slice is independent of the fibre tile: no differently coloured strips,
   and opening a long accordion cannot stretch the grain or its edge thickness. */
@supports (-webkit-mask-box-image-source: none) {
  html body :is(.home-story, .desk-examples, .section:where(#availability), .footer,
    .feature-section, .support-main, .legal-main, .product-hero > div,
    .buy-card:where(#product-purchase > .buy-card), .product-detail-grid article, .use-cases,
    .support-card, .support-contact, .faq details, .feature-section details,
    .audio-column .audio-track, .reviews-section, .review-form, .review-card, .reviews-empty)::before,
  html body:not(.reference-home) .header::before { mask-image: none; }
}
/* Retire the old opaque wood cutouts; depth now follows the actual paper edge. */
html body :is(.home-story, .desk-examples, .section:where(#availability), .footer,
  .feature-section, .support-main, .legal-main, .product-hero > div,
  .buy-card:where(#product-purchase > .buy-card), .product-detail-grid article, .use-cases,
  .support-card, .support-contact, .faq details, .feature-section details,
  .audio-column .audio-track, .reviews-section, .review-form, .review-card, .reviews-empty)::after {
  content: none;
  display: none;
}
html body :is(.support-main, .legal-main, .product-hero > div,
  .buy-card:where(#product-purchase > .buy-card), .support-card, .faq details) > .paper-corner { display: none; }

/* Small cards sit lightly on the larger sheets, without heavy repeated frames. */
html body :is(.support-card, .support-contact, .faq details,
  .feature-section details, .audio-column .audio-track, .review-card) {
  --sheet-edge: 8px;
  --sheet-wash: #fffaf027;
  filter: drop-shadow(0 1px .5px #79532a52) drop-shadow(1px 4px 4px #4b321b23);
}
html body .audio-column .audio-track.is-original { border-left: 2px solid #e76528; }
html body .audio-column .audio-track.is-original::before { left: -2px; }
/* A small settings illustration gets a small sheet, not an empty full row. */
html body .feature-section details[open] {
  flex: 0 1 auto;
  width: fit-content;
  max-width: 100%;
}

html body.reference-home .home-story::before { inset: -12px -3px; }
html body.reference-home :is(.desk-examples, .section:where(#availability))::before { inset: -16px 0; }
/* A footer ends the page. Its bottom edge is flush, not a new gap of desk. */
html body .footer.footer::before {
  top: -3px;
  bottom: 0;
  left: 0;
  right: 0;
  /* Only the exposed top edge is torn. Sides and bottom meet the viewport. */
  mask: none;
  -webkit-mask-box-image-source: url('assets/desk/paper-top-contour-v32.svg');
  -webkit-mask-box-image-slice: 24 0 0 0 fill;
  -webkit-mask-box-image-width: var(--sheet-edge) 0 0;
}
html body .footer.footer {
  width: 100%;
  max-width: none;
  margin-inline: 0;
  margin-bottom: 0;
  border: 0;
  border-radius: 0;
  padding-inline: max(22px, 5vw, calc((100% - 1320px) / 2));
}
/* Short secondary pages keep the compact paper content, with free desk space
   above (never below) the terminal footer. Long pages retain normal flow. */
html body:not(.reference-home) { display: flex; flex-direction: column; }
html body:not(.reference-home) > .footer.footer { margin-top: auto; flex-shrink: 0; }
html body:not(.reference-home) > .header { flex-shrink: 0; }

/* A header must not gain a filter/transform: its menu tools are viewport-fixed. */
html body:not(.reference-home) .header {
  --sheet-edge: 10px;
  --sheet-wash: #fffaf015;
  position: relative;
  z-index: 40;
  isolation: isolate;
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: 0 7px 13px -9px #49301c52;
  filter: none;
}
html body .ea-dialog {
  background: #f3e4c6 var(--sheet-fibre) center top / 560px auto repeat;
  border-left: 1px solid #fff4d9ad;
  box-shadow: -2px 0 1px #7d592b70, -15px 0 28px #39261638;
}
html body .ea-language-menu {
  background: #f3e4c6 var(--sheet-fibre) center top / 560px auto repeat;
  box-shadow: inset 0 1px 0 #fff8df, 0 2px 2px #6e482a33, 0 10px 20px -7px #492e1b52;
}

@media (max-width: 760px) {
  html:root body :is(.home-story, .feature-section, .support-main, .legal-main) { --sheet-edge: 11px; }
  html:root body :is(.support-card, .faq details, .feature-section details) { --sheet-edge: 7px; }
}

/* The homepage hero is live paper below the photographic desktop breakpoint.
   These three responsive surfaces must share the same finish as every sheet,
   rather than falling back to the old flat cream rectangles. */
@media (max-width: 1100px) {
  html body.reference-home :is(.header, .hero-copy, .hero-media) {
    --sheet-edge: 12px;
    --sheet-wash: transparent;
    position: relative;
    isolation: isolate;
    border: 0;
    border-radius: 0;
    background: none;
    box-shadow: none;
  }
  html body.reference-home :is(.hero-copy, .hero-media) {
    filter: drop-shadow(0 1px .7px #704b2770) drop-shadow(2px 9px 9px #49301c38);
  }
  html body.reference-home .header {
    /* Menu/language controls must never gain a filtered fixed ancestor. */
    filter: none;
    box-shadow: 0 7px 13px -9px #49301c52;
  }
  html body.reference-home :is(.header, .hero-copy, .hero-media)::before {
    content: '';
    display: block;
    position: absolute;
    inset: -3px;
    width: auto;
    height: auto;
    z-index: -1;
    border: 0;
    border-radius: 0;
    background: #f3e4c6 var(--sheet-fibre) center top / 560px auto repeat;
    box-shadow: inset 0 1px 1px #fff8e6d9, inset -1px -2px 2px #a6834c38;
    opacity: 1;
    transform: none;
    filter: none;
    clip-path: none;
    mask: var(--sheet-contour) center / 100% 100% no-repeat;
    -webkit-mask-box-image: var(--sheet-contour) 24 fill / var(--sheet-edge) / 0 stretch;
    pointer-events: none;
  }
  @supports (-webkit-mask-box-image-source: none) {
    html body.reference-home :is(.header, .hero-copy, .hero-media)::before { mask-image: none; }
  }
  html body.reference-home :is(.header, .hero-copy, .hero-media)::after,
  html body.reference-home .hero-copy > .paper-corner { display: none; content: none; }
  html body.reference-home .hero-media { padding: 14px 14px 9px; }
}
