/*
 * FastTracker 2 Clone - WebAssembly page
 *
 * A dark, glassy frame around the tracker: deep background with soft colour
 * glows, translucent surfaces, and one violet-to-cyan accent gradient.
 */

:root {
    --bg: #07080d;
    --glass: rgba(255, 255, 255, 0.045);
    --glass-strong: rgba(255, 255, 255, 0.08);
    --panel: rgba(18, 20, 30, 0.86);
    --line: rgba(255, 255, 255, 0.09);
    --line-strong: rgba(255, 255, 255, 0.16);
    --text: #f1f3f9;
    --text-muted: #9198ad;
    --violet: #8b6cff;
    --cyan: #2dd4ee;
    --accent: linear-gradient(135deg, var(--violet), var(--cyan));
    --danger: #ff6b78;
    --radius: 12px;
    --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

html,
body {
    height: 100%;
    margin: 0;
}

body {
    background: var(--bg);
    color: var(--text);
    font: 14px/1.5 var(--font);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Colour glows and a faint dot grid behind everything */
body::before,
body::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
}

body::before {
    background:
        radial-gradient(60vw 50vh at 12% -5%, rgba(139, 108, 255, 0.28), transparent 70%),
        radial-gradient(55vw 55vh at 95% 105%, rgba(45, 212, 238, 0.2), transparent 70%),
        radial-gradient(40vw 40vh at 70% 0%, rgba(232, 92, 200, 0.1), transparent 70%);
}

body::after {
    background-image: radial-gradient(rgba(255, 255, 255, 0.07) 1px, transparent 1px);
    background-size: 22px 22px;
    -webkit-mask-image: radial-gradient(ellipse at center, #000 30%, transparent 78%);
    mask-image: radial-gradient(ellipse at center, #000 30%, transparent 78%);
}

button {
    font: inherit;
    color: inherit;
}

:focus-visible {
    outline: 2px solid var(--cyan);
    outline-offset: 2px;
}

/* ---------------------------------------------------------------- Layout */

#ft2-container {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    height: 100%;
}

#ft2-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px 24px;
    flex-wrap: wrap;
    padding: 12px 22px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.brand-mark {
    flex: none;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    box-shadow: 0 6px 22px -4px rgba(139, 108, 255, 0.7);
}

.brand h1 {
    margin: 0;
    font-size: 17px;
    font-weight: 680;
    line-height: 1.2;
    letter-spacing: -0.015em;
}

.brand p {
    margin: 1px 0 0;
    color: var(--text-muted);
    font-size: 12.5px;
    line-height: 1.3;
}

#header-buttons {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

#ft2-display {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
    padding: 6px 22px 14px;
    overflow: hidden;
}

#ft2-display:fullscreen {
    padding: 0;
    background: #000;
}

/* The tracker's frame */
#ft2-stage {
    position: relative;
    max-width: 100%;
    padding: 7px;
    line-height: 0;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.03));
    border-radius: 16px;
    box-shadow:
        inset 0 0 0 1px var(--line-strong),
        0 0 0 1px rgba(0, 0, 0, 0.6),
        0 40px 90px -30px rgba(139, 108, 255, 0.55),
        0 30px 80px -40px rgba(45, 212, 238, 0.5),
        0 24px 60px rgba(0, 0, 0, 0.6);
    animation: stage-in 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

@keyframes stage-in {
    from { opacity: 0; transform: translateY(10px) scale(0.985); }
    to   { opacity: 1; transform: none; }
}

#ft2-display:fullscreen #ft2-stage {
    padding: 0;
    background: none;
    border-radius: 0;
    box-shadow: none;
    animation: none;
}

#ft2-canvas {
    display: block;
    width: 632px;
    height: 400px;
    max-width: 100%;
    background: #000;
    border-radius: 10px;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    cursor: default;
}

#ft2-display:fullscreen #ft2-canvas {
    border-radius: 0;
}

#ft2-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px 20px;
    flex-wrap: wrap;
    padding: 0 22px 14px;
    color: var(--text-muted);
    font-size: 12.5px;
}

#ft2-footer a {
    color: var(--text);
    text-decoration: none;
    border-bottom: 1px solid var(--line-strong);
}

#ft2-footer a:hover {
    border-bottom-color: var(--cyan);
}

.hints {
    display: flex;
    align-items: center;
    gap: 6px 18px;
    flex-wrap: wrap;
    justify-content: center;
    margin: 0;
    padding: 0;
    list-style: none;
}

.hints li + li::before {
    content: "";
    display: inline-block;
    width: 3px;
    height: 3px;
    margin-right: 18px;
    vertical-align: middle;
    background: var(--line-strong);
    border-radius: 50%;
}

/* What is loaded right now */
.chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    max-width: 280px;
    height: 28px;
    padding: 0 12px 0 10px;
    background: var(--glass);
    border: 1px solid var(--line);
    border-radius: 999px;
    white-space: nowrap;
}

