:root {
    --black: #000000;
    --orange: #D05511;
    --purple: #37257B;
    --purple-light: #6a52d4;
    --text: #f2e9e4;
    --muted: #b8a9a0;
    --box-bg: rgba(0, 0, 0, 0.6);
    --box-bg-orange: rgba(208, 85, 17, 0.6);
    --cut: 12px;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    min-height: 100%;
    background: var(--black);
    color: var(--text);
    font-family: "Share Tech Mono", ui-monospace, monospace;
}

/* Matrix rain sits behind everything and never scrolls */
#matrix {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    z-index: 0;
    display: block;
}

/* ---------- Cyberpunk boxes ---------- */

.cyber {
    position: relative;
    background: var(--box-bg);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    border: 1px solid var(--orange);
    clip-path: polygon(
        var(--cut) 0, 100% 0,
        100% calc(100% - var(--cut)),
        calc(100% - var(--cut)) 100%,
        0 100%, 0 var(--cut)
    );
    box-shadow: inset 0 0 14px rgba(208, 85, 17, 0.18);
}

/* Diagonal border lines on the two cut corners + a small accent tab */
.cyber::before {
    content: "";
    position: absolute;
    inset: -1px;
    pointer-events: none;
    background:
        linear-gradient(135deg, transparent 7.6px, var(--orange) 7.6px 9.2px, transparent 9.2px) top left / 14px 14px no-repeat,
        linear-gradient(-45deg, transparent 7.6px, var(--orange) 7.6px 9.2px, transparent 9.2px) bottom right / 14px 14px no-repeat,
        linear-gradient(var(--orange), var(--orange)) top 0 right 18px / 36px 3px no-repeat,
        linear-gradient(var(--purple-light), var(--purple-light)) bottom 0 left 18px / 20px 3px no-repeat;
}

/* ---------- Glitch on hover (0.5s) ---------- */

.glitch::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0;
    background:
        linear-gradient(transparent 0 30%, rgba(208, 85, 17, 0.35) 30% 34%, transparent 34% 62%,
                        rgba(55, 37, 123, 0.55) 62% 68%, transparent 68%);
    mix-blend-mode: screen;
}

.glitch:hover,
.glitch:focus-visible {
    animation: glitch 0.5s steps(1, end) 1;
}

.glitch:hover::after,
.glitch:focus-visible::after {
    animation: glitch-slices 0.5s steps(1, end) 1;
}

.glitch:hover > *,
.glitch:focus-visible > * {
    animation: glitch-text 0.5s steps(1, end) 1;
}

@keyframes glitch {
    0%   { transform: translate(0, 0); }
    10%  { transform: translate(-4px, 1px) skewX(-6deg); }
    20%  { transform: translate(3px, -2px); }
    30%  { transform: translate(-2px, 0) skewX(4deg); }
    45%  { transform: translate(5px, 1px); }
    60%  { transform: translate(-3px, -1px) skewX(-3deg); }
    75%  { transform: translate(2px, 2px); }
    90%  { transform: translate(-1px, 0); }
    100% { transform: none; }
}

@keyframes glitch-slices {
    0%   { opacity: 1; transform: translateY(0); }
    20%  { opacity: 1; transform: translateY(-40%); }
    40%  { opacity: 0.8; transform: translateY(25%); }
    60%  { opacity: 1; transform: translateY(-15%) scaleY(0.6); }
    80%  { opacity: 0.6; transform: translateY(35%); }
    100% { opacity: 0; transform: none; }
}

@keyframes glitch-text {
    0%   { text-shadow: -3px 0 var(--purple-light), 3px 0 var(--orange); }
    25%  { text-shadow: 3px 0 var(--purple-light), -3px 0 var(--orange); }
    50%  { text-shadow: -2px 1px var(--purple-light), 2px -1px var(--orange); }
    75%  { text-shadow: 4px 0 var(--purple-light), -4px 0 var(--orange); }
    100% { text-shadow: none; }
}

@media (prefers-reduced-motion: reduce) {
    .glitch:hover,
    .glitch:hover::after,
    .glitch:hover > * {
        animation: none;
    }
}

/* ---------- Embed ---------- */

.embed {
    padding: 14px;
}

/* Pulse at 170 BPM (60 / 170 = 0.353s per beat) while not hovered */
.embed:not(:hover) {
    animation: beat 0.353s ease-out infinite;
}

