/* ==========================================================================
   Desktop surface, wallpaper, logo pill, nav pill, taskbar, desktop icons.
   ========================================================================== */

.hxp-desktop {
    position: fixed;
    inset: 0;
    overflow: hidden;
}

/* --- wallpaper ---------------------------------------------------------- */

.hxp-wallpaper {
    position: absolute;
    inset: 0;
    z-index: 0;
    /* A flat blue behind the photo so first paint is never white. */
    background: linear-gradient(180deg, #2a6fc9 0%, #63a6e8 45%, #7ab648 62%, #5d9c3a 100%);
}

.hxp-wallpaper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

/* --- logo pill, top left ------------------------------------------------ */

.hxp-logo {
    position: absolute;
    z-index: 60;
    left: calc(var(--canvas-gutter) + 9 * var(--u));
    top: calc(10 * var(--u));
    height: calc(48 * var(--u));
    padding-inline: calc(13 * var(--u));

    display: flex;
    align-items: center;
    gap: calc(13 * var(--u));

    background: var(--glass);
    border: 1px solid var(--glass-edge);
    border-radius: var(--win-radius);
    backdrop-filter: blur(10px);
    text-decoration: none;
}

.hxp-logo__mark {
    display: grid;
    place-items: center;
    width: calc(30 * var(--u));
    height: calc(30 * var(--u));
    background: var(--harry-yellow);
    border-radius: calc(6 * var(--u));
}

.hxp-logo__mark img {
    width: calc(17 * var(--u));
    height: auto;
}

.hxp-logo__rule {
    width: 1px;
    height: calc(25 * var(--u));
    background: var(--glass-edge);
}

.hxp-logo__word img {
    width: calc(63 * var(--u));
    height: auto;
}

/* --- nav pill, top right ------------------------------------------------ */

.hxp-nav {
    position: absolute;
    /* Above the modal scrim: the contact panel hangs off this nav, so the rest
       of it has to stay clickable while the panel is open. */
    z-index: 860;
    right: calc(var(--canvas-gutter) + 10 * var(--u));
    top: calc(10 * var(--u));
    height: calc(48 * var(--u));

    display: flex;
    align-items: center;

    background: var(--glass);
    border: 1px solid var(--glass-edge);
    border-radius: var(--win-radius);
    backdrop-filter: blur(10px);
}

.hxp-nav__list {
    display: flex;
    align-items: center;
    margin: 0;
    padding: 0;
    list-style: none;
    height: 100%;
}

.hxp-nav__list li {
    display: flex;
    align-items: center;
    height: 100%;
}

.hxp-nav__list li + li {
    border-left: 1px solid var(--glass-edge);
}

.hxp-nav__list a {
    display: flex;
    align-items: center;
    height: 100%;
    padding-inline: calc(27 * var(--u));
    font-size: calc(var(--t-title) * var(--u));
    font-weight: 400;
    text-transform: capitalize;
    text-decoration: none;
    color: var(--ink);
    opacity: 0.72;
    transition: opacity 0.15s var(--ease);
    white-space: nowrap;
}

.hxp-nav__list a:hover,
.hxp-nav__list a:focus-visible {
    opacity: 1;
}

.hxp-nav__list .current-menu-item a,
.hxp-nav__list a[aria-current="page"] {
    opacity: 1;
    font-weight: 600;
}

/* --- desktop icons ------------------------------------------------------ */

.hxp-icons {
    position: absolute;
    z-index: 5;   /* behind the windows, as on a real desktop */
    /* The bin belongs to the screen, not the canvas: bottom-right corner of
       the desktop, whatever width the composition is spread across. */
    right: calc(22 * var(--u));
    bottom: calc(var(--taskbar-h) + 22 * var(--u));
    display: flex;
    flex-direction: column;
    gap: calc(14 * var(--u));
}

.hxp-icon {
    display: grid;
    justify-items: center;
    text-decoration: none;   /* shortcuts are links or buttons; both read alike */
    color: inherit;
    gap: 4px;
    width: calc(76 * var(--u));
    padding: 4px;
    border-radius: 3px;
}

.hxp-icon:hover .hxp-icon__img,
.hxp-icon:focus-visible .hxp-icon__img {
    filter: brightness(1.12);
}

.hxp-icon__img img {
    width: calc(48 * var(--u));
    height: calc(48 * var(--u));
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.45));
}