.chip > span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
}

.chip-dot {
    flex: none;
    width: 7px;
    height: 7px;
    background: var(--text-muted);
    border-radius: 50%;
}

.chip.is-active {
    color: var(--text);
    border-color: rgba(45, 212, 238, 0.35);
}

.chip.is-active .chip-dot {
    background: var(--cyan);
    box-shadow: 0 0 0 0 rgba(45, 212, 238, 0.6);
    animation: pulse 2s ease-out infinite;
}

@keyframes pulse {
    to { box-shadow: 0 0 0 7px rgba(45, 212, 238, 0); }
}

/* --------------------------------------------------------------- Buttons */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 38px;
    padding: 0 14px;
    background: var(--glass);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    font-size: 13.5px;
    font-weight: 550;
    letter-spacing: -0.005em;
    white-space: nowrap;
    cursor: pointer;
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    transition: background-color 0.15s, border-color 0.15s, transform 0.1s, box-shadow 0.15s;
}

.btn:hover {
    background: var(--glass-strong);
    border-color: var(--line-strong);
}

.btn:active {
    transform: translateY(1px);
}

.btn svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex: none;
}

.btn .icon-solid {
    fill: currentColor;
    stroke: none;
}

a.btn {
    color: inherit;
    text-decoration: none;
}

.btn .chevron {
    width: 12px;
    height: 12px;
    margin-left: -2px;
    opacity: 0.6;
    transition: transform 0.15s;
}

.btn[aria-expanded="true"] {
    background: var(--glass-strong);
    border-color: var(--line-strong);
}

.btn[aria-expanded="true"] .chevron {
    transform: rotate(180deg);
}

.btn-primary {
    background: var(--accent);
    border-color: transparent;
    color: #fff;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.28),
        0 8px 24px -8px rgba(139, 108, 255, 0.8);
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
}

.btn-primary:hover {
    background: var(--accent);
    border-color: transparent;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.35),
        0 10px 30px -6px rgba(139, 108, 255, 0.95);
    filter: brightness(1.08);
}

.btn-icon {
    width: 38px;
    padding: 0;
    justify-content: center;
}

/* ------------------------------------------------------------------ Menu */

.menu {
    position: relative;
}

.menu-list {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 20;
    width: 300px;
    padding: 6px;
    background: var(--panel);
    border: 1px solid var(--line-strong);
    border-radius: 14px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
    -webkit-backdrop-filter: blur(20px) saturate(140%);
    backdrop-filter: blur(20px) saturate(140%);
    animation: menu-in 0.14s ease-out;
}

@keyframes menu-in {
    from { opacity: 0; transform: translateY(-4px) scale(0.98); }
    to   { opacity: 1; transform: none; }
}

.menu-title {
    margin: 0;
    padding: 8px 10px 6px;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 8px 10px;
    background: none;
    border: 0;
    border-radius: 9px;
    text-align: left;
    cursor: pointer;
    transition: background-color 0.12s;
}

.dropdown-item:hover,
.dropdown-item:focus-visible {
    background: var(--glass-strong);
}

/* A small "cover" per module, each in its own hue */
.module-art {
    flex: none;
    width: 34px;
    height: 34px;
    border-radius: 9px;
    background: linear-gradient(135deg, #8b6cff, #2dd4ee);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.dropdown-item:nth-of-type(2) .module-art {
    background: linear-gradient(135deg, #ff8a5c, #e85cc8);
}

.dropdown-item:nth-of-type(3) .module-art {
    background: linear-gradient(135deg, #34d399, #2d8cee);
}

.dropdown-item:nth-of-type(4) .module-art {
    background: linear-gradient(135deg, #fbbf24, #f97316);
}

.dropdown-item:nth-of-type(5) .module-art {
    background: linear-gradient(135deg, #f472b6, #8b6cff);
}

.module-text {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-width: 0;
}

.module-name {
    overflow: hidden;
    font-size: 13.5px;
    font-weight: 550;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.module-source {
    color: var(--text-muted);
    font-size: 12px;
}

.module-format {
    flex: none;
    padding: 2px 7px;
    background: var(--glass);
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--text-muted);
    font: 10.5px var(--mono);
    letter-spacing: 0.06em;
}

/* -------------------------------------------------------------- Progress */

.progress {
    height: 5px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 999px;
}

.progress-fill {
    position: relative;
    width: 0;
    height: 100%;
    overflow: hidden;
    background: var(--accent);
    border-radius: 999px;
    box-shadow: 0 0 12px rgba(45, 212, 238, 0.6);
    transition: width 0.2s ease-out;
}

/* a light sweeping across the filled part shows the download is alive */
.progress-fill::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.55), transparent);
    transform: translateX(-100%);
    animation: progress-sheen 1.2s ease-in-out infinite;
}

@keyframes progress-sheen {
    to { transform: translateX(100%); }
}

.progress.indeterminate .progress-fill {
    width: 40%;
    transition: none;
    animation: progress-slide 1.15s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

.progress.indeterminate .progress-fill::after {
    animation: none;
}

@keyframes progress-slide {
    from { transform: translateX(-100%); }
    to   { transform: translateX(250%); }
}

/* Boot progress, covering the canvas until the tracker has drawn itself */
.loading-overlay {
    position: absolute;
    inset: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(60% 60% at 50% 45%, rgba(139, 108, 255, 0.16), transparent 70%),
        #05060a;
    border-radius: 10px;
    line-height: 1.5;
    transition: opacity 0.35s;
}

.loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.loading-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: min(300px, 76%);
    text-align: center;
}

.loading-content .brand-mark {
    width: 52px;
    height: 52px;
    margin-bottom: 18px;
    border-radius: 15px;
    animation: mark-breathe 2.2s ease-in-out infinite;
}

@keyframes mark-breathe {
    50% { transform: scale(1.06); box-shadow: 0 10px 34px -4px rgba(139, 108, 255, 0.95); }
}

#loading-message {
    margin: 0 0 14px;
    font-size: 16px;
    font-weight: 620;
    letter-spacing: -0.01em;
}

.loading-content .progress {
    width: 100%;
}

.loading-submessage {
    min-height: 1.5em;
    margin: 12px 0 0;
    color: var(--text-muted);
    font-size: 12.5px;
}

/* Download / file load progress, floating over the top of the tracker */
.load-status {
    position: absolute;
    top: 22px;
    left: 50%;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 12px;
    width: min(400px, calc(100% - 36px));
    padding: 12px 14px;
    transform: translateX(-50%);
    background: var(--panel);
    border: 1px solid var(--line-strong);
    border-radius: 14px;
    box-shadow:
        0 18px 50px rgba(0, 0, 0, 0.65),
        0 0 0 1px rgba(0, 0, 0, 0.4);
    line-height: 1.4;
    -webkit-backdrop-filter: blur(20px) saturate(140%);
    backdrop-filter: blur(20px) saturate(140%);
    animation: status-in 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
    transition: opacity 0.2s, transform 0.2s;
}

.load-status.is-leaving {
    opacity: 0;
    transform: translate(-50%, -6px);
}

@keyframes status-in {
    from { opacity: 0; transform: translate(-50%, -10px) scale(0.97); }
    to   { opacity: 1; transform: translate(-50%, 0); }
}

/* spinner while working, tick when done, cross on error */
.load-status-icon {
    position: relative;
    flex: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: conic-gradient(from 0deg, var(--cyan), var(--violet), transparent 75%);
    -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3.5px), #000 calc(100% - 3px));
    mask: radial-gradient(farthest-side, transparent calc(100% - 3.5px), #000 calc(100% - 3px));
    animation: spin 0.85s linear infinite;
}

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

.load-status.is-done .load-status-icon,
.load-status.is-error .load-status-icon {
    -webkit-mask: none;
    mask: none;
    animation: none;
}

.load-status.is-done .load-status-icon {
    background: var(--accent);
}

.load-status.is-done .load-status-icon::after {
    content: "";
    position: absolute;
    left: 10.5px;
    top: 7px;
    width: 7px;
    height: 12px;
    border: solid #fff;
    border-width: 0 2.5px 2.5px 0;
    transform: rotate(45deg);
}

.load-status.is-error .load-status-icon {
    background: rgba(255, 107, 120, 0.16);
    box-shadow: inset 0 0 0 1.5px rgba(255, 107, 120, 0.6);
}

.load-status.is-error .load-status-icon::before,
.load-status.is-error .load-status-icon::after {
    content: "";
    position: absolute;
    left: 14px;
    top: 8px;
    width: 2px;
    height: 14px;
    background: var(--danger);
    border-radius: 1px;
    transform: rotate(45deg);
}

.load-status.is-error .load-status-icon::after {
    transform: rotate(-45deg);
}

.load-status-main {
    flex: 1;
    min-width: 0;
}

.load-status-row {
    display: flex;
    align-items: baseline;
    gap: 10px;
}

.load-status-row + .progress {
    margin-top: 9px;
}

.load-status-title {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    font-size: 13.5px;
    font-weight: 600;
    letter-spacing: -0.005em;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.load-status-detail {
    flex: none;
    color: var(--text-muted);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

.load-status.is-error {
    border-color: rgba(255, 107, 120, 0.45);
}

.load-status.is-error .load-status-row {
    flex-direction: column;
    gap: 1px;
}

.load-status.is-error .load-status-title,
.load-status.is-error .load-status-detail {
    flex: none;
    max-width: 100%;
    white-space: normal;
}

.load-status-close {
    flex: none;
    width: 26px;
    height: 26px;
    padding: 0;
    background: var(--glass);
    border: 0;
    border-radius: 8px;
    color: var(--text-muted);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}

.load-status-close:hover {
    background: var(--glass-strong);
    color: var(--text);
}

/* Shown while a file is dragged over the page */
.drop-hint {
    position: absolute;
    inset: 7px;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(7, 8, 13, 0.7);
    border: 2px dashed rgba(45, 212, 238, 0.8);
    border-radius: 10px;
    line-height: 1.5;
    opacity: 0;
    pointer-events: none;
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);
    transition: opacity 0.15s;
}

.drop-hint span {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 22px;
    background: var(--accent);
    border-radius: 999px;
    box-shadow: 0 14px 40px -8px rgba(139, 108, 255, 0.9);
    color: #fff;
    font-size: 15px;
    font-weight: 650;
}

.drop-hint svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}

body.is-dragging .drop-hint {
    opacity: 1;
}

/* --------------------------------------------------------------- Dialogs */

.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(4, 5, 9, 0.62);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    animation: fade-in 0.15s ease-out;
}

@keyframes fade-in {
    from { opacity: 0; }
}

.modal.hidden {
    display: none;
}

.modal-content {
    display: flex;
    flex-direction: column;
    width: min(460px, 100%);
    max-height: 100%;
    background: var(--panel);
    border: 1px solid var(--line-strong);
    border-radius: 18px;
    box-shadow:
        0 40px 100px rgba(0, 0, 0, 0.7),
        0 30px 80px -40px rgba(139, 108, 255, 0.6);
    -webkit-backdrop-filter: blur(24px) saturate(140%);
    backdrop-filter: blur(24px) saturate(140%);
    animation: modal-in 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes modal-in {
    from { opacity: 0; transform: translateY(10px) scale(0.98); }
}

.modal-wide {
    width: min(960px, 100%);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 18px 14px 24px;
}

.modal-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 660;
    letter-spacing: -0.015em;
}

.modal-close {
    width: 32px;
    height: 32px;
    padding: 0;
    background: var(--glass);
    border: 1px solid var(--line);
    border-radius: 10px;
    color: var(--text-muted);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}

.modal-close:hover {
    background: var(--glass-strong);
    color: var(--text);
}

.modal-body {
    padding: 6px 24px 24px;
    overflow-y: auto;
}

.modal-body p {
    margin: 0;
    color: var(--text-muted);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 0 18px 18px;
}

.error-details {
    margin-top: 14px;
    color: var(--text-muted);
    font-size: 12.5px;
}

.error-details summary {
    cursor: pointer;
}

.error-details pre {
    max-height: 180px;
    margin: 8px 0 0;
    padding: 12px;
    overflow: auto;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid var(--line);
    border-radius: 10px;
    font: 11.5px/1.5 var(--mono);
    white-space: pre-wrap;
    word-break: break-word;
}

/* Keyboard shortcuts */
.shortcuts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 12px;
}

.shortcuts-grid section {
    padding: 14px 16px 8px;
    background: var(--glass);
    border: 1px solid var(--line);
    border-radius: 14px;
}

.shortcuts-grid h3 {
    margin: 0 0 6px;
    font-size: 12px;
    font-weight: 650;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    background: var(--accent);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    width: fit-content;
}

.shortcuts-grid dl {
    margin: 0;
}

.shortcuts-grid dl > div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 6px 0;
}

.shortcuts-grid dl > div + div {
    border-top: 1px solid var(--line);
}

.shortcuts-grid dt {
    flex: none;
    color: var(--text-muted);
    font-size: 12px;
}

.shortcuts-grid dd {
    margin: 0;
    font-size: 13px;
    text-align: right;
}

kbd {
    display: inline-block;
    min-width: 22px;
    padding: 2px 6px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.05));
    border: 1px solid var(--line-strong);
    border-bottom-width: 2px;
    border-radius: 6px;
    color: var(--text);
    font: 11px/1.4 var(--mono);
    text-align: center;
}

/* ------------------------------------------------------------ Small screens */

@media (max-width: 900px) {
    .hints {
        display: none;
    }
}

@media (max-width: 640px) {
    #ft2-header {
        padding: 10px 12px;
    }

    #ft2-display {
        padding: 4px 12px 12px;
    }

    #ft2-footer {
        padding: 0 12px 12px;
    }

    .brand p,
    .btn-label {
        display: none;
    }

    .btn {
        width: 38px;
        padding: 0;
        justify-content: center;
    }

    .btn .chevron {
        display: none;
    }

    .menu-list {
        position: fixed;
        top: 64px;
        right: 12px;
        left: 12px;
        width: auto;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .progress.indeterminate .progress-fill {
        width: 100%;
        opacity: 0.6;
    }
}
