/* ==========================================================================
   run.events header — standalone, framework-free
   Design tokens mirrored from MyRunEvents/sass (run-event-theme, portal-intro,
   mat-toolbar, mat-sidenav) so this bar reads as part of the run.events
   platform.

   Layout, mirroring the organizer portal's event home:
     1. purple brand bar   — logo, decorative art, user + avatar (opens the menu)
     2. entity row         — the event chip, close button on the right
     3. title row          — event title + breadcrumb, and the HOST APPLICATION'S
                             commands on the right
   ========================================================================== */

/* --- Typography: same webfont the portals use ---------------------------- */

@font-face {
    font-family: 'IBM Plex Sans';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("https://cdn.run.events/fonts/IBMPlexSans-Regular-v2.woff2") format('woff2');
}

@font-face {
    font-family: 'IBM Plex Sans';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url("https://cdn.run.events/fonts/IBMPlexSans-Medium-v2.woff2") format('woff2');
}

@font-face {
    font-family: 'IBM Plex Sans';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url("https://cdn.run.events/fonts/IBMPlexSans-Bold-v2.woff2") format('woff2');
}

/* --- Tokens -------------------------------------------------------------- */

:root {
    --re-primary: #6a4a9e;
    --re-primary-dark: #573a8c;
    --re-primary-contrast: #ffffff;
    --re-secondary: #ec2252;
    --re-tertiary: #f6c713;
    --re-text: #000000;
    --re-light-gray: #e0e0e0;
    --re-card-bg: #f6f7f9;
    --re-surface: #ffffff;
    --re-font: 'IBM Plex Sans', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --re-radius: 5px;
    /* Left/right inset. Set it to match your own toolbar's inset exactly. */
    --re-row-padding: 16px;

    /* Published by the component; read it to size your canvas. */
    --re-header-height: 0px;
}

/* --- Shell --------------------------------------------------------------- */

run-events-header {
    display: block;
    width: 100%;
    flex: 0 0 auto;
    font-family: var(--re-font);
    color: var(--re-text);
    -webkit-font-smoothing: antialiased;
}

/* Reserve the final height before the script upgrades the element,
   so the canvas below does not jump on load. */
run-events-header:not(:defined) {
    min-height: 176px;
    background: var(--re-primary);
}

run-events-header[compact]:not(:defined) {
    min-height: 138px;
}

run-events-header * {
    box-sizing: border-box;
}

/* Content container: flush with the edge, like the host application's own
   toolbar. Change --re-row-padding to shift both rows at once. */
.re-row__inner {
    display: flex;
    align-items: center;
    gap: 16px;
    width: 100%;
    padding: 0 var(--re-row-padding);
}

.re-header a {
    text-decoration: none;
}

.re-header button {
    font-family: inherit;
}

.re-header :focus-visible {
    outline: 2px solid var(--re-primary);
    outline-offset: 2px;
}

.re-brandbar :focus-visible {
    outline-color: var(--re-primary-contrast);
}

/* --- Row 1: the purple brand bar ----------------------------------------- */

.re-brandbar {
    background-color: var(--re-primary);
    color: var(--re-primary-contrast);
}

.re-brandbar .re-row__inner {
    height: 56px;
    gap: 20px;
}

.re-brand-logo {
    display: flex;
    align-items: center;
    flex: 0 0 auto;
    line-height: 1;
}

.re-brand-logo img {
    display: block;
    max-width: 140px;
    max-height: 28px;
    object-fit: contain;
}

/* Decorative strip, exactly like .toolbar-bg-img in the portals. */
.re-brand-art {
    flex: 1 1 auto;
    align-self: stretch;
    max-width: 900px;
    margin-right: 24px;
    background-repeat: no-repeat;
    background-position: center;
    background-size: cover;
}

/* Menu trigger */

.re-brand-right {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-left: auto;
    flex: 0 0 auto;
    border: 0;
    padding: 0;
    background: transparent;
    color: inherit;
    cursor: pointer;
}

