/* components.css */

/* =============== BUTTONS =============== */
.btn {
    padding: 12px 20px;
    border: none;
    min-height: 44px;
    border-radius: var(--homeza-button-radius);
    font-size: 1rem;
    line-height: 1.25;
    font-weight: 600;
    font-family: var(--font-family);
    cursor: pointer;
    transition: var(--transition-fast);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    position: relative;
    overflow: hidden;
}

.btn:active {
    transform: scale(0.98);
}

/* Ripple pseudo-element */
.btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle, var(--primary-very-light) 10%, transparent 10.01%);
    transform: scale(10);
    opacity: 0;
    transition: transform 0.5s, opacity 0.5s;
}

.btn:active::after {
    transform: scale(0);
    opacity: 0.3;
    transition: 0s;
}

.btn-primary {
    background: var(--accent-fill);
    color: white;
    box-shadow: none;
}

.btn-primary:active {
    background: color-mix(in srgb, var(--accent-fill) 85%, black);
    box-shadow: none;
    transform: scale(0.98);
}

.btn-secondary {
    background: var(--white);
    color: var(--accent-ink);
    border: 1px solid var(--border);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-danger {
    background: var(--danger-fill);
    color: white;
}

.btn-group {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

.btn-group .btn {
    flex: 1;
}

/* =============== LOADING & TOASTS =============== */

/* Overlay для затемнения — light theme */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(254, 251, 243, 0.85);
    backdrop-filter: blur(20px);
    z-index: 999;
    display: none;
}

/* Overlay — dark theme */
[data-theme="dark"] .loading-overlay {
    background: rgba(30, 27, 20, 0.85);
}

.loading-overlay.active {
    display: block;
}

.loading {
    display: none;
    text-align: center;
    padding: 48px 32px;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--border-radius-large);
    box-shadow: var(--shadow-lg);
    min-width: 320px;
    max-width: 400px;
}

.loading.active {
    display: block;
}

/* iOS-style activity indicator: 12 спиц по кругу, каждая угасает по очереди */
.spinner {
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 0;
    background: transparent;
    margin: 18px auto 32px;
    position: relative;
    color: var(--primary);
}

.spinner > i {
    position: absolute;
    top: 0;
    left: 50%;
    width: 4px;
    height: 11px;
    margin-left: -2px;
    background: currentColor;
    border-radius: 2px;
    opacity: 0.18;
    transform-origin: 2px 22px;
    animation: iosSpin 1.2s linear infinite;
}
.spinner > i:nth-child(1)  { transform: rotate(  0deg); animation-delay: -1.1s; }
.spinner > i:nth-child(2)  { transform: rotate( 30deg); animation-delay: -1.0s; }
.spinner > i:nth-child(3)  { transform: rotate( 60deg); animation-delay: -0.9s; }
.spinner > i:nth-child(4)  { transform: rotate( 90deg); animation-delay: -0.8s; }
.spinner > i:nth-child(5)  { transform: rotate(120deg); animation-delay: -0.7s; }
.spinner > i:nth-child(6)  { transform: rotate(150deg); animation-delay: -0.6s; }
.spinner > i:nth-child(7)  { transform: rotate(180deg); animation-delay: -0.5s; }
.spinner > i:nth-child(8)  { transform: rotate(210deg); animation-delay: -0.4s; }
.spinner > i:nth-child(9)  { transform: rotate(240deg); animation-delay: -0.3s; }
.spinner > i:nth-child(10) { transform: rotate(270deg); animation-delay: -0.2s; }
.spinner > i:nth-child(11) { transform: rotate(300deg); animation-delay: -0.1s; }
.spinner > i:nth-child(12) { transform: rotate(330deg); animation-delay:  0s; }

@keyframes iosSpin {
    0%   { opacity: 1; }
    100% { opacity: 0.18; }
}

