/* =========================================================================
   PREPIQ BOOT SEQUENCE  (embed on the IQ Books stage)
   =========================================================================
   PrepIQ's promise is a finished set of working papers, so the opening is the
   set assembling: sheets arriving one after another, squaring up into a bound
   file, index tabs appearing down the edge, and the spine closing over them.

   The sheets are the ones PrepIQ actually builds — extended trial balance,
   lead schedules, fixed assets, capital allowances, tax computation, notes —
   and the client and year end are the real job. Bronze throughout, which is
   PrepIQ's colour across the suite.
   ========================================================================= */

#piq-boot {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: #14100a;
    opacity: 0;
    transition: opacity 0.35s ease;
    font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}

#piq-boot.is-in  { opacity: 1; }
#piq-boot.is-out { opacity: 0; transition: opacity 0.55s ease; }

#piq-boot .piqb-wash {
    position: absolute;
    left: 50%;
    top: 46%;
    width: 1100px;
    height: 1100px;
    margin: -550px 0 0 -550px;
    pointer-events: none;
    background: radial-gradient(circle at 50% 50%,
        rgba(168, 118, 46, 0.26) 0%,
        rgba(168, 118, 46, 0.09) 34%,
        transparent 64%);
    animation: piqbBreathe 5s ease-in-out infinite;
}

@keyframes piqbBreathe {
    0%, 100% { transform: scale(1);    opacity: 0.85; }
    50%      { transform: scale(1.07); opacity: 1; }
}

/* Faint ruled paper behind everything — the desk this is happening on. */
#piq-boot .piqb-rule {
    position: absolute;
    inset: -10%;
    pointer-events: none;
    opacity: 0.55;
    background-image: linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px);
    background-size: 100% 34px;
    mask-image: radial-gradient(ellipse 60% 55% at 50% 46%, #000 0%, #000 42%, transparent 82%);
    -webkit-mask-image: radial-gradient(ellipse 60% 55% at 50% 46%, #000 0%, #000 42%, transparent 82%);
}

#piq-boot .piqb-stage {
    position: relative;
    width: min(1180px, 94vw);
    height: min(700px, 88vh);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ---- the file ---------------------------------------------------------- */

#piq-boot .piqb-file {
    position: relative;
    width: 404px;
    height: 280px;
    margin-top: -58px;
    perspective: 1400px;
}

/* Every schedule is a sheet that flies in and squares up on the stack. */
#piq-boot .piqb-sheet {
    position: absolute;
    inset: 0;
    border-radius: 5px;
    background: linear-gradient(168deg, #fbf7ef 0%, #f1e8d8 100%);
    box-shadow: 0 10px 26px rgba(8, 5, 2, 0.5);
    transform-origin: 12% 50%;
    opacity: 0;
    animation: piqbSheetIn 0.72s cubic-bezier(0.2, 1.1, 0.32, 1) forwards;
    animation-delay: var(--delay);
    padding: 18px 20px 0 30px;
    overflow: hidden;
}

@keyframes piqbSheetIn {
    0% {
        opacity: 0;
        transform: translate(var(--fromX), var(--fromY)) rotate(var(--fromR)) scale(0.92);
    }
    100% {
        opacity: 1;
        transform: translate(0, 0) rotate(var(--restR)) scale(1);
    }
}

/* The bound edge — the spine the whole set hangs from. */
#piq-boot .piqb-sheet::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 9px;
    background: linear-gradient(180deg, #c08c33, #8d6524);
}

#piq-boot .piqb-sheet-name {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: #2f2416;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#piq-boot .piqb-sheet-ref {
    margin-top: 3px;
    font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 10px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #a8762e;
}

/* Ruled lines standing in for the schedule's own figures. */
#piq-boot .piqb-sheet-lines {
    margin-top: 15px;
    display: grid;
    gap: 8px;
}

#piq-boot .piqb-sheet-lines i {
    display: block;
    height: 4px;
    border-radius: 2px;
    background: rgba(47, 36, 22, 0.14);
}

#piq-boot .piqb-sheet-lines i:nth-child(2n)   { width: 78%; }
#piq-boot .piqb-sheet-lines i:nth-child(3n)   { width: 60%; }
#piq-boot .piqb-sheet-lines i.is-total {
    width: 42%;
    height: 4px;
    background: rgba(168, 118, 46, 0.55);
    margin-top: 3px;
}

