:root {
    color-scheme: light;
    --page: #f6f7f9;
    --surface: #ffffff;
    --surface-muted: #fafafa;
    --text: #1f2328;
    --muted: #6b7280;
    --muted-strong: #4b5563;
    --border: #e1e5ea;
    --border-strong: #cfd6df;
    --accent: #2f3a4a;
    --accent-hover: #1f2937;
    --accent-soft: #eef2f6;
    --success: #2f6f56;
    --success-soft: #eaf6f0;
    --shadow: 0 18px 50px rgba(31, 35, 40, 0.08);
    --shadow-soft: 0 10px 30px rgba(31, 35, 40, 0.05);
    --radius-lg: 22px;
    --radius-md: 16px;
    --radius-sm: 10px;
}

* {
    box-sizing: border-box;
}

html {
    min-width: 320px;
    min-height: 100%;
    background: var(--page);
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--text);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(246, 247, 249, 0) 280px),
        var(--page);
    font-family: Inter, "Segoe UI", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

button,
a {
    font: inherit;
}

button {
    border: 0;
}

a {
    color: inherit;
    text-decoration: none;
}

.courses-page {
    width: min(100% - 48px, 1120px);
    margin: 0 auto;
    padding: 40px 0 76px;
}

.courses-header {
    display: grid;
    gap: 22px;
    margin-bottom: 32px;
}

.courses-back {
    display: inline-flex;
    align-items: center;
    justify-self: start;
    gap: 8px;
    color: var(--muted-strong);
    font-size: 14px;
    font-weight: 650;
    transition: color 180ms ease, transform 180ms ease;
}

.courses-back:hover {
    color: var(--text);
    transform: translateX(-2px);
}

.courses-header h1 {
    margin: 0 0 8px;
    font-size: clamp(26px, 3vw, 34px);
    font-weight: 760;
    line-height: 1.16;
}

.courses-header p {
    max-width: 620px;
    margin: 0;
    color: var(--muted);
    font-size: 15px;
    line-height: 1.6;
}

.courses-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.courses-card {
    display: grid;
    gap: 18px;
    align-content: space-between;
    min-height: 248px;
    padding: 22px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    box-shadow: var(--shadow-soft);
    transition: border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.courses-card:hover,
.courses-card:focus-within {
    border-color: var(--border-strong);
    box-shadow: var(--shadow);
    transform: translateY(-3px);
}

.courses-card--enrolled {
    border-color: #cfe1d9;
}

.courses-card__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.courses-card h2 {
    margin: 0;
    font-size: 19px;
    font-weight: 750;
    line-height: 1.28;
}

.courses-card__badge {
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
    min-height: 26px;
    padding: 0 9px;
    border-radius: 999px;
    color: var(--success);
    background: var(--success-soft);
    font-size: 12px;
    font-weight: 750;
    white-space: nowrap;
}

.courses-card__description,
.courses-card__meta {
    margin: 0;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.65;
}

.courses-card__meta {
    color: var(--muted-strong);
    font-size: 13px;
    font-weight: 720;
}

.courses-card__link,
.courses-state button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    justify-self: start;
    min-height: 40px;
    padding: 0 15px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    background: #ffffff;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: border-color 180ms ease, background-color 180ms ease, transform 180ms ease;
}

.courses-card__link:hover,
.courses-state button:hover {
    border-color: var(--border-strong);
    background: var(--accent-soft);
    transform: translateY(-1px);
}

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

.courses-card__link--primary:hover {
    border-color: var(--accent-hover);
    background: var(--accent-hover);
}

.courses-state {
    padding: 24px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--muted-strong);
    background: var(--surface);
    box-shadow: var(--shadow-soft);
    font-size: 15px;
    line-height: 1.55;
}

.courses-state--error {
    display: grid;
    gap: 14px;
    justify-items: start;
    border-color: #e3b8b8;
    color: #7a2f2f;
    background: #fffafa;
}

.courses-state--error p {
    margin: 0;
}

.courses-state--empty {
    text-align: center;
}

[hidden] {
    display: none !important;
}

.courses-back:focus-visible,
.courses-card__link:focus-visible,
.courses-state button:focus-visible {
    outline: 3px solid rgba(47, 58, 74, 0.18);
    outline-offset: 3px;
}

@media (max-width: 900px) {
    .courses-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 720px) {
    .courses-page {
        width: min(100% - 32px, 1120px);
        padding-top: 32px;
    }

    .courses-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 460px) {
    .courses-page {
        width: min(100% - 24px, 1120px);
    }

    .courses-card {
        padding: 20px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }
}
