/**
 * Clock Practice Widget styles
 *
 * No !important, no inline styles, no hardcoded URLs.
 * Touch targets ≥ 44px; mobile-first breakpoints at 768px and 480px.
 */

/* ====================================================================== */
/* ROOT + CONTAINER                                                       */
/* ====================================================================== */

.clock-practice-root {
    --cp-accent: #2563eb;
    --cp-accent-deep: #1e40af;
    --cp-success: #16a34a;
    --cp-danger: #dc2626;
    --cp-text: #1f2937;
    --cp-text-muted: #64748b;
    --cp-border: #e5e7eb;
    --cp-bg-panel: #f8fafc;
    --cp-bg-tab: #ffffff;
    --cp-radius: 12px;
    /* Header v3 geometry: align the merged header card to this widget's
       720px container (fleet polish item 2) */
    --as-header-max: 720px;

    font-family: var(--as-font);
    color: var(--cp-text);
    box-sizing: border-box;
}

.clock-practice-root *,
.clock-practice-root *::before,
.clock-practice-root *::after {
    box-sizing: inherit;
}

.clock-practice-container {
    max-width: 720px;
    margin: 0 auto;
    padding: 20px;
    background: #ffffff;
    border-radius: var(--cp-radius);
    border: 1px solid var(--cp-border);
}

.clock-practice-loading {
    text-align: center;
    padding: 40px 20px;
    color: var(--cp-text-muted);
}

.clock-practice-loading .loading-spinner {
    width: 32px;
    height: 32px;
    margin: 0 auto 12px;
    border: 3px solid var(--cp-border);
    border-top-color: var(--cp-accent);
    border-radius: 50%;
    animation: cp-spin 0.8s linear infinite;
}

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

/* ====================================================================== */
/* LEGACY HEADER — no-universal-header fallback only                      */
/* The live header is the merged 3-section bar from universal-header.js   */
/* (createExerciseLayout); cp-header/cp-title render only when that       */
/* script is missing.                                                     */
/* ====================================================================== */

.cp-header {
    margin-bottom: 16px;
}

.cp-title {
    font-size: 20px;
    font-weight: 700;
    margin: 0 0 12px;
    color: var(--cp-text);
    text-align: center;
}

/* ====================================================================== */
/* LEVEL PICKER (⚙ Options panel + session-complete screen)               */
/* ====================================================================== */

.cp-mode-selector-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

/* Label wraps the select (implicit association — no duplicate ids when
   the picker renders in two places), so it carries the row layout. */
.cp-mode-selector-label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 600;
    color: var(--cp-text);
    letter-spacing: 0.3px;
}

/* Inside the ⚙ Options dropdown the row is the only content — no
   trailing margin, comfy touch height. */
.clock-practice-root .te-mh-settings .cp-mode-selector-row {
    margin-bottom: 0;
}

.clock-practice-root .te-mh-settings .cp-mode-select {
    min-height: 48px;
}

/* Visible picker on the session-complete screen (level-hopping moment) */
.cp-complete-picker {
    margin-bottom: 16px;
}

.cp-mode-select {
    font-family: inherit;
    font-size: 15px;
    font-weight: 500;
    color: var(--cp-text);
    background: var(--cp-bg-tab);
    border: 2px solid var(--cp-border);
    border-radius: 10px;
    padding: 10px 36px 10px 14px;
    min-width: 280px;
    max-width: 100%;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%231e3a8a' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.cp-mode-select:hover {
    border-color: var(--cp-accent);
}

.cp-mode-select:focus {
    outline: none;
    border-color: var(--cp-accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
}

.cp-mode-instruction {
    font-size: 14px;
    color: var(--cp-text-muted);
    text-align: center;
    margin: 0;
    padding: 8px 12px;
    background: var(--cp-bg-panel);
    border-radius: 8px;
}

/* ====================================================================== */
/* BODY + SHARED PROMPT                                                   */
/* ====================================================================== */

.cp-body {
    margin: 16px 0;
}

.cp-mode {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.cp-mode.shake .cp-clock-svg {
    animation: cp-shake 0.4s ease;
}

@keyframes cp-shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-6px); }
    75% { transform: translateX(6px); }
}

.cp-prompt {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
    text-align: center;
    min-height: 28px;
}

