/* === Rubik's Cube Solver — Dark Glassmorphism Theme === */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

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

:root {
    --bg-from: #06060f;
    --bg-to: #120828;
    --glass-bg: rgba(255, 255, 255, 0.04);
    --glass-border: rgba(255, 255, 255, 0.08);
    --accent-cyan: #00f0ff;
    --accent-magenta: #c050ff;
    --text: rgba(255, 255, 255, 0.92);
    --text-dim: rgba(255, 255, 255, 0.5);
    --radius: 14px;
}

html, body {
    height: 100%;
    overflow: hidden;
    font-family: 'Inter', system-ui, sans-serif;
    background: linear-gradient(145deg, var(--bg-from), var(--bg-to));
    color: var(--text);
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

/* === Canvas === */
#canvas-container {
    position: fixed;
    inset: 0;
    z-index: 0;
}
#canvas-container canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* === Header === */
#header {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    text-align: center;
    pointer-events: none;
}
#header h1 {
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-magenta));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
#header .version-badge {
    display: inline-block;
    margin-top: 4px;
    padding: 2px 8px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    font-size: 0.65rem;
    font-weight: 500;
    letter-spacing: 0.05em;
    color: var(--text-dim);
}

/* === Move Display === */
#move-display {
    position: fixed;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    max-width: 90vw;
    padding: 8px 18px;
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    font-size: 0.82rem;
    font-weight: 500;
    letter-spacing: 0.04em;
    color: var(--text-dim);
    white-space: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}
#move-display.visible {
    opacity: 1;
}
#move-display .move {
    display: inline-block;
    padding: 2px 5px;
    border-radius: 4px;
    transition: all 0.2s;
}
#move-display .move.active {
    color: var(--accent-cyan);
    background: rgba(0, 240, 255, 0.12);
    font-weight: 700;
}
#move-display .move.done {
    color: var(--text-dim);
    opacity: 0.5;
}

/* === Status === */
#status {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-dim);
    letter-spacing: 0.05em;
    opacity: 0;
    transition: opacity 0.4s;
    pointer-events: none;
}
#status.visible {
    opacity: 1;
}

/* === Controls Panel === */
#controls-panel {
    position: fixed;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
    padding: 14px 22px;
    background: var(--glass-bg);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--glass-border);
    border-radius: 18px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.slider-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--text-dim);
    letter-spacing: 0.05em;
    text-transform: uppercase;
    padding: 0 4px;
}

.slider-row span {
    white-space: nowrap;
    min-width: 90px;
}

.slider-row input[type="range"] {
    flex: 1;
    height: 4px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.1);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
}

.slider-row input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--accent-cyan);
    box-shadow: 0 0 8px var(--accent-cyan);
    transition: transform 0.15s ease;
}

.slider-row input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.25);
}

.buttons-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

.btn {
    padding: 11px 22px;
    border: none;
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-magenta));
    color: #fff;
    box-shadow: 0 4px 20px rgba(0, 240, 255, 0.2);
}
.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 28px rgba(0, 240, 255, 0.35);
}
.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
    border: 1px solid var(--glass-border);
}
.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-1px);
}
.btn-secondary:active {
    transform: translateY(0);
}

.btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    transform: none !important;
}

/* === Loading Overlay === */
#loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(145deg, var(--bg-from), var(--bg-to));
    transition: opacity 0.5s;
}
#loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}
.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--glass-border);
    border-top-color: var(--accent-cyan);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* === Floating Help Button === */
#btn-help {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    color: var(--text);
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}
#btn-help:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--accent-cyan);
    box-shadow: 0 0 12px rgba(0, 240, 255, 0.3);
    transform: scale(1.05);
}
#btn-help:active {
    transform: scale(0.95);
}

/* === Modal Overlay === */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(4, 3, 10, 0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}
.modal-overlay.open {
    opacity: 1;
    pointer-events: all;
}

/* === Modal Content === */
.modal-content {
    background: rgba(20, 15, 35, 0.85);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    width: 90%;
    max-width: 580px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    padding: 24px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5), 0 0 40px rgba(192, 80, 255, 0.15);
    position: relative;
    transform: scale(0.95);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.modal-overlay.open .modal-content {
    transform: scale(1);
}

