/**
 * PathwayAI UI polish — shared public, student, admin surfaces.
 * Loaded once per request via pathway_print_ui_polish_css().
 */

:root {
    --ui-radius: 12px;
    --ui-radius-sm: 8px;
    --ui-focus: 0 0 0 3px rgba(99, 102, 241, 0.35);
    --ui-shadow: 0 8px 28px rgba(15, 21, 48, 0.08);
    --ui-shadow-hover: 0 12px 36px rgba(15, 21, 48, 0.12);
}

/* Forms — touch-friendly, clear focus */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="search"],
input[type="url"],
select,
textarea {
    min-height: 44px;
    border-radius: var(--ui-radius-sm);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    box-shadow: var(--ui-focus);
    border-color: #6366f1;
}

textarea {
    min-height: 96px;
    line-height: 1.55;
}

label {
    font-weight: 600;
    margin-bottom: 6px;
    display: block;
}

.form-card label + input,
.form-card label + select,
.form-card label + textarea {
    margin-bottom: 14px;
}

/* Buttons */
.btn {
    min-height: 44px;
    border-radius: var(--ui-radius-sm);
    transition: transform 0.12s ease, box-shadow 0.15s ease, background 0.15s ease;
    font-weight: 600;
}

.btn:active:not(:disabled) {
    transform: translateY(1px);
}

.btn-primary {
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.25);
}

.btn-primary:hover:not(:disabled) {
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.35);
}

/* Cards */
.card {
    border-radius: var(--ui-radius);
    box-shadow: var(--ui-shadow);
    transition: box-shadow 0.2s ease;
}

.card:hover {
    box-shadow: var(--ui-shadow-hover);
}

/* Alerts */
.alert {
    border-radius: var(--ui-radius-sm);
    padding: 12px 14px;
    line-height: 1.5;
}

/* Hero & public sections */
.hero {
    padding-top: 48px;
    padding-bottom: 48px;
}

.subtitle,
.small-muted {
    line-height: 1.6;
}

.cta-row {
    gap: 12px;
    flex-wrap: wrap;
}

/* Onboarding choices */
.onboarding-choice {
    border-radius: var(--ui-radius);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.onboarding-choice:hover {
    box-shadow: var(--ui-shadow);
}

/* Navbar readability */
.navbar a,
.nav-links a {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
}

/* Admin shell */
.admin-sidebar a,
.admin-topbar .btn {
    min-height: 40px;
}

/* Mobile tab bar */
.mobile-tabbar a {
    min-height: 48px;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .btn,
    .card,
    input,
    select,
    textarea {
        transition: none;
    }
}

.turnstile-wrap {
    margin: 16px 0;
    min-height: 65px;
}

@media (max-width: 640px) {
    .container {
        padding-left: 16px;
        padding-right: 16px;
    }

    .hero h1 {
        font-size: clamp(1.5rem, 6vw, 2rem);
        line-height: 1.2;
    }
}

/* Keyboard focus — visible ring without mouse click ring */
:focus-visible {
    outline: none;
    box-shadow: var(--ui-focus);
}

.btn:focus:not(:focus-visible) {
    box-shadow: none;
}

/* Disabled controls */
.btn:disabled,
input:disabled,
select:disabled,
textarea:disabled {
    opacity: 0.62;
    cursor: not-allowed;
    transform: none !important;
}

/* Tables — readable hierarchy */
.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    border-collapse: collapse;
}

table th {
    font-weight: 700;
    text-align: left;
}

table tbody tr:nth-child(even) {
    background: rgba(99, 102, 241, 0.04);
}

body.dark table tbody tr:nth-child(even) {
    background: rgba(148, 163, 184, 0.06);
}

/* Modals / overlays */
.modal-backdrop,
.lw-gate-overlay {
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

/* Skeleton loading utility */
.ui-skeleton {
    background: linear-gradient(90deg, rgba(148, 163, 184, 0.12) 25%, rgba(148, 163, 184, 0.22) 50%, rgba(148, 163, 184, 0.12) 75%);
    background-size: 200% 100%;
    animation: ui-skeleton-shimmer 1.2s ease-in-out infinite;
    border-radius: var(--ui-radius-sm);
    min-height: 1em;
}

/* Dashboard boot skeleton — overlay only (never hide real content) */
.dash-boot-skeleton {
    position: fixed;
    inset: 0;
    z-index: 120;
    overflow-y: auto;
    padding: calc(var(--topbar-h, 56px) + 12px) var(--rail-x, 16px) 24px;
    max-width: none;
    margin: 0;
    background: #070b14;
    pointer-events: none;
}

html.dash-ready .dash-boot-skeleton,
.dash-boot-skeleton[hidden] {
    display: none !important;
}

.dash-boot-skeleton__hero {
    min-height: 140px;
    margin-bottom: 16px;
    border-radius: var(--radius-lg, 12px);
}

.dash-boot-skeleton__grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.dash-boot-skeleton__grid .ui-skeleton {
    min-height: 96px;
    border-radius: var(--radius-md, 10px);
}

.dash-boot-skeleton__mission {
    min-height: 180px;
    border-radius: var(--radius-lg, 12px);
}

@media (min-width: 768px) {
    .dash-boot-skeleton__grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@keyframes ui-skeleton-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Smooth scrolling — respect reduced motion */
html {
    scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    .ui-skeleton {
        animation: none;
        background: rgba(148, 163, 184, 0.16);
    }
}

/* Empty states */
.empty-state {
    padding: 28px 20px;
    text-align: center;
    line-height: 1.6;
    border-radius: var(--ui-radius);
}

/* Progress bars */
progress,
.progress-bar {
    border-radius: 999px;
    overflow: hidden;
}

/* Tooltips via title — ensure readable */
[title] {
    cursor: help;
}
