/* ---------------------------------------------------------------------------
   Utility classes for one-off layout tweaks formerly written as
   inline `style="..."` attributes. Keep these small, predictable, and named.
--------------------------------------------------------------------------- */

/* --- Tailwind-CDN replacements (used by auth & app forms) ----------------- */

.text-sm {
    font-size: 0.875rem;
    line-height: 1.25rem;
}

.h-10 {
    height: 2.5rem;
}

.h-15 {
    height: 60px;
}

.w-full {
    width: 100%;
}

.h-full {
    height: 100%;
}

.flex {
    display: flex;
}

.flex-col {
    flex-direction: column;
}

.justify-end {
    justify-content: flex-end;
}

.justify-between {
    justify-content: space-between;
}

.gap-2 {
    gap: 0.5rem;
}

.pt-5 {
    padding-top: 1.25rem;
}

/* --- Brand & icons -------------------------------------------------------- */

.brand-icon {
    width: 40px;
    height: 40px;
}

.brand-title {
    font-size: 24px;
    font-weight: bold;
    margin: 0;
}

.brand-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding-bottom: 25px;
}

.error-text {
    color: red;
}

/* --- Public landing page -------------------------------------------------- */

.about-wrapper {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: center;
    max-width: 100%;
    margin: 0 auto;
}

.about-text {
    text-align: justify;
    line-height: 1.6;
}

.about-banner-desktop,
.about-banner-mobile {
    border-radius: 12px;
}

.about-banner-desktop {
    width: 1170px;
    max-width: 100%;
    display: block;
}

.about-banner-mobile {
    width: 400px;
    max-width: 100%;
    display: none;
}

@media (max-width: 768px) {
    .about-banner-desktop {
        display: none;
    }
    .about-banner-mobile {
        display: block;
    }
}

/* --- Teachers & cards used on public landing/teacher list ----------------- */

.teacher-card-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 40px;
    padding: 20px 20px 20px 50px;
    border-radius: 12px;
    margin: 20px auto;
    box-sizing: border-box;
}

.teacher-card-link {
    all: unset;
    flex-shrink: 0;
}

.teacher-card-avatar {
    border-radius: 50%;
    width: 150px;
    height: 150px;
    object-fit: cover;
    display: block;
}

.teacher-card-info {
    flex: 1;
    min-width: 250px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.teacher-card-name {
    margin: 0;
    font-size: 1.4rem;
    color: #333;
}

.teacher-card-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    font-size: 0.95rem;
    color: #555;
}

.teacher-card-langs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.lang-badge {
    background: green;
    color: #fff;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.8rem;
}

/* --- Article cards on public + management pages --------------------------- */

.unstyled-link {
    all: unset;
    cursor: pointer;
}

.article-card-title {
    min-height: 50px;
}

.article-card-title-tall {
    min-height: 75px;
}

