/**
 * My Profile shortcode — redesigned template (v1.7.0)
 *
 * Brand-adaptive via the plugin's existing --scorm-* color tokens.
 * All derived surfaces/pills/borders use color-mix() on top of the tokens,
 * so a tenant changing --scorm-primary-color (or mapping to Astra globals)
 * gets a coherent palette without overriding individual selectors.
 */

/* =========================================================================
   1. Token aliases
   ========================================================================= */

.scorm-my-profile {
    --scorm-profile-identity-bg: color-mix(in srgb, var(--scorm-primary-color) 6%, var(--scorm-surface-color));
    --scorm-profile-border: color-mix(in srgb, var(--scorm-primary-color) 18%, var(--scorm-surface-color));
    --scorm-profile-border-strong: color-mix(in srgb, var(--scorm-primary-color) 30%, var(--scorm-surface-color));

    --scorm-profile-progress-track: color-mix(in srgb, var(--scorm-primary-color) 12%, var(--scorm-surface-color));

    --scorm-profile-pill-done-bg: color-mix(in srgb, var(--scorm-completed-color) 14%, var(--scorm-surface-color));
    --scorm-profile-pill-done-text: color-mix(in srgb, var(--scorm-completed-color) 80%, var(--scorm-heading-color));
    --scorm-profile-pill-active-bg: color-mix(in srgb, var(--scorm-primary-color) 12%, var(--scorm-surface-color));
    --scorm-profile-pill-active-text: color-mix(in srgb, var(--scorm-primary-color) 80%, var(--scorm-heading-color));
    --scorm-profile-pill-warn-bg: color-mix(in srgb, var(--scorm-in-progress-color) 18%, var(--scorm-surface-color));
    --scorm-profile-pill-warn-text: color-mix(in srgb, var(--scorm-in-progress-color) 80%, var(--scorm-heading-color));
    --scorm-profile-pill-muted-bg: color-mix(in srgb, var(--scorm-muted-text-color) 10%, var(--scorm-surface-color));
    --scorm-profile-pill-muted-text: var(--scorm-muted-text-color);

    --scorm-profile-heading-font: Merriweather, Georgia, serif;
    --scorm-profile-body-font: "Open Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* =========================================================================
   2. Layout
   ========================================================================= */

.scorm-my-profile {
    max-width: 960px;
    margin: 0 auto;
    padding: 20px 32px 72px;
    color: var(--scorm-text-color);
    font-family: var(--scorm-profile-body-font);
    font-size: 15px;
    line-height: 1.55;
    box-sizing: border-box;
}

.scorm-my-profile *,
.scorm-my-profile *::before,
.scorm-my-profile *::after {
    box-sizing: inherit;
}

.scorm-my-profile h1,
.scorm-my-profile h2,
.scorm-my-profile h3 {
    font-family: var(--scorm-profile-heading-font);
    color: var(--scorm-heading-color);
    margin: 0;
}

.scorm-my-profile h1.scorm-my-profile__title {
    font-size: 32px;
    font-weight: 900;
    letter-spacing: -0.02em;
    line-height: 1.15;
    margin: 0 0 4px;
}

.scorm-my-profile__subtitle {
    margin: 0 0 24px;
    font-size: 14px;
    color: var(--scorm-muted-text-color);
}

/* Suppress the host theme's page title when the shortcode owns the heading.
   Targets the title elements themselves — not their surrounding site header —
   across Astra (.entry-header/.entry-title), Twenty-* core themes, block
   themes (.wp-block-post-title), and Beaver Builder page title rows
   (.fl-page-header-title). */
body.scorm-my-profile-hides-title .entry-header,
body.scorm-my-profile-hides-title .entry-title,
body.scorm-my-profile-hides-title .page-title,
body.scorm-my-profile-hides-title .wp-block-post-title,
body.scorm-my-profile-hides-title .fl-page-header-title {
    display: none !important;
}

.scorm-my-profile a {
    color: var(--scorm-primary-color);
    text-decoration: none;
}

.scorm-my-profile a:hover {
    text-decoration: underline;
}

.scorm-profile-section {
    margin-top: 40px;
}

.scorm-profile-section__header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.scorm-profile-section__title {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.01em;
}

.scorm-profile-section__link {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
}

/* =========================================================================
   3. Identity card
   ========================================================================= */

.scorm-profile-identity {
    display: block;
    padding: 28px 32px;
    background: var(--scorm-profile-identity-bg);
    border: 1px solid var(--scorm-profile-border);
    border-radius: 12px;
}

.scorm-profile-identity__top {
    display: flex;
    align-items: center;
    gap: 24px;
}

.scorm-profile-identity__avatar {
    flex: 0 0 auto;
    width: 84px;
    height: 84px;
    border-radius: 50%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--scorm-primary-color), var(--scorm-secondary-color));
    color: var(--scorm-button-text-color, #fff);
    font-family: var(--scorm-profile-heading-font);
    font-weight: 800;
    font-size: 32px;
    letter-spacing: 0.02em;
}

