/* Compatibility bridge for the legacy HeroUI-flavored class names.
   Visual primitives are provided by src/styles/*.css via onboarding.css. */

body.hero-body {
    min-height: 100vh;
    background: var(--background);
    color: var(--text-primary);
    overflow-x: hidden;
}

body.hero-body::before,
body.hero-body::after {
    display: none !important;
}

#shui-three-bg {
    position: fixed;
    inset: 0;
    z-index: 0;
    display: none !important;
    visibility: hidden !important;
    pointer-events: none;
}

#folder-picker {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

#boot-overlay {
    display: none;
}

body.boot-active #boot-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: grid;
    place-items: center;
    background: var(--background);
    color: var(--text-primary);
}

.boot-panel {
    display: grid;
    gap: var(--space-3);
    width: min(360px, calc(100vw - 32px));
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--elevation-2);
    padding: var(--space-6);
}

.boot-logo {
    color: var(--text-primary);
    font-size: var(--font-size-sm);
    font-weight: 800;
    letter-spacing: 0;
}

.boot-status,
.boot-progress__text {
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
}

.boot-progress {
    overflow: hidden;
    height: 4px;
    border-radius: var(--radius-pill);
    background: var(--surface-subtle);
}

.boot-progress__bar {
    display: block;
    width: 0;
    height: 100%;
    background: var(--accent);
    transition: width var(--motion-duration-slow) var(--motion-ease);
}

.hero-shell {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    gap: var(--space-5);
    box-sizing: border-box;
    width: 100%;
    max-width: var(--page-max-width);
    margin: 0 auto;
    padding: clamp(var(--space-4), 2.4vw, var(--space-7)) clamp(var(--space-4), 4vw, var(--space-8)) var(--space-10);
}

.app-topbar {
    position: sticky;
    top: var(--space-3);
    z-index: 30;
    display: grid;
    grid-template-columns: minmax(160px, 0.8fr) minmax(280px, 520px) minmax(160px, 0.8fr);
    align-items: center;
    gap: var(--space-3);
    min-height: 56px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--elevation-1);
    padding: var(--space-2);
}

.app-topbar__brand {
    display: inline-flex;
    align-items: baseline;
    gap: var(--space-2);
    min-width: 0;
    padding: 0 var(--space-3);
    color: var(--text-primary);
    white-space: nowrap;
}

.app-topbar__brand-name {
    overflow: hidden;
    font-size: 1rem;
    font-weight: 700;
    text-overflow: ellipsis;
}

.app-topbar__brand-meta {
    color: var(--accent);
    font-size: var(--font-size-xs);
    font-weight: 700;
    text-transform: uppercase;
}

.app-topbar__actions,
.hero-header {
    justify-self: end;
}

.app-topbar .remote-auth-account {
    max-width: 100%;
}

.app-topbar .remote-auth-account__trigger {
    max-width: 100%;
    min-height: var(--control-height);
    border-color: var(--border);
    background: var(--surface-subtle);
}

.app-topbar .remote-auth-account__name {
    max-width: 132px;
}

.site-footer {
    position: relative;
    z-index: 1;
    display: flex;
    justify-content: center;
    padding: 0 var(--space-4) var(--space-8);
}

.site-footer__github {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    min-height: var(--control-height);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--text-primary);
    box-shadow: var(--elevation-1);
    padding: 0 var(--space-3);
    text-decoration: none;
    font-size: var(--font-size-sm);
    font-weight: 700;
}

.site-footer__github:hover,
.site-footer__github:focus-visible {
    border-color: var(--border-strong);
    background: var(--surface-subtle);
}

.hero-header,
.app-topbar,
.hero-panel__header,
.browse-title-bar,
.practice-view__header {
    min-width: 0;
}

.hero-header__actions,
.hero-panel__actions,
.category-actions,
.exam-actions,
.fallback-actions,
.overview-workbench__actions,
.topbar-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
}