.cp-prompt-text {
    font-size: 18px;
    font-weight: 600;
    color: var(--cp-text);
}

.cp-prompt-target {
    color: var(--cp-accent);
    font-size: 22px;
    margin: 0 4px;
}

.cp-prompt-target-time {
    color: var(--cp-accent);
    font-size: 22px;
    font-weight: 700;
}

.cp-prompt-done {
    color: var(--cp-success);
    font-size: 18px;
}

.cp-math-prompt {
    font-size: 17px;
    line-height: 1.5;
    max-width: 480px;
    margin: 0 auto;
}

.cp-math-prompt strong {
    color: var(--cp-accent);
    font-size: 19px;
}

.cp-prompt-audio-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    background: var(--cp-bg-tab);
    border: 1.5px solid var(--cp-border);
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
    font-family: inherit;
}

.cp-prompt-audio-btn:hover {
    border-color: var(--cp-accent);
    background: #eff6ff;
    transform: scale(1.05);
}

.cp-prompt-audio-btn:active {
    transform: scale(0.95);
}

/* Amber hint pill in the bottom help row — same treatment as every widget
   (stable action geography: help lives at the bottom, in amber). Scoped
   under the root so the background beats the Elementor kit's button white
   (0,2,0 > 0,1,1). */
.clock-practice-root .cp-hint-btn {
    padding: 8px 16px;
    min-height: 44px;
    background: #fef3c7;
    border: 1.5px solid #ca8a04;
    border-radius: 999px;
    color: #ca8a04;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.clock-practice-root .cp-hint-btn:hover {
    background: #fde68a;
    border-color: #a16207;
    color: #a16207;
}

.clock-practice-root .cp-hint-btn:disabled {
    opacity: 0.35;
    cursor: default;
    pointer-events: none;
}

.cp-help-row {
    display: flex;
    justify-content: center;
    padding-top: 8px;
}

/* Hint text shares the reserved feedback line — amber, no layout shift */
.cp-fb-hint { color: #ca8a04; }

/* Invisible fat hit targets on the SVG face (numbers, hands, center) */
.cp-hit,
.cp-hand-hit {
    pointer-events: all;
    cursor: pointer;
}

/* ====================================================================== */
/* CLOCK SVG                                                              */
/* ====================================================================== */

.cp-clock-wrap {
    width: 100%;
    max-width: 360px;
    aspect-ratio: 1 / 1;
}

/* Modern face (fleet polish item 7): soft slate ring + rounded tick caps +
   lighter numerals + a whisper of depth — kills the "old-timey, corners
   too sharp" look without touching any geometry or hit targets. */
.cp-clock-svg {
    width: 100%;
    height: 100%;
    display: block;
    touch-action: none; /* prevent scroll while dragging hands */
    filter: drop-shadow(0 2px 5px rgba(15, 23, 42, 0.08));
}

.cp-face {
    fill: #ffffff;
    stroke: #cbd5e1;
    stroke-width: 1.2;
}

.cp-tick {
    stroke: #cbd5e1;
    stroke-width: 0.6;
    stroke-linecap: round;
}

.cp-tick.major {
    stroke: #64748b;
    stroke-width: 1.3;
    stroke-linecap: round;
}

.cp-number {
    font-size: 6.5px;
    font-weight: 600;
    fill: #334155;
    cursor: pointer;
    user-select: none;
    transition: fill 0.15s ease;
}

.cp-number:hover {
    fill: var(--cp-accent);
}

.cp-number.highlight {
    fill: var(--cp-accent);
}

.cp-number.active {
    fill: var(--cp-accent);
    animation: cp-pulse 1.2s ease-in-out infinite;
}

.cp-number.lit {
    fill: var(--cp-success);
}

.cp-number.correct {
    fill: var(--cp-success);
}

.cp-number.wrong {
    fill: var(--cp-danger);
}

.cp-number-lit-label {
    font-size: 3.5px;
    fill: var(--cp-success);
    font-weight: 600;
    user-select: none;
    pointer-events: none;
}

@keyframes cp-pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.45; }
}

.cp-hand {
    stroke-linecap: round;
    transition: stroke 0.15s ease;
}

.cp-hand-hour {
    stroke: #1e3a8a;
    stroke-width: 3.5;
}

.cp-hand-minute {
    stroke: #dc2626;
    stroke-width: 2;
}