.re-hello {
    font-size: 15px;
    line-height: 1.5;
    white-space: nowrap;
}

.re-avatar {
    width: 35px;
    height: 35px;
    min-width: 35px;
    border-radius: 100%;
    background: rgba(255, 255, 255, 0.9);
    color: var(--re-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    transition: opacity 0.3s;
}

.re-brand-right:hover .re-avatar {
    opacity: 0.8;
}

.re-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 100%;
}

/* --- Row 2: the event chip ----------------------------------------------- */

.re-chipbar {
    background: var(--re-surface);
    border-bottom: 1px solid rgba(224, 224, 224, 0.7);
}

.re-chipbar .re-row__inner {
    min-height: 52px;
    padding-top: 8px;
    padding-bottom: 8px;
}

.re-chip {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    max-width: 460px;
    padding: 8px 16px;
    border: 1px solid rgba(224, 224, 224, 0.9);
    border-radius: 8px;
    background: var(--re-surface);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.07);
    color: var(--re-text);
    font-size: 15px;
    line-height: 20px;
    font-weight: 500;
}

a.re-chip {
    transition: box-shadow 0.3s, border-color 0.3s;
}

a.re-chip:hover {
    border-color: rgba(106, 74, 158, 0.5);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.re-chip>i {
    color: var(--re-primary);
    font-size: 16px;
    flex: 0 0 auto;
}

.re-chip-logo {
    width: 22px;
    height: 22px;
    min-width: 22px;
    border-radius: 100%;
    object-fit: cover;
}

.re-chip span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.re-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    margin-left: auto;
    flex: 0 0 auto;
    border: 1px solid rgba(224, 224, 224, 0.9);
    border-radius: var(--re-radius);
    background: var(--re-surface);
    color: #6b6b70;
    font-size: 16px;
    cursor: pointer;
    transition: color 0.3s, border-color 0.3s, background-color 0.3s;
}

.re-close:hover {
    color: var(--re-primary);
    border-color: rgba(106, 74, 158, 0.5);
    background-color: rgba(106, 74, 158, 0.04);
}

/* --- Row 3: title, breadcrumb and the host application's commands -------- */

.re-titlebar {
    background: var(--re-surface);
    border-bottom: 1px solid rgba(224, 224, 224, 0.7);
}

.re-titlebar .re-row__inner {
    min-height: 68px;
    padding-top: 10px;
    padding-bottom: 10px;
    flex-wrap: wrap;
    gap: 12px 24px;
}

.re-title-block {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
    flex: 1 1 auto;
}