.scorm-profile-identity__avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.scorm-profile-identity__initials {
    line-height: 1;
}

.scorm-profile-identity__body {
    flex: 1 1 auto;
    min-width: 0;
}

.scorm-profile-identity__name {
    font-size: 28px;
    font-weight: 800;
    line-height: 1.15;
    margin-bottom: 4px;
    overflow-wrap: anywhere;
}

.scorm-my-profile .scorm-profile-identity__email {
    margin: 0 0 4px;
    font-size: 14px;
    color: var(--scorm-muted-text-color);
    overflow-wrap: anywhere;
}

.scorm-my-profile .scorm-profile-identity__since {
    margin: 0;
    font-size: 13px;
    color: var(--scorm-muted-text-color);
}

.scorm-profile-identity__actions {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: stretch;
}

.scorm-profile-identity__actions .scorm-btn {
    justify-content: center;
}

.scorm-profile-edit-toggle {
    cursor: pointer;
}

.scorm-profile-logout {
    color: var(--scorm-failed-color) !important;
    border-color: color-mix(in srgb, var(--scorm-failed-color) 45%, transparent);
}

.scorm-profile-logout:hover {
    border-color: var(--scorm-failed-color);
    background: color-mix(in srgb, var(--scorm-failed-color) 8%, transparent);
}

/* Button primitives scoped to the profile so a tenant theme doesn't steamroll them */
.scorm-my-profile .scorm-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 16px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    border-radius: var(--scorm-button-radius, 8px);
    border: 1px solid transparent;
    background: var(--scorm-primary-color);
    color: var(--scorm-button-text-color, #fff);
    text-decoration: none;
    cursor: pointer;
    transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}

.scorm-my-profile .scorm-btn:hover {
    text-decoration: none;
    background: color-mix(in srgb, var(--scorm-primary-color) 85%, #000);
}

.scorm-my-profile .scorm-btn--outline,
.scorm-my-profile .scorm-btn-secondary {
    background: transparent;
    color: var(--scorm-heading-color);
    border-color: var(--scorm-profile-border-strong);
}

.scorm-my-profile .scorm-btn--outline:hover,
.scorm-my-profile .scorm-btn-secondary:hover {
    background: var(--scorm-profile-identity-bg);
    border-color: var(--scorm-primary-color);
    color: var(--scorm-heading-color);
}

.scorm-my-profile .scorm-btn--ghost {
    background: transparent;
    border-color: transparent;
    color: var(--scorm-heading-color);
    padding-inline: 8px;
}

.scorm-my-profile .scorm-btn--ghost:hover {
    background: color-mix(in srgb, var(--scorm-failed-color) 10%, transparent);
}

.scorm-my-profile .scorm-btn--disabled {
    cursor: not-allowed;
    background: var(--scorm-profile-pill-muted-bg);
    color: var(--scorm-muted-text-color);
    border-color: var(--scorm-profile-border);
}

.scorm-my-profile .scorm-btn-primary {
    background: var(--scorm-primary-color);
    color: var(--scorm-button-text-color, #fff);
    border-color: transparent;
}

/* Identity-card group/role chips */
.scorm-profile-identity__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.scorm-profile-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.02em;
    background: var(--scorm-surface-color);
    border: 1px solid var(--scorm-profile-border);
    color: var(--scorm-muted-text-color);
}

.scorm-profile-chip__role {
    color: var(--scorm-heading-color);
}

.scorm-profile-chip--leader {
    background: color-mix(in srgb, var(--scorm-primary-color) 8%, transparent);
    border-color: color-mix(in srgb, var(--scorm-primary-color) 25%, transparent);
    color: var(--scorm-primary-color);
}

.scorm-profile-chip--leader .scorm-profile-chip__role {
    color: var(--scorm-primary-color);
}

.scorm-profile-chip__icon {
    flex: 0 0 auto;
    color: currentColor;
}

/* =========================================================================
   4. Stats row
   ========================================================================= */

.scorm-profile-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-top: 24px;
}