.cp-hand.draggable {
    cursor: grab;
}

.cp-hand.draggable:active {
    cursor: grabbing;
}

.cp-hand.highlight {
    filter: drop-shadow(0 0 4px rgba(37, 99, 235, 0.6));
}

.cp-hand.correct {
    stroke: var(--cp-success);
}

.cp-hand.wrong {
    stroke: var(--cp-danger);
    animation: cp-shake 0.4s ease;
}

.cp-center {
    fill: #1e3a8a; /* matches the hour hand — reads as one modern hub */
    stroke: #ffffff;
    stroke-width: 0.7;
    cursor: pointer;
    transition: fill 0.15s ease;
}

.cp-center.highlight {
    fill: var(--cp-accent);
}

.cp-center.correct {
    fill: var(--cp-success);
}

/* ====================================================================== */
/* CHOICE BUTTONS (Read mode + Math mode)                                 */
/* ====================================================================== */

.cp-choice-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    width: 100%;
    max-width: 360px;
}

.cp-choice-btn {
    padding: 14px 12px;
    min-height: 56px;
    background: #ffffff;
    border: 2px solid var(--cp-border);
    border-radius: 10px;
    font-size: 20px;
    font-weight: 700;
    color: var(--cp-text);
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s ease;
}

.cp-choice-btn:hover:not(:disabled) {
    border-color: var(--cp-accent);
    background: #eff6ff;
    color: var(--cp-accent);
}

.cp-choice-btn:disabled {
    cursor: default;
}

.cp-choice-btn.correct {
    background: #f0fdf4;
    border-color: var(--cp-success);
    color: var(--cp-success);
}

.cp-choice-btn.wrong {
    background: #fef2f2;
    border-color: var(--cp-danger);
    color: var(--cp-danger);
}

.cp-choice-btn.reveal {
    background: #f0fdf4;
    border-color: var(--cp-success);
    color: var(--cp-success);
    animation: cp-reveal 0.6s ease;
}

@keyframes cp-reveal {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.05); }
}

/* ====================================================================== */
/* SET MODE — drag controls + steppers + check button                     */
/* ====================================================================== */

/* ±5-minute steppers — fine-motor alternative to dragging. Green
   action-surface family (matches the fleet: #ecfdf5 / #10b981 / #047857).
   Scoped under the root so the background/color beat the Elementor kit's
   button styles on specificity (0,2,0 > 0,1,1) — no !important needed. */
.clock-practice-root .cp-stepper-row {
    display: flex;
    justify-content: center;
    gap: 12px;
    width: 100%;
}

.clock-practice-root .cp-stepper-btn {
    min-height: 48px;
    min-width: 116px;
    padding: 10px 18px;
    background: #ecfdf5;
    border: 2px solid #10b981;
    border-radius: 10px;
    color: #047857;
    font-size: 17px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.15s ease;
}

.clock-practice-root .cp-stepper-btn:hover:not(:disabled) {
    background: #d1fae5;
}

.clock-practice-root .cp-stepper-btn:active:not(:disabled) {
    transform: scale(0.97);
}

.clock-practice-root .cp-stepper-btn:disabled {
    opacity: 0.35;
    cursor: default;
}

.cp-set-current {
    font-size: 14px;
    color: var(--cp-text-muted);
}

.cp-set-current strong {
    color: var(--cp-text);
    font-size: 18px;
    font-weight: 700;
}

.cp-action-row {
    display: flex;
    gap: 10px;
    justify-content: center;
    width: 100%;
}

.cp-action-btn {
    padding: 12px 28px;
    min-height: 48px;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    border: 2px solid transparent;
    transition: all 0.15s ease;
}

.cp-action-primary {
    background: var(--cp-accent);
    color: #ffffff;
    border-color: var(--cp-accent);
}

.cp-action-primary:hover {
    background: var(--cp-accent-deep);
    border-color: var(--cp-accent-deep);
}

/* ====================================================================== */
/* FEEDBACK LINE                                                          */
/* ====================================================================== */

.cp-feedback-line {
    min-height: 24px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
}

.cp-fb {
    font-size: 15px;
    font-weight: 600;
}

.cp-fb-correct {
    color: var(--cp-success);
}

.cp-fb-wrong {
    color: var(--cp-danger);
}

