/* Proovly — the seasonal themes' layouts, shared by every theme (views/theme.rs). A theme only gives its
   pictures: the app sets them as variables on .app (--paper, --home-foot, --me-art and the others) and
   names the parts it has as classes (.has-paper, .no-home-paper, .no-me-paper, .has-foot, .has-me-art) and its layout
   (.layout-photo or .layout-faded). Its drawings by the cards are pictures over the page (.frost, from
   views/frost.rs). So a new theme needs no rules here, only its pictures in views/theme.rs. The page
   headers have no rules here: they look the same in every theme (styles.css), with the theme's pictures.
   A theme's own colours (winter) are in its own file, on html[data-look], so the first paint has them. */

/* ---------- the paper ----------
   The theme's picture along both edges of every screen, behind the cards, repeated down the page and
   scrolling with it. */
.app.has-paper { isolation: isolate; }
.app.has-paper::before,
.app.has-paper .home-body::before {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: var(--paper) top center / 100% auto repeat-y;
}
/* Home's sheet slides up over the photo, so it carries the paper too, from where it turns solid. */
.app.has-paper .home-body::before {
  -webkit-mask-image: linear-gradient(180deg, transparent 48px, #000 120px); mask-image: linear-gradient(180deg, transparent 48px, #000 120px);
}
/* On Home the sheet carries the paper alone: the page's own copy would show through the sheet's clear
   top edge, out of step with it. */
.app.has-paper:has(.view.home)::before { content: none; }
/* A theme whose drawings by Home's or Me's cards take the paper's place there keeps that page without it. */
.app.no-home-paper .home-body::before { content: none; }
.app.no-me-paper:has(.view.me)::before { content: none; }
/* Some papers are only for light mode: dark mode keeps its plain dark page. */
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) .app.paper-light-only::before,
  html:not([data-theme="light"]) .app.paper-light-only .home-body::before { content: none; }
}
html[data-theme="dark"] .app.paper-light-only::before,
html[data-theme="dark"] .app.paper-light-only .home-body::before { content: none; }

/* ---------- the photo layout (autumn, New Year's Eve) ---------- */
/* The page headers keep the plain paper of the original design: the paper is invisible on them and
   starts below the header, fading in under the hero pictures as they fade out. Add and Library headers
   are the same height (styles.css), so they share the stops. */