.scorm-profile-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 20px 12px;
    background: var(--scorm-surface-color);
    border: 1px solid var(--scorm-profile-border);
    border-radius: 10px;
    text-align: center;
}

.scorm-profile-stat__value {
    font-family: var(--scorm-profile-heading-font);
    font-weight: 900;
    font-size: 32px;
    line-height: 1;
    color: var(--scorm-primary-color);
}

.scorm-profile-stat__label {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--scorm-muted-text-color);
}

/* =========================================================================
   4b. Resume hero
   ========================================================================= */

.scorm-profile-resume {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    margin-top: 32px;
    padding: 22px 26px;
    background: linear-gradient(
        135deg,
        color-mix(in srgb, var(--scorm-primary-color) 10%, var(--scorm-surface-color)) 0%,
        color-mix(in srgb, var(--scorm-secondary-color, var(--scorm-primary-color)) 6%, var(--scorm-surface-color)) 100%
    );
    border: 1px solid color-mix(in srgb, var(--scorm-primary-color) 22%, transparent);
    border-radius: 12px;
}

.scorm-profile-resume__body {
    flex: 1 1 auto;
    min-width: 0;
}

.scorm-profile-resume__eyebrow {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--scorm-primary-color);
    margin-bottom: 6px;
}

.scorm-profile-resume__title {
    margin: 0 0 10px;
    font-size: 20px;
    font-weight: 800;
    line-height: 1.25;
    color: var(--scorm-heading-color);
    overflow-wrap: anywhere;
}

.scorm-profile-resume__progress {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.scorm-profile-resume__progress .scorm-profile-progress__bar {
    flex: 1 1 200px;
    max-width: 320px;
}

.scorm-profile-resume__meta {
    font-size: 13px;
    color: var(--scorm-muted-text-color);
}

.scorm-profile-resume__action {
    flex: 0 0 auto;
}

/* =========================================================================
   5. Courses list + rows + pills + progress
   ========================================================================= */

.scorm-profile-course-list,
.scorm-profile-list {
    background: var(--scorm-surface-color);
    border: 1px solid var(--scorm-profile-border);
    border-radius: 10px;
    overflow: hidden;
}

.scorm-profile-course-row {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 18px 20px;
    border-top: 1px solid var(--scorm-profile-border);
}

.scorm-profile-course-row:first-child {
    border-top: 0;
}

.scorm-profile-course-row__main {
    flex: 1 1 auto;
    min-width: 0;
}

.scorm-profile-course-row__meta {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
    flex-wrap: wrap;
}

.scorm-profile-course-row__title {
    font-family: var(--scorm-profile-heading-font);
    font-size: 17px;
    font-weight: 700;
    line-height: 1.3;
    margin: 0 0 8px;
}

.scorm-profile-course-row__title a {
    color: var(--scorm-heading-color);
}

.scorm-profile-course-row__title a:hover {
    color: var(--scorm-primary-color);
    text-decoration: none;
}

.scorm-profile-course-row__action {
    flex: 0 0 auto;
}

.scorm-profile-tag {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--scorm-primary-color);
}

.scorm-profile-pill {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    border-radius: 999px;
    background: var(--scorm-profile-pill-muted-bg);
    color: var(--scorm-profile-pill-muted-text);
}

.scorm-profile-pill--done {
    background: var(--scorm-profile-pill-done-bg);
    color: var(--scorm-profile-pill-done-text);
}

.scorm-profile-pill--active {
    background: var(--scorm-profile-pill-active-bg);
    color: var(--scorm-profile-pill-active-text);
}

.scorm-profile-pill--warn {
    background: var(--scorm-profile-pill-warn-bg);
    color: var(--scorm-profile-pill-warn-text);
}

.scorm-profile-pill--muted {
    background: var(--scorm-profile-pill-muted-bg);
    color: var(--scorm-profile-pill-muted-text);
}

.scorm-profile-progress {
    display: flex;
    align-items: center;
    gap: 12px;
}