/* Index tabs down the right edge, one per sheet, appearing as it lands. */
#piq-boot .piqb-tab {
    position: absolute;
    right: -58px;
    width: 58px;
    height: 21px;
    border-radius: 0 4px 4px 0;
    background: linear-gradient(90deg, #a8762e, #c9974a);
    box-shadow: 3px 3px 10px rgba(8, 5, 2, 0.45);
    opacity: 0;
    transform: translateX(-14px);
    animation: piqbTabIn 0.42s cubic-bezier(0.22, 1, 0.36, 1) forwards;
    animation-delay: var(--delay);
    display: grid;
    place-items: center;
    font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: #1d1508;
}

@keyframes piqbTabIn {
    to { opacity: 1; transform: translateX(0); }
}

/* The bind: a light runs down the spine and the set is one file. */
#piq-boot .piqb-bind {
    position: absolute;
    left: -4px;
    top: -10px;
    bottom: -10px;
    width: 16px;
    border-radius: 7px;
    background: linear-gradient(180deg, rgba(255, 226, 168, 0), rgba(255, 226, 168, 0.95), rgba(255, 226, 168, 0));
    opacity: 0;
    filter: blur(1px);
}

#piq-boot .piqb-file.is-bound .piqb-bind { animation: piqbBind 0.85s ease-out forwards; }

@keyframes piqbBind {
    0%   { opacity: 0; transform: translateY(-60%) scaleY(0.35); }
    45%  { opacity: 1; }
    100% { opacity: 0; transform: translateY(60%) scaleY(0.35); }
}

#piq-boot .piqb-file.is-bound { animation: piqbSquare 0.7s cubic-bezier(0.22, 1, 0.36, 1) forwards; }

@keyframes piqbSquare {
    0%   { transform: scale(1) rotate(0deg); }
    40%  { transform: scale(1.045) rotate(-0.6deg); }
    100% { transform: scale(1.02) rotate(0deg); }
}

/* ---- caption + counters ------------------------------------------------ */

#piq-boot .piqb-caption {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(50% + 154px);
    text-align: center;
    opacity: 0;
    animation: piqbFade 0.6s ease 0.75s forwards;
}

@keyframes piqbFade { to { opacity: 1; } }

#piq-boot .piqb-mark {
    font-size: 27px;
    font-weight: 600;
    letter-spacing: -0.015em;
    color: #ffffff;
}

#piq-boot .piqb-mark b { color: #c9974a; font-weight: 600; }

#piq-boot .piqb-client {
    margin-top: 10px;
    font-size: 17px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.92);
}

#piq-boot .piqb-phase {
    margin-top: 8px;
    font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 11px;
    letter-spacing: 0.06em;
    color: rgba(255, 255, 255, 0.5);
    min-height: 1.3em;
    transition: opacity 0.25s ease;
}

#piq-boot .piqb-stats {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    top: calc(50% + 268px);
    display: flex;
    gap: 46px;
    opacity: 0;
    animation: piqbFade 0.7s ease 1.7s forwards;
}

#piq-boot .piqb-stat { text-align: center; min-width: 96px; }

#piq-boot .piqb-stat b {
    display: block;
    font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 26px;
    font-weight: 600;
    color: #ffffff;
    font-variant-numeric: tabular-nums;
    line-height: 1.15;
}

#piq-boot .piqb-stat span {
    display: block;
    margin-top: 5px;
    font-size: 9.5px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: rgba(255, 255, 255, 0.36);
}

@media (max-width: 720px) {
    #piq-boot .piqb-file { width: 250px; height: 174px; }
    #piq-boot .piqb-tab { right: -38px; width: 38px; }
    #piq-boot .piqb-stats { gap: 20px; }
    #piq-boot .piqb-stat { min-width: 60px; }
}

@media (prefers-reduced-motion: reduce) {
    #piq-boot .piqb-wash { animation: none; }
    #piq-boot .piqb-sheet { animation: none; opacity: 1; transform: rotate(var(--restR)); }
    #piq-boot .piqb-tab { animation: none; opacity: 1; transform: none; }
    #piq-boot .piqb-file.is-bound { animation: none; }
    #piq-boot .piqb-caption,
    #piq-boot .piqb-stats { animation: none; opacity: 1; }
}
