/**
 * time-picker.css
 *
 * Desktop clock dials and mobile wheel picker, including AM/PM, 12/24-hour controls, minute shortcuts, and touch-oriented responsive geometry.
 *
 * Sections:
 * 1. Shared picker header and desktop controls
 * 2. Desktop clock dials
 * 3. Minute/AM-PM/action controls
 * 4. Mobile wheel picker
 * 5. Small-mobile adjustments
 *
 * Troubleshooting:
 * - Wheel item heights must stay synchronized with constants in time-picker.js.
 * - Desktop `.picker-face` is replaced by `.mobile-wheel-picker` at ≤620px.
 */

/* 1. Shared readout/header and desktop format controls. */
.picker-header{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:14px;
    margin:0 42px 16px 0;
}

.picker-header > div:first-child{
    display:grid;
    gap:2px;
}

.picker-header span,
.dial-heading span{
    color:var(--soft);
    font-size:11px;
    font-weight:850;
    letter-spacing:.1em;
    text-transform:uppercase;
}

.picker-header strong{
    color:var(--text);
    font-size:34px;
    font-weight:950;
    line-height:1;
    font-variant-numeric:tabular-nums;
}

/* Hidden on desktop; activated inside the mobile breakpoint. */
.mobile-wheel-picker{
    display:none;
}

.picker-mode-toggle{
    display:inline-grid;
    grid-template-columns:1fr 1fr;
    gap:4px;
    border:1px solid rgba(255,255,255,.09);
    border-radius:8px;
    background:rgba(13,18,26,.68);
    padding:4px;
}

.picker-mode-toggle button{
    min-height:30px;
    border-radius:6px;
    background:transparent;
    color:var(--muted);
    padding:0 12px;
    font-size:13px;
}

.picker-mode-toggle button.is-active{
    background:rgba(53,194,165,.28);
    color:var(--accent);
    box-shadow:inset 0 1px 0 rgba(255,255,255,.06);
}

/* 2. Desktop side-by-side clock dial panels. */
.picker-face{
    display:grid;
    grid-template-columns:1fr 1fr;
    gap:12px;
}

.dial-group{
    display:grid;
    gap:12px;
    justify-items:center;
}

.dial-panel{
    border:1px solid rgba(255,255,255,.09);
    border-radius:8px;
    background:
        linear-gradient(180deg, rgba(31,38,50,.8), rgba(24,30,40,.72));
    padding:14px;
    box-shadow:inset 0 1px 0 rgba(255,255,255,.03);
}

.dial-heading{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:12px;
    width:100%;
}

.dial-heading > div:first-child{
    display:grid;
    gap:2px;
}

.dial-heading strong{
    color:var(--accent);
    font-size:24px;
    font-weight:950;
    font-variant-numeric:tabular-nums;
}

.minute-dial-wrap{
    display:grid;
    grid-template-columns:auto 26px;
    align-items:center;
    gap:7px;
}

/* Number positions use each span's --i value from index.php. */
.clock-dial{
    --dial-size:210px;
    --dial-number-radius:82px;
    --dial-hour-outer-radius:87px;
    --dial-hour-inner-radius:84px;
    --hour-hand-length:74px;
    --minute-hand-length:78px;
    position:relative;
    width:var(--dial-size);
    height:var(--dial-size);
    margin:auto;
    border:1px solid rgba(255,255,255,.1);
    border-radius:999px;
    background:
        radial-gradient(circle at center, rgba(53,194,165,.14) 0 14%, transparent 15%),
        radial-gradient(circle at center, transparent 0 68%, rgba(255,255,255,.035) 69% 70%, transparent 71%),
        #151b24;
    box-shadow:
        inset 0 0 0 1px rgba(0,0,0,.18),
        inset 0 12px 30px rgba(0,0,0,.16);
    cursor:pointer;
    touch-action:none;
    user-select:none;
}

.clock-dial span{
    position:absolute;
    left:50%;
    top:50%;
    width:24px;
    height:24px;
    display:grid;
    place-items:center;
    color:var(--muted);
    font-size:11px;
    font-weight:850;
    transform:
        translate(-50%, -50%)
        rotate(calc(var(--i) * 30deg))
        translateY(calc(var(--dial-number-radius) * -1))
        rotate(calc(var(--i) * -30deg));
}

.clock-dial .hour-outer{
    color:#cfd7e4;
    font-size:10px;
}

.clock-dial.hour-mode-12 .hour-outer{
    display:none;
}

.clock-dial.hour-mode-24 .hour-inner{
    display:none;
}

.clock-dial.hour-mode-24 .hour-outer{
    transform:
        translate(-50%, -50%)
        rotate(calc(var(--i) * 15deg))
        translateY(calc(var(--dial-hour-outer-radius) * -1))
        rotate(calc(var(--i) * -15deg));
}