.scorm-profile-progress__bar {
    flex: 1 1 260px;
    max-width: 260px;
    height: 6px;
    border-radius: 3px;
    background: var(--scorm-profile-progress-track);
    overflow: hidden;
}

.scorm-profile-progress__fill {
    height: 100%;
    background: var(--scorm-primary-color);
    border-radius: inherit;
}

.scorm-profile-progress__meta {
    font-size: 12px;
    color: var(--scorm-muted-text-color);
}

/* =========================================================================
   6. Two-column bottom (groups + certificates)
   ========================================================================= */

.scorm-profile-two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-top: 40px;
}

.scorm-profile-two-col .scorm-profile-section {
    margin-top: 0;
    /* Grid items default to min-width:auto (=min-content). Long titles or
       action buttons inside the rows can otherwise push the section wider
       than the 1fr column, breaking out of the .scorm-my-profile container
       on narrow viewports. */
    min-width: 0;
}

/* =========================================================================
   7. Group + certificate rows
   ========================================================================= */

.scorm-profile-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    border-top: 1px solid var(--scorm-profile-border);
    color: inherit;
}

.scorm-profile-row:first-child {
    border-top: 0;
}

.scorm-my-profile a.scorm-profile-row,
.scorm-my-profile a.scorm-profile-row:hover,
.scorm-my-profile a.scorm-profile-row:focus,
.scorm-my-profile a.scorm-profile-row:visited,
.scorm-my-profile a.scorm-profile-row:active {
    text-decoration: none;
    color: inherit;
    box-shadow: none;
}

.scorm-my-profile a.scorm-profile-row:hover {
    background: color-mix(in srgb, var(--scorm-primary-color) 5%, var(--scorm-surface-color));
    text-decoration: none;
}

.scorm-my-profile a.scorm-profile-row:hover .scorm-profile-row__title {
    color: var(--scorm-primary-color);
}

.scorm-my-profile a.scorm-profile-row .scorm-profile-row__title,
.scorm-my-profile a.scorm-profile-row .scorm-profile-row__meta {
    text-decoration: none;
}

.scorm-my-profile a.scorm-profile-row .scorm-profile-row__meta {
    color: var(--scorm-muted-text-color, #64748b);
}

.scorm-profile-row__body {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.scorm-profile-row__title {
    font-family: var(--scorm-profile-heading-font);
    font-size: 15px;
    font-weight: 700;
    color: var(--scorm-heading-color);
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.scorm-profile-row__meta {
    font-size: 12px;
    color: var(--scorm-muted-text-color, #71717a);
    font-weight: 400;
}

.scorm-profile-row__link {
    flex: 0 0 auto;
    font-size: 13px;
    font-weight: 600;
    color: var(--scorm-primary-color);
}

.scorm-profile-avatar-tile {
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--scorm-primary-color);
    color: var(--scorm-button-text-color, #fff);
    font-family: var(--scorm-profile-heading-font);
    font-weight: 800;
    font-size: 14px;
    letter-spacing: 0.02em;
    line-height: 1;
}

.scorm-profile-cert-icon {
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    color: var(--scorm-primary-color);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.scorm-profile-cert-icon svg {
    width: 100%;
    height: 100%;
    display: block;
}

/* =========================================================================
   8. Inline editor (toggled by JS inside identity card)
   ========================================================================= */

.scorm-profile-identity__editor {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--scorm-profile-border);
}

.scorm-profile-identity__editor[hidden] {
    display: none;
}

.scorm-profile-edit-toggle[aria-expanded="true"] {
    background: var(--scorm-profile-identity-bg);
    border-color: var(--scorm-primary-color);
}

.scorm-profile-editor__section + .scorm-profile-editor__section {
    margin-top: 28px;
    padding-top: 24px;
    border-top: 1px solid var(--scorm-profile-border-strong);
}

.scorm-profile-editor__section-title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--scorm-heading-color);
}

.scorm-profile-editor__message {
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 14px;
    margin-bottom: 12px;
}

.scorm-profile-editor__message.is-error {
    background: color-mix(in srgb, var(--scorm-failed-color) 10%, var(--scorm-surface-color));
    color: var(--scorm-failed-color);
}

.scorm-profile-editor__message.is-success {
    background: color-mix(in srgb, var(--scorm-completed-color) 10%, var(--scorm-surface-color));
    color: color-mix(in srgb, var(--scorm-completed-color) 80%, var(--scorm-heading-color));
}

.scorm-profile-identity__editor .scorm-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.scorm-profile-identity__editor .scorm-form-group {
    margin-bottom: 14px;
}

.scorm-profile-identity__editor .scorm-form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--scorm-heading-color);
    margin-bottom: 4px;
}