.hxp-icon__label {
    font-family: var(--font-xp);
    font-size: 11px;
    line-height: 1.25;
    color: #fff;
    text-align: center;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.85);
}

/* ==========================================================================
   Taskbar
   ========================================================================== */

.hxp-taskbar {
    position: absolute;
    z-index: 100;
    left: 0;
    right: 0;
    bottom: 0;
    height: var(--taskbar-h);

    display: flex;
    align-items: stretch;
    justify-content: space-between;

    background: var(--luna-taskbar);
    font-family: var(--font-xp);
    font-size: 11px;
    color: #fff;
    user-select: none;
}

.hxp-taskbar__lead {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1 1 0;
    min-width: 0;
    padding-right: 6px;
}

/* --- start button ------------------------------------------------------- */

.hxp-start {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 100%;
    padding: 4px 24px 5px 10px;
    background: var(--luna-start);
    border-radius: 0 9px 9px 0;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35),
                inset 0 -3px 6px rgba(0, 0, 0, 0.28);
    cursor: default;
    flex-shrink: 0;
}

/* Inert by brief, but it should read as decorative rather than broken. */
.hxp-start[disabled] {
    opacity: 1;
}

.hxp-start:hover {
    filter: brightness(1.07);
}

.hxp-start__flag {
    width: 16px;
    height: 16px;
    filter: drop-shadow(1px 1px 1px rgba(0, 0, 0, 0.5));
}

.hxp-start__label {
    font-family: "Franklin Gothic Medium", "Segoe UI", Tahoma, sans-serif;
    font-size: 18px;
    font-style: italic;
    font-weight: 700;
    line-height: 1;
    text-shadow: 1px 1.5px 3px #2b3100;
}

/* --- program tabs ------------------------------------------------------- */

.hxp-tasklist {
    display: flex;
    align-items: center;
    gap: 2px;
    flex: 1 1 0;
    min-width: 0;
    overflow: hidden;
}

.hxp-tab {
    display: flex;
    align-items: center;
    gap: 3px;
    flex: 1 1 0;
    min-width: 36px;
    max-width: 160px;   /* the XP kit's documented behaviour */
    height: 22px;
    padding: 4px 15px 4px 10px;

    background: var(--luna-tab);
    border: 1px solid var(--luna-tab-edge);
    border-radius: 3px;
    box-shadow: inset -1px -0.5px 3px #2652b0,
                inset 2px 0 2px rgba(155, 197, 255, 0.5);
    color: #fff;
    overflow: hidden;
}

.hxp-tab:hover {
    filter: brightness(1.1);
}

.hxp-tab.is-active {
    background: var(--luna-tab-active);
    box-shadow: inset 1px 0.5px 2px rgba(0, 0, 0, 0.5),
                inset -1px -1px 3px #2a5db6;
}

.hxp-tab__icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.hxp-tab__label {
    flex: 1 1 0;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: left;
}

/* --- system tray -------------------------------------------------------- */