.clock-dial .hour-inner{
    color:#cfd7e4;
    font-size:12px;
    opacity:1;
    transform:
        translate(-50%, -50%)
        rotate(calc(var(--i) * 30deg))
        translateY(calc(var(--dial-hour-inner-radius) * -1))
        rotate(calc(var(--i) * -30deg));
}

.clock-hand{
    position:absolute;
    left:50%;
    bottom:50%;
    border-radius:999px;
    transform-origin:bottom center;
}

.hour-hand{
    width:4px;
    height:var(--hour-hand-length);
    background:#eef3fb;
    box-shadow:0 0 14px rgba(246,248,251,.16);
}

.minute-hand{
    width:3px;
    height:var(--minute-hand-length);
    background:var(--accent);
    box-shadow:0 0 14px rgba(53,194,165,.2);
}

.clock-pin{
    position:absolute;
    left:50%;
    top:50%;
    width:10px;
    height:10px;
    border-radius:999px;
    background:var(--accent);
    transform:translate(-50%, -50%);
    box-shadow:
        0 0 0 8px rgba(53,194,165,.14),
        0 0 24px rgba(53,194,165,.26);
}

/* 3. Desktop adjustment controls and shared picker footer styling. */
.minute-nudges{
    display:grid;
    gap:6px;
}

.minute-nudges button{
    width:26px;
    min-height:26px;
    border-radius:7px;
    background:#242c3b;
    color:var(--text);
    padding:0;
    font-size:14px;
}

.ampm-toggle{
    display:none;
    grid-template-columns:1fr 1fr;
    gap:6px;
    width:132px;
}

.ampm-toggle.is-visible{
    display:grid;
}

.ampm-toggle button{
    min-height:30px;
    border-radius:7px;
    background:#242c3b;
    color:var(--muted);
    padding:0;
    font-size:12px;
}

.ampm-toggle button.is-active{
    background:rgba(53,194,165,.28);
    color:var(--accent);
}

.minute-nudges button:hover{
    background:rgba(53,194,165,.2);
}

.dial-stepper{
    display:grid;
    grid-template-columns:1fr 1fr;
    gap:8px;
    width:138px;
}

.dial-stepper button{
    min-height:32px;
    border-radius:7px;
    background:#242c3b;
    color:var(--text);
    padding:0;
}

.minute-chips{
    display:grid;
    grid-template-columns:repeat(4, 1fr);
    gap:6px;
    width:210px;
    margin-top:0;
}

.minute-chips button,
.picker-actions button:first-child{
    background:#242c3b;
    color:var(--text);
}

.minute-chips button{
    min-height:34px;
    border-radius:7px;
    padding:0 10px;
}

/* Tablet: stack desktop dials before the full mobile wheel layout takes over. */
@media (max-width:900px){
    .time-popover-panel{
            width:min(430px, 100%);
        }

    .picker-header{
            align-items:flex-start;
            flex-direction:column;
            margin-right:36px;
        }

    .picker-face{
            grid-template-columns:1fr;
        }
}

