﻿/* ==================================================================
   halloween.css - the site-wide Halloween theme.
   Inert unless <html> has class "hw" (App.razor sets it on the first
   render, HalloweenVeil keeps it in step with the Halloween switch;
   users on the GrinchList never get it).
   Works on top of either color mode: light pages turn bone/pumpkin,
   dark pages turn purple night; the brand blue becomes night purple,
   headers and headings go orange. Nothing here touches the production
   board's row colors: they carry production meaning.
   The production board's own skin (AnyProductionBoard.razor.css) adds
   the table frame and cobweb on top of this.
   ================================================================== */

html.hw {
    --FRONTENDCOLOR: #2a1740; /* navbar, table heads, packer/shipping headers */
    --hw-orange: #ff8a1f;
    --hw-orange-light: #ffa340;
    --hw-orange-deep: #b34c00; /* orange that reads on light backgrounds (5.3:1 on white) */
    --hw-night: #140d1c;
    --hw-panel: #24162f;
    --hw-line: #4a2d5e;
    --hw-bone: #f3ead8;
    --hw-accent: var(--hw-orange-deep);
}

/* ---- Light mode: bone paper with a pumpkin warmth -------------------- */
html.hw[data-bs-theme="light"], html.hw:not([data-bs-theme]) {
    --bs-body-bg: #f8f1e7;
    --bs-body-bg-rgb: 248, 241, 231;
    --bs-tertiary-bg: #f1e5d3;
    --bs-tertiary-bg-rgb: 241, 229, 211;
    --bs-secondary-bg: #e9d9c2;
    --bs-secondary-bg-rgb: 233, 217, 194;
    --bs-border-color: #cdb79b;
    --bs-link-color: #b34c00;
    --bs-link-color-rgb: 179, 76, 0;
    --bs-link-hover-color: #8f3c00;
    --bs-link-hover-color-rgb: 143, 60, 0;
}

/* ---- Dark mode: purple night --------------------------------------- */
html.hw[data-bs-theme="dark"] {
    --hw-accent: var(--hw-orange-light);
    --bs-body-bg: #140d1c;
    --bs-body-bg-rgb: 20, 13, 28;
    --bs-tertiary-bg: #24162f;
    --bs-tertiary-bg-rgb: 36, 22, 47;
    --bs-secondary-bg: #2e1c3d;
    --bs-secondary-bg-rgb: 46, 28, 61;
    --bs-border-color: #4a2d5e;
    --bs-link-color: #ffa340;
    --bs-link-color-rgb: 255, 163, 64;
    --bs-link-hover-color: #ffc27a;
    --bs-link-hover-color-rgb: 255, 194, 122;
}

/* ---- Accents ------------------------------------------------------- */

/* table heads are already night purple through --FRONTENDCOLOR (app.css) */
html.hw thead {
    color: var(--hw-orange);
}

html.hw h1, html.hw h2, html.hw h3, html.hw h4 {
    color: var(--hw-accent);
}

html.hw .btn-primary {
    --bs-btn-bg: var(--hw-orange);
    --bs-btn-border-color: var(--hw-orange);
    --bs-btn-color: #000;
    --bs-btn-hover-bg: var(--hw-orange-light);
    --bs-btn-hover-border-color: var(--hw-orange-light);
    --bs-btn-hover-color: #000;
    --bs-btn-active-bg: #e67300;
    --bs-btn-active-border-color: #e67300;
    --bs-btn-active-color: #000;
    --bs-btn-disabled-bg: var(--hw-orange);
    --bs-btn-disabled-border-color: var(--hw-orange);
    --bs-btn-disabled-color: #000;
    --bs-btn-focus-shadow-rgb: 255, 138, 31;
}

html.hw .btn-warning {
    --bs-btn-bg: var(--hw-orange);
    --bs-btn-border-color: var(--hw-orange);
    --bs-btn-hover-bg: var(--hw-orange-light);
    --bs-btn-hover-border-color: var(--hw-orange-light);
    --bs-btn-active-bg: #e67300;
    --bs-btn-active-border-color: #e67300;
    --bs-btn-disabled-bg: var(--hw-orange);
    --bs-btn-disabled-border-color: var(--hw-orange);
    --bs-btn-focus-shadow-rgb: 255, 138, 31;
}