.hxp-tray {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.hxp-tray__overflow {
    display: grid;
    place-items: center;
    width: 19px;
    height: 19px;
    margin-right: -9px;
    z-index: 2;
    background: linear-gradient(135deg, #90d7f9 20%, #0a99f1 49.5%, #0671eb 80%);
    border: 1px solid #0f225e;
    border-radius: 50%;
}

.hxp-tray__icons {
    display: flex;
    align-items: center;
    gap: 1px;
    height: var(--taskbar-h);
    padding: 3px 8px 3px 11px;
    background: var(--luna-tray);
    filter: drop-shadow(-1px 0 0.5px rgba(0, 0, 0, 0.5));
    z-index: 1;
}

.hxp-tray__icons img {
    width: 16px;
    height: 16px;
}

.hxp-clock {
    padding-inline: 4px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* ==========================================================================
   Blue screen — the blue button's payload
   ========================================================================== */

.hxp-bsod {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: grid;
    place-items: center;
    padding: 8vh 8vw;
    background: #0000aa;
    color: #fff;
    font-family: "Lucida Console", "Courier New", monospace;
    font-size: clamp(12px, 1.35vw, 16px);
    line-height: 1.6;
    cursor: pointer;
}

.hxp-bsod__inner {
    max-width: 76ch;
}

.hxp-bsod b {
    background: #aaa;
    color: #0000aa;
    padding: 0 8px;
}

.hxp-bsod p {
    margin: 0 0 1.4em;
}

/* ==========================================================================
   Detonation — the red button's payload

   The desktop comes apart and piles up along the bottom of the screen, then
   rebuilds itself with a reload. Everything here is transform and opacity, so
   the fall stays on the compositor: the physics in detonate.js writes one
   transform per piece per frame and touches nothing else.
   ========================================================================== */

/* The page is inert for the thirty seconds it takes to come back. Half a
   demolished desktop is not a thing anyone should be able to click through. */
.hxp-detonating .hxp-desktop {
    pointer-events: none;
    user-select: none;
}

/* On the mobile stack the desktop is a scrolling column rather than a fixed
   pane, so falling pieces would push the page taller and hand you a scrollbar
   into empty space. Both are clamped for the duration. */
.hxp-detonating,
.hxp-detonating .hxp-desktop {
    overflow: hidden;
}

/* A piece in flight. The frame's own transitions would fight the integration -
   every step would ease towards the last position instead of landing on it. */
.hxp-boom {
    transition: none !important;
    will-change: transform;
    pointer-events: none;
}

/* Reduced motion: no blast, no tumble, no shake. The desktop simply goes, and
   the notice carries the same information the animation would have. */
.hxp-detonating--still .hxp-desktop {
    opacity: 0.12;
    filter: grayscale(1);
}

/* --- the blast ---------------------------------------------------------- */

.hxp-boom-flash {
    position: fixed;
    inset: 0;
    z-index: 9998;
    pointer-events: none;
    background: radial-gradient(
        circle at var(--ox) var(--oy),
        rgba(255, 255, 255, 0.95) 0%,
        rgba(255, 224, 130, 0.85) 12%,
        rgba(255, 120, 32, 0.55) 26%,
        rgba(120, 20, 0, 0.25) 44%,
        rgba(0, 0, 0, 0) 66%
    );
    animation: hxp-boom-flash 900ms var(--ease) forwards;
}

/* The shockwave, thrown from the button rather than from the middle of the
   screen - the ring has to leave from where the press happened. */
.hxp-boom-flash__wave {
    position: absolute;
    left: var(--ox);
    top: var(--oy);
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.9);
    box-shadow: 0 0 40px 12px rgba(255, 170, 60, 0.55);
    animation: hxp-boom-wave 900ms cubic-bezier(0.16, 0.84, 0.32, 1) forwards;
}

@keyframes hxp-boom-flash {
    0%   { opacity: 0; }
    6%   { opacity: 1; }
    100% { opacity: 0; }
}

@keyframes hxp-boom-wave {
    0%   { transform: scale(0.2); opacity: 1; border-width: 6px; }
    100% { transform: scale(90); opacity: 0; border-width: 0.5px; }
}

/* --- the shake ---------------------------------------------------------- */

.hxp-desktop.is-detonated {
    animation: hxp-boom-shake 640ms linear;
}

@keyframes hxp-boom-shake {
    0%   { transform: translate3d(0, 0, 0); }
    8%   { transform: translate3d(-14px, 8px, 0) rotate(-0.5deg); }
    18%  { transform: translate3d(12px, -10px, 0) rotate(0.45deg); }
    30%  { transform: translate3d(-10px, -6px, 0) rotate(-0.3deg); }
    44%  { transform: translate3d(8px, 7px, 0) rotate(0.28deg); }
    60%  { transform: translate3d(-5px, 4px, 0) rotate(-0.16deg); }
    78%  { transform: translate3d(3px, -3px, 0); }
    100% { transform: translate3d(0, 0, 0); }
}

/* --- the notice --------------------------------------------------------- */

.hxp-boom-panel {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: grid;
    place-items: center;
    padding: 6vh 6vw;
    background: rgba(0, 0, 0, 0.55);
    font-family: var(--font-xp);
    animation: hxp-boom-in 260ms var(--ease) both;
}

@keyframes hxp-boom-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.hxp-boom-panel__frame {
    width: min(460px, 100%);
    background: #ece9d8;
    color: #1a1a1a;
    border: 1px solid #0a246a;
    border-radius: 8px 8px 4px 4px;
    box-shadow: 0 24px 60px -12px rgba(0, 0, 0, 0.7);
    overflow: hidden;
}

.hxp-boom-panel__bar {
    padding: 6px 10px;
    background: var(--luna-tab-active);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.45);
}

.hxp-boom-panel__body {
    padding: 16px 18px 18px;
    font-size: 12px;
    line-height: 1.55;
}

.hxp-boom-panel__body p {
    margin: 0 0 10px;
}

.hxp-boom-panel__lead {
    font-size: 14px;
    font-weight: 700;
}

.hxp-boom-panel__count {
    margin-top: 14px !important;
    font-variant-numeric: tabular-nums;
}

.hxp-boom-panel__meter {
    height: 12px;
    background: #fff;
    border: 1px solid #7f9db9;
    border-radius: 2px;
    overflow: hidden;
}

/* The XP segmented progress bar - blocks, not a smooth sweep. */
.hxp-boom-panel__meter span {
    display: block;
    height: 100%;
    width: var(--fill, 0%);
    background:
        repeating-linear-gradient(90deg,
            #3aa33a 0 8px,
            transparent 8px 11px);
    transition: width 0.25s linear;
}

.hxp-boom-panel__actions {
    margin-top: 16px;
    display: flex;
    justify-content: flex-end;
}

.hxp-boom-panel__btn {
    padding: 5px 18px;
    font: inherit;
    font-size: 12px;
    color: #1a1a1a;
    background: linear-gradient(180deg, #fdfdfd 0%, #eceae2 46%, #dedbcf 100%);
    border: 1px solid #7f9db9;
    border-radius: 3px;
}

.hxp-boom-panel__btn:hover {
    border-color: #f5a623;
    background: linear-gradient(180deg, #fff 0%, #f6f1de 46%, #ecdfae 100%);
}

/* ==========================================================================
   Bouncing word — DVD-player screensaver

   Idle for a minute and it comes to the front over everything, taskbar
   included. It never takes the pointer, so the dim can never swallow a click:
   whatever you do to dismiss it also reaches the page underneath.
   ========================================================================== */

.hxp-saver {
    position: absolute;
    inset: 0;
    z-index: 900;            /* over the windows and the taskbar, under the BSOD */
    overflow: hidden;
    pointer-events: none;
    contain: strict;         /* the drift never invalidates the rest of the page */

    background: rgba(6, 10, 18, 0.55);

    opacity: 0;
    visibility: hidden;
    transition: opacity 0.6s var(--ease), visibility 0s linear 0.6s;
}

.hxp-saver.is-awake {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.8s var(--ease), visibility 0s;
}

.hxp-saver__word {
    position: absolute;
    top: 0;
    left: 0;
    font-family: var(--font-display);
    font-size: calc(56 * var(--u));
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    white-space: nowrap;

    color: var(--saver-colour, var(--harry-yellow));
    text-shadow: 0 calc(2 * var(--u)) calc(8 * var(--u)) rgba(0, 0, 0, 0.45);

    /* JS writes translate3d only, so the drift stays on the compositor. */
    will-change: transform;
    transition: color 0.25s var(--ease);
}

/* Nobody wants a word ricocheting behind the copy they are reading. It stays,
   it just stops moving. */
@media (prefers-reduced-motion: reduce) {
    .hxp-saver__word {
        transition: none;
    }
}

/* The stacked tier scrolls; a bouncing word over it is only noise. */
@media (max-width: 1023.98px) {
    .hxp-saver {
        display: none;
    }
}

/* ==========================================================================
   Start menu — XP's two columns, sitting on the taskbar.
   ========================================================================== */

.hxp-start-menu {
    position: absolute;
    left: 0;
    bottom: var(--taskbar-h);
    z-index: 120;               /* over the windows, under the screensaver */

    width: 380px;
    max-width: calc(100vw - 8px);
    border: 1px solid #0a3a91;
    border-bottom: 0;
    border-radius: 8px 8px 0 0;
    box-shadow: 0 -2px 18px rgba(0, 0, 0, 0.45);
    overflow: hidden;

    font-family: var(--font-xp);
    font-size: 12px;
    color: #10233f;

    transform-origin: 0 100%;
    animation: hxp-start-in 0.12s var(--ease);
}

.hxp-start-menu[hidden] {
    display: none;
}

@keyframes hxp-start-in {
    from { opacity: 0; transform: translateY(8px) scale(0.99); }
    to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    .hxp-start-menu { animation: none; }
}

/* --- header -------------------------------------------------------------- */

.hxp-start-menu__head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: linear-gradient(180deg, #3f83e0 0%, #1c5cc4 46%, #14459f 100%);
    border-bottom: 2px solid #f0a05a;
}

.hxp-start-menu__avatar {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    background: var(--harry-yellow);
    border: 2px solid rgba(255, 255, 255, 0.85);
    border-radius: 4px;
}

.hxp-start-menu__avatar img {
    width: 18px;
    height: auto;
}

.hxp-start-menu__name {
    font-size: 14px;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
}

/* --- columns ------------------------------------------------------------- */

/* Taller than its contents, with everything held at the top - XP's menu keeps
   its height whether it holds four entries or a dozen, and the space below the
   last one is part of the look. */
.hxp-start-menu__body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: stretch;
    min-height: 340px;
}

.hxp-start-menu__col {
    margin: 0;
    padding: 8px 0;
    list-style: none;

    /* Entries sit at the top; the empty run below them is deliberate. */
    display: flex;
    flex-direction: column;
    align-content: flex-start;
}

.hxp-start-menu__col--left {
    background: #fff;
}

.hxp-start-menu__col--right {
    background: #d3e5f7;
    border-left: 1px solid #b6cfe8;
}

.hxp-start-menu__gap {
    margin-bottom: 6px;
    padding-bottom: 6px;
    border-bottom: 1px solid #dbe4ee;
}

.hxp-start-menu__rule {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid #b6cfe8;
}

/* --- items --------------------------------------------------------------- */

.hxp-start-item {
    display: flex;
    align-items: center;
    gap: 11px;
    width: 100%;
    padding: 8px 12px;
    background: none;
    border: 0;
    color: inherit;
    font: inherit;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}

.hxp-start-item:hover,
.hxp-start-item:focus-visible {
    background: linear-gradient(180deg, #3f8ae8, #1f62cf);
    color: #fff;
    outline: none;
}

.hxp-start-item:hover .hxp-start-item__sub,
.hxp-start-item:focus-visible .hxp-start-item__sub {
    color: rgba(255, 255, 255, 0.8);
}

.hxp-start-item__icon {
    flex: 0 0 auto;
    width: 26px;
    height: 26px;
    object-fit: contain;
}

.hxp-start-item--big .hxp-start-item__icon {
    width: 32px;
    height: 32px;
}

.hxp-start-item__icon--glyph {
    display: grid;
    place-items: center;
}

.hxp-start-item__icon--glyph svg {
    width: 24px;
    height: 24px;
}

.hxp-start-item__text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.hxp-start-item__title {
    font-weight: 700;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hxp-start-menu__col--right .hxp-start-item__title {
    font-weight: 400;
}

.hxp-start-item__sub {
    line-height: 1.3;
    color: #5a6a7e;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- footer -------------------------------------------------------------- */

.hxp-start-menu__foot {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 16px;
    padding: 7px 14px;
    background: linear-gradient(180deg, #3f83e0 0%, #1c5cc4 46%, #14459f 100%);
    border-top: 1px solid #5f9ae8;
}

.hxp-start-session {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 4px;
    background: none;
    border: 0;
    border-radius: 3px;
    color: #fff;
    font: inherit;
    text-decoration: none;
    cursor: pointer;
}

.hxp-start-session:hover,
.hxp-start-session:focus-visible {
    color: #fff;
    text-decoration: underline;
    outline: none;
    background: rgba(255, 255, 255, 0.14);
}

.hxp-start-session__badge {
    display: grid;
    place-items: center;
    width: 19px;
    height: 19px;
    border-radius: 4px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

.hxp-start-session__badge--off {
    background: linear-gradient(180deg, #f0c14b 0%, #d99a1c 55%, #b87c0c 100%);
}

.hxp-start-session__badge--power {
    background: linear-gradient(180deg, #e2564a 0%, #c62b1d 55%, #a81b0f 100%);
}

/* --- the button while the menu is up ------------------------------------- */

.hxp-start[aria-expanded="true"] {
    filter: brightness(1.12);
    box-shadow:
        inset 0 2px 5px rgba(0, 0, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

/* The stacked tier has no desktop to summon windows onto. */
@media (max-width: 1023.98px) {
    .hxp-start-menu {
        display: none !important;
    }
}