/* 4. Mobile: JavaScript positions wheel buttons around the highlighted center row. */
@media (max-width:620px){
    /* Mobile: wheel items are absolutely positioned by time-picker.js. */
    #mobileHourWheel button{
        min-height:46px;
    }

    #mobileHourWheel,
    #mobileMinuteWheel{
        overflow:hidden;
        touch-action:none;
    }

    #mobileHourWheel button,
    #mobileMinuteWheel button{
        position:absolute;
        left:0;
        top:50%;
        transition:color .12s ease;
        will-change:transform, opacity;
    }

    #mobileMinuteWheel button{
        min-height:41px;
    }

    .time-popover{
            place-items:start center;
            padding:clamp(18px, 7vh, 52px) 14px 14px;
            overflow:hidden;
        }

    .time-popover-panel{
            width:100%;
            max-width:390px;
            max-height:calc(100vh - 28px);
            max-height:calc(100dvh - 28px);
            overflow:hidden;
            padding:14px;
            border-color:var(--line);
            background:
                linear-gradient(180deg, rgba(26,32,42,.98), rgba(18,24,34,.98));
            overscroll-behavior:contain;
        }

    .picker-header{
            gap:8px;
            margin:0 40px 12px;
            align-items:center;
            text-align:center;
        }

    .picker-header span{
            font-size:10px;
        }

    .picker-header strong{
            font-size:30px;
        }

    .mobile-wheel-picker{
            display:grid;
            gap:12px;
            margin-top:6px;
        }

    .wheel-stage{
            position:relative;
            display:grid;
            grid-template-columns:minmax(0, 1fr) 18px minmax(0, 1fr);
            align-items:center;
            gap:8px;
            min-height:218px;
            border-radius:8px;
            background:
                linear-gradient(180deg, rgba(33,40,55,.72), transparent 20%, transparent 80%, rgba(18,24,34,.72)),
                #121822;
            overflow:hidden;
        }

    .wheel-stage::before{
            content:"";
            position:absolute;
            left:0;
            right:0;
            top:50%;
            height:34px;
            border-radius:8px;
            background:rgba(53,194,165,.12);
            border:1px solid rgba(53,194,165,.18);
            transform:translateY(-50%);
            pointer-events:none;
        }

    .wheel-stage::after{
            content:"";
            position:absolute;
            inset:0;
            background:
                linear-gradient(180deg, #121822, rgba(18,24,34,0) 30%, rgba(18,24,34,0) 70%, #121822);
            pointer-events:none;
        }

    .time-wheel-divider{
            position:relative;
            z-index:1;
            color:var(--accent);
            font-size:26px;
            font-weight:850;
            text-align:center;
            line-height:1;
            transform:translateY(-1px);
        }

    .time-wheel{
            position:relative;
            z-index:1;
            height:218px;
            padding-block:89px;
            overflow-y:auto;
            overscroll-behavior:contain;
            scroll-snap-type:y proximity;
            scrollbar-width:none;
            touch-action:pan-y;
            -webkit-overflow-scrolling:touch;
        }

    .time-wheel::-webkit-scrollbar{
            display:none;
        }

    .time-wheel button{
            width:100%;
            min-height:34px;
            display:grid;
            place-items:center;
            border-radius:8px;
            background:transparent;
            color:rgba(169,178,193,.56);
            padding:0;
            font-size:19px;
            font-weight:650;
            line-height:1;
            font-variant-numeric:tabular-nums;
            scroll-snap-align:center;
            scroll-snap-stop:normal;
            transform:scale(.94);
            transition:color .16s ease, transform .18s ease;
        }

    .time-wheel button.is-selected{
            color:var(--text);
            transform:scale(1.06);
        }

    .mobile-minute-chips{
            display:grid;
            grid-template-columns:repeat(4, minmax(0, 1fr));
            gap:8px;
        }

    .mobile-minute-chips button{
            min-height:36px;
            border:1px solid var(--line);
            border-radius:8px;
            background:#121822;
            color:var(--text);
            padding:0;
            font-size:14px;
        }

    .mobile-minute-chips button:hover{
            background:rgba(53,194,165,.14);
        }

    .mobile-ampm-toggle{
            display:grid;
            grid-template-columns:1fr 1fr;
            gap:6px;
            border:1px solid var(--line);
            border-radius:8px;
            background:#121822;
            padding:4px;
        }

    .mobile-time-options{
            display:grid;
            grid-template-columns:1fr 1fr;
            gap:8px;
        }

    .mobile-format-toggle{
            display:grid;
            grid-template-columns:1fr 1fr;
            gap:4px;
            border:1px solid var(--line);
            border-radius:8px;
            background:#121822;
            padding:4px;
        }

    .mobile-format-toggle button{
            min-height:38px;
            border-radius:6px;
            background:transparent;
            color:var(--muted);
            padding:0;
            font-size:14px;
        }

    .mobile-format-toggle button.is-active{
            background:rgba(53,194,165,.2);
            color:var(--accent);
        }

    .mobile-time-options.is-24-hour{
            grid-template-columns:minmax(0, 1fr) minmax(0, 1fr);
        }

    .mobile-ampm-toggle.is-hidden{
            display:none;
        }

    .mobile-ampm-toggle button{
            min-height:38px;
            border-radius:6px;
            background:transparent;
            color:var(--muted);
            padding:0;
            font-size:14px;
        }

    .mobile-ampm-toggle button.is-active{
            background:var(--accent);
            color:#071412;
            box-shadow:0 8px 20px rgba(53,194,165,.2);
        }

    .picker-face{
            display:none;
        }
}

/* 5. Small mobile: shorten wheel geometry while preserving touch targets. */
@media (max-width:360px){
    /* Small mobile: retain a usable touch target in the shorter wheel. */
    #mobileHourWheel button{
        min-height:44px;
    }

    #mobileMinuteWheel button{
        min-height:40px;
    }

    .time-popover-panel{
            padding:10px;
        }

    .picker-header{
            margin-bottom:10px;
        }

    .picker-header strong{
            font-size:28px;
        }

    .wheel-stage{
            min-height:188px;
        }

    .time-wheel{
            height:188px;
            padding-block:74px;
        }

    .time-wheel button{
            font-size:18px;
        }

    .mobile-time-options:not(.is-24-hour){
            grid-template-columns:1fr;
        }
}