.app.layout-photo.has-paper:has(.view:is(.add, .library))::before {
  -webkit-mask-image: linear-gradient(180deg, transparent calc(env(safe-area-inset-top, 0px) + 195px), #000 calc(env(safe-area-inset-top, 0px) + 265px));
  mask-image: linear-gradient(180deg, transparent calc(env(safe-area-inset-top, 0px) + 195px), #000 calc(env(safe-area-inset-top, 0px) + 265px));
}
/* On Me the paper starts lower, at the stats card, below the greeting block. */
.app.layout-photo.has-paper:has(.view.me)::before {
  -webkit-mask-image: linear-gradient(180deg, transparent calc(env(safe-area-inset-top, 0px) + 265px), #000 calc(env(safe-area-inset-top, 0px) + 335px));
  mask-image: linear-gradient(180deg, transparent calc(env(safe-area-inset-top, 0px) + 265px), #000 calc(env(safe-area-inset-top, 0px) + 335px));
}

/* Words that lie straight on the page, not on a card, sit on the paper: a glow in the page colour
   around the letters keeps them readable, the same glow as on the header pictures. */
.app.layout-photo .view :is(h1, h2, h3, p, label, .q-label, .me-name, .count, .dg-head, .cal-hint):not(:is(.card, .banner, .need, .btn, .chip, .seg, .page-hero, .home-hero, .overlay) *) {
  text-shadow: 0 0 2px var(--bg), 0 0 2px var(--bg), 0 0 3px var(--bg), 0 0 3px var(--bg), 0 0 4px var(--bg), 0 0 5px var(--bg), 0 0 6px var(--bg), 0 0 8px var(--bg);
}

/* ---------- Home's foot ----------
   Home ends on the theme's picture (in the shape 3:1), resting on the tab bar, and the last card sits on
   it: the card's bottom edge meets the picture about three quarters down (8% of the width). The picture
   lies over the cards, and taps go through it. */
.app.has-foot .home-body { padding-bottom: calc(78px + env(safe-area-inset-bottom, 0px) + 8%); }
.app.has-foot .home-body::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: calc(74px + env(safe-area-inset-bottom, 0px)); z-index: 4;
  aspect-ratio: 3; pointer-events: none; background: var(--home-foot) bottom center / 100% auto no-repeat;
}
/* Add can end on the same picture: the words at its foot sit in the picture's open middle. */
.app.has-add-foot .view.add { padding-bottom: calc(78px + env(safe-area-inset-bottom, 0px) + 18%); }
.app.has-add-foot .view.add::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: calc(74px + env(safe-area-inset-bottom, 0px)); z-index: 4;
  aspect-ratio: 3; pointer-events: none; background: var(--home-foot) bottom center / 100% auto no-repeat;
}
/* "Saved as you write" stays readable over the picture: it sits above it on a soft glow in the card's
   colour. The last card gives up its own layer for that: no z-index, and its rise animation lets go of the
   card when it ends. Its flower is lifted above the card before it. */
.app.has-foot .home-body .reflect { z-index: auto; animation-fill-mode: backwards; }
.app.has-foot .home-body .reflect .j-flower { z-index: 3; }
.app.has-foot .home-body .reflect .j-saved {
  position: relative; z-index: 5; width: fit-content; margin-left: auto; padding: 2px 10px; border-radius: 999px;
  background: var(--surface); box-shadow: 0 0 10px 6px var(--surface);
}

/* ---------- Me's picture ----------
   The theme's picture in the top right corner, behind the greeting (--me-art-w wide, in the shape
   --me-art-ratio). It scrolls with the page, and taps go through it. */
.app.has-me-art .view.me { position: relative; }
.app.has-me-art .view.me::before {
  content: ""; position: absolute; top: 0; right: 0; z-index: -1; width: var(--me-art-w); aspect-ratio: var(--me-art-ratio);
  pointer-events: none; background: var(--me-art) top right / 100% auto no-repeat;
}

/* ---------- Home's intention ----------
   A theme's drawing over the intention card's top right corner gets room (--intention-room): a long
   intention wraps before it instead of running under it. */
.intention-text { padding-right: var(--intention-room, 0px); }

/* ---------- drawings by the cards ----------
   The theme's drawings over a page (CardDrawings in views/mod.rs, after the mockups: winter's sprigs and
   snowflakes, Valentine's roses, ribbons and hearts, Christmas pine, Easter flowers, summer's sea and grass). Each one is placed by its card, clear of words
   (placeFrost in interop.js), and fades in once placed; when the page changes, it glides to its new place.
   Taps go through them. The sprigs (roses, ribbons) are cut flat at the screen's edge, so they sit on it and
   stay still; the small ones (snowflakes, stars, hearts) sway. */
.frost { position: absolute; inset: 0; z-index: 3; pointer-events: none; overflow: clip; opacity: 0; transition: opacity .8s var(--ease) .2s; }
.frost.placed { opacity: 1; }
.frost.placed .fr { transition: top .5s var(--ease); }
.stagger > .frost { animation: none; }
.fr { position: absolute; user-select: none; }
.fr.sprig { filter: drop-shadow(0 3px 5px rgba(120, 78, 66, .14)); }
.fr[hidden] { display: none; }
.fr:not(.sprig) { will-change: transform; animation: leaf-sway 9s ease-in-out infinite; }
.fr:not(.sprig):nth-child(3n) { animation-delay: -3s; }
.fr:not(.sprig):nth-child(3n + 1) { animation-delay: -6s; }
@media (prefers-reduced-motion: reduce) { .fr { animation: none !important; } }
