/* ===== Grid Glow Theme ===== */

/* ===== Toolbar (rendered in the page header) ===== */

.gg-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 18px;
    align-items: center;
    padding: 6px 14px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.07);
    backdrop-filter: blur(6px);
}

.gg-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--muted, #6b7280);
    letter-spacing: 0.02em;
    user-select: none;
}

.gg-switch {
    position: relative;
    width: 38px;
    height: 20px;
    padding: 0;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.05);
    cursor: pointer;
    transition: background 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}

.gg-switch:focus-visible {
    outline: 2px solid rgba(94, 234, 212, 0.6);
    outline-offset: 2px;
}

.gg-switch-thumb {
    position: absolute;
    top: 1px;
    left: 1px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #94a3b8;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1),
                background 0.25s ease,
                box-shadow 0.25s ease;
}

.gg-switch[aria-pressed="true"] {
    background: rgba(94, 234, 212, 0.18);
    border-color: rgba(94, 234, 212, 0.45);
    box-shadow: 0 0 12px rgba(94, 234, 212, 0.25);
}

.gg-switch[aria-pressed="true"] .gg-switch-thumb {
    transform: translateX(18px);
    background: #5eead4;
    box-shadow: 0 0 8px rgba(94, 234, 212, 0.7);
}

/* ===== Clock area (clock + AM/PM badge) ===== */

.gg-clock-area {
    position: relative;
    display: inline-block;
    padding-top: 30px;  /* room for the absolute AM/PM sitting just above the digits */
}

.gg-clock {
    --cell-size: clamp(16px, 2.8vw, 26px);
    --cell-gap: clamp(3px, 0.5vw, 6px);
    --digit-gap: clamp(10px, 1.4vw, 22px);

    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--digit-gap);
    perspective: 800px;
    max-width: 100%;
}

.gg-digit {
    display: grid;
    grid-template-columns: repeat(5, var(--cell-size));
    grid-template-rows: repeat(7, var(--cell-size));
    gap: var(--cell-gap);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.gg-colon {
    display: grid;
    grid-template-columns: var(--cell-size);
    grid-template-rows: repeat(7, var(--cell-size));
    gap: var(--cell-gap);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.gg-cell {
    width: var(--cell-size);
    height: var(--cell-size);
    border-radius: calc(var(--cell-size) * 0.22);
    background: rgba(255, 255, 255, 0.025);
    border: 1px solid rgba(255, 255, 255, 0.04);
    box-shadow: inset 0 0 4px rgba(0, 0, 0, 0.4);
    transition:
        background-color 280ms ease,
        border-color 280ms ease,
        box-shadow 280ms ease;
    transform-style: preserve-3d;
    will-change: transform;
}

.gg-cell.on {
    background: linear-gradient(135deg, #5eead4 0%, #22d3ee 55%, #0ea5e9 100%);
    border-color: rgba(94, 234, 212, 0.55);
    box-shadow:
        0 0 10px rgba(94, 234, 212, 0.55),
        0 0 22px rgba(34, 211, 238, 0.35),
        0 0 38px rgba(14, 165, 233, 0.18),
        inset 0 0 8px rgba(255, 255, 255, 0.35);
}

/* ===== AM/PM badge (sits just above the top-right of the digits) ===== */

.gg-meridiem {
    position: absolute;
    top: 0;
    right: 0;
    font-size: clamp(10px, 1vw, 12px);
    font-weight: 700;
    letter-spacing: 0.22em;
    padding: 4px 9px;
    border-radius: 6px;
    color: #5eead4;
    background: rgba(94, 234, 212, 0.1);
    border: 1px solid rgba(94, 234, 212, 0.4);
    box-shadow: 0 0 10px rgba(94, 234, 212, 0.25);
    text-shadow: 0 0 6px rgba(94, 234, 212, 0.7);
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.gg-meridiem[hidden] {
    display: none;
}

/* ===== Flip animations ===== */

.gg-cell.flip-in {
    animation: gg-flip-in 520ms cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.gg-cell.flip-out {
    animation: gg-flip-out 420ms cubic-bezier(0.55, 0, 0.7, 0.2) both;
}

@keyframes gg-flip-in {
    0% {
        transform: rotateX(-95deg) scale(0.4);
        opacity: 0;
        background: rgba(255, 255, 255, 0.02);
        box-shadow: inset 0 0 4px rgba(0, 0, 0, 0.6);
    }
    45% {
        transform: rotateX(15deg) scale(1.08);
        opacity: 1;
    }
    70% {
        transform: rotateX(-6deg) scale(1.02);
    }
    100% {
        transform: rotateX(0deg) scale(1);
        opacity: 1;
    }
}

@keyframes gg-flip-out {
    0% {
        transform: rotateX(0deg) scale(1);
        opacity: 1;
    }
    60% {
        transform: rotateX(75deg) scale(0.85);
        opacity: 0.4;
    }
    100% {
        transform: rotateX(95deg) scale(0.4);
        opacity: 0;
    }
}

/* Pulse glow when seconds tick */
.gg-clock.tick .gg-digit:last-of-type .gg-cell.on {
    animation: gg-pulse 700ms ease-out;
}

@keyframes gg-pulse {
    0%   { box-shadow: 0 0 0 rgba(94, 234, 212, 0); }
    35%  {
        box-shadow:
            0 0 14px rgba(94, 234, 212, 0.85),
            0 0 30px rgba(34, 211, 238, 0.55),
            0 0 60px rgba(14, 165, 233, 0.35),
            inset 0 0 10px rgba(255, 255, 255, 0.5);
    }
    100% {
        box-shadow:
            0 0 10px rgba(94, 234, 212, 0.55),
            0 0 22px rgba(34, 211, 238, 0.35),
            0 0 38px rgba(14, 165, 233, 0.18),
            inset 0 0 8px rgba(255, 255, 255, 0.35);
    }
}

/* Hiding/showing seconds */
.gg-clock.no-seconds .gg-segment-seconds,
.gg-clock.no-seconds .gg-segment-colon-seconds {
    display: none;
}

/* Mobile sizing */
@media (max-width: 640px) {
    .gg-clock {
        --cell-size: clamp(12px, 5.5vw, 20px);
        --cell-gap: 3px;
        --digit-gap: 8px;
    }
    .gg-toolbar { gap: 6px 12px; padding: 5px 10px; }
    .gg-toggle-label { font-size: 11px; }
    .gg-clock-area { padding-top: 24px; }
}