/* ============================================
   THE KITCHEN'S DECORATIONS
   What's up on the game page (decor.py). Each piece is
   templates/decor/<key>.html. base.html loads this file whenever anything
   is up, which with the kitchen is every day (config.CALENDAR_DECOR).

   Drawn in the brand's register: inline SVG (not emoji), a scene across
   the top of the welcome, and of today's post-game when something is
   happening (a big day, the inspector's visit; any other day, and the
   archive, plain), no pointer events, and nothing on the guessing screen
   but the birthday's bunting, still. Reduced motion stills everything
   (foot of the file).
   ============================================ */

/* --- Where decor hangs (templates/decor/_place.html) --- */

/* welcome: over the welcome screen, behind its content, which sits 1rem
   lower than it would without a drawing, so the greeting is on clear cream
   below the drawing's fade */
.welcome-container.has-decor {
    position: relative;
    padding-top: 2.5rem;
}
.welcome-container.has-decor > :not(.decor-welcome) {
    position: relative;
    z-index: 1;
}
.decor-welcome {
    position: absolute;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
}
.decor-welcome > * {
    position: absolute;
}

/* today's post-game on a big day, or the inspector's (has-scene,
   decor.on_post_game): the welcome's drawing across the top, the summary
   starting lower (the ::before) so the puzzle number sits on clear cream
   under its fade, the day's line under the number as on the welcome. Any
   other day, and the archive, the post-game is plain */
.post-game.has-scene {
    position: relative;
}
.post-game.has-scene::before {
    content: '';
    display: block;
    height: 5.75rem;
}
.post-game.has-scene > :not(.decor-welcome) {
    position: relative;
    z-index: 1;
}
.post-game-day {
    margin: 0.5rem auto 0;
}

/* strip: along the top of the guessing screen (the birthday) */
.decor-strip {
    margin-bottom: 0.5rem;
    pointer-events: none;
    overflow: hidden;
}
.decor-strip svg {
    display: block;
    width: 100%;
}


/* ============================================
   SCENES, AND THE KITCHEN
   The welcome has one a day: the kitchen at rest (kitchen.html), the
   season in its window, with the small days' pieces inside it
   (kitchen-*.html), or on the day a scene: a big day in the kitchen (lit
   for Christmas Day and the birthday; lamplit for Diwali; lantern-red for
   Chinese New Year; the morning for Eid al-Fitr, sun through a lattice;
   the lights low for Valentine's Day; the lights out for Halloween;
   moonlit for the Mid-Autumn Festival; candlelit for Día de Muertos; the
   morning after for New Year's Day, the room at rest with last night
   still out), or outside (New Year's Eve, Easter Sunday, the turning
   points of the year). All drawn by tools/kitchen_art.py.

   Drawn in cut-paper layers, light the only gradient, across the top of
   the welcome and fading into the page, the greeting on clear cream just
   under its faded foot. The kitchen at rest is still but for the stars in
   its window at night (its window keeps the kitchen's clock: decor.sky,
   docs/kitchen-scenes.md "The window's clock"); elsewhere the motion
   is slow: rays that brighten and dim or turn, leaves or snow that fall,
   lights that twinkle, flames that flicker, lanterns that sway, steam that
   rises, fireworks that bloom, bats, a spider and balloons that hover, a
   hare, a chick, a pancake and a lion dance that hop, eggs that wobble,
   lamps that float.

   A moving element carries no transform attribute of its own: the
   animation would replace it and send the element to the scene's corner.
   Place it with a group around it (or inside it) instead.
   ============================================ */

/* A scene across the top of the welcome, faded into the page */
.decor-welcome .decor-scene {
    top: 0;
    left: 0;
    width: 100%;
    height: 120px;
    opacity: 0.9;
    -webkit-mask-image: linear-gradient(to bottom, #000 62%, transparent);
    mask-image: linear-gradient(to bottom, #000 62%, transparent);
}
.scene-rays {
    animation: sceneBreathe 7s ease-in-out infinite;
}
.scene-turn {
    animation: sceneTurn 120s linear infinite;
}
.scene-fall > * {
    transform-box: fill-box;
    animation: sceneFall 12s linear infinite;
}
.scene-fall > :nth-child(2) {
    animation-duration: 14s;
    animation-delay: -5s;
}
.scene-fall > :nth-child(3) {
    animation-delay: -9s;
}
.scene-star {
    animation: decorTwinkle 3s ease-in-out infinite;
}
.scene-glow {
    animation: decorGlow 2.6s ease-in-out infinite;
}
.scene-sway {
    transform-box: fill-box;
    transform-origin: 50% 0;
    animation: decorSway 4.8s ease-in-out infinite;
}
.scene-hover {
    animation: sceneHover 3.2s ease-in-out infinite;
}
.scene-hop {
    animation: sceneHop 5s ease-in-out infinite;
}
.scene-wobble {
    transform-box: fill-box;
    transform-origin: 50% 100%;
    animation: decorWobble 6s ease-in-out infinite;
}
.scene-smoke > * {
    transform-box: fill-box;
    transform-origin: 50% 100%;
    animation: sceneSmoke 4.2s ease-out infinite;
}
.scene-snow > * {
    animation: sceneSnow 9s linear infinite;
}
.scene-snow > :nth-child(2n) {
    animation-duration: 11s;
    animation-delay: -4s;
}
.scene-snow > :nth-child(3n) {
    animation-delay: -7s;
}
.scene-burst {
    transform-box: fill-box;
    transform-origin: center;
    animation: sceneBurst 3.6s ease-out infinite;
}
.scene-drift {
    animation: sceneDrift 8s ease-in-out infinite alternate;
}

@keyframes sceneBreathe {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.55; }
}

@keyframes sceneTurn {
    to { transform: rotate(360deg); }
}

@keyframes sceneFall {
    0% { transform: translate(0, 0) rotate(0deg); opacity: 0; }
    10%, 85% { opacity: 1; }
    100% { transform: translate(-34px, 72px) rotate(240deg); opacity: 0; }
}

@keyframes sceneHover {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}

@keyframes sceneHop {
    0%, 70%, 100% { transform: translateY(0); }
    78% { transform: translateY(-7px); }
    86% { transform: translateY(0); }
}

@keyframes sceneSmoke {
    0% { transform: translateY(0) scale(0.6); opacity: 0; }
    20% { opacity: 0.9; }
    100% { transform: translate(4px, -16px) scale(1.4); opacity: 0; }
}

@keyframes sceneSnow {
    0% { transform: translate(0, 0); opacity: 0; }
    10%, 85% { opacity: 1; }
    100% { transform: translate(-12px, 80px); opacity: 0; }
}

@keyframes sceneDrift {
    from { transform: translateX(0); }
    to { transform: translateX(-10px); }
}

@keyframes sceneBurst {
    0% { transform: scale(0.3); opacity: 0; }
    15% { opacity: 1; }
    60% { transform: scale(1); opacity: 0.9; }
    100% { transform: scale(1.08); opacity: 0; }
}


/* ============================================
   THE GUESSING SCREEN: the birthday's bunting (13 May)
   ============================================ */

.birthday-bunting {
    display: block;
    width: 100%;
    height: 24px;
}


/* ============================================
   SHARED MOTION
   ============================================ */

@keyframes decorSway {
    0%, 100% { transform: rotate(-4deg); }
    50% { transform: rotate(4deg); }
}

@keyframes decorTwinkle {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

@keyframes decorGlow {
    0%, 100% { opacity: 1; }
    40% { opacity: 0.72; }
    55% { opacity: 0.95; }
    70% { opacity: 0.66; }
}

@keyframes decorWobble {
    0%, 76%, 100% { transform: rotate(0deg); }
    80% { transform: rotate(-9deg); }
    85% { transform: rotate(7deg); }
    90% { transform: rotate(-4deg); }
    95% { transform: rotate(2deg); }
}

@media (prefers-reduced-motion: reduce) {
    .decor,
    .decor * {
        animation: none !important;
    }
}