.hero-section,
.hero-panel,
.hero-surface,
.hero-card,
.category-card,
.exam-item,
.overview-shortcut,
.practice-trend-card__face,
.practice-custom-card__face,
.practice-trend-reserved-card,
.account-view__profile,
.account-view__stat,
.account-view__form {
    min-width: 0;
}

.hero-panel__title,
.category-title,
.exam-info h4,
.overview-shortcut strong {
    overflow-wrap: anywhere;
}

.hero-panel__muted,
.category-meta,
.exam-meta,
.exam-description,
.overview-shortcut p,
.overview-library-heading p {
    color: var(--text-secondary);
}

.hero-nav,
.shui-filter-group,
.shui-segmented-control {
    display: flex;
    align-items: center;
    gap: var(--space-1);
}

.hero-nav {
    justify-self: center;
    flex-wrap: nowrap;
    width: 100%;
    max-width: 520px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface-subtle);
    box-shadow: none;
    padding: var(--space-1);
}

.shui-filter-group,
.shui-segmented-control {
    flex-wrap: wrap;
}

.ui-button,
.hero-btn,
.hero-panel .btn,
.overview-workbench__action,
.exam-item-action-btn,
.exam-list-empty-action,
.shui-filter-btn,
.shui-segmented-btn,
.hero-nav__btn,
.theme-card-btn,
.lm-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    min-height: var(--control-height);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--text-primary);
    box-shadow: none;
    cursor: pointer;
    font: inherit;
    font-size: var(--font-size-sm);
    font-weight: 600;
    line-height: 1;
    padding: 0 var(--space-3);
    text-decoration: none;
    transition:
        background-color var(--motion-duration) var(--motion-ease),
        border-color var(--motion-duration) var(--motion-ease),
        color var(--motion-duration) var(--motion-ease),
        box-shadow var(--motion-duration) var(--motion-ease),
        transform var(--motion-duration-fast) var(--motion-ease);
}

.ui-button:hover:not(:disabled),
.hero-btn:hover:not(:disabled),
.hero-panel .btn:hover:not(:disabled),
.overview-workbench__action:hover:not(:disabled),
.exam-item-action-btn:hover:not(:disabled),
.exam-list-empty-action:hover:not(:disabled),
.shui-filter-btn:hover,
.shui-segmented-btn:hover,
.hero-nav__btn:hover,
.theme-card-btn:hover,
.lm-btn:hover {
    border-color: var(--border-strong);
    background: var(--surface-subtle);
    color: var(--text-primary);
    box-shadow: var(--elevation-1);
    transform: none;
}

.ui-button:active,
.hero-btn:active,
.hero-panel .btn:active,
.overview-workbench__action:active,
.exam-item-action-btn:active,
.exam-list-empty-action:active,
.shui-filter-btn:active,
.shui-segmented-btn:active,
.hero-nav__btn:active,
.theme-card-btn:active,
.lm-btn:active {
    background: color-mix(in srgb, var(--surface-subtle) 78%, var(--border));
    transform: translateY(1px);
}

.ui-button:focus-visible,
.hero-body button:focus-visible,
.hero-body a:focus-visible,
.hero-body input:focus-visible,
.hero-body select:focus-visible,
.hero-body textarea:focus-visible {
    outline: var(--focus-outline);
    outline-offset: 2px;
    box-shadow: var(--focus-ring);
}

.ui-button:disabled,
.ui-button[aria-disabled="true"],
.hero-body button:disabled,
.hero-body button[aria-disabled="true"] {
    cursor: not-allowed;
    opacity: 0.55;
    transform: none;
    box-shadow: none;
}

.ui-button.is-loading,
.ui-button[aria-busy="true"],
.hero-body button.is-loading,
.hero-body button[aria-busy="true"] {
    cursor: progress;
    opacity: 0.82;
}

.ui-button--primary,
.overview-workbench__action--primary,
.hero-panel .btn-primary,
.category-card .btn:not(.btn-secondary),
.exam-item-action-btn:not(.btn-secondary) {
    border-color: var(--accent);
    background: var(--accent);
    color: var(--surface);
}