/* Accessibility fallback: manual Next, shown only when auto-advance is off. */
.cp-fb-next {
    font-size: 14px;
    font-weight: 600;
    color: var(--cp-text-muted, #64748b);
    background: transparent;
    border: none;
    cursor: pointer;
    font-family: inherit;
    padding: 0 8px;
    white-space: nowrap;
}

/* ====================================================================== */
/* PROGRESS PIPS — now the shared .ex-nav row (shared-components.css).    */
/* Local rule below only restores the divider the old cp-progress-row    */
/* drew above the pips.                                                  */
/* ====================================================================== */

.clock-practice-container .ex-nav {
    margin-top: 16px;
    border-top: 1px solid var(--cp-border);
}

/* ====================================================================== */
/* LOGIN PROMPT                                                           */
/* ====================================================================== */

.cp-login-prompt {
    text-align: center;
    padding: 40px 20px;
}

.cp-login-prompt h3 {
    margin: 0 0 8px;
    font-size: 20px;
}

.cp-login-prompt p {
    margin: 0 0 20px;
    color: var(--cp-text-muted);
}

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

.cp-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    min-height: 48px;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    font-family: inherit;
    border: 2px solid transparent;
    transition: all 0.15s ease;
}

.cp-btn-primary {
    background: var(--cp-accent);
    color: #ffffff;
    border-color: var(--cp-accent);
}

.cp-btn-primary:hover {
    background: var(--cp-accent-deep);
    border-color: var(--cp-accent-deep);
    color: #ffffff;
}

.cp-btn-secondary {
    background: #ffffff;
    color: var(--cp-text);
    border-color: var(--cp-border);
}

.cp-btn-secondary:hover {
    border-color: var(--cp-accent);
    color: var(--cp-accent);
}

.cp-complete-fallback {
    text-align: center;
    padding: 30px 20px;
}

.cp-complete-fallback h3 {
    margin: 0 0 8px;
}

.cp-complete-fallback p {
    color: var(--cp-text-muted);
    margin: 0 0 20px;
}

/* ====================================================================== */
/* MOBILE (≤768px)                                                        */
/* ====================================================================== */

@media (max-width: 768px) {
    .clock-practice-container {
        padding: 14px;
    }

    .cp-mode-select {
        font-size: 14px;
        min-width: 0;
        width: 100%;
        padding: 10px 32px 10px 12px;
    }

    .cp-mode-selector-row {
        gap: 8px;
    }

    .cp-mode-selector-label {
        width: 100%;
    }

    .cp-title {
        font-size: 18px;
        margin-bottom: 10px;
    }

    .clock-practice-root .cp-stepper-btn {
        min-width: 0;
        flex: 1;
        max-width: 160px;
        font-size: 16px;
    }

    .cp-prompt-text {
        font-size: 16px;
    }

    .cp-prompt-target {
        font-size: 20px;
    }

    .cp-math-prompt {
        font-size: 15px;
    }

    .cp-math-prompt strong {
        font-size: 17px;
    }

    .cp-clock-wrap {
        max-width: 280px;
    }

    .cp-choice-btn {
        font-size: 18px;
        padding: 12px 8px;
        min-height: 52px;
    }
}

@media (max-width: 480px) {
    .cp-mode-select {
        font-size: 13px;
        padding: 9px 28px 9px 10px;
    }

    .cp-clock-wrap {
        max-width: 240px;
    }
}

/* ====================================================================== */
/* REDUCED MOTION                                                         */
/* ====================================================================== */

@media (prefers-reduced-motion: reduce) {
    .cp-number.active,
    .cp-choice-btn.reveal,
    .cp-hand.wrong,
    .cp-mode.shake .cp-clock-svg {
        animation: none;
    }
    .clock-practice-loading .loading-spinner {
        animation-duration: 2s;
    }
}

/* ====================================================================== */
/* FOCUS RINGS                                                            */
/* ====================================================================== */

.cp-mode-select:focus-visible,
.cp-choice-btn:focus-visible,
.cp-action-btn:focus-visible,
.cp-btn:focus-visible,
.cp-hint-btn:focus-visible,
.cp-stepper-btn:focus-visible,
.cp-prompt-audio-btn:focus-visible {
    outline: 3px solid rgba(37, 99, 235, 0.5);
    outline-offset: 2px;
}