.article-card-summary {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

.article-card-summary-tall {
    min-height: 150px;
}

.article-meta-padded {
    padding-top: 50px;
}

.article-meta-floating {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    margin-bottom: 10px;
    padding: 12px 1rem 0;
    border-top: 1px solid var(--border, rgba(0, 0, 0, 0.08));
}

.article-tags {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.article-tags-row {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border, rgba(0, 0, 0, 0.08));
}

.tag-icon {
    font-size: 1rem;
}

.tag-item {
    background: var(--text-secondary);
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.85rem;
    color: white;
    display: flex;
    align-items: center;
    gap: 6px;
}

.level-badge {
    background: green;
    color: #ffffff;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 0.8rem;
    display: inline-block;
}

/* --- Article landing list grid ------------------------------------------- */

.articles-grid-flex {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.articles-grid-tight {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.articles-grid-small {
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
}

.ebooks-grid-flex {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.ebooks-grid-fixed-4 {
    grid-template-columns: repeat(4, 1fr);
}

.no-results {
    display: none;
    grid-column: 1 / -1;
    text-align: center;
    font-size: 1.2rem;
    color: #555;
}

/* --- Article detail page ------------------------------------------------- */

.teacher-header-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    padding-left: 2rem;
    height: 250px;
    padding-top: 40px;
    border-radius: 15px;
    background-image: var(--hero-bg);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    box-shadow: 0 5px 20px var(--shadow);
    margin-bottom: 1rem;
}

.author-photo {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    background-image: var(--author-bg);
    background-size: cover;
    background-position: center;
    box-shadow: 0 5px 20px var(--shadow);
    border: 4px solid white;
}

.article-detail-content {
    border-radius: 15px;
    padding: 2rem;
    box-shadow: 0 5px 20px var(--shadow);
    margin-bottom: 2rem;
}

.article-detail-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.article-detail-icon {
    font-size: 1.5rem;
}

.article-detail-title {
    margin: 0;
}

.read-time-badge {
    display: inline-block;
    padding: 4px 8px;
    font-size: 12px;
    font-weight: 500;
    color: #fff;
    background-color: green;
    border-radius: 12px;
    margin-right: 6px;
}

.date-badge {
    display: inline-block;
    padding: 4px 8px;
    font-size: 12px;
    font-weight: 500;
    color: #fff;
    background-color: #213337;
    border-radius: 12px;
    margin-right: 6px;
}

/* --- Index / popular articles ------------------------------------------- */

.summary-tall {
    min-height: 290px;
    text-align: justify;
}

.book-card-tall {
    min-height: 500px;
    position: relative;
}

/* --- Teacher detail page ------------------------------------------------ */

.icon-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.icon-row h1 {
    margin: 0;
}

.intro-video {
    border-radius: 5px;
}

.review-progress-fill {
    height: 100%;
    width: var(--fill-percent, 0%);
    background: var(--primary, #204d48);
    border-radius: inherit;
}

.reviews-padding {
    padding-top: 80px;
}

/* --- Teachers (search) page --------------------------------------------- */

.teacher-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    border: 1px solid #ddd;
    padding: 1rem;
    border-radius: 10px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.teacher-card-header {
    display: flex;
    gap: 1rem;
}

.teacher-card-avatar-sm {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
}

.teacher-card-basic {
    flex: 1;
}

.teacher-card-summary-box {
    min-height: 75px;
}

.teacher-card-bio {
    text-align: justify;
    margin: 1rem 0;
    flex-grow: 1;
}

.teacher-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.teacher-card-footer.spaced {
    margin-top: auto;
}

.teacher-card-footer.tight {
    margin-top: 0.5rem;
}

.teacher-card-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-contact {
    border: none;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
}

.search-input-padded {
    padding: 6px;
}

/* --- Books / management cards ------------------------------------------- */

.add-card {
    background-color: var(--dark-gray);
}

.add-card-tall {
    height: 700px;
    background-color: var(--dark-gray);
}

.add-card-medium {
    height: 500px;
    min-height: 500px;
}

.add-card-title {
    color: whitesmoke;
    font-size: 25pt;
    font-style: oblique;
}

.book-card-flex {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 500px;
}

.book-card-content {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.book-card-meta {
    margin-top: auto;
}

/* --- Article create / edit ---------------------------------------------- */

.editor-page-section {
    background-color: white;
    border-radius: 12px;
    padding: 5px;
    margin-bottom: 10px;
}

.editor-page-section.no-mb {
    margin-bottom: 0;
}

.editor-page-container {
    padding: 5px;
    margin: 5px;
    max-width: 100%;
}

.editor-banner-wrapper {
    margin: 0 0 10px 0;
    padding: 0;
}

.editor-banner-image {
    cursor: pointer;
    width: 100%;
    max-height: 250px;
    border-radius: 10px;
}

.editor-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    border-radius: 7px;
}

.editor-toolbar .ql-formats.right {
    margin-left: auto;
}

.editor-action-btn {
    color: black;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 6px;
    height: 28px;
    width: 80px;
    background: #f3f3f3;
}

.editor-action-btn + .editor-action-btn {
    margin-left: 5px;
}

.editor-meta-row {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}

.editor-meta-item {
    flex: 0 0 20%;
}

.editor-meta-item.flex-grow {
    flex: 1 1 20%;
}

.editor-tags-input {
    height: 46px;
}

/* --- Book create/edit --------------------------------------------------- */

.book-form-row {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    max-width: 100%;
    flex-wrap: wrap;
}

.book-image-pane {
    flex: 0 0 250px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.book-image-preview {
    cursor: pointer;
    width: 100%;
    max-height: 250px;
    object-fit: cover;
    border-radius: 10px;
}

.book-fields-pane {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
    position: relative;
}

.pdf-upload-row {
    margin-top: 10px;
}

.pdf-upload-label {
    cursor: pointer;
    border: 1px solid #ccc;
    padding: 10px;
    display: inline-block;
    border-radius: 5px;
}

.book-meta-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: end;
    margin-top: 10px;
}

.book-meta-item {
    flex: 1 1 120px;
}

.book-meta-button {
    flex: 1 1 100px;
    display: flex;
    align-items: end;
}

.book-meta-button.narrow {
    flex: 0 0 20px;
}

.book-publish-btn {
    margin-top: 24px;
}

.hidden-input {
    display: none;
}

/* --- Sign-in/sign-up shared ---------------------------------------------- */

.background-card {
    background-color: white;
    border-radius: 12px;
}

.section-bg-light {
    background-color: #ffffff;
}

.section-bg-grey {
    background-color: #E8E9EB;
}

/* ---------------------------------------------------------------------------
   Responsive — tablet (≤1024px) and mobile (≤640px) overrides for the
   public pages (index, articles list/detail, books list, teacher detail).
   Desktop styles are the defaults declared above; these blocks only narrow
   things down for smaller viewports.
--------------------------------------------------------------------------- */

@media (max-width: 1024px) {
    /* Public landing & content sections breathe a bit on tablet. */
    .about-wrapper {
        gap: 1.5rem;
    }

    /* Two-column grids on tablet. */
    .articles-grid-flex {
        grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    }

    .ebooks-grid-flex {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    }

    .ebooks-grid-fixed-4 {
        grid-template-columns: repeat(2, 1fr);
    }

    .articles-grid-tight {
        grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    }

    /* Teacher cards on the index/teachers list collapse padding. */
    .teacher-card-row {
        gap: 24px;
        padding: 20px;
    }

    .teacher-card-avatar {
        width: 120px;
        height: 120px;
    }

    /* Article hero on detail pages: keep height but tighten padding. */
    .teacher-header-wrapper {
        height: 220px;
        padding-left: 1.5rem;
        padding-top: 30px;
    }

    .author-photo {
        width: 120px;
        height: 120px;
    }

    .article-detail-content {
        padding: 1.5rem;
    }

    /* Tall-card minimums get smaller so cards don't dominate. */
    .book-card-tall {
        min-height: 460px;
    }

    .summary-tall {
        min-height: 240px;
    }
}

@media (max-width: 640px) {
    /* Single-column grids on phones. */
    .articles-grid-flex,
    .articles-grid-tight,
    .articles-grid-small,
    .ebooks-grid-flex,
    .ebooks-grid-fixed-4 {
        grid-template-columns: 1fr;
    }

    /* Teacher cards on the index page stack image above info. */
    .teacher-card-row {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 16px;
        padding: 16px;
    }

    .teacher-card-info {
        align-items: center;
    }

    .teacher-card-stats,
    .teacher-card-langs {
        justify-content: center;
    }

    .teacher-card-avatar {
        width: 110px;
        height: 110px;
    }

    /* Article hero shrinks and stacks; the floating author photo recenters. */
    .teacher-header-wrapper {
        height: 180px;
        padding: 0;
        justify-content: center;
        align-items: flex-end;
    }

    .author-photo {
        width: 96px;
        height: 96px;
        margin-bottom: -48px;
    }

    .article-detail-content {
        padding: 1.25rem;
        margin-top: 60px;
    }

    .article-detail-header {
        gap: 0.75rem;
    }

    .article-detail-icon {
        font-size: 1.25rem;
    }

    /* Article-meta row (read time / views) wraps on phones. */
    .article-meta {
        flex-wrap: wrap;
        gap: 8px;
    }

    /* Tag row tightens up. */
    .article-tags {
        gap: 6px;
    }

    .tag-item {
        font-size: 0.78rem;
        padding: 4px 10px;
    }

    /* Tall-card minimums removed entirely on phones — content height wins. */
    .book-card-tall,
    .summary-tall {
        min-height: 0;
    }

    .article-card-title-tall {
        min-height: 0;
    }

    .article-card-summary-tall {
        min-height: 0;
    }

    /* Books page: floating level badge becomes static so cards size to content. */
    .article-meta-floating {
        position: static;
        margin: 12px 0 0 0;
        padding: 12px 0 0;
    }

    /* Reset book-card-tall positioning context that was set for the badge. */
    .book-card-tall {
        position: static;
    }

    /* Article detail "padded" meta ditches its 50px top padding. */
    .article-meta-padded {
        padding-top: 16px;
    }

    /* Public landing about banner already swaps via .about-banner-mobile;
       gap below it shrinks on small screens. */
    .about-wrapper {
        gap: 1rem;
    }

    /* Brand row + auth pages: no horizontal squish needed. */
    .brand-title {
        font-size: 20px;
    }
}

@media (max-width: 420px) {
    .read-time-badge,
    .date-badge {
        font-size: 11px;
        padding: 3px 6px;
    }

    .level-badge {
        font-size: 0.75rem;
        padding: 0.2rem 0.45rem;
    }

    .tag-item {
        font-size: 0.72rem;
    }
}