.ui-button--primary:hover:not(:disabled),
.overview-workbench__action--primary:hover:not(:disabled),
.hero-panel .btn-primary:hover:not(:disabled),
.category-card .btn:not(.btn-secondary):hover:not(:disabled),
.exam-item-action-btn:not(.btn-secondary):hover:not(:disabled) {
    border-color: var(--accent-strong);
    background: var(--accent-strong);
    color: var(--surface);
}

.hero-panel .btn-secondary,
.exam-item-action-btn.btn-secondary {
    border-color: var(--border);
    background: var(--surface);
    color: var(--text-primary);
}

.hero-panel .btn-warning,
.hero-btn--warn {
    border-color: color-mix(in srgb, var(--warning) 42%, var(--border));
    background: var(--warning-subtle);
    color: var(--warning-strong);
}

.hero-panel .btn-info {
    border-color: var(--accent);
    background: var(--accent);
    color: var(--surface);
}

.hero-panel .btn-success {
    border-color: var(--success);
    background: var(--success);
    color: var(--surface);
}

.hero-nav__btn,
.shui-filter-btn,
.shui-segmented-btn {
    flex: 0 1 auto;
    min-width: 0;
}

.hero-nav__btn {
    flex: 1 1 0;
    min-height: var(--control-height);
    border-color: transparent;
    background: transparent;
    color: var(--text-secondary);
    white-space: nowrap;
}

.hero-nav__btn.active,
.hero-nav__btn[aria-current="page"],
.shui-filter-btn.active,
.shui-filter-btn[aria-pressed="true"],
.shui-segmented-btn.active,
.shui-segmented-btn[aria-pressed="true"] {
    border-color: var(--border);
    background: var(--surface);
    color: var(--accent);
    box-shadow: var(--elevation-1);
    text-shadow: none;
}

.shui-segmented-indicator,
.hero-nav__liquid-indicator {
    display: none;
}

.overview-workbench,
.category-grid,
.exam-list,
.practice-stats,
.practice-history-list,
.account-view__stats,
.account-view__forms {
    display: grid;
    gap: var(--space-4);
}

.hero-panel,
.hero-surface,
.hero-card,
.ui-card,
.category-card,
.exam-item,
.overview-shortcut,
.practice-trend-card__face,
.practice-custom-card__face,
.practice-trend-reserved-card,
.account-view__profile,
.account-view__stat,
.account-view__form {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    background-image: none;
    box-shadow: var(--elevation-1);
}

.hero-panel {
    display: grid;
    gap: var(--space-5);
    padding: clamp(var(--space-5), 3vw, var(--space-7));
}

.view.hero-panel {
    display: none;
}

.view.hero-panel.active {
    display: grid;
}

.hero-panel__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-4);
    margin: 0;
}

.hero-panel__title {
    margin: 0;
    color: var(--text-primary);
    font-size: clamp(1.35rem, 2.2vw, 1.75rem);
    font-weight: 700;
    line-height: var(--line-height-tight);
}

.hero-panel__muted {
    font-size: var(--font-size-sm);
    line-height: var(--line-height-normal);
}

.hero-panel__eyebrow,
.overview-workbench__kicker,
.overview-shortcut span {
    color: var(--accent);
}

.hero-surface,
.hero-card,
.ui-card,
.overview-shortcut,
.category-card,
.exam-item {
    padding: var(--space-4);
}

.overview-workbench__primary {
    border-left: 4px solid var(--accent);
}

.overview-workbench {
    grid-template-columns: minmax(0, 1.45fr) minmax(260px, 0.7fr);
}

.overview-workbench__side,
.account-view__stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-3);
}

.overview-shortcut,
.category-card,
.exam-item {
    display: grid;
    gap: var(--space-3);
}

.category-grid {
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.category-header {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
}

.category-icon,
.exam-list-empty-icon,
.practice-history-empty-icon,
.overview-section-icon {
    display: none;
}

.exam-list {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    align-content: start;
    overflow-y: auto;
}

.exam-item {
    align-content: space-between;
}

.exam-actions,
.category-actions {
    justify-content: flex-start;
}

.search-container,
.search-wrapper {
    min-width: 0;
}

.search-container {
    display: grid;
    gap: var(--space-2);
}

.search-clear-btn,
.modal-close,
.modal-close-btn,
.clock-action-btn,
.practice-custom-card__icon-btn {
    width: var(--control-height);
    min-width: var(--control-height);
    height: var(--control-height);
    padding: 0;
}

.message-container,
.modal-overlay,
.clock-modal {
    isolation: isolate;
}

.message::before,
.message::after,
.hero-card::before,
.hero-card::after,
.category-card::before,
.category-card::after,
.exam-item::before,
.exam-item::after,
.practice-trend-card__face::before,
.practice-trend-card__face::after {
    display: none;
}

#settings-view .settings-layout {
    display: grid;
    grid-template-columns: minmax(180px, 220px) minmax(0, 1fr);
    gap: var(--space-5);
    align-items: start;
}

#settings-view .settings-sidebar,
#settings-view .settings-content,
#settings-view .settings-section-card,
#settings-view .settings-action-grid,
#settings-view .hero-settings-actions,
#settings-view .settings-session-list {
    min-width: 0;
}

#settings-view .settings-action-grid,
#settings-view .hero-settings-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: var(--space-2);
}

#settings-view .settings-action-grid .btn,
#settings-view .hero-settings-actions .btn {
    width: 100%;
}

#settings-view .settings-session-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: var(--space-2);
    align-items: center;
}

#settings-view .settings-session-card__meta,
#settings-view .settings-session-card__badges {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}

#settings-view .settings-session-card__badge {
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    background: var(--surface-subtle);
    color: var(--text-secondary);
    font-size: var(--font-size-xs);
    font-weight: 700;
    padding: var(--space-1) var(--space-2);
}

#settings-view .settings-session-card__badge.is-current {
    border-color: color-mix(in srgb, var(--success) 28%, var(--border));
    background: var(--success-subtle);
    color: var(--success);
}

#settings-view .settings-session-manager__status[data-kind="error"],
.reading-candidate-code-status[data-kind="error"],
.practice-timer-status[data-kind="error"] {
    color: var(--danger);
}

#settings-view .settings-session-manager__status[data-kind="success"],
.reading-candidate-code-status[data-kind="success"],
.practice-timer-status[data-kind="success"] {
    color: var(--success);
}

.theme-options-viewport > div,
.theme-card > div {
    min-width: 0;
}

.theme-card,
.theme-option,
.tool-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    color: var(--text-primary);
    box-shadow: var(--elevation-1);
}

.theme-card-btn,
.lm-btn,
.clock-action-btn {
    border-radius: var(--radius-md);
}

@media (max-width: 980px) {
    .app-topbar {
        position: static;
        grid-template-columns: minmax(0, 1fr);
    }

    .app-topbar__brand,
    .app-topbar__actions,
    .hero-header,
    .hero-nav {
        justify-self: stretch;
    }

    .hero-nav {
        max-width: none;
    }

    .hero-header__actions {
        justify-content: flex-start;
    }

    #settings-view .settings-layout,
    .overview-workbench,
    .account-view__forms {
        grid-template-columns: minmax(0, 1fr);
    }

    #settings-view .settings-sidebar {
        position: static;
        display: flex;
        overflow-x: auto;
    }
}

@media (max-width: 640px) {
    .hero-shell {
        padding: var(--space-3) var(--space-3) var(--space-8);
    }

    .app-topbar {
        gap: var(--space-2);
        padding: var(--space-2);
    }

    .hero-nav {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        width: 100%;
    }

    .hero-nav__btn {
        width: 100%;
    }

    .app-topbar .remote-auth-account__trigger {
        width: 100%;
    }

    .hero-header__actions,
    .hero-panel__actions,
    .category-actions,
    .exam-actions,
    .fallback-actions,
    .overview-workbench__actions {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
    }

    .overview-workbench__side,
    .account-view__stats,
    #settings-view .settings-session-card {
        grid-template-columns: minmax(0, 1fr);
    }
}
