/*
 * OpenLearn-style "<name>'s SOMAS Profile" summary page (index.php) - separate from
 * core's own user/profile.php, which is left completely untouched. "View full profile"
 * links out to that real page for the full field-by-field details (course list, login
 * activity, reports, etc.) this summary intentionally leaves out. Only the OpenLearn
 * tiles/sidebar elements that map to something this site actually has are kept - no
 * public/private toggle, no "My OU life"/"My saved items".
 *
 * Plain CSS, not SCSS - this plugin doesn't depend on theme_somas's build pipeline, so it
 * keeps working (just uncoloured, via the var() fallbacks below) even if a different theme
 * is active. Colour values here are theme_somas's own compiled defaults ($border-color,
 * $gray-*, $somas-header-nav-bg) - duplicated rather than shared so this plugin has no
 * hard dependency on any of theme_somas's SCSS variables.
 */
.local-somasprofile-page #page.drawers {
    width: 100%;
    max-width: 1280px;
    margin-left: auto;
    margin-right: auto;
}

.somas-profile-layout {
    display: flex;
    align-items: flex-start;
    gap: 1.5rem;
    max-width: 1280px;
    margin: 1.5rem auto;
    padding: 0;
}

.somas-profile-sidebar {
    flex: 0 0 300px;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    min-width: 0;
}

/*
 * One unified card - avatar/name/subtitle, a divider, then the nav list, all inside the
 * same box (previously two separate boxes with a gap between them).
 */
.somas-profile-card {
    background: #fff;
    border: 1px solid #d7dfe3;
}

.somas-profile-card-header {
    padding: 1.5rem 1.5rem 1.25rem;
    text-align: center;
}

.somas-profile-avatar {
    margin: 0 auto 0.75rem;
    width: 96px;
}

.somas-profile-avatar img {
    display: block;
    width: 96px;
    height: 96px;
    border-radius: 50%;
    object-fit: cover;
}

.somas-profile-name {
    font-size: 1.2rem;
    font-weight: 700;
    line-height: 1.3;
    color: #1e2939;
}

.somas-profile-subtitle {
    color: #55595c;
    font-size: 0.9rem;
}

.somas-profile-lecturer-status {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.4rem;
    padding: 0 1.5rem 1.25rem;
    text-align: center;
    font-weight: 700;
}

.somas-profile-lecturer-icon-public {
    color: #2e7d32;
}

.somas-profile-lecturer-icon-private {
    color: #c62828;
}

.somas-profile-lecturer-label-public {
    color: #2e7d32;
}

.somas-profile-lecturer-label-private {
    color: #c62828;
}

.somas-profile-lecturer-status a {
    color: #255c9a;
    text-decoration: none;
}

.somas-profile-lecturer-status a:hover,
.somas-profile-lecturer-status a:focus {
    text-decoration: underline;
}

.somas-profile-nav {
    list-style: none;
    margin: 0;
    padding: 0;
    border-top: 1px solid #d7dfe3;
    text-align: left;
}

.somas-profile-nav-item {
    border-bottom: 1px solid #d7dfe3;
}

.somas-profile-nav-item:last-child {
    border-bottom: 0;
}

.somas-profile-nav-item a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1.5rem;
    color: #1e2939;
    font-weight: 600;
    text-decoration: none;
}

.somas-profile-nav-item span {
    min-width: 0;
    overflow-wrap: anywhere;
}

.somas-profile-nav-item a:hover,
.somas-profile-nav-item a:focus {
    background: #f7f7f9;
    text-decoration: none;
}