/* Размер-вариант поменьше: для inline */
.spinner.spinner-sm { width: 20px; height: 20px; margin: 6px auto 12px; }
.spinner.spinner-sm > i { height: 5px; transform-origin: 1.25px 10px; }
.spinner.spinner-sm > i:nth-child(1)  { transform: rotate(  0deg); }
.spinner.spinner-sm > i:nth-child(2)  { transform: rotate( 30deg); }
.spinner.spinner-sm > i:nth-child(3)  { transform: rotate( 60deg); }
.spinner.spinner-sm > i:nth-child(4)  { transform: rotate( 90deg); }
.spinner.spinner-sm > i:nth-child(5)  { transform: rotate(120deg); }
.spinner.spinner-sm > i:nth-child(6)  { transform: rotate(150deg); }
.spinner.spinner-sm > i:nth-child(7)  { transform: rotate(180deg); }
.spinner.spinner-sm > i:nth-child(8)  { transform: rotate(210deg); }
.spinner.spinner-sm > i:nth-child(9)  { transform: rotate(240deg); }
.spinner.spinner-sm > i:nth-child(10) { transform: rotate(270deg); }
.spinner.spinner-sm > i:nth-child(11) { transform: rotate(300deg); }
.spinner.spinner-sm > i:nth-child(12) { transform: rotate(330deg); }

/* Inline-вариант (для кнопок/toast'ов): тот же круг, размер 14px */
.spinner-inline {
    display: inline-block;
    width: 14px;
    height: 14px;
    position: relative;
    vertical-align: middle;
    color: currentColor;
}
.spinner-inline > i {
    position: absolute;
    top: 0;
    left: 50%;
    width: 1.5px;
    height: 4px;
    margin-left: -0.75px;
    background: currentColor;
    border-radius: 1px;
    opacity: 0.2;
    transform-origin: 0.75px 7px;
    animation: iosSpin 1.2s linear infinite;
}
.spinner-inline > i:nth-child(1)  { transform: rotate(  0deg); animation-delay: -1.1s; }
.spinner-inline > i:nth-child(2)  { transform: rotate( 30deg); animation-delay: -1.0s; }
.spinner-inline > i:nth-child(3)  { transform: rotate( 60deg); animation-delay: -0.9s; }
.spinner-inline > i:nth-child(4)  { transform: rotate( 90deg); animation-delay: -0.8s; }
.spinner-inline > i:nth-child(5)  { transform: rotate(120deg); animation-delay: -0.7s; }
.spinner-inline > i:nth-child(6)  { transform: rotate(150deg); animation-delay: -0.6s; }
.spinner-inline > i:nth-child(7)  { transform: rotate(180deg); animation-delay: -0.5s; }
.spinner-inline > i:nth-child(8)  { transform: rotate(210deg); animation-delay: -0.4s; }
.spinner-inline > i:nth-child(9)  { transform: rotate(240deg); animation-delay: -0.3s; }
.spinner-inline > i:nth-child(10) { transform: rotate(270deg); animation-delay: -0.2s; }
.spinner-inline > i:nth-child(11) { transform: rotate(300deg); animation-delay: -0.1s; }
.spinner-inline > i:nth-child(12) { transform: rotate(330deg); animation-delay:  0s; }

.loading .section-title {
    color: var(--text-primary);
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 12px;
    text-align: center;
    display: block;
}

.loading .text-gray {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.5;
    max-width: 280px;
    margin: 0 auto;
    text-align: center;
}

.toast {
    position: fixed;
    top: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary-dark);
    color: white;
    padding: 12px 20px;
    /* 09.10.2026: left:50% сжимал тост до половины экрана, а «таблетка» на длинном
       тексте (отказ с объяснением) рисовала круг поверх кнопок. Ширина — по тексту,
       не шире экрана без полей; скругление — как у карточек. */
    width: max-content;
    max-width: calc(100vw - 32px);
    box-sizing: border-box;
    border-radius: 18px;
    font-weight: 600;
    z-index: 1001;
    animation: slideDown 0.3s ease-out;
    text-align: center;
    line-height: 1.3;
}

.toast.error {
    background: var(--primary);
}

/* =============== MODALS =============== */

/* Success Modal */
.success-modal {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    z-index: 99999 !important;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(254, 251, 243, 0.85);
    backdrop-filter: blur(20px);
}

[data-theme="dark"] .modal-overlay {
    background: rgba(30, 27, 20, 0.85);
}

.modal-content {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    padding: 32px 24px;
    box-shadow: var(--shadow-lg);
    position: relative;
    z-index: 1;
    text-align: center;
    max-width: 400px;
    width: 100%;
}

.modal-icon {
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-title {
    font-size: 20px;
    font-weight: 600;
    margin: 0 0 12px 0;
    color: var(--text-primary);
}

.modal-message {
    font-size: 16px;
    line-height: 1.5;
    margin: 0 0 24px 0;
    color: var(--text-secondary);
}

.modal-btn {
    width: 100%;
    padding: 12px 20px;
    font-size: 16px;
    font-weight: 500;
}

/* =============== VIDEO MODAL =============== */
.video-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 20px;
}

.video-modal {
    background: var(--surface);
    border-radius: var(--border-radius);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

.video-header {
    background: var(--primary);
    color: white;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.video-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.close-video-btn {
    background: rgba(0,0,0,.2);
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    border-radius: 50%;
    transition: var(--transition-fast);

    width: 44px;

    height: 44px;
}

.close-video-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.video-content {
    padding: 20px;
}

/* === OTP code input (authorization) === */
.otp-row {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin: 8px 0 16px;
}
.otp-cell {
    width: 56px;
    height: 64px;
    text-align: center;
    font-size: 28px;
    font-weight: 600;
    line-height: 1;
    color: #2A2A2A;
    border: 2px solid var(--border);
    border-radius: 14px;
    background: #F7F6F4;
    outline: none;
    caret-color: var(--primary);
    transition: border-color 0.18s ease, transform 0.12s ease, background 0.18s ease, box-shadow 0.18s ease;
    -webkit-appearance: none;
    appearance: none;
    -webkit-user-select: text;
    user-select: text;
}
.otp-cell:focus {
    border-color: var(--primary);
    background: #fff;
    transform: scale(1.04);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.06);
}
.otp-cell.filled {
    border-color: var(--primary);
    background: #fff;
}
.otp-cell.error {
    border-color: #E55;
    background: #FFF3F3;
    animation: otp-shake 0.32s ease;
}
@keyframes otp-shake {
    0%, 100% { transform: translateX(0); }
    25%      { transform: translateX(-4px); }
    75%      { transform: translateX(4px); }
}
@media (max-width: 360px) {
    .otp-row { gap: 8px; }
    .otp-cell { width: 50px; height: 58px; font-size: 24px; }
}


.homeza-main-action,
.workout-action.homeza-main-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 44px;
    padding: 10px 12px;
    border: 0;
    border-radius: var(--homeza-button-radius);
    background: var(--accent-fill);
    color: #fff;
    font: 500 1rem/1.25 var(--font-family);
    cursor: pointer;
    box-shadow: none;
    text-align: center;
}
.homeza-main-action:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.homeza-main-action .homeza-icon { width: 20px; height: 20px; stroke-width: 1.75; }
.homeza-main-action:active:not(:disabled),
.workout-action.homeza-main-action:active:not(:disabled) {
    transform: scale(.98);
    background: color-mix(in srgb, var(--accent-fill) 85%, black);
}

/* Pointer feedback on actions without changing their hit area. */
@media (hover: hover) {
    :root { --action-hover-brightness: .92; }
    [data-theme="dark"] { --action-hover-brightness: 1.12; }
    :where(button:not(.immersive-playback), a[href], [role="button"], [role="tab"], [role="switch"], summary,
        .dy-period > label:has(> input:enabled), .library-carousel-card, .dash-nav-card, .profile-item,
        .choice-card, .day-card, .day-card-edit, .equipment-item, .expand-icon,
        .week-dot:has(.scheduled, .completed, .today), .day-workout-card:not(.rest-day), #quickStartCard)
        :not(.unused-selector) {}
    :where(button:not(.immersive-playback), a[href], [role="button"], [role="tab"], [role="switch"], summary,
        .dy-period > label:has(> input:enabled), .library-carousel-card, .dash-nav-card, .profile-item,
        .choice-card, .day-card, .day-card-edit, .equipment-item, .expand-icon,
        .week-dot:has(.scheduled, .completed, .today), .day-workout-card:not(.rest-day), #quickStartCard):hover:not(:active, :disabled, [aria-disabled="true"]) {
        filter: brightness(var(--action-hover-brightness));
    }
}


/* Keep an edge on filled and quiet buttons without changing their layout. */
:root { --action-boundary: color-mix(in srgb, var(--text-primary) 24%, var(--border)); }
:is(.btn, .homeza-main-action, .homeza-round-control, .workout-action,
    .workout-start-btn, .prog-switch-btn, .wc-empty-btn,
    .btn-workout-completed, .btn-continue-workout):not(:focus-visible) {
    outline: 1px solid var(--action-edge, var(--action-boundary));
    outline-offset: -1px;
}

:is(.btn-primary, .btn-success, .btn-danger, .homeza-main-action, .workout-action--primary,
    .workout-start-btn, .wc-empty-btn.primary,
    .btn-workout-completed, .btn-continue-workout) {
    --action-edge: rgba(255,255,255,.34);
}

/* Educational video entries use the app's existing actions and modal. */
button.education-entry[hidden],
.education-viewer [hidden] {
    display: none;
}

.education-entry.workout-action {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-block: 4px 12px;
}

#profileEducationVideo {
    width: 100%;
    text-align: start;
    font: inherit;
    cursor: pointer;
}

.eq-education-entry {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    align-self: flex-start;
    margin-top: 8px;
}

.education-viewer {
    --education-video-inset: 10px;
    --education-video-height: min(66vh, 66dvh);
    background: rgba(28, 20, 17, .72);
    padding: 16px;
}

.education-viewer .video-modal {
    width: min(100%, calc(var(--education-video-height) * var(--education-video-ratio, 2) + 2 * var(--education-video-inset) + 2px));
    max-height: min(90vh, 90dvh);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: 0 12px 44px rgba(24, 16, 12, .26);
    container: education-video / inline-size;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.education-viewer .video-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    min-height: 50px;
    padding: 3px var(--education-video-inset);
    gap: 8px;
    background: var(--surface);
    color: var(--text-primary);
}

.education-viewer .video-header h3 {
    margin-inline-start: 2px;
    font-size: 1rem;
    line-height: 1.25;
    overflow-wrap: anywhere;
}

.education-viewer .video-header button {
    display: grid;
    place-items: center;
    margin: 0;
    color: var(--text-secondary);
    border: 0;
    background: transparent;
    max-inline-size: 100%;
    overflow-wrap: anywhere;
}

.education-viewer .video-header .education-viewer-skip {
    padding: 0 8px;
    font-size: .875rem;
    line-height: 1.25;
}

.education-viewer-skip .homeza-icon {
    display: none;
}

@container education-video (max-width: 245px) {
    .education-viewer .video-header h3 {
        margin-inline-start: 0;
        font-size: .875rem;
    }

    .education-viewer-skip {
        inline-size: 44px;
    }

    .education-viewer-skip > span {
        position: absolute;
        inline-size: 1px;
        block-size: 1px;
        overflow: hidden;
        clip-path: inset(50%);
        white-space: nowrap;
    }

    .education-viewer-skip .homeza-icon {
        display: block;
    }
}

.education-viewer .video-header button:is(:hover, :focus-visible) {
    background: var(--surface-secondary);
    color: var(--text-primary);
}

.education-viewer .video-header button:focus-visible {
    outline-offset: -2px;
}

.education-viewer .video-content {
    padding: var(--education-video-inset);
}

.education-viewer .close-video-btn {
    flex: 0 0 44px;
    display: grid;
    place-items: center;
}

.education-viewer-player {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: var(--education-video-height);
    margin-inline: auto;
    object-fit: contain;
    border-radius: 10px;
    background: var(--surface-secondary);
}

@media (orientation: landscape) and (max-height: 450px) {
    .education-viewer { --education-video-height: min(56vh, 56dvh); }
}

.education-viewer-list {
    padding: 0;
    margin: 12px 0 0;
    list-style: none;
    display: grid;
    gap: 6px;
}

.education-viewer-list button {
    width: 100%;
    justify-content: flex-start;
    text-align: start;
}

.education-viewer-list button[aria-current="true"] {
    color: var(--accent-ink, var(--primary));
    background: var(--primary-very-light);
}

.education-viewer-error p {
    margin: 0 0 10px;
    color: var(--text-secondary);
}
