/* abelbrata.com - 3D cube (cube.js) + speedcubing timer (timer.js). Light theme. */

/* ------------------------------------------------------------------ cube */

[data-cube] {
    position: relative;
}

[data-cube] > .cube-canvas {
    position: absolute;
    inset: 0;
    top: 0; right: 0; bottom: 0; left: 0;
    display: block;
    width: 100%;
    height: 100%;
    outline: none;
    cursor: grab;
    touch-action: none;            /* drags turn/orbit the cube instead of scrolling */
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none;
    border-radius: 14px;
}

[data-cube] > .cube-canvas:active {
    cursor: grabbing;
}

[data-cube] > .cube-canvas:focus-visible {
    box-shadow: inset 0 0 0 2px var(--accent, #c41e3a);
}

/* WebGL running: hide the PHP fallback image. Without WebGL it stays visible. */
[data-cube].is-cube-ready > img,
[data-cube].is-cube-ready > picture,
[data-cube].is-cube-ready > .cube-fallback {
    display: none;
}

[data-cube] > img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Controls placed inside the cube element */
.cube-actions {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 12px;
    z-index: 1;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    pointer-events: none;
}

.cube-actions > * {
    pointer-events: auto;
}

[data-cube] [data-cube-action] {
    position: relative;
    z-index: 1;
}

:where([data-cube-action]) {
    appearance: none;
    -webkit-appearance: none;
    border: 1px solid var(--line, rgba(0, 0, 0, .1));
    background: rgba(255, 255, 255, .88);
    color: var(--ink, #111);
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    padding: 10px 16px;
    border-radius: 999px;
    cursor: pointer;
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    transition: border-color .15s, color .15s, background-color .15s;
}

:where([data-cube-action]):hover {
    border-color: var(--accent, #c41e3a);
    color: var(--accent, #c41e3a);
}

:where([data-cube-action]):focus-visible {
    outline: 2px solid var(--accent, #c41e3a);
    outline-offset: 2px;
}

/* ------------------------------------------------------------------ timer */

.tm {
    --tm-ready: #009e60;
    display: grid;
    gap: 20px;
    color: var(--ink, #111);
}

.tm-top {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px 20px;
}

.tm-scramble {
    margin: 0;
    flex: 1 1 320px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
    font-size: clamp(16px, 2.4vw, 22px);
    line-height: 1.5;
    letter-spacing: .02em;
    word-spacing: .2em;
    overflow-wrap: anywhere;
}

.tm-tools {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}

.tm-btn {
    appearance: none;
    -webkit-appearance: none;
    border: 1px solid var(--line, rgba(0, 0, 0, .1));
    background: #fff;
    color: var(--ink, #111);
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    padding: 10px 16px;
    min-height: 44px;
    border-radius: 999px;
    cursor: pointer;
    transition: border-color .15s, color .15s;
}

.tm-btn:hover {
    border-color: var(--accent, #c41e3a);
    color: var(--accent, #c41e3a);
}

.tm-btn-quiet {
    min-height: 36px;
    padding: 8px 14px;
    font-weight: 500;
    color: var(--muted, #666);
}

.tm-check {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--muted, #666);
    cursor: pointer;
    min-height: 44px;
}

.tm-check input {
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: var(--accent, #c41e3a);
}

.tm-btn:focus-visible,
.tm-chip:focus-visible,
.tm-check input:focus-visible {
    outline: 2px solid var(--accent, #c41e3a);
    outline-offset: 2px;
}

/* The timer cube, when the page puts it inside the root */
.tm > [data-cube] {
    width: 100%;
    max-width: 360px;
    aspect-ratio: 1 / 1;
    justify-self: center;
}

/* Big display / touch area */
.tm-pad {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: clamp(180px, 34vh, 320px);
    padding: 24px 12px;
    border: 1px solid var(--line, rgba(0, 0, 0, .1));
    border-radius: 14px;
    background: #fff;
    cursor: pointer;
    outline: none;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    transition: border-color .15s, box-shadow .15s;
}

.tm-pad:focus-visible {
    border-color: var(--ink, #111);
    box-shadow: 0 0 0 3px rgba(0, 0, 0, .06);
}

.tm-display {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
    font-variant-numeric: tabular-nums;
    font-size: clamp(56px, 16vw, 148px);
    font-weight: 700;
    line-height: 1;
    letter-spacing: -.02em;
    color: var(--ink, #111);
    transition: color .1s;
    white-space: nowrap;
}

.tm-hint {
    font-size: 14px;
    color: var(--muted, #666);
    min-height: 1.4em;
    text-align: center;
}

.tm.is-holding .tm-display {
    color: var(--accent, #c41e3a);
}

.tm.is-ready .tm-display {
    color: var(--tm-ready);
}

.tm.is-ready .tm-pad {
    border-color: var(--tm-ready);
}

.tm.is-inspecting .tm-display {
    color: #ff5800;
}

/* While running, everything but the clock steps back */
.tm.is-running .tm-top,
.tm.is-running .tm-stats,
.tm.is-running .tm-list-head,
.tm.is-running .tm-list,
.tm.is-running > [data-cube] {
    opacity: .15;
    pointer-events: none;
    transition: opacity .2s;
}

/* Stats */
.tm-stats {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
    margin: 0;
}

.tm-stat {
    padding: 12px 10px;
    border: 1px solid var(--line, rgba(0, 0, 0, .1));
    border-radius: 14px;
    text-align: center;
    min-width: 0;
}

.tm-stat dt {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--muted, #666);
}

.tm-stat dd {
    margin: 4px 0 0;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-variant-numeric: tabular-nums;
    font-size: clamp(16px, 2.6vw, 22px);
    font-weight: 600;
    overflow-wrap: anywhere;
}

/* Solve list */
.tm-list-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.tm-list-title {
    margin: 0;
    font-size: 18px;
}

.tm-list {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 420px;
    overflow-y: auto;
    border-top: 1px solid var(--line, rgba(0, 0, 0, .1));
}

.tm-solve {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 2px;
    border-bottom: 1px solid var(--line, rgba(0, 0, 0, .1));
}

.tm-solve-n {
    min-width: 3.2em;
    color: var(--muted, #666);
    font-variant-numeric: tabular-nums;
    font-size: 14px;
}

.tm-solve-t {
    flex: 1 1 auto;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-variant-numeric: tabular-nums;
    font-size: 17px;
    font-weight: 600;
}

.tm-solve.is-dnf .tm-solve-t {
    color: var(--muted, #666);
}

.tm-solve.is-plus2 .tm-solve-t {
    color: #b36b00;
}

.tm-solve-acts {
    display: inline-flex;
    gap: 6px;
}

.tm-chip {
    appearance: none;
    -webkit-appearance: none;
    min-width: 40px;
    min-height: 36px;
    padding: 6px 10px;
    border: 1px solid var(--line, rgba(0, 0, 0, .1));
    border-radius: 10px;
    background: #fff;
    color: var(--ink, #111);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.tm-chip:hover {
    border-color: var(--ink, #111);
}

.tm-chip[aria-pressed="true"] {
    background: var(--accent, #c41e3a);
    border-color: var(--accent, #c41e3a);
    color: #fff;
}

.tm-chip-del {
    font-size: 18px;
    line-height: 1;
    color: var(--muted, #666);
}

.tm-chip-del:hover {
    color: var(--accent, #c41e3a);
    border-color: var(--accent, #c41e3a);
}

.tm-sr {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

@media (max-width: 640px) {
    .tm {
        gap: 16px;
    }

    .tm-stats {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .tm-pad {
        min-height: 42vh;      /* a big thumb target on phones */
    }

    .tm-tools {
        width: 100%;
        justify-content: space-between;
    }
}

@media (prefers-reduced-motion: reduce) {
    .tm-display,
    .tm-pad,
    .tm.is-running .tm-top,
    .tm.is-running .tm-stats {
        transition: none;
    }
}