.re-title {
    margin: 0;
    font-size: 28px;
    line-height: 1;
    font-weight: 700;
    color: var(--re-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.re-title-status {
    margin-left: 10px;
    font-size: 14px;
    font-weight: 400;
    color: var(--re-primary);
    white-space: nowrap;
}

.re-breadcrumb {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    line-height: 16px;
    color: var(--re-primary);
    min-width: 0;
}

.re-breadcrumb a,
.re-breadcrumb i {
    color: var(--re-primary);
}

.re-breadcrumb a:hover {
    text-decoration: underline;
}

.re-breadcrumb .re-crumb-sep {
    color: var(--re-primary);
    opacity: 0.7;
}

.re-breadcrumb .re-crumb-last {
    color: var(--re-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.re-commands {
    display: flex;
    align-items: center;
    gap: 8px;
    /* Shrinkable: many commands scroll inside this box rather than pushing
       anything past the right edge. */
    flex: 0 1 auto;
    min-width: 0;
    margin-left: auto;
    max-width: 100%;
    overflow-x: auto;
    scrollbar-width: thin;
}

.re-commands>* {
    flex: 0 0 auto;
}

.re-cmd {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 34px;
    padding: 0 14px;
    border: 1px solid var(--re-light-gray);
    border-radius: var(--re-radius);
    background: var(--re-surface);
    color: var(--re-text);
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.01em;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 0.3s, border-color 0.3s, color 0.3s;
}

.re-cmd i {
    font-size: 15px;
}

.re-cmd:hover {
    border-color: var(--re-primary);
    color: var(--re-primary);
    background-color: rgba(106, 74, 158, 0.04);
}

.re-cmd--primary {
    background-color: var(--re-primary);
    border-color: var(--re-primary);
    color: var(--re-primary-contrast);
}

.re-cmd--primary:hover {
    background-color: var(--re-primary-dark);
    border-color: var(--re-primary-dark);
    color: var(--re-primary-contrast);
}

.re-cmd--ghost {
    border-color: transparent;
    background: transparent;
}

.re-cmd--ghost:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

/* Borderless icon + label, like "Design Guidelines" in the portal. */
.re-cmd--link {
    border-color: transparent;
    background: transparent;
    font-weight: 500;
    padding: 0 8px;
}

.re-cmd--link i {
    color: var(--re-primary);
    font-size: 17px;
}

.re-cmd--link:hover {
    background: transparent;
    border-color: transparent;
    color: var(--re-primary);
    text-decoration: underline;
}

.re-cmd--danger {
    border-color: var(--re-secondary);
    color: var(--re-secondary);
}

.re-cmd--danger:hover {
    border-color: var(--re-secondary);
    color: var(--re-secondary);
    background-color: rgba(236, 34, 82, 0.06);
}

.re-cmd.re-cmd--active {
    border-color: var(--re-primary);
    color: var(--re-primary);
    background-color: rgba(106, 74, 158, 0.12);
}

.re-cmd[disabled] {
    opacity: 0.45;
    pointer-events: none;
}

.re-cmd-group {
    display: inline-flex;
    align-items: center;
}

.re-cmd-group .re-cmd {
    border-radius: 0;
    margin-left: -1px;
}

.re-cmd-group .re-cmd:first-child {
    border-radius: var(--re-radius) 0 0 var(--re-radius);
    margin-left: 0;
}

.re-cmd-group .re-cmd:last-child {
    border-radius: 0 var(--re-radius) var(--re-radius) 0;
}

.re-cmd-divider {
    width: 1px;
    height: 22px;
    min-width: 1px;
    margin: 0 4px;
    background: var(--re-light-gray);
}

.re-cmd-spacer {
    flex: 1 1 auto;
    min-width: 8px;
}

/* --- Flyout / sidebar (mirrors the portal's mat-sidenav) ----------------- */

.re-flyout-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

.re-flyout {
    position: fixed;
    top: 0;
    right: 0;
    z-index: 1001;
    width: min(360px, 92vw);
    height: 100%;
    padding: 15px 0 0 0;
    display: flex;
    flex-direction: column;
    background: var(--re-primary);
    color: var(--re-primary-contrast);
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.28);
    transform: translateX(100%);
    transition: transform 0.3s ease;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.re-header.re-menu-open .re-flyout {
    transform: translateX(0);
}

.re-header.re-menu-open .re-flyout-backdrop {
    opacity: 1;
    visibility: visible;
}

.re-flyout-head {
    display: flex;
    justify-content: flex-end;
    margin-right: 15px;
}

.re-flyout-close {
    border: 0;
    background: transparent;
    color: var(--re-primary-contrast);
    font-size: 22px;
    line-height: 1;
    padding: 8px;
    cursor: pointer;
    border-radius: 100%;
    transition: background-color 0.3s;
}

.re-flyout-close:hover {
    background-color: rgba(255, 255, 255, 0.17);
}

.re-flyout-profile {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    padding: 40px 20px 55px;
    text-align: center;
}

.re-flyout-avatar {
    width: 80px;
    height: 80px;
    min-width: 80px;
    border-radius: 100%;
    background: var(--re-surface);
    color: var(--re-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    font-size: 34px;
}

.re-flyout-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 100%;
}

.re-flyout-name {
    margin: 0;
    font-size: 16px;
    line-height: 24px;
    word-break: break-word;
}

.re-flyout-caption {
    font-size: 12px;
    line-height: 16px;
    opacity: 0.8;
}

.re-flyout-links {
    list-style: none;
    margin: 0;
    padding: 0 0 0 40px;
}

.re-flyout-links li {
    border-bottom: 1px solid rgba(0, 0, 0, 0.4);
}

.re-flyout-links li:first-child {
    border-top: 1px solid rgba(0, 0, 0, 0.4);
}

.re-flyout-links a,
.re-flyout-links button {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
    padding: 20px 0;
    border: 0;
    background: transparent;
    color: var(--re-primary-contrast);
    font-size: 16px;
    line-height: 24px;
    text-align: left;
    cursor: pointer;
}

.re-flyout-links i {
    width: 24px;
    padding: 0 15px 0 10px;
    box-sizing: content-box;
    text-align: center;
    font-size: 20px;
}

.re-flyout-links a::before,
.re-flyout-links a::after,
.re-flyout-links button::before,
.re-flyout-links button::after {
    content: "";
    position: absolute;
    top: 0;
    height: 100%;
    opacity: 0;
    transition: opacity 0.3s;
}

.re-flyout-links a::after,
.re-flyout-links button::after {
    left: -40px;
    width: calc(100% + 40px);
    background: rgba(255, 255, 255, 0.17);
}

.re-flyout-links a::before,
.re-flyout-links button::before {
    left: -40px;
    width: 4px;
    background: var(--re-tertiary);
}

.re-flyout-links a:hover::before,
.re-flyout-links a:hover::after,
.re-flyout-links button:hover::before,
.re-flyout-links button:hover::after {
    opacity: 1;
}

.re-flyout-links span {
    position: relative;
}

.re-flyout-footer {
    margin-top: auto;
    padding: 30px 20px;
    text-align: center;
    font-size: 12px;
    line-height: 16px;
    opacity: 0.75;
}

/* --- Compact mode: <run-events-header compact> --------------------------- */

run-events-header[compact] .re-brandbar .re-row__inner {
    height: 48px;
}

run-events-header[compact] .re-brand-logo img {
    max-width: 118px;
    max-height: 28px;
}

run-events-header[compact] .re-avatar {
    width: 30px;
    height: 30px;
    min-width: 30px;
}

run-events-header[compact] .re-chipbar .re-row__inner {
    min-height: 44px;
    padding-top: 5px;
    padding-bottom: 5px;
}

run-events-header[compact] .re-chip {
    padding: 5px 12px;
    font-size: 14px;
}

run-events-header[compact] .re-titlebar .re-row__inner {
    min-height: 54px;
    padding-top: 7px;
    padding-bottom: 7px;
}

run-events-header[compact] .re-title {
    font-size: 22px;
}

run-events-header[compact] .re-cmd {
    height: 32px;
}

run-events-header[compact] .re-flyout-links a,
run-events-header[compact] .re-flyout-links button {
    padding: 15px 0;
}

/* --- Responsive ---------------------------------------------------------- */

@media (max-width: 1100px) {

    /* Decorative strip is the first thing to go. */
    .re-brand-art {
        display: none;
    }

    .re-brand-right {
        margin-left: auto;
    }
}

@media (max-width: 700px) {
    .re-hello {
        display: none;
    }

    .re-title {
        font-size: 22px;
    }

    .re-commands {
        margin-left: 0;
        width: 100%;
    }
}

@media (max-width: 600px) {
    :root {
        --re-row-padding: 16px;
    }

    .re-brandbar .re-row__inner {
        height: 52px;
        gap: 14px;
    }

    .re-brand-logo img {
        max-width: 110px;
        max-height: 26px;
    }

    .re-breadcrumb {
        display: none;
    }
}