.scorm-profile-identity__editor .scorm-form-group input {
    width: 100%;
    padding: 9px 12px;
    font-family: inherit;
    font-size: 14px;
    color: var(--scorm-text-color);
    background: var(--scorm-surface-color);
    border: 1px solid var(--scorm-profile-border-strong);
    border-radius: 6px;
    line-height: 1.4;
}

.scorm-profile-identity__editor .scorm-form-group input:focus {
    outline: 2px solid color-mix(in srgb, var(--scorm-primary-color) 30%, transparent);
    outline-offset: 1px;
    border-color: var(--scorm-primary-color);
}

.scorm-profile-editor__actions {
    display: flex;
    gap: 10px;
    margin-top: 16px;
    align-items: center;
}

.scorm-profile-editor__actions .btn-loading {
    display: none;
}

.scorm-profile-editor__actions .scorm-btn.is-loading .btn-text {
    display: none;
}

.scorm-profile-editor__actions .scorm-btn.is-loading .btn-loading {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* =========================================================================
   9. Empty states
   ========================================================================= */

.scorm-profile-empty {
    padding: 20px;
    background: var(--scorm-surface-color);
    border: 1px dashed var(--scorm-profile-border);
    border-radius: 10px;
    font-size: 14px;
    color: var(--scorm-muted-text-color);
    text-align: left;
}

.scorm-profile-empty a {
    font-weight: 600;
}

/* Login notice used when the shortcode renders for a logged-out user */
.scorm-login-notice {
    max-width: 480px;
    margin: 48px auto;
    padding: 28px 32px;
    text-align: center;
    background: color-mix(in srgb, var(--scorm-primary-color) 6%, var(--scorm-surface-color));
    border: 1px solid color-mix(in srgb, var(--scorm-primary-color) 18%, var(--scorm-surface-color));
    border-radius: 12px;
}

.scorm-login-notice h3 {
    font-family: Merriweather, Georgia, serif;
    font-size: 22px;
    margin-bottom: 8px;
    color: var(--scorm-heading-color);
}

.scorm-login-notice p {
    color: var(--scorm-muted-text-color);
    margin: 0 0 18px;
}

/* =========================================================================
   10. Responsive
   ========================================================================= */

@media (max-width: 768px) {
    .scorm-my-profile {
        padding: 28px 20px 56px;
    }

    .scorm-profile-two-col {
        grid-template-columns: 1fr;
    }

    .scorm-profile-course-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 14px;
    }

    .scorm-profile-course-row__action {
        width: 100%;
    }

    .scorm-profile-course-row__action .scorm-btn {
        width: 100%;
        justify-content: center;
    }

    .scorm-profile-progress__bar {
        flex: 1 1 auto;
        max-width: none;
    }
}

/* Identity card row layout collapses well before 480px because the avatar
   (84px) + actions stack (~150px) leaves <200px for the name/email column.
   Stack early so 481–600px viewports don't get per-letter wrapping. */
@media (max-width: 600px) {
    .scorm-profile-identity {
        padding: 24px;
    }

    .scorm-profile-resume {
        flex-direction: column;
        align-items: stretch;
    }

    .scorm-profile-resume__action .scorm-btn {
        width: 100%;
        justify-content: center;
    }

    .scorm-profile-identity__top {
        flex-direction: column;
        align-items: flex-start;
        text-align: left;
    }

    .scorm-profile-identity__actions {
        flex-direction: row;
        width: 100%;
    }

    .scorm-profile-identity__actions .scorm-btn {
        flex: 1 1 0;
    }

    .scorm-profile-identity__editor .scorm-form-row {
        grid-template-columns: 1fr;
    }

    .scorm-profile-section__header {
        flex-wrap: wrap;
    }
}

@media (max-width: 380px) {
    .scorm-profile-stats {
        grid-template-columns: 1fr;
    }

    .scorm-profile-identity__avatar {
        width: 72px;
        height: 72px;
        font-size: 28px;
    }

    .scorm-profile-identity__name {
        font-size: 24px;
    }
}
