/* =========================
   Base
   ========================= */

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    max-width: 1200px;
    margin: 0 auto;
    padding: 30px 20px;

    font-family: Arial, sans-serif;
    line-height: 1.5;

    color: #222;
    background-color: #f7f7f7;
}

h1 {
    margin-top: 0;
}

.page-title {
    margin: 0 0 20px;
    text-align: center;
}

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

/* =========================
   Header
   ========================= */


.logo {
    display: block;
    width: 300px;
    max-width: 100%;
    height: auto;
    margin: 0 auto;
}

header {
    margin-bottom: 10px;
    padding: 0;
    text-align: center;
}

a:focus-visible {
    outline: 2px solid #228b22;
    outline-offset: 4px;
}

.label {
    font-weight: bold;
}


/* =========================
   Common cards
   ========================= */

.card,
.course,
.form-card {
    border: 1px solid #ddd;
    border-radius: 12px;
    background-color: white;
}


/* =========================
   Common buttons
   ========================= */

.button,
.course-button,
.submit-button,
.filter-button,
.suggestion-button,
.home-button,
.reset-filter {
    border-radius: 8px;
    font: inherit;
    transition: background-color 0.2s,
    color 0.2s,
    transform 0.2s;
}

.button,
.course-button,
.submit-button,
.filter-button {
    color: white;
    background-color: #228b22;
}

.button:hover,
.course-button:hover,
.submit-button:hover,
.filter-button:hover {
    background-color: #1b6d1b;
    transform: translateY(-1px);
}


/* =========================
   Courses list
   ========================= */

.course-filter {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;

    width: 100%;
    max-width: 760px;
    margin: 0 auto 25px;
}

.filter-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;

    flex-wrap: wrap;
}

.filter-row:first-child input {
    width: 250px;
}

.search-field {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.search-input-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.filter-help {
    margin-top: 5px;
    margin-left: 210px;

    font-size: 13px;
    color: #777;
}

.filter-field {
    display: flex;
    align-items: center;
    gap: 6px;
}

.price-filter-label {
    font-weight: bold;
}

.course-filter input {
    width: 110px;
    padding: 8px 10px;

    border: 1px solid #ccc;
    border-radius: 8px;

    font-size: 16px;
}

.course-filter select {
    height: 42px;
    padding: 0 10px;

    border: 1px solid #ccc;
    border-radius: 8px;

    font-size: 16px;
    background-color: white;
}

.course-filter input:focus,
.course-filter select:focus {
    outline: 2px solid #228b22;
    outline-offset: 1px;
}

.filter-button,
.reset-filter {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    height: 42px;
    padding: 0 18px;

    font-size: 15px;
}

.filter-button {
    border: 1px solid #228b22;
    cursor: pointer;
}

.reset-filter {
    border: 1px solid #999;

    color: #555;
    background-color: white;
}

.reset-filter:hover {
    background-color: #eee;
    transform: translateY(-1px);
}

.ordering-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;

    margin-top: 20px;
}

.ordering-row select {
    padding: 8px 10px;

    border: 1px solid #ccc;
    border-radius: 8px;

    font-size: 16px;
}

.suggestion-link {
    margin-bottom: 30px;
    text-align: center;
}

.suggestion-button {
    display: inline-block;

    padding: 10px 18px;

    border: 2px solid #228b22;

    color: #228b22;
    font-weight: bold;

    background-color: white;
}

.suggestion-button:hover {
    color: white;
    background-color: #228b22;
    transform: translateY(-1px);
}

.courses-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.course {
    display: flex;
    flex-direction: column;
    padding: 18px;
}

.course-header {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.course-image-link {
    display: block;
    width: 100%;
    flex-shrink: 0;
    border-radius: 10px;
}

.course-image {
    display: block;

    object-fit: contain;

    border-radius: 10px;
    background-color: #f7f7f7;

    transition: transform 0.25s ease,
    box-shadow 0.25s ease;
}

.course-header .course-image {
    width: 100%;
    height: 190px;
    object-fit: contain;
}

.course-image:hover,
.course-image-link:hover .course-image {
    transform: translateY(-5px);
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.15);
}

.course-info {
    flex-grow: 1;
    min-width: 0;
}

.course-title {
    margin-top: 0;
    margin-bottom: 15px;
}

.course-title a:hover,
.author-name:hover {
    text-decoration: underline;
}

.description {
    display: -webkit-box;
    margin-top: 16px;

    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
}

.price {
    margin-top: auto;
    margin-bottom: 0;
    padding-top: 14px;
    font-size: 17px;
}

.course-button {
    display: inline-block;
    align-self: flex-start;
    margin-top: 15px;
    padding: 10px 18px;
}


/* =========================
   Categories
   ========================= */

.tags {
    margin: 15px 0;
}

.tag {
    display: inline-block;

    margin: 3px 5px 3px 0;
    padding: 4px 10px;

    border-radius: 15px;

    background-color: #e3f2fd;
}


/* =========================
   Authors
   ========================= */

.authors-label {
    margin-top: 18px;
    margin-bottom: 8px;
}

.authors {
    display: flex;
    flex-wrap: wrap;
    gap: 15px 25px;
}

.author {
    display: flex;
    align-items: center;
    gap: 10px;
}

.author-avatar-link {
    display: block;
    flex-shrink: 0;

    border-radius: 50%;
}

.author-avatar,
.author-initials {
    width: 48px;
    height: 48px;

    border-radius: 50%;

    transition: transform 0.25s ease,
    box-shadow 0.25s ease;
}