html.hw .form-control:focus,
html.hw .form-select:focus,
html.hw .form-check-input:focus,
html.hw .btn:focus-visible {
    border-color: var(--hw-orange);
    box-shadow: 0 0 0 0.25rem rgba(255, 138, 31, 0.45);
}

html.hw .form-check-input:checked {
    background-color: var(--hw-orange);
    border-color: var(--hw-orange);
}

html.hw .modal-header,
html.hw .card-header {
    background-color: var(--FRONTENDCOLOR);
    color: var(--hw-orange);
}

    html.hw .modal-header .btn-close {
        filter: invert(1) grayscale(100%) brightness(200%);
    }

html.hw .accordion-button:not(.collapsed) {
    background-color: var(--FRONTENDCOLOR);
    color: var(--hw-orange);
}

/* ==================================================================
   BATS - HalloweenVeil.razor.js makes these on a click, a swarm at a
   time (none while one is still in the air). Global because the
   elements are made in JS, outside any component's scoped CSS.
   A bat is a solid silhouette: a body with two spiky wings; each wing
   swings about the body in 3D (rotateY foreshortens it, rotate beats
   it down). --w is the wingspan at distance 1; the flight scales it.
   ================================================================== */

.hw-bat-layer {
    position: fixed;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: 1060; /* over the modals, they are only in the air a few seconds */
}

.hw-bat {
    position: absolute;
    left: 0;
    top: 0;
    width: var(--w, 40px);
    height: calc(var(--w, 40px) * 0.5);
    margin: calc(var(--w, 40px) * -0.25) 0 0 calc(var(--w, 40px) * -0.5); /* centered on its point */
    perspective: calc(var(--w, 40px) * 4);
    transform-style: preserve-3d;
    will-change: transform;
}

    .hw-bat > i {
        position: absolute;
        display: block;
        background-repeat: no-repeat;
        background-size: 100% 100%;
    }

    .hw-bat .hw-body {
        left: 39%;
        top: 0;
        width: 22%;
        height: 100%;
        background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 24'%3e%3cpath fill='%23120a18' stroke='%23ffa340' stroke-opacity='.7' stroke-width='.8' stroke-linejoin='round' d='M3 1L5 8C3 10 2 13 2 16C2 20 5 23 8 23C11 23 14 20 14 16C14 13 13 10 11 8L13 1L9.5 5.5C8.5 5.2 7.5 5.2 6.5 5.5Z'/%3e%3c/svg%3e");
        animation: hw-bob var(--flap, 0.18s) ease-in-out infinite alternate;
    }

    .hw-bat .hw-wing {
        top: 16%;
        width: 46%;
        height: 64%;
        animation: var(--flap, 0.18s) ease-in-out infinite alternate;
    }

    /* each wing turns about its root at the body; the right one is the
       left one's drawing mirrored (a scaleX flip would swing it about
       the root onto the body) */
    .hw-bat .hw-wing.l {
        left: 0;
        transform-origin: 100% 50%;
        background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 20'%3e%3cpath fill='%23120a18' stroke='%23ffa340' stroke-opacity='.7' stroke-width='.8' stroke-linejoin='round' d='M32 3C22 -1 10 2 1 8Q3 15 9 19Q13 13 18 18Q22 13 27 19Q30 15 32 14Z'/%3e%3c/svg%3e");
        animation-name: hw-flap-l;
    }

    .hw-bat .hw-wing.r {
        right: 0;
        transform-origin: 0 50%;
        background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 20'%3e%3cpath fill='%23120a18' stroke='%23ffa340' stroke-opacity='.7' stroke-width='.8' stroke-linejoin='round' d='M0 3C10 -1 22 2 31 8Q29 15 23 19Q19 13 14 18Q10 13 5 19Q2 15 0 14Z'/%3e%3c/svg%3e");
        animation-name: hw-flap-r;
    }

/* up: tip raised and the wing turned toward edge-on; down: tip dropped, wing flat to the viewer */
@keyframes hw-flap-l {
    from { transform: rotate(-24deg) rotateY(60deg); }
    to   { transform: rotate(18deg) rotateY(-8deg); }
}

@keyframes hw-flap-r {
    from { transform: rotate(24deg) rotateY(-60deg); }
    to   { transform: rotate(-18deg) rotateY(8deg); }
}

@keyframes hw-bob {
    from { transform: translateY(-6%); }
    to   { transform: translateY(6%); }
}