.somas-profile-nav-item i {
    width: 20px;
    text-align: center;
    color: var(--somas-course-accent, #255c9a);
}

/* The current page - "My profile" itself, never a link. */
.somas-profile-nav-current {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1.5rem;
    font-weight: 700;
    color: var(--somas-course-accent, #255c9a);
    background: #f7f7f9;
}

.somas-profile-nav-current i {
    width: 20px;
    text-align: center;
}

/*
 * The block's own markup (.somas-advert-card in blocks/somas_advert) already carries its
 * full card styling (background colour, padding, logo, text) - this wrapper only needs to
 * exist so the sidebar's flex gap applies evenly whether or not an admin has actually
 * configured/placed the block yet (see {{#advertblock}} in templates/myprofile.mustache).
 */
.somas-profile-advert .somas-advert-card {
    margin: 0;
    width: 100%;
}

.somas-profile-main {
    flex: 1 1 auto;
    min-width: 0;
    background: #fff;
    padding: 2rem;
    border: 1px solid #d7dfe3;
}

.somas-profile-heading {
    margin: 0 0 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #d7dfe3;
    font-size: 1.75rem;
    font-weight: 700;
    color: #1e2939;
}

.somas-profile-intro {
    max-width: 46rem;
    color: #212529;
}

.somas-profile-subheading {
    margin: 2rem 0 1rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: #1e2939;
}

.somas-profile-subheading:first-of-type {
    margin-top: 0.5rem;
}

.somas-profile-tiles {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin: 1.5rem 0;
}

.somas-profile-tile {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1.25rem;
    background: #f7f7f9;
    border: 1px solid #d7dfe3;
    color: inherit;
    text-decoration: none;
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.somas-profile-tile:hover,
.somas-profile-tile:focus {
    color: inherit;
    text-decoration: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.somas-profile-tile-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: #fff;
    color: var(--somas-course-accent, #255c9a);
    font-size: 1.25rem;
}

.somas-profile-tile-body {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    min-width: 0;
}

.somas-profile-tile-title {
    font-weight: 700;
    color: var(--somas-course-accent, #255c9a);
}

.somas-profile-tile-text {
    font-size: 0.9rem;
    line-height: 1.4;
    color: #212529;
}

.somas-profile-edit-row {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin: 1.5rem 0 0;
}

.somas-profile-edit-btn {
    display: inline-block;
    padding: 0.85rem 2rem;
    border-radius: 50px;
    background: #255C9A;
    color: #fff;
    font-weight: 700;
    text-decoration: none;
    transition: background-color 0.2s ease;
}

.somas-profile-edit-btn:hover,
.somas-profile-edit-btn:focus {
    background: #1D4A7C;
    color: #fff;
    text-decoration: none;
}

/*
 * Secondary action - out to core's own user/profile.php (untouched) for the full
 * field-by-field detail list (course profiles, login activity, reports, etc.) this
 * summary page intentionally leaves out. Outlined, not filled, so it doesn't compete with
 * the edit button as the primary action.
 */
.somas-profile-preferences-btn,
.somas-profile-fullprofile-btn {
    display: inline-block;
    padding: 0.85rem 2rem;
    border-radius: 50px;
    border: 2px solid #255C9A;
    color: #255C9A;
    font-weight: 700;
    text-decoration: none;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.somas-profile-preferences-btn:hover,
.somas-profile-preferences-btn:focus,
.somas-profile-fullprofile-btn:hover,
.somas-profile-fullprofile-btn:focus {
    background: #255C9A;
    color: #fff;
    text-decoration: none;
}

/*
 * Course list rows - "My achievements" (achievements.php) and "In progress"
 * (inprogress.php): image left, title/subtitle/meta/action stacked right.
 */
.somas-profile-course-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.somas-profile-certificate-list {
    background: #fff;
    color: #403d3d;
}

.somas-profile-certificate-row {
    display: grid;
    grid-template-columns: 170px minmax(0, 1fr) auto;
    gap: 26px;
    padding: 26px 0;
    border-top: 1px dashed #aaa16b;
    border-bottom: 1px dashed #aaa16b;
}

.somas-profile-certificate-image {
    display: block;
    width: 100%;
    aspect-ratio: 270 / 192;
}

.somas-profile-certificate-image img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.somas-profile-certificate-details {
    min-width: 0;
}

.somas-profile-certificate-details p {
    margin: 0 0 14px;
}

.somas-profile-certificate-title {
    display: block;
    margin-bottom: 14px;
    color: #000;
}

.somas-profile-certificate-title a {
    color: #000;
    text-decoration: none;
}

.somas-profile-certificate-title a:hover,
.somas-profile-certificate-title a:focus {
    text-decoration: underline;
}

.somas-profile-certificate-actions {
    padding-left: 25px;
    border-left: 1px solid #d3cfca;
}

.somas-profile-certificate-download {
    display: inline-block;
    padding: 12px 18px;
    border-radius: 8px;
    background: #255C9A;
    color: #fff;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
}

.somas-profile-certificate-download:hover,
.somas-profile-certificate-download:focus {
    background: #1D4A7C;
    color: #fff;
    text-decoration: none;
}

.somas-profile-certificate-statement {
    display: block;
    margin-top: 12px;
    color: #255C9A;
    font-weight: 700;
}

.somas-profile-course-row {
    display: grid;
    grid-template-columns: 120px minmax(0, 1fr) auto;
    gap: 20px;
    padding: 24px 0;
    border-top: 1px dashed #aaa397;
    color: #111;
}

.somas-profile-course-row:last-child {
    border-bottom: 0;
}

.somas-profile-course-image {
    width: 100%;
    aspect-ratio: 270 / 192;
}

.somas-profile-course-image img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Badge rows (badges.php) reuse .somas-profile-course-row's 3-column grid (image/body/
   actions) and -body/-title/-subtitle/-meta/-actions/-action - only the image itself needs
   its own treatment (square, smaller, no crop, centred in the 120px image column rather
   than stretched to fill it). */
.somas-profile-badge-image {
    display: flex;
    align-items: flex-start;
    justify-content: center;
}

.somas-profile-badge-image img {
    display: block;
    width: 90px;
    height: 90px;
    object-fit: contain;
}

.somas-profile-course-body {
    min-width: 0;
}

.somas-profile-course-title {
    display: block;
    margin: 0 0 8px;
    font-size: 1.1rem;
}

.somas-profile-course-title a {
    color: #1e2939;
    text-decoration: none;
}

.somas-profile-course-title a:hover,
.somas-profile-course-title a:focus {
    text-decoration: underline;
}

.somas-profile-course-subtitle {
    margin: 0 0 12px;
    color: #55595c;
    font-size: 0.9rem;
}

.somas-profile-course-meta {
    margin: 0 0 12px;
    color: #212529;
    font-size: 0.9rem;
    font-weight: 700;
}

.somas-profile-course-action {
    display: inline-block;
    padding: 12px 18px;
    border-radius: 7px;
    background: #255C9A;
    color: #fff;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
}

.somas-profile-course-action:hover,
.somas-profile-course-action:focus {
    background: #1D4A7C;
    color: #fff;
    text-decoration: none;
}

.somas-profile-course-actions {
    padding-left: 16px;
    border-left: 1px solid #d3cfca;
}

.somas-profile-course-statement {
    display: block;
    margin-top: 4px;
}

.somas-profile-course-nocert {
    display: inline-block;
    color: #55595c;
    font-size: 0.85rem;
    font-style: italic;
}

.somas-profile-progress {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.somas-profile-progress progress {
    appearance: none;
    width: 100%;
    min-width: 0;
    height: 16px;
    border: 0;
    border-radius: 0;
    background: #d3cfca;
}

.somas-profile-progress progress::-webkit-progress-bar {
    background: #d3cfca;
}

.somas-profile-progress progress::-webkit-progress-value {
    background: #568300;
}

.somas-profile-progress progress::-moz-progress-bar {
    background: #568300;
}
.somas-profile-empty {
    color: #55595c;
}

/*
 * This page's own hero card already shows the profile's avatar and name - core's default
 * context header (#page-header, avatar + name + "Message" button) would just duplicate
 * that, so it's hidden here. Scoped to .local-somasprofile-page (see classes/local/
 * helper.php::setup_page()) rather than the shared #page-user-profile body id, since core's
 * own user/profile.php reuses that same pagetype/id and still needs its context header
 * (it has no hero card of its own to duplicate).
 */
.local-somasprofile-page #page-header {
    display: none;
}

@media (max-width: 1279.98px) {
    .somas-profile-layout {
        padding-left: 1rem;
        padding-right: 1rem;
    }
}

@media (max-width: 991.98px) {
    .somas-profile-layout {
        flex-direction: column;
    }

    .somas-profile-sidebar {
        flex: 1 1 auto;
        width: 100%;
    }

    .somas-profile-tiles {
        grid-template-columns: 1fr;
    }

    .somas-profile-course-row {
        grid-template-columns: 80px minmax(0, 1fr);
        gap: 16px;
    }

    .somas-profile-course-image {
        width: 80px;
    }

    .somas-profile-course-image img {
        width: 100%;
        height: 100%;
    }

    .somas-profile-course-actions {
        grid-column: 2;
        padding: 0;
        border: 0;
        min-width: 0;
    }

    .somas-profile-course-action,
    .somas-profile-certificate-download {
        max-width: 100%;
        white-space: normal;
        overflow-wrap: anywhere;
        text-align: center;
    }

    .somas-profile-certificate-row {
        grid-template-columns: 90px minmax(0, 1fr);
        gap: 16px;
    }

    .somas-profile-certificate-actions {
        grid-column: 2;
        padding-left: 0;
        border-left: 0;
        min-width: 0;
    }
}

@media (max-width: 380px) {
    .somas-profile-main {
        padding: 1.25rem;
    }

    .somas-profile-heading {
        font-size: 1.5rem;
    }

    .somas-profile-course-row {
        grid-template-columns: minmax(0, 1fr);
        gap: 12px;
    }

    .somas-profile-course-image {
        width: 120px;
        max-width: 100%;
    }

    .somas-profile-course-actions {
        grid-column: 1;
    }

    .somas-profile-certificate-row {
        grid-template-columns: minmax(0, 1fr);
    }

    .somas-profile-certificate-image {
        max-width: 170px;
    }

    .somas-profile-certificate-actions {
        grid-column: 1;
    }
}

/*
 * Lecturer profile page (lecturer.php) - a standalone, public-facing marketing page (not
 * part of the private mypublic sidebar shell above), same two-column layout the
 * local_somaslecturers plugin this replaces used, just renamed from .local-somaslecturers-*
 * to .somas-lecturer-* for consistency with this plugin's own naming.
 */
.somas-lecturer-layout {
    max-width: 1280px;
    margin: 0 auto;
    display: flex;
    gap: 2.5rem;
    align-items: flex-start;
}

.somas-lecturer-main {
    flex: 1 1 auto;
    min-width: 0;
}

.somas-lecturer-sidebar {
    flex: 0 0 320px;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

@media (max-width: 900px) {
    .somas-lecturer-layout {
        flex-direction: column;
    }

    .somas-lecturer-sidebar {
        flex: 1 1 auto;
        width: 100%;
    }
}

/* White content card on the theme's own grey page canvas ($body_bg: $gray-200, theme_somas/
   scss/somas/_general.scss) - same treatment as theme_somas's other main-column content
   (e.g. .somas-course-info-main on course/info.php). Values copied from that rule's own
   compiled output (background:#fff, border-radius:.1rem, border:1px solid #d7dfe3) since
   this plain CSS file has no access to the theme's SCSS variables. */
.somas-lecturer-profile {
    max-width: 100%;
    background: #fff;
    padding: 1.5rem;
    border-radius: 0.1rem;
    border: 1px solid #d7dfe3;
}

.somas-lecturer-header {
    display: flex;
    flex-wrap: wrap;
    gap: 2rem;
    margin-bottom: 2rem;
}

.somas-lecturer-photo {
    flex: 0 0 auto;
    width: 200px;
}

.somas-lecturer-photo-img {
    width: 200px;
    height: auto;
    display: block;
}

.somas-lecturer-summary {
    flex: 1 1 320px;
    min-width: 0;
}

.somas-lecturer-name {
    font-size: 1.75rem;
    font-weight: 700;
    margin: 0 0 0.25rem;
}

.somas-lecturer-department {
    font-size: 1.05rem;
    color: #333;
    margin: 0 0 1rem;
}

.somas-lecturer-bio-label {
    font-weight: 700;
    margin: 0 0 0.35rem;
}

.somas-lecturer-bio {
    line-height: 1.6;
    max-width: 100%;
    overflow-wrap: anywhere;
}

/* A lecturer's bio is raw HTML they authored themselves (lecturer_profile::get_bio_html()) -
   an oversized image, table, or unbroken URL in there must never push the 1280px
   .somas-lecturer-layout wider than its own cap. */
.somas-lecturer-bio img,
.somas-lecturer-bio video,
.somas-lecturer-bio iframe,
.somas-lecturer-bio table {
    max-width: 100%;
    height: auto;
}

.somas-lecturer-activities-heading {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.somas-lecturer-activities-subheading {
    font-size: 1rem;
    font-weight: 400;
    color: #555;
    margin-bottom: 1rem;
}

.somas-lecturer-courses-list {
    margin: 0;
    padding: 0;
}

.somas-lecturer-course-card {
    list-style: none;
    display: flex;
    gap: 1rem;
    padding: 1rem 0;
    border-bottom: 1px solid #ddd;
    align-items: flex-start;
}

.somas-lecturer-course-card:last-child {
    border-bottom: none;
}

.somas-lecturer-course-imgwrap {
    flex: 0 0 auto;
    display: block;
}

.somas-lecturer-course-img {
    width: 140px;
    height: 90px;
    object-fit: cover;
    display: block;
}

.somas-lecturer-course-body {
    flex: 1 1 auto;
    min-width: 0;
}

.somas-lecturer-course-title {
    margin: 0 0 0.35rem;
    font-size: 1.1rem;
    font-weight: 700;
}

.somas-lecturer-course-desc {
    margin: 0 0 0.5rem;
    color: #444;
    overflow-wrap: anywhere;
}

.somas-lecturer-course-link {
    font-weight: 700;
}

@media (max-width: 600px) {
    .somas-profile-edit-row > a {
        width: 100%;
        text-align: center;
    }

    .somas-lecturer-profile {
        padding: 1rem;
    }

    .somas-lecturer-header {
        gap: 1rem;
    }

    .somas-lecturer-photo,
    .somas-lecturer-photo-img {
        width: 140px;
    }

    .somas-lecturer-course-card {
        flex-direction: column;
    }

    .somas-lecturer-course-img {
        width: 100%;
        max-width: 320px;
        height: auto;
        aspect-ratio: 270 / 192;
    }
}