.modal-close {
    position: absolute;
    top: 18px;
    right: 18px;
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 1.6rem;
    cursor: pointer;
    transition: color 0.2s;
    line-height: 1;
}
.modal-close:hover {
    color: var(--accent-magenta);
}

.modal-content h2 {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 18px;
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-magenta));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 12px;
}

.modal-body {
    overflow-y: auto;
    flex: 1;
    padding-right: 8px;
    font-size: 0.86rem;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.8);
}

/* Custom Scrollbar for Modal Body */
.modal-body::-webkit-scrollbar {
    width: 6px;
}
.modal-body::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.02);
    border-radius: 3px;
}
.modal-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}
.modal-body::-webkit-scrollbar-thumb:hover {
    background: var(--accent-cyan);
}

.modal-section {
    margin-bottom: 24px;
}
.modal-section h3 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--accent-cyan);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.notation-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 16px;
}
.cube-net {
    display: grid;
    grid-template-columns: repeat(4, 42px);
    grid-template-rows: repeat(3, 42px);
    gap: 5px;
    margin: 20px auto;
    width: fit-content;
    justify-content: center;
}
.net-face {
    width: 42px;
    height: 42px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    color: #fff;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.15);
}
.net-face.face-u { grid-column: 2; grid-row: 1; background: #ffffff; color: #111; }
.net-face.face-l { grid-column: 1; grid-row: 2; background: #ff5800; }
.net-face.face-f { grid-column: 2; grid-row: 2; background: #009b48; }
.net-face.face-r { grid-column: 3; grid-row: 2; background: #b71234; }
.net-face.face-b { grid-column: 4; grid-row: 2; background: #0046ad; }
.net-face.face-d { grid-column: 2; grid-row: 3; background: #ffd500; color: #111; }
.notation-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 8px 12px;
    border-radius: 8px;
    text-align: center;
}
.notation-card strong {
    color: var(--accent-magenta);
    font-size: 1rem;
}
.notation-card div {
    font-size: 0.72rem;
    color: var(--text-dim);
    margin-top: 2px;
}
.step-card {
    background: rgba(255, 255, 255, 0.02);
    border-left: 3px solid var(--accent-magenta);
    padding: 12px 16px;
    border-radius: 0 10px 10px 0;
    margin-bottom: 12px;
}
.step-card h4 {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
}
.algo-box {
    background: rgba(0, 0, 0, 0.25);
    border: 1px dashed rgba(192, 80, 255, 0.25);
    padding: 6px 10px;
    border-radius: 6px;
    font-family: monospace;
    font-size: 0.85rem;
    color: var(--accent-cyan);
    margin-top: 6px;
}

/* === Timer Display === */
#timer-display {
    position: fixed;
    top: 110px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    padding: 6px 16px;
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--accent-cyan);
    letter-spacing: 0.05em;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}
#timer-display.visible {
    opacity: 1;
}
#timer-display.solved {
    color: #00ff66;
    border-color: rgba(0, 255, 102, 0.3);
    box-shadow: 0 0 16px rgba(0, 255, 102, 0.2);
}

/* === Responsive === */
@media (max-width: 480px) {
    #canvas-container {
        bottom: 120px;
    }
    #controls-panel {
        gap: 6px;
        padding: 10px 14px;
        bottom: 16px;
    }
    #status {
        bottom: 160px;
    }
    .btn {
        padding: 10px 16px;
        font-size: 0.76rem;
    }
    #header h1 {
        font-size: 0.95rem;
    }
    #btn-help {
        top: 15px;
        right: 15px;
        width: 32px;
        height: 32px;
        font-size: 1rem;
    }
}

/* === Desktop Layout Adjustments === */
@media (min-width: 481px) {
    #controls-panel {
        bottom: auto;
        top: 50%;
        right: 28px;
        left: auto;
        transform: translateY(-50%);
        flex-direction: column;
        width: 190px;
        align-items: stretch;
        gap: 16px;
    }
    .buttons-row {
        flex-direction: column;
        gap: 10px;
    }
    .slider-row {
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
        text-align: center;
    }
}