@keyframes beat {
    0%   { transform: scale(1.012); box-shadow: inset 0 0 34px rgba(208, 85, 17, 0.6); border-color: #ff7a33; }
    100% { transform: scale(1);     box-shadow: inset 0 0 14px rgba(208, 85, 17, 0.18); border-color: var(--orange); }
}

@media (prefers-reduced-motion: reduce) {
    .embed:not(:hover) {
        animation: none;
    }
}

.embed iframe {
    display: block;
    border: 0;
    border-radius: 12px;
}


/* ---------- XMB (PS3-style menu) ---------- */

html,
body {
    height: 100%;
    overflow: hidden; /* the XMB is a single fixed screen */
    overscroll-behavior: none;
}

.xmb {
    position: fixed;
    inset: 0;
    z-index: 1;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* Header: clock + sound toggle, title, subtitle (top right like the PS3 clock) */
.header {
    position: fixed;
    top: 20px;
    right: 28px;
    z-index: 2;
    text-align: right;
}

.status {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 14px;
    font-size: 0.95rem;
    color: var(--muted);
    margin-bottom: 8px;
}

.sound-toggle {
    background: none;
    border: 1px solid rgba(208, 85, 17, 0.5);
    color: var(--muted);
    font: inherit;
    font-size: 0.8rem;
    padding: 3px 8px;
    cursor: pointer;
}

.sound-toggle[aria-pressed="true"] {
    color: var(--orange);
    border-color: var(--orange);
}

.title {
    font-family: "Orbitron", sans-serif;
    font-weight: 800;
    font-size: clamp(1.3rem, 3.2vw, 2.4rem);
    letter-spacing: 0.04em;
    margin: 0;
    color: var(--text);
    text-shadow:
        -2px 0 var(--purple-light),
        2px 0 var(--orange),
        0 0 18px rgba(208, 85, 17, 0.55);
}

.subtitle {
    margin: 6px 0 0;
    font-size: clamp(0.85rem, 1.6vw, 1.05rem);
    letter-spacing: 0.4em;
    text-transform: lowercase;
    color: var(--orange);
}

/* Everything in the XMB is placed by xmb.js with transforms; these only animate */
.xmb-cat,
.xmb-item {
    position: absolute;
    left: 0;
    top: 0;
    transition: transform 0.28s cubic-bezier(.2, .8, .2, 1), opacity 0.28s ease;
    /* no will-change here: it would switch off the backdrop blur inside the boxes */
}

/* Categories */
.xmb-cat {
    width: 110px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    background: none;
    border: 0;
    padding: 0;
    color: var(--text);
    font: inherit;
    cursor: pointer;
}

.xmb-cat svg {
    width: 64px;
    height: 64px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: filter 0.28s ease, color 0.28s ease;
}

.xmb-cat-label {
    font-family: "Orbitron", sans-serif;
    font-size: 0.85rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.xmb-cat.is-active svg {
    color: #fff;
    filter: drop-shadow(0 0 6px var(--orange)) drop-shadow(0 0 14px rgba(208, 85, 17, 0.7));
}

.xmb-cat.is-active .xmb-cat-label {
    opacity: 1;
}

/* Items: an orange box with the brand icon, name and handle */
.xmb-item {
    display: block;
    color: var(--text);
    text-decoration: none;
    font: inherit;
    background: none;
    border: 0;
    padding: 0;
    text-align: left;
    cursor: pointer;
}

.xmb-box {
    display: flex;
    align-items: center;
    gap: 14px;
    width: var(--item-w, 300px);
    padding: 10px 14px 10px 10px;
    background: var(--box-bg-orange);
}

.xmb-icon {
    flex: none;
    width: 44px;
    height: 44px;
    background: #fff;
    -webkit-mask: var(--icon) center / 30px 30px no-repeat;
    mask: var(--icon) center / 30px 30px no-repeat;
}

.xmb-text {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.xmb-title {
    font-family: "Orbitron", sans-serif;
    font-size: 0.78rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: #d9ccff;
    text-shadow: 0 0 6px rgba(55, 37, 123, 0.9);
}

.xmb-sub {
    font-size: 1.05rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.xmb-hint {
    display: none;
    margin-left: auto;
    flex: none;
    font-size: 0.8rem;
    color: #fff;
    opacity: 0.85;
}

.xmb-item.is-active .xmb-box {
    box-shadow: inset 0 0 22px rgba(255, 140, 70, 0.55), 0 0 0 1px #ff7a33;
}

.xmb-item.is-dim .xmb-icon,
.xmb-item.is-dim .xmb-text {
    opacity: 0.6;
}

.xmb-item.is-active .xmb-hint {
    display: block;
}

.xmb-item.copied .xmb-hint {
    color: #d9ccff;
}

/* Spotify panel: shown next to the list while the playlist item is selected */
.xmb-embed {
    position: fixed;
    z-index: 1;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0s linear 0.25s;
}

.xmb-embed.is-visible {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.25s ease;
}

/* Control hints, bottom right like the PS3 */
.controls {
    position: fixed;
    right: 28px;
    bottom: 18px;
    z-index: 2;
    display: flex;
    gap: 18px;
    font-size: 0.85rem;
    color: var(--muted);
}

.controls b {
    color: var(--orange);
    font-weight: normal;
}

@media (max-width: 700px) {
    .header {
        left: 16px;
        right: 16px;
        top: 14px;
        text-align: center;
    }

    .status {
        justify-content: center;
    }

    .controls {
        display: none; /* phones use tap and swipe */
    }

    .xmb-cat svg {
        width: 48px;
        height: 48px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .xmb-cat,
    .xmb-item {
        transition-duration: 0.01s;
    }
}