.author-avatar {
    display: block;
    object-fit: cover;
}

.author-avatar-placeholder,
.author-initials {
    display: flex;
    align-items: center;
    justify-content: center;

    color: white;

    font-size: 20px;
    font-weight: bold;
    letter-spacing: 1px;

    background-color: #d84d4d;
}

.author-avatar-link:hover .author-avatar,
.author-avatar-link:hover .author-initials,
.author-avatar-link:hover .author-avatar-placeholder {
    transform: translateY(-4px);
    box-shadow: 0 7px 15px rgba(0, 0, 0, 0.18);
}

.author-name {
    font-weight: bold;
}


/* =========================
   Course detail
   ========================= */

.card {
    max-width: 900px;
    margin: 0 auto;
    padding: 30px;
}

.card h1 {
    margin: 0 0 25px;
    line-height: 1.25;
}

.card > .course-image {
    width: 300px;
    max-width: 100%;
    margin: 0 auto 30px;
}

.card .price {
    margin-top: 25px;
    font-size: 22px;
}

.home-navigation {
    margin-bottom: 25px;
}

.buttons {
    margin-top: 35px;
}

.button,
.home-button {
    display: inline-block;
    padding: 10px 18px;
}

.home-button {
    color: white;
    background-color: #666;
}

.home-button:hover {
    background-color: #555;
    transform: translateY(-1px);
}


/* =========================
   Course suggestion form
   ========================= */

.intro {
    margin: 0 0 30px;

    color: #555;
    text-align: center;
}

.form-card {
    max-width: 760px;
    margin: 0 auto;
    padding: 30px;
}

.success-message {
    margin-bottom: 25px;
    padding: 14px 18px;

    border: 1px solid #228b22;
    border-radius: 8px;

    color: #1b6d1b;
    background-color: #edf8ed;
}

.form-section {
    margin-bottom: 30px;
}

.form-section:last-of-type {
    margin-bottom: 20px;
}

.form-section-title {
    margin: 0 0 6px;
    font-size: 20px;
}

.form-section-description {
    margin: 0 0 20px;

    color: #666;
    font-size: 14px;
}

.form-field {
    margin-bottom: 20px;
}

.form-field:last-child {
    margin-bottom: 0;
}

.form-card label {
    display: block;

    margin-bottom: 7px;

    font-weight: bold;
}

.form-card input[type="text"],
.form-card input[type="email"],
.form-card input[type="url"],
.form-card textarea {
    display: block;

    width: 100%;
    padding: 11px 12px;

    border: 1px solid #bbb;
    border-radius: 7px;

    color: #222;
    background-color: white;

    font: inherit;
}

.form-card textarea {
    resize: vertical;
}

.form-card input[type="text"]:focus,
.form-card input[type="email"]:focus,
.form-card input[type="url"]:focus,
.form-card textarea:focus {
    outline: none;

    border-color: #228b22;
    box-shadow: 0 0 0 2px rgba(34, 139, 34, 0.12);
}

.required-mark {
    color: #c62828;
}

.optional {
    margin-left: 5px;

    color: #777;

    font-size: 13px;
    font-weight: normal;
}

.checkbox-field {
    margin-top: 20px;
}

.form-card .checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 10px;

    margin: 0;

    font-weight: normal;
    cursor: pointer;
}

.checkbox-label input {
    flex-shrink: 0;
    margin-top: 4px;
}

.error-list {
    margin: 7px 0 0;
    padding: 0;

    color: #c62828;

    font-size: 14px;
    list-style: none;
}

.submit-button {
    display: block;

    margin: 30px auto 0;
    padding: 11px 24px;

    border: none;

    font-weight: bold;

    cursor: pointer;
}

/* =========================
   Footer
   ========================= */

.site-footer {
    margin-top: 60px;
    padding: 30px 20px;

    text-align: center;
    color: #777;

    border-top: 1px solid #ddd;
}

.site-footer p {
    margin: 5px 0;
}

/* =========================
   Responsive
   ========================= */

@media (max-width: 800px) {
    .courses-grid {
        grid-template-columns: 1fr;
    }

    body {
        padding: 20px 12px;
    }

    .course {
        padding: 20px;
    }

    .course-image-link {
        width: 100%;
    }

    .course-header .course-image {
        width: 100%;
        height: auto;
        max-width: 350px;
        aspect-ratio: 1 / 1;

        margin: 0 auto;
    }

    .authors {
        flex-direction: column;
    }

    .filter-help {
        margin-left: 0;
    }

    .ordering-row {
        flex-wrap: wrap;
    }
}

@media (max-width: 600px) {
    .card,
    .form-card {
        padding: 20px;
    }

    .button,
    .submit-button {
        width: 100%;
        text-align: center;
    }

    .course-filter {
        width: 100%;
    }

    .filter-row,
    .search-input-row,
    .ordering-row {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
    }


    .filter-field,
    .search-field {
        width: 100%;
    }

    .filter-field {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }

    .search-field input,
    .ordering-row select {
        width: 100%;
        max-width: 100%;
    }

    .filter-field input {
        width: 140px;
        max-width: 100%;
    }

    .course-filter select {
        max-width: 100%;
    }

    .filter-help {
        margin-left: 0;
        text-align: left;
    }

    .price-filter-label {
        align-self: flex-start;
    }

    .filter-button,
    .reset-filter {
        align-self: center;
    }
}