/* ==========================================================================
   TYPOGRAPHY SCALE
   Alle Schriftgrößen im Modul werden über diese Stufen gesetzt – keine
   Einzelwerte oder px/rem-Mischung mehr direkt in den Regeln verwenden.
   ========================================================================== */
   :root {
    --fs-xs:   0.75rem;   /* 12px – Fein-/Metatext: Slider-Labels, Datenschutzhinweis, Badges, Dateigröße, Nav-Label */
    --fs-sm:   0.875rem;  /* 14px – Bedienelemente & Sekundärtext: Edit-/Sort-/Add-/Nav-Buttons, kleine Icons */
    --fs-base: 1rem;      /* 16px – Basis-UI: Primär-Buttons, Popup-Text, Button-Block */
    --fs-md:   1.125rem;  /* 18px – Fließtext: Block-Inhalt, Listen, Accordion-Inhalt, Alerts */
    --fs-lg:   1.375rem;  /* 22px – Kleine Überschriften & Feature-Icons: Accordion-Button, Kacheln, Step-Titel */
    --fs-xl:   1.75rem;   /* 28px – Abschnittsüberschriften: Block-Titel */
    --fs-2xl:  2rem;      /* 32px – Große Icons / mobile Hero-Überschrift */
    --fs-3xl:  3rem;      /* 48px – Hero-Titel */
}

#page-header,
.activity-navigation,
#region-main-settings-menu {
    display: none;
}

.block-container .block-title {
    padding: 0;
    margin: 0;
    font-size: var(--fs-xl);
}

.path-mod #region-main h2.block-title {
    display: block;
}

.alert-success {
    background: #d4edda;
    color: #155724;
}

/* ==========================================================================
   VIEW PAGE STYLES
   ========================================================================== */

/* Blocks Container */
.blocks-container {
    min-height: 200px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
}

.block-container a {
    color: var(--primary, #0f6cbf);
}

/* Block Card */
.block-card {
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
    cursor: move;
    transition: all 0.2s;
}

.block-card:hover {
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

/* Block Header */
.cometascreator-block-header {
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.block-actions button {
    margin-left: 5px;
}
/* Edit Buttons Wrapper - unified for all blocks */

.block-edit-buttons {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
}

.block-edit-buttons a {
    color: var(--black-text, #1a1a1a) !important;
}

.block-edit-buttons-centered {
    position: relative;
    top: auto;
    right: auto;
    justify-content: center;
    margin-bottom: 10px;
}

.block-edit-buttons-centered .block-sort-btn,
.block-edit-buttons-centered .block-edit-btn {
    position: relative;
    top: auto;
    right: auto;
}

.block-edit-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 38px;
    box-sizing: border-box;
    background: #f5f5f5;
    color: #2d2d2d;
    border: 1px solid #e8e8e8;
    border-radius: 6px;
    padding: 0 14px;
    font-size: var(--fs-sm);
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}


.block-sort-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 38px;
    width: 38px;
    box-sizing: border-box;
    background: #f5f5f5;
    color: #2d2d2d;
    border: 1px solid #e8e8e8;
    border-radius: 6px;
    padding: 0;
    margin-right: 3px;
    font-size: var(--fs-sm);
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.block-sort-btn:hover {
    background: #e8e8e8;
    text-decoration: none;
    color: #1a1a1a;
    transform: translateY(-1px);
}

.block-edit-btn:hover {
    background: #e8e8e8;
    text-decoration: none;
    color: #1a1a1a;
    transform: translateY(-1px);
}

.block-edit-btn i {
    font-size: var(--fs-sm);
}

.block-container.block-editable:hover {
    border: 3px solid var(--primary) !important;
    border-radius: 8px;
}

.block-wrapper[data-block-type="multiplechoice"] .block-container,
.block-wrapper[data-block-type="checklist"] .block-container,
.block-wrapper[data-block-type="freetext"] .block-container,
.block-wrapper[data-block-type="slider"] .block-container,
.block-wrapper[data-block-type="matching"] .block-container {
    border: 1px solid #e8e8e8;
    padding: 40px;
}

.block-container {
    border-radius: 8px;
    transition: border 0.2s ease, box-shadow 0.2s ease;
    border: 1px solid transparent;
    max-width: 850px;
    margin: auto;
    margin: 0 auto;
    font-size: var(--fs-base);
    padding: 0;
}

/* Add Block Divider (between blocks in edit mode) */
.block-add-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 10px 0;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.block-add-divider:hover {
    opacity: 1;
}

.block-add-divider::before,
.block-add-divider::after {
    content: '';
    flex: 1;
    height: 2px;
    border-top: 2px dashed var(--primary, #0f6cbf);
}

.block-add-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--primary, #0f6cbf);
    color: white;
    border-radius: 50%;
    text-decoration: none;
    font-size: var(--fs-sm);
    margin: 0 10px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.block-add-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    color: white;
    text-decoration: none;
}

.block-add-btn i {
    line-height: 1;
}

.block-wrapper {
    display: block;
    margin-bottom: 48px;
}

/* Remove margin-bottom on block-wrapper in edit mode */
.edit-mode-active .block-wrapper {
    margin-bottom: 0;
}

.cometascreator-header-wrapper {
    margin-bottom: 40px;
    margin-top: 0;
    position: relative;
}

/* Pull the header wrapper up to sit flush against the top navigation.
   Boost's .main-inner card adds padding-top (1.5rem) plus a margin-top
   (0.5rem base, 1.5rem at >=576px); we cancel both so the hero meets the
   navbar with no gap. */
#page.drawers .cometascreator-header-wrapper {
    margin-top: -2rem;
}

@media (min-width: 576px) {
    #page.drawers .cometascreator-header-wrapper {
        margin-top: -3rem;
    }
}

.cometascreator-header {
    padding: 32px 0 24px 0;
}

.header-settings-btn-wrapper {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 100;
    display: flex;
    gap: 5px;
}

.header-settings-btn-wrapper .btn-edit {
    padding: 8px 14px;
    font-size: var(--fs-sm);
}

.header-settings-btn-wrapper .btn-edit i {
    color: #2d2d2d;
}

.block-container.block_text_normal.has-bg-color {
    padding: 24px;
}

.dark-bg {
    color: #ffffff;
}
.dark-bg .block-content,
.dark-bg .block-content p,
.dark-bg .block-content li,
.dark-bg .block-content a,
.dark-bg .button-inline-content,
.dark-bg .button-inline-content p,
.dark-bg .button-inline-content li,
.dark-bg .button-inline-content a {
    color: rgba(255, 255, 255, 0.92);
}

.block-wrapper.normal {
    width: 100%;
}

.block-wrapper.normal[style*="background-color"] {
    width: 100vw;
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
}

/* Full-width image: rendered as a full-bleed background band, like the hero. */
.block-image-full-width {
    width: 100vw;
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
    margin-bottom: 40px;
    position: relative;
    line-height: 0;
}

.block-image-full-width img {
    width: 100%;
    height: auto;
    display: block;
}

#page.drawers {
    overflow-x: clip;
}

.block-wrapper.callout {
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
    border-radius: 8px;
}

.block-container.block_text_callout {
    border: 3px solid var(--primary);
    border-radius: 8px;
    background-color: rgba(var(--primary-rgb, 15, 108, 191), 0.08);
    padding: 24px;
}

.block-container.block_text_callout.has-bg-color {
    background: none;
}

.block_text_callout h3 {
    color: var(--primary);
}

.cometascreator-markread-btn.dark-bg {
    color: var(--primary);
    background: rgb(237, 237, 237);
    border: 1px solid var(--primary);
}

.title-wrapper {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.btn-edit-title {
    padding: 8px 16px;
    font-size: var(--fs-sm);
}

.cometascreator-hero {
    /* Full-bleed: break out of the content column to the full viewport width. */
    width: 100vw;
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
    height: 350px;
    background-size: cover;
    background-position: left center;
    background-repeat: no-repeat;
}

/* When the left drawer is open, the hero must shift right so its left edge
   aligns with the drawer border instead of staying centred.
   158.5px = drawer-margin-left(285) − hero-left-without-offset(126.5). */
body.drawer-open-left .cometascreator-hero,
#page.drawers.show-drawer-left .cometascreator-hero {
    margin-left: calc(50% - 50vw + 158.5px);
    margin-right: calc(50% - 50vw - 158.5px);
}

/* Right drawer (315px): offset 141.5px. */
body.drawer-open-right .cometascreator-hero,
#page.drawers.show-drawer-right .cometascreator-hero {
    margin-left: calc(50% - 50vw + 141.5px);
    margin-right: calc(50% - 50vw - 141.5px);
}

/* Both drawers open simultaneously: offset 300px. */
body.drawer-open-left.drawer-open-right .cometascreator-hero,
#page.drawers.show-drawer-left.show-drawer-right .cometascreator-hero {
    margin-left: calc(50% - 50vw + 300px);
    margin-right: calc(50% - 50vw - 300px);
}

.cometascreator-header {
    background: white;
    border-bottom: 1px solid #e8e8e8;
    padding: 48px 0 40px 0;
}

.cometascreator-header .container-custom {
    max-width: 900px;
    margin: 0 auto;
    padding: 24px 24px;
}

.cometascreator-header.has-hero {
    padding: 32px 0 28px 0;
    margin-bottom: 40px;
}

.cometascreator-title {
    font-size: var(--fs-3xl);
    font-weight: 800;
    line-height: 1.2;
    color: #1a1a1a;
    margin: 0 0 20px 0;
    letter-spacing: -0.03em;
}

.btn-edit {
    display: inline-block;
    padding: 12px 24px;
    background: #f5f5f5;
    color: #2d2d2d;
    border-radius: 8px;
    text-decoration: none;
    font-size: var(--fs-base);
    font-weight: 600;
    transition: all 0.2s ease;
    border: 1px solid #e8e8e8;
}

.btn-edit:hover {
    background: #e8e8e8;
    text-decoration: none;
    color: #1a1a1a;
}

/* ==========================================================================
   RESPONSIVE DESIGN
   ========================================================================== */

@media (max-width: 768px) {
    .cometascreator-title {
        font-size: var(--fs-2xl);
    }

    .cometascreator-hero {
        height: 250px;
    }

    .cometascreator-header {
        padding: 32px 0 24px 0;
    }

    .cometascreator-header.has-hero {
        padding: 24px 0 20px 0;
    }

    .cometascreator-content {
        padding: 32px 16px;
    }

    /* .block-container {
        margin-bottom: 32px;
    } */

    .block-title {
        font-size: var(--fs-xl);
        padding: 32px 24px 0 24px;
    }

    .block-content {
        font-size: var(--fs-md);
        padding: 0;
    }

    .rise-accordion-button {
        padding: 24px;
        font-size: var(--fs-md);
    }

    .rise-accordion-content {
        padding: 0 24px 32px 24px;
        font-size: var(--fs-md);
    }

    .block-container[data-block-type="multiplechoice"],
    .block-container[data-block-type="checklist"],
    .block-container[data-block-type="freetext"],
    .block-container[data-block-type="slider"],
    .block-container[data-block-type="matching"],
    .block-container[data-block-type="image"] {
        padding: 24px 0;
    }
}

/* ==========================================================================
   ACCORDION STYLES
   ========================================================================== */

.rise-accordion {
    border: none;
    border-radius: 12px;
    overflow: hidden;
    background: white;
    border: 1px solid #e8e8e8;
}

.rise-accordion-item {
    border-bottom: 1px solid #e8e8e8;
}

.rise-accordion-item:last-child {
    border-bottom: none;
}

.rise-accordion-button {
    width: 100%;
    padding: 22px 30px;
    background: white;
    border: none;
    text-align: left;
    cursor: pointer;
    font-size: var(--fs-lg);
    font-weight: 600;
    color: #1a1a1a;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background-color 0.2s ease;
    letter-spacing: -0.01em;
}

.rise-accordion-button:hover {
    background-color: #fafafa;
}

.rise-accordion-button:focus {
    outline: none;
}

.rise-accordion-title {
    flex: 1;
    padding-right: 24px;
}

.rise-accordion-icon {
    font-size: var(--fs-2xl);
    font-weight: 300;
    color: #666;
    line-height: 1;
    transition: transform 0.3s ease, color 0.3s ease;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.rise-accordion-button:hover .rise-accordion-icon {
    color: #1a1a1a;
}

.rise-accordion-button[aria-expanded="true"] .rise-accordion-icon {
    transform: rotate(45deg);
}

.rise-accordion-content {
    padding: 20px 40px 40px 40px;
    font-size: var(--fs-md);
    line-height: 1.7;
    color: #2d2d2d;
}

.rise-accordion .collapse {
    transition: none;
}

.rise-accordion .collapse.show {
    display: block;
}

.rise-accordion .collapse:not(.show) {
    display: none;
}

/* Benutzerdefinierte Farbe: Der Hintergrund kommt inline auf .rise-accordion-item,
   der Kopf ist dann transparent. Dunkle Farben (.dark-bg) bekommen weisse Schrift. */
.rise-accordion.has-color .rise-accordion-button {
    background: transparent;
}

.rise-accordion.has-color .rise-accordion-button:hover {
    background-color: rgba(0, 0, 0, 0.04);
}

.rise-accordion.dark-bg .rise-accordion-button,
.rise-accordion.dark-bg .rise-accordion-icon,
.rise-accordion.dark-bg .rise-accordion-button:hover .rise-accordion-icon {
    color: #ffffff;
}

.rise-accordion.dark-bg .rise-accordion-item {
    border-color: rgba(255, 255, 255, 0.2);
}

/* Akkordeon mit 2 Einträgen pro Zeile: jedes Item als eigene Karte.
   Jedes geöffnete Item belegt zwei Grid-Zeilen (Kopf + Inhalt) als Subgrid.
   Dadurch sind geöffnete Karten einer Zeile gleich hoch (das höchste
   bestimmt die Höhe) und ihre Köpfe stehen auf gleicher Höhe.
   Unter 769px greift wieder das normale einspaltige Akkordeon. */
@media (min-width: 769px) {
    .rise-accordion.cols-2 {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        column-gap: 16px;
        row-gap: 0; /* Zeilenabstand via margin-bottom der Items, sonst landet er zwischen Kopf und Inhalt */
        margin-bottom: -16px; /* gleicht den Abstand unter der letzten Zeile aus */
        border: none;
        border-radius: 0;
        overflow: visible;
        background: transparent;
    }

    .rise-accordion.cols-2 .rise-accordion-item,
    .rise-accordion.cols-2 .rise-accordion-item:last-child {
        display: grid;
        grid-row: span 2;
        grid-template-rows: subgrid;
        margin-bottom: 16px;
        border: 1px solid #e8e8e8;
        border-radius: 12px;
        overflow: hidden;
        background: white;
    }

    /* Geschlossene Items werden nicht mitgezogen: kein Subgrid, nur so hoch
       wie der eigene Kopf. Gleiche Höhe gilt nur unter geöffneten Items. */
    .rise-accordion.cols-2 .rise-accordion-item:not(:has(> .collapse.show)) {
        display: block;
        align-self: start;
    }

    .rise-accordion.cols-2 .rise-accordion-button {
        padding: 20px 24px;
        font-size: var(--fs-md);
    }

    .rise-accordion.cols-2 .rise-accordion-title {
        padding-right: 16px;
    }

    .rise-accordion.cols-2 .rise-accordion-content {
        padding: 20px 24px 32px 24px;
    }
}

/* ==========================================================================
   LIST BLOCK STYLES
   ========================================================================== */

/* List mode - clean list without bullets */
.list-block-items {
    list-style: none;
    padding: 0;
    margin: 0;
}

.checklist-progress,
.flipcards-progress {
    border-top: 1px solid #eee;
    padding-top: 12px;
}

.checklist-progress-count,
.flipcards-progress-count {
    color: #4f46e5;
    font-weight: 600;
}

.checklist-checkbox {
    accent-color: #4f46e5;
}

.option-item.checklist-checked {
    border-color: #c7d2fe;
    background: #eef2ff;
}

.option-item.checklist-checked:hover {
    border-color: #a5b4fc;
    background: #e0e7ff;
}

.option-item.checklist-checked .option-label {
    color: #3730a3;
}

.option-item {
    background: #f8f9fa;
    padding: 0;
    margin-bottom: 10px;
    border-radius: 8px;
    border: 1px solid #e8e8e8;
    overflow: hidden;
}

.option-item:hover,
.option-item label:hover {
    cursor: pointer;
}

.option-item label {
    display: flex;
    align-items: center;
    width: 100%;
    margin: 0;
    padding: 12px 16px;
    cursor: pointer;
}

/* Drag-to-reorder handle on editor item rows. */
.drag-handle {
    cursor: grab;
    color: #9ca3af;
    touch-action: none;
}

.drag-handle:active {
    cursor: grabbing;
}

.sortable-dragging {
    opacity: 0.5;
}

.option-item input[type="radio"], .option-item input[type="checkbox"] {
    width: 20px;
    height: 20px;
    min-width: 20px;
    min-height: 20px;
    flex-shrink: 0;
    margin-right: 16px;
    cursor: pointer;
    outline: none;
}

.option-item input[type="radio"]:focus, .option-item input[type="checkbox"]:focus {
    box-shadow: none;
}

.list-block-items > li {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 12px 0;
    border-bottom: 1px solid #eee;
    font-size: var(--fs-md);
    line-height: 1.7;
}

.list-block-items > li:last-child {
    border-bottom: none;
}

.list-item-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #6b7280;
    color: white;
    border-radius: 10px;
    font-size: var(--fs-md);
}

.list-item-content {
    flex: 1;
    min-width: 0;
}

.list-item-title {
    color: #1a1a1a;
    font-size: var(--fs-md);
}

.list-item-text {
    color: #2d2d2d;
    font-size: var(--fs-md);
    line-height: 1.7;
}

.list-item-text p {
    margin: 0 0 8px 0;
}

.list-item-text p:last-child {
    margin-bottom: 0;
}

.list-item-text a {
    color: #0066cc;
    text-decoration: underline;
}

/* Tiles mode - 3 columns, equal width and height */
.list-tiles-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    align-items: stretch;
    width: 100%;
    box-sizing: border-box;
    margin-top: 15px;
}

.list-tiles-container.cols-2 {
    grid-template-columns: repeat(2, 1fr);
}

.list-tiles-container.cols-3 {
    grid-template-columns: repeat(3, 1fr);
}

.list-tile {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 12px;
    padding: 20px;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-width: 0; /* Wichtig: verhindert Overflow */
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* .list-tile:hover {
    background: #fff;
    border-color: #9ca3af;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
} */

.list-tile-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #6b7280;
    color: white;
    border-radius: 12px;
    font-size: var(--fs-lg);
    margin-bottom: 12px;
}

.list-tile-title {
    font-size: var(--fs-md);
    font-weight: 600;
    /*color: #1a1a1a;*/
    margin-bottom: 8px;
    text-align: left;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.list-tile-content {
    font-size: var(--fs-base);
    line-height: 1.6;
    /*color: #555;*/
    text-align: left;
    flex: 1;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.list-tile-content p {
    margin: 0 0 8px 0;
}

.list-tile-content p:last-child {
    margin-bottom: 0;
}

.list-tile-content a {
    color: inherit;
    text-decoration: underline;
}

/* Responsive tiles */
@media (max-width: 992px) {
    .list-tiles-container.cols-3 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 576px) {
    .list-tiles-container,
    .list-tiles-container.cols-2,
    .list-tiles-container.cols-3 {
        grid-template-columns: 1fr;
    }

    /* Kein geerbtes 24px-Padding aus der generischen .block-content-Regel */
    .list-tile .list-tile-content {
        padding: 0;
    }
}

/* Steps Mode - Process/Carousel Style */
.list-steps-container {
    position: relative;
    margin-top: 15px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.list-step {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 16px;
    padding: 32px;
    display: flex;
    flex-direction: column;
}

.step-title {
    font-size: var(--fs-lg);
    font-weight: 700;
    margin: 0 0 16px 0;
    color: #1a1a1a;
}

.path-mod #region-main h2.step-title {
    display: block;
}

.step-content {
    font-size: var(--fs-md);
    line-height: 1.7;
    color: #2d2d2d;
    flex: 1;
}

.step-content p {
    margin: 0 0 12px 0;
}

.step-content p:last-child {
    margin-bottom: 0;
}

.step-navigation {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.step-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2px solid currentColor;
    background: transparent;
    color: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--fs-md);
    transition: all 0.2s ease;
    opacity: 0.6;
}

.step-btn:hover {
    opacity: 1;
    transform: scale(1.1);
}

.step-btn:active {
    transform: scale(0.95);
}

.step-btn i {
    line-height: 1;
}

/* Text Block with Image */
.text-with-image {
    display: flex;
    gap: 24px;
    align-items: flex-start;
    flex-wrap: wrap;
    padding-top: 15px;
}

.text-image-wrapper {
    min-width: 200px;
}

.text-content-wrapper {
    min-width: 200px;
}

.text-content-wrapper .block-content {
    padding-top: 0;
}

/* Give image wrapper the same bottom spacing as the text content
   so flex align-items (center/flex-end) aligns them correctly.
   We use padding-bottom on the wrapper since padding is inside the flex-item box. */
.text-with-image .text-image-wrapper {
    padding-bottom: 20px;
}

.text-with-image .text-content-wrapper .block-content p:last-child {
    margin-bottom: 0;
}

.text-with-image .text-content-wrapper .block-content {
    padding-bottom: 20px;
}

.text-block-image {
    width: 100%;
    height: auto;
    border-radius: 8px;
    object-fit: cover;
}

/* Mobile: Stack vertically */
@media (max-width: 768px) {
    .text-with-image {
        flex-direction: column;
    }

    .text-with-image .text-content-wrapper {
        flex: 1 1 100% !important;
        min-width: 100%;
    }

    /* On mobile, always show image first regardless of position setting */
    .text-with-image .text-image-wrapper {
        order: -1;
    }

    /* Default: full width on mobile */
    .text-with-image .text-image-wrapper {
        flex: 1 1 100% !important;
        min-width: 100% !important;
        padding: 0 24px;
    }

    /* For small image splits (10-30%), scale image proportionally on mobile */
    .text-with-image.text-with-image-split-10 .text-image-wrapper,
    .text-with-image.text-with-image-split-20 .text-image-wrapper,
    .text-with-image.text-with-image-split-30 .text-image-wrapper {
        flex: 0 0 auto !important;
        min-width: 0 !important;
        display: flex;
        justify-content: flex-start;
    }

    .text-with-image.text-with-image-split-10 .text-image-wrapper .text-block-image {
        width: 30% !important;
        height: auto;
    }

    .text-with-image.text-with-image-split-20 .text-image-wrapper .text-block-image {
        width: 40% !important;
        height: auto;
    }

    .text-with-image.text-with-image-split-30 .text-image-wrapper .text-block-image {
        width: 50% !important;
        height: auto;
    }
}
/* ==========================================================================
   MATCHING BLOCK
   ========================================================================== */

.matching-rows {
    display: flex;
    gap: 20px;
}

.matching-col-left,
.matching-col-right {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.matching-dnd-item {
    background: #fff;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    padding: 16px 20px;
    line-height: 1.5;
    min-height: 60px;
    display: flex;
    align-items: center;
    transition: all 0.2s ease;
    gap: 12px;
}

.matching-dnd-fixed {
    background: #f8f9fa;
}

.matching-dnd-draggable {
    background: #fff;
    border-color: var(--primary, #0f6cbf);;
    cursor: grab;
    user-select: none;
}

.matching-dnd-draggable:hover {
    border-color: var(--primary, #0f6cbf);
    box-shadow: 0 2px 6px rgba(13, 110, 253, 0.15);
    transform: translateY(-1px);
}

.matching-dnd-draggable:active {
    cursor: grabbing;
}

.matching-dragging {
    opacity: 0.4;
    cursor: grabbing !important;
}

.matching-number {
    min-width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #e9ecef;
    border-radius: 20%;
    font-weight: 600;
    font-size: var(--fs-xs);
    color: #6c757d;
    flex-shrink: 0;
}

@media (max-width: 576px) {
    .matching-rows {
        flex-direction: column;
    }

    .matching-col-left {
        border-bottom: 2px solid #dee2e6;
        padding-bottom: 12px;
    }
}

/* ==========================================================================
   SLIDER BLOCK
   ========================================================================== */

.slider-block-inner {
    padding: 20px 0 8px;
}

.slider-labels {
    display: flex;
    justify-content: space-between;
    font-size: var(--fs-xs);
    color: #9ca3af;
    margin-bottom: 10px;
}

.slider-label-min,
.slider-label-max {
    max-width: 45%;
}

.slider-track-wrapper {
    position: relative;
}

.slider-dots {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    transform: translateY(-50%);
    pointer-events: none;
    height: 0;
}

.slider-dot {
    position: absolute;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.55);
    transform: translate(-50%, -50%);
}

.slider-dot.dot-right {
    background: rgba(0, 0, 0, 0.18);
}

.slider-input {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 16px;
    border-radius: 999px;
    background: #e5e7eb;
    outline: none;
    cursor: pointer;
    margin: 0;
    display: block;
}

.slider-input::-webkit-slider-runnable-track {
    height: 16px;
    border-radius: 999px;
}

.slider-input::-moz-range-track {
    height: 16px;
    border-radius: 999px;
    background: #e5e7eb;
}

.slider-input::-moz-range-progress {
    height: 16px;
    border-radius: 999px;
}

.slider-input::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #ffffff;
    border: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.20);
    cursor: pointer;
    margin-top: -7px;
    transition: box-shadow 0.15s ease, transform 0.1s ease;
}

.slider-input::-moz-range-thumb {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #ffffff;
    border: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.20);
    cursor: pointer;
    transition: box-shadow 0.15s ease, transform 0.1s ease;
}

.slider-input:hover::-webkit-slider-thumb {
    box-shadow: 0 3px 14px rgba(0, 0, 0, 0.28);
    transform: scale(1.08);
}

.slider-input:hover::-moz-range-thumb {
    box-shadow: 0 3px 14px rgba(0, 0, 0, 0.28);
}

.slider-input:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.slider-input:disabled::-webkit-slider-thumb {
    cursor: not-allowed;
}

.slider-value-display {
    text-align: center;
    font-size: var(--fs-md);
    font-weight: 500;
    color: #374151;
    margin-top: 10px;
    line-height: 1;
}

.slider-submit-row {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: flex-start;
    flex-wrap: wrap;
    margin-top: 20px;
}

.slider-feedback {
    margin-top: 12px;
}

.slider-question {
    margin-bottom: 12px;
    color: #374151;
}

.slider-privacy-notice {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: var(--fs-xs);
    padding: 5px 10px;
    border-radius: 6px;
    margin-bottom: 14px;
}

.slider-privacy-private {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

/* Hide "correct answer" checkbox in mood mode */
#slider-ranges-container .range-correct-row {
    display: none;
}

#slider-ranges-container.slider-mode-test .range-correct-row {
    display: block;
}

/* ==========================================================================
   Button block
   ========================================================================== */
.button-block {
    padding: 20px 0;
}
.button-block a {
    color: white;
}

.button-block-btn {
    display: inline-block;
    font-size: var(--fs-base);
    padding: 14px 32px;
    border-radius: 50px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s ease;
    background: var(--primary, #0f6cbf);
    color: #fff;
}

.button-block-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    background: var(--primary-dark, #0a5293);
    color: #fff;
    text-decoration: none;
}

/* Button painted in the infobox colour instead of the theme colour. Needs to
   out-specify button.button-block-btn (which removes the border) and
   .button-block-btn:hover (which forces the primary colour back), hence the
   element + two classes. Light/dark text follows the same .dark-bg class the
   infobox uses, set server-side by mod_cometascreator_is_dark_color(). */
button.button-block-btn.button-block-btn-boxcolor {
    background: var(--cc-btn-inline-bg, #FAFAF8);
    color: #1a1a1a;
    border: 1px solid color-mix(in srgb, var(--cc-btn-inline-bg, #FAFAF8) 100%, black 15%);
}

button.button-block-btn.button-block-btn-boxcolor:hover {
    background: color-mix(in srgb, var(--cc-btn-inline-bg, #FAFAF8) 100%, black 8%);
    color: #1a1a1a;
}

button.button-block-btn.button-block-btn-boxcolor.dark-bg,
button.button-block-btn.button-block-btn-boxcolor.dark-bg:hover {
    color: #ffffff;
    border-color: color-mix(in srgb, var(--cc-btn-inline-bg, #FAFAF8) 100%, white 25%);
}

/* Optional icon in front of the button label. Margin rather than flex gap so
   the anchor variant keeps its inline-block layout. */
.button-block-icon {
    margin-right: 10px;
}

/* Button as actual button (for popup) */
button.button-block-btn {
    border: none;
    cursor: pointer;
}

/* Button Popup Modal */
.button-popup-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.button-popup-overlay.active {
    opacity: 1;
}

.button-popup-modal {
    background: #fff;
    border-radius: 16px;
    padding: 32px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    transform: scale(0.9) translateY(20px);
    transition: transform 0.2s ease;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.button-popup-overlay.active .button-popup-modal {
    transform: scale(1) translateY(0);
}

.button-popup-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 36px;
    height: 36px;
    border: none;
    background: #f3f4f6;
    border-radius: 50%;
    font-size: var(--fs-lg);
    line-height: 1;
    cursor: pointer;
    color: #6b7280;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.button-popup-close:hover {
    background: #e5e7eb;
    color: #1f2937;
}

.button-popup-title {
    margin: 0 0 16px 0;
    padding-right: 40px;
    color: #1a1a1a;
}

.button-popup-content {
    font-size: var(--fs-base);
    line-height: 1.7;
    color: #2d2d2d;
}

.button-popup-content p {
    margin: 0 0 12px 0;
}

.button-popup-content p:last-child {
    margin-bottom: 0;
}

.button-popup-content a {
    color: var(--primary, #0f6cbf);
    text-decoration: underline;
}

.button-popup-content ul,
.button-popup-content ol {
    margin: 0 0 12px 0;
    padding-left: 24px;
}

.button-popup-content li {
    margin-bottom: 6px;
}

/* Button inline infobox (variant c): the trigger is replaced in place by the
   information panel. Modelled on the "pill" pattern from the reveal_cards
   study (variant 14A): narrower than the surrounding block elements, centred,
   and scaling up on open.

   The background colour is author-picked; the border is derived from it with
   color-mix() so a light background (e.g. pale yellow) automatically gets a
   darker border in the same hue. */
.button-inline-box {
    position: relative;
    width: 100%;
    max-width: 640px;
    /* No top margin: the box must start at the same height as the button it
       replaces, otherwise opening it looks like the content jumps down. */
    margin: 0 auto;
    box-sizing: border-box;
    padding: 1.3rem 1.5rem;
    border-radius: 12px;
    text-align: left;
    background-color: var(--cc-btn-inline-bg, #FAFAF8);
    border: 1px solid color-mix(in srgb, var(--cc-btn-inline-bg, #FAFAF8) 100%, black 15%);
    animation: button-inline-in 0.42s cubic-bezier(0.34, 1.45, 0.64, 1);
}

@keyframes button-inline-in {
    from { opacity: 0; transform: scale(0.72); }
    60%  { opacity: 1; }
    to   { opacity: 1; transform: scale(1); }
}

.button-inline-box[hidden] {
    display: none;
}

.button-inline-close {
    position: absolute;
    top: 10px;
    right: 12px;
    background: none;
    border: none;
    padding: 4px;
    line-height: 1;
    font-size: 15px;
    color: rgba(0, 0, 0, 0.45);
    cursor: pointer;
    transition: color 0.15s;
}

.button-inline-close:hover {
    color: rgba(0, 0, 0, 0.8);
}

/* Not a heading: the block header above already carries the block's h2, so a
   second heading inside the box would be structurally wrong. Keeping it a div
   also sidesteps the rule that hides bare h2 elements inside #region-main. */
.button-inline-title {
    margin: 0 0 8px 0;
    padding-right: 40px;
    font-size: 17px;
    font-weight: 700;
    line-height: 1.3;
    color: #1a1a1a;
}

.button-inline-content {
    font-size: var(--fs-base);
    line-height: 1.7;
    color: #2d2d2d;
}

.button-inline-content p {
    margin: 0 0 12px 0;
}

.button-inline-content p:last-child {
    margin-bottom: 0;
}

.button-inline-content a {
    color: var(--primary, #0f6cbf);
    text-decoration: underline;
}

.button-inline-content ul,
.button-inline-content ol {
    margin: 0 0 12px 0;
    padding-left: 24px;
}

.button-inline-content li {
    margin-bottom: 6px;
}

/* Dark infobox background. The text colours come from the shared .dark-bg rule
   further up (same class the text and list blocks use, set server-side by
   mod_cometascreator_is_dark_color()); only what is specific to this box is
   defined here. The border has to mix towards white instead of black - a dark
   border on a dark box would be invisible. */
.button-inline-box.dark-bg {
    border-color: color-mix(in srgb, var(--cc-btn-inline-bg, #FAFAF8) 100%, white 25%);
}

.button-inline-box.dark-bg .button-inline-close {
    color: rgba(255, 255, 255, 0.6);
}

.button-inline-box.dark-bg .button-inline-close:hover {
    color: #ffffff;
}

@media (prefers-reduced-motion: reduce) {
    .button-inline-box {
        animation: none;
    }
}

/* ==========================================================================
   Download block
   ========================================================================== */
.download-block {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 16px;
    background: #f9fafb;
}

.download-block-link,
.download-block-content {
    display: flex;
    align-items: center;
    gap: 16px;
}

.download-block-link {
    text-decoration: none;
    color: inherit;
}

.download-block-link:hover {
    text-decoration: none;
    color: inherit;
}

.download-block-icon {
    flex-shrink: 0;
    font-size: var(--fs-2xl);
    color: var(--primary, #0f6cbf);
    line-height: 1;
}

.download-block-info {
    flex: 1;
    min-width: 0;
}

.download-block-filename {
    font-weight: 500;
    color: #374151;
    word-break: break-all;
}

.download-block-size {
    font-size: var(--fs-sm);
    color: #9ca3af;
    margin-top: 2px;
}

.download-block-description {
    font-size: var(--fs-sm);
    color: #6b7280;
    margin-top: 8px;
}

.download-block-action {
    flex-shrink: 0;
}

.download-block-action .btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

/* ==========================================================================
   Iframe / Embed block
   ========================================================================== */
/* Full-width mode: aspect ratio via the padding-bottom trick. */
.block-iframe-container {
    width: 100%;
    position: relative;
    overflow: hidden;
    height: 0;
}

.block-iframe-container iframe,
.block-iframe-container embed,
.block-iframe-container object,
.block-iframe-container video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

/* Full-HTML mode: scrollable, no fixed aspect ratio. */
.block-iframe-fullhtml {
    height: auto;
    min-height: 600px;
    padding-bottom: 0;
    overflow: auto;
}

.block-iframe-fullhtml iframe {
    position: relative;
    height: 600px;
    min-height: 600px;
}

/* Normal-width mode: aspect ratio via the CSS aspect-ratio property. */
.block-iframe-normal {
    height: auto;
    padding-bottom: 0;
    border-radius: 12px;
}

.iframe-aspect-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: var(--iframe-aspect, 16 / 9);
}

.iframe-aspect-wrapper iframe,
.iframe-aspect-wrapper embed,
.iframe-aspect-wrapper object,
.iframe-aspect-wrapper video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

/* ==========================================================================
   Interactive Scene block
   ========================================================================== */
/* The iframe auto-sizes its own height via the cometas bridge, so the wrapper
   only controls width. */
.cometas-interactive-frame-wrapper {
    width: 100%;
    border-radius: 12px;
    overflow: hidden;
}

.cometas-interactive-frame {
    display: block;
    width: 100%;
    border: 0;
}

/* Medium mode: wider than the 900px reading column but still centred, capped at
   1100px. Breaks out of the column using the same centre-relative offset as the
   full-bleed image band (calc(50% - W/2)); the 16px gutter and the page-level
   overflow-x: clip keep it from spawning a horizontal scrollbar on narrow
   viewports. The plain width cap (min 100%, 1100px) fails here because 100%
   resolves against the 900px container, so it could never grow past it.
   Shared with the click demo's medium width. */
.cometas-interactive-medium,
.clickdemo-width-medium {
    width: min(1100px, calc(100vw - 32px));
    max-width: 100vw;
    margin-left: calc(50% - min(550px, calc(50vw - 16px)));
    margin-right: calc(50% - min(550px, calc(50vw - 16px)));
}

/* Full-width mode: break out of the content column to the full viewport, using
   the identical full-bleed technique as the full-width image band
   (.block-image-full-width) and the hero. */
.cometas-interactive-full {
    width: 100vw;
    max-width: 100vw;
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
    border-radius: 0;
}

.cometascreator-reset-btn {
    background: transparent;
    color: #999;
    border: 1.5px solid #ccc;
    margin-left: 8px;
}

.cometascreator-btn {
    padding: 10.5px 14px;
}

.alert {
    padding: 20px 24px;
    border-radius: 8px;
    font-size: var(--fs-md);
    line-height: 1.6;
    border: none;
    margin: 0;
}

.multiplechoice-completed .option-item:has(input:checked) {
    opacity: 1;
    border-color: #28a745;
    background: #d4edda;
    border-width: 2px;
}

.options-container {
    margin-bottom: 32px;
}

.video-transcript-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--primary, #0f6cbf);
    color: #fff;
    border: none;
    border-radius: 50px;
    font-size: var(--fs-base);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.video-transcript-toggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    background: var(--primary-dark, #0a5293);
}

.video-transcript-toggle.active {
    background: var(--primary-dark, #0a5293);
}

/* Video Transcript Toggle */
.video-transcript-wrapper {
    margin-top: 16px;
    text-align: center;
}

.video-transcript-text {
    text-align: left;
}

/* ==========================================================================
   Footer activity navigation (previous / overview / next)
   ========================================================================== */

.activity-nav-wrapper {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 24px;
}

.activity-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 20px 0;
    border-top: 1px solid #e5e7eb;
    margin-top: 32px;
}

.activity-nav .nav-left {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.activity-nav .nav-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.activity-nav .next-info {
    text-align: left;
    margin-right: 16px;
}

.activity-nav .next-label {
    font-size: var(--fs-xs);
    color: #6b7280;
    line-height: 1.3;
}

.activity-nav .next-title {
    font-size: var(--fs-sm);
    font-weight: 600;
    color: #374151;
    margin-top: 2px;
    line-height: 1.3;
}

.activity-nav .nav-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: var(--fs-base);
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
    white-space: nowrap;
}

.activity-nav .nav-btn:hover {
    background: #e5e7eb;
    border-color: #d1d5db;
    text-decoration: none;
    color: #374151;
}

/* Overview button: secondary style, smaller */
.activity-nav .nav-btn-overview {
    font-size: var(--fs-sm);
    color: #6b7280;
    padding: 10px 14px;
}

.activity-nav .nav-btn-overview:hover {
    color: #374151;
}

/* Previous: arrow nudges left on hover */
.activity-nav .nav-btn-prev i {
    transition: transform 0.2s;
}

.activity-nav .nav-btn-prev:hover i {
    transform: translateX(-3px);
}

/* Next: arrow nudges right on hover */
.activity-nav .nav-btn-next i {
    transition: transform 0.2s;
}

.activity-nav .nav-btn-next:hover i {
    transform: translateX(3px);
}

/* Responsive: stack on small screens */
@media (max-width: 540px) {
    .activity-nav {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .activity-nav .nav-left,
    .activity-nav .nav-right {
        justify-content: center;
    }

    .activity-nav .next-info {
        margin-right: 0;
        text-align: center;
    }
}

/* ============================================================
   Branching / reveals (runtime)
   ============================================================ */

/* Applied by renderer.php on conditional wrappers; removed by visibility.js
   when a reveal rule fires. */
.cc-hidden {
    display: none !important;
}

/* Edit-mode branching badges. The renderer stamps .cc-trigger on blocks that
   carry reveal rules and .cc-conditional on reveal targets (edit mode only),
   turned into small coloured icon badges in the block-edit-buttons bar.
   Font-family covers FA 4/5/6 across themes. */
.cc-trigger .block-edit-buttons::before,
.cc-conditional .block-edit-buttons::after {
    font-family: "Font Awesome 6 Free", "Font Awesome 5 Free", FontAwesome, fontawesome;
    font-weight: 900;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    font-size: var(--fs-sm);
    margin-right: 6px;
    order: -1;
}

/* Trigger: violet fork badge */
.cc-trigger .block-edit-buttons::before {
    content: "\f126";  /* fa-code-fork */
    background: #f3e8ff;
    color: #9333ea;
}

/* Conditional: blue bolt badge */
.cc-conditional .block-edit-buttons::after {
    content: "\f0e7";  /* fa-bolt */
    background: #dbeafe;
    color: #2563eb;
}

.block-wrapper[data-block-type] {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 500ms ease-out, transform 500ms ease-out;
    scroll-margin-top: 50vh;
}

.block-wrapper[data-block-type].block-visible {
    opacity: 1;
    transform: translateY(0);
}

/* Subtle image zoom-in to match the original's polish. */
.block-wrapper[data-block-type="text"] .text-block-image {
    transform: scale(0.9);
    transition: transform 600ms ease-out;
}

.block-wrapper[data-block-type="text"].block-visible .text-block-image {
    transform: scale(1);
}

/* Accessibility: no motion + never leave a block stuck invisible. */
@media (prefers-reduced-motion: reduce) {
    .block-wrapper[data-block-type] {
        opacity: 1;
        transform: none;
        transition: none;
    }

    .block-wrapper[data-block-type="text"] .text-block-image {
        transform: none;
    }
}

.cometascreator-tts-play-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: transparent;
    color: var(--primary, #0f6cbf);
    border: 1px solid var(--primary, #0f6cbf);
    border-radius: 999px;
    padding: 6px 14px;
    font-size: var(--fs-sm);
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.cometascreator-tts-audio {
    width: 100%;
    max-width: 400px;
    height: 36px;
    margin-top: 8px;
}

.cometascreator-tts-play-btn:hover {
    background: var(--primary, #0f6cbf);
    color: #fff;
}

.cometascreator-tts-play-btn[data-tts-loading="1"],
.cometascreator-tts-play-btn:disabled {
    opacity: 0.7;
    cursor: wait;
}

/* Soft fade-in + slide-up when a block is revealed mid-session. Added by
   visibility.js and removed ~0.8s later so it only plays once per reveal. */
.cc-just-revealed {
    animation: cc-reveal 0.5s ease-out;
}

@keyframes cc-reveal {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (prefers-reduced-motion: reduce) {
    .cc-just-revealed {
        animation: none;
    }
}

/* Floating scroll hint shown when new blocks are revealed below the viewport.
   Centered on the content axis: visibility.js sets the inline `left` in px. */
.cc-scroll-hint {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(80px);
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background: #7d99b0;
    color: #fff;
    font-size: var(--fs-md);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease, background 0.2s ease;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cc-scroll-hint:hover {
    background: #5f7a91;
}

.cc-scroll-hint:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.cc-scroll-hint--visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
    animation: cc-bounce 1.6s ease-in-out infinite;
}

@keyframes cc-bounce {
    0%, 100% {
        transform: translateX(-50%) translateY(0);
    }
    50% {
        transform: translateX(-50%) translateY(-6px);
    }
}

@media (prefers-reduced-motion: reduce) {
    .cc-scroll-hint--visible {
        animation: none;
    }
}

/* End-of-page "Everything done" banner. */
.completion-done {
    padding: 20px 24px;
    background: #e6f4ea;
    border: 1px solid #c4e5cf;
    border-radius: 8px;
    color: #2d7a3a;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
}

.completion-done .fa {
    font-size: var(--fs-md);
}

/* ===========================================================================
   Hotgraphic block — view styles
   =========================================================================== */

.block-hotgraphic,
.block-hotgraphic-full-width {
    width: 100%;
    display: flex;
    justify-content: center;
}

.hotgraphic-view-canvas {
    position: relative;
    display: inline-block;
    max-width: 100%;
    border-radius: 8px;
    overflow: hidden;
    line-height: 0;
}

.hotgraphic-view-canvas .hotgraphic-view-image {
    display: block;
    max-width: 100%;
    width: auto;
    height: auto;
}

.hotgraphic-view-canvas .hotgraphic-hotspot {
    cursor: pointer;
    background: transparent;
    padding: 0;
    font: inherit;
    color: inherit;
    outline: none;
}

/* Tooltip (hover / pinned) */
.hotgraphic-tooltip {
    position: absolute;
    left: 0;
    top: 0;
    min-width: 180px;
    max-width: 320px;
    padding: 14px 18px;
    background: #fff;
    color: #2d2d2d;
    font-size: 17px;
    line-height: 1.7;
    font-weight: 400;
    text-align: left;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(0, 0, 0, 0.04);
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s ease, visibility 0.15s ease;
    z-index: 20;
    white-space: normal;
    text-transform: none;
    letter-spacing: normal;
}

.hotgraphic-tooltip.is-visible {
    opacity: 1;
    visibility: visible;
}

.hotgraphic-tooltip.is-pinned {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.hotgraphic-tooltip-title {
    font-size: 19px;
    font-weight: 700;
    line-height: 1.3;
    color: #1a1a1a;
    margin: 0 0 6px 0;
}

.hotgraphic-tooltip-text {
    margin: 0;
}

.hotgraphic-tooltip .cometascreator-tts-player {
    margin-top: 10px;
}

/* Stop vibration when pinned */
.hotgraphic-view-canvas .hotgraphic-hotspot.is-pinned::after {
    animation: none;
}

/* Touch devices: hide tooltips (fall back to popup) */
@media (hover: none) {
    .hotgraphic-tooltip {
        display: none !important;
    }
}
/* ============================================================
 * Review Subsystem
 *
 * Selector prefix: .cometascreator-review-*
 * All styles only take effect when the master switch is enabled,
 * because the markup is never rendered otherwise.
 * ============================================================ */

/* Global glass effect — used by review pins, header button and the
   course-page badge. Tweak in one place to retheme. */
.cc-glass {
    background: rgba(245, 243, 255, 0.55);
    backdrop-filter: blur(8px) saturate(140%);
    -webkit-backdrop-filter: blur(8px) saturate(140%);
    border: 1px solid rgba(221, 214, 254, 0.7);
    color: rgba(109, 40, 217, 0.88);
    box-shadow: 0 1px 3px rgba(124, 58, 237, 0.08);
    transition: background .15s ease, color .15s ease,
                transform .12s ease, box-shadow .12s ease, opacity .15s ease;
}
.cc-glass:hover {
    background: rgba(237, 233, 254, 0.85);
    color: rgba(109, 40, 217, 1);
    box-shadow: 0 3px 8px rgba(124, 58, 237, 0.15);
}

/* Review header button counter badge. The button itself inherits
   .btn.btn-edit styling from the header toolbar. */
.cometascreator-review-btn-counter {
    background: #7c3aed;
    color: white;
    border-radius: 10px;
    padding: 0 7px;
    margin-left: 4px;
    font-size: 11px;
    font-weight: 600;
    min-width: 18px;
    text-align: center;
    line-height: 18px;
}

/* Block pin — absolutely positioned in the block header so it never
   affects block height. In edit mode, overridden to static so it sits
   inline with the sort/edit buttons. */
.cometascreator-review-pin {
    position: absolute;
    top: 0;
    right: 0;
    height: 28px;
    padding: 0 10px;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    font-size: 13px;
    line-height: 1;
    z-index: 5;
}

.cc-actions{
    display: flex;
    gap: 8px;
    flex-direction: row;
    align-items: center;
}

.cometascreator-review-pin:hover {
    transform: translateY(-1px);
}

/* The review pin slot in the shared block header. Zero-sized so it
   never affects block dimensions — the pin is positioned absolutely
   on top of the header. */
.cc-review-pin-slot {
    position: absolute;
    top: 0;
    right: 0;
    width: 0;
    height: 0;
    overflow: visible;
    z-index: 5;
}

/* Edit mode: pin sits inline with the sort/edit buttons, not floating */
.cometascreator-review-pin.is-edit-mode {
    position: static;
    top: auto;
    right: auto;
    margin-left: 8px;
}

/* Course-page badge: inline next to the activity name (set via
   $cm->set_after_link in lib.php). */
.cometascreator-review-pin.is-course-badge {
    position: static;
    top: auto;
    right: auto;
    height: 22px;
    padding: 0 8px;
    font-size: 12px;
    margin-left: 8px;
    vertical-align: middle;
    cursor: default;
}
.cometascreator-review-pin.is-course-badge:hover {
    transform: none;
}

/* Empty pin (no comments yet) — invisible, zero layout footprint.
   Revealed on block hover via the wrapper selector. */
.cometascreator-review-pin.is-empty {
    opacity: 0;
    pointer-events: none;
    transition: opacity .15s ease-out;
}
.block-wrapper:hover .cometascreator-review-pin.is-empty {
    opacity: 1;
    pointer-events: auto;
}

@media (prefers-reduced-motion: reduce) {
    .cometascreator-review-pin.is-empty {
        transition: none;
    }
}

.cometascreator-review-pin-counter {
    background: #7c3aed;
    color: white;
    border-radius: 9px;
    padding: 0 6px;
    font-size: 11px;
    font-weight: 600;
    line-height: 16px;
}

/* Side panel */
.cometascreator-review-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 420px;
    max-width: 100vw;
    height: 100vh;
    background: white;
    box-shadow: -4px 0 16px rgba(0, 0, 0, 0.1);
    transform: translateX(100%);
    transition: transform .25s ease;
    z-index: 1050;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.cometascreator-review-panel.is-open {
    transform: translateX(0);
}
.cometascreator-review-panel-header {
    padding: 16px 20px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    flex-shrink: 0;
}
.cometascreator-review-panel-title h2 {
    font-size: 18px;
    margin: 0 0 4px 0;
    color: #1f2937;
}
.cometascreator-review-panel-subtitle {
    margin: 0;
    color: #6b7280;
    font-size: 13px;
}
.cometascreator-review-panel-close {
    background: transparent;
    border: 0;
    font-size: 18px;
    color: #6b7280;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
}
.cometascreator-review-panel-close:hover {
    color: #1f2937;
}
.cometascreator-review-panel-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px 20px;
    border-bottom: 1px solid #e5e7eb;
    flex-shrink: 0;
}
.cometascreator-review-panel-chips:empty {
    padding: 0;
    border-bottom: 0;
}
.cometascreator-review-chip {
    background: #f5f3ff;
    color: #6d28d9;
    border: 1px solid #ddd6fe;
    border-radius: 14px;
    padding: 3px 10px;
    font-size: 12px;
    cursor: pointer;
}
.cometascreator-review-chip:hover {
    background: #ede9fe;
}
.cometascreator-review-panel-body {
    overflow-y: auto;
    padding: 16px 20px;
    flex: 1;
}

/* Empty state */
.cometascreator-review-empty {
    text-align: center;
    color: #6b7280;
    padding: 40px 20px;
}
.cometascreator-review-empty-icon {
    font-size: 40px;
    color: #d1d5db;
    margin-bottom: 12px;
}
.cometascreator-review-empty-title {
    font-weight: 600;
    margin-bottom: 4px;
}
.cometascreator-review-empty-body {
    margin: 0;
    font-size: 13px;
}

/* Block group */
.cometascreator-review-group {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    margin-bottom: 16px;
    overflow: hidden;
}
.cometascreator-review-group-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: #fafafa;
    border-bottom: 1px solid #e5e7eb;
}
.cometascreator-review-group-title {
    font-size: 14px;
    font-weight: 600;
    margin: 0;
    color: #1f2937;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
}
.cometascreator-review-group-count {
    background: #e5e7eb;
    color: #374151;
    border-radius: 10px;
    padding: 1px 8px;
    font-size: 11px;
}
.cometascreator-review-group-thread {
    padding: 8px 14px;
}
.cometascreator-review-group-archive-action {
    padding: 0 14px 8px;
}

/* Composer */
.cometascreator-review-composer {
    padding: 0 14px 12px;
}
.cometascreator-review-composer-input {
    width: 100%;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 13px;
    resize: none;
    transition: border-color .15s ease;
    background: #fff;
    color: #1f2937;
}
.cometascreator-review-composer.is-expanded .cometascreator-review-composer-input {
    border-color: #7c3aed;
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
}
.cometascreator-review-composer-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 8px;
}
.cometascreator-review-composer-hint {
    color: #6b7280;
    font-size: 11px;
    margin-right: auto;
}

/* Archive toggle */
.cometascreator-review-group-archive {
    border-top: 1px solid #e5e7eb;
    background: #f9fafb;
}
.cometascreator-review-archive-toggle {
    width: 100%;
    background: transparent;
    border: 0;
    text-align: left;
    padding: 8px 14px;
    color: #6b7280;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
}
.cometascreator-review-archive-toggle:hover {
    color: #1f2937;
}
.cometascreator-review-archive-list {
    padding: 4px 14px 10px;
}
.cometascreator-review-archive-list .cometascreator-review-comment.is-archived {
    opacity: 0.75;
}

.block-content li[data-list="bullet"],
.block-content ul > li {
    list-style-type: disc;
}

.block-content li[data-list="ordered"],
.block-content ol > li:not([data-list]) {
    list-style-type: decimal;
}

/* Single comment */
.cometascreator-review-comment {
    display: flex;
    gap: 10px;
    padding: 8px 0;
}
.cometascreator-review-comment + .cometascreator-review-comment {
    border-top: 1px solid #f3f4f6;
}
.cometascreator-review-comment-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    color: white;
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.cometascreator-review-comment-body {
    flex: 1;
    min-width: 0;
}
.cometascreator-review-comment-meta {
    font-size: 12px;
    color: #6b7280;
    margin-bottom: 2px;
    display: flex;
    align-items: baseline;
    gap: 8px;
}
.cometascreator-review-comment-author {
    color: #1f2937;
    font-weight: 600;
}
.cometascreator-review-comment-edited {
    font-style: italic;
    cursor: help;
}
.cometascreator-review-comment-content {
    font-size: 13px;
    color: #1f2937;
    white-space: pre-wrap;
    word-wrap: break-word;
}
.cometascreator-review-comment-actions {
    margin-top: 4px;
    display: flex;
    gap: 4px;
}
.cometascreator-review-comment-actions .btn-link {
    padding: 2px 6px;
    font-size: 12px;
    color: #6b7280;
    text-decoration: none;
}
.cometascreator-review-comment-actions .btn-link:hover {
    color: #1f2937;
    text-decoration: underline;
}
.cometascreator-review-comment-actions .cometascreator-review-action-danger {
    color: #dc2626;
}
.cometascreator-review-comment-actions .cometascreator-review-action-danger:hover {
    color: #991b1b;
}

/* Inline edit textarea */
.cometascreator-review-comment-editor-input {
    width: 100%;
    border: 1px solid #7c3aed;
    border-radius: 6px;
    padding: 6px 8px;
    font-size: 13px;
    resize: none;
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
    color: #1f2937;
    background: #fff;
}
.cometascreator-review-comment-editor-actions {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
    margin-top: 6px;
}

/* Mobile */
@media (max-width: 640px) {
    .cometascreator-review-panel {
        width: 100vw;
    }
    .cometascreator-review-btn-label {
        display: none;
    }
}

/* Overview pages */
.cometascreator-review-overview {
    margin-top: 8px;
}
.cometascreator-review-overview-summary {
    color: #6b7280;
    margin-bottom: 12px;
    font-size: 14px;
}
.cometascreator-review-overview-toolbar {
    margin-bottom: 12px;
}
.cometascreator-review-overview-table {
    width: 100%;
}
.cometascreator-review-overview-snippet {
    max-width: 320px;
    color: #4b5563;
    font-size: 13px;
    word-break: break-word;
}
.cometascreator-review-overview-archived td {
    opacity: 0.75;
}

/* Clickable block-title in panel (jumps to block on the page) */
.cometascreator-review-group-title-clickable {
    cursor: pointer;
    transition: color .12s ease;
}
.cometascreator-review-group-title-clickable:hover,
.cometascreator-review-group-title-clickable:focus {
    color: #6d28d9;
    text-decoration: underline;
    outline: none;
}
/* ==================== Flipcards Block ==================== */

.flipcards-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    align-items: stretch;
    width: 100%;
    box-sizing: border-box;
    margin-top: 15px;
}

.flipcards-container.cols-2 {
    grid-template-columns: repeat(2, 1fr);
}

.flipcards-container.cols-3 {
    grid-template-columns: repeat(3, 1fr);
}

.flipcard {
    perspective: 1400px;
    cursor: pointer;
    user-select: none;
    min-height: 180px;
    display: flex;
}

.flipcard:focus,
.flipcard:focus-visible {
    outline: none;
    box-shadow: none;
}

/* Beide Seiten liegen per Grid in derselben Zelle uebereinander. Dadurch
   bestimmt die hoehere Seite die Kartenhoehe (kein position:absolute), und
   die Karten einer Zeile gleichen sich ueber das Grid der Container-Ebene
   automatisch der hoechsten Karte an. */
.flipcard-inner {
    position: relative;
    width: 100%;
    display: grid;
    transform-style: preserve-3d;
    transition: transform 0.55s cubic-bezier(0.4, 0.15, 0.2, 1);
    will-change: transform;
}

.flipcard.flipped .flipcard-inner {
    transform: rotateY(180deg);
}

.flipcard-face {
    grid-area: 1 / 1;
    position: relative;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    background: #f8f9fa;
    border-radius: 12px;
    padding: 20px 20px 44px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    min-width: 0;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Vertikale Ausrichtung des Karteninhalts. */
.flipcards-container.align-top .flipcard-face {
    justify-content: flex-start;
}

.flipcards-container.align-center .flipcard-face {
    justify-content: center;
}

.flipcards-container.align-bottom .flipcard-face {
    justify-content: flex-end;
}

.flipcard-back {
    transform: rotateY(180deg);
}

.flipcard-icon {
    font-size: var(--fs-lg);
    margin-bottom: 10px;
}

.flipcard-text {
    font-size: var(--fs-sm);
}

/* Fusszeile mit Positions-Punkten und Dreh-Icon. Der Inhalt haelt durch das
   untere Padding der Kartenseite immer Abstand dazu. */
.flipcard-footer {
    position: absolute;
    bottom: 14px;
    left: 20px;
    right: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    pointer-events: none;
}

.flipcard-dots {
    display: flex;
    gap: 5px;
}

.flipcard-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.28;
}

.flipcard-dots span.on {
    opacity: 0.9;
}

.flipcard-turn {
    font-size: var(--fs-sm);
    opacity: 0.5;
}

@media (max-width: 768px) {
    .flipcards-container,
    .flipcards-container.cols-2,
    .flipcards-container.cols-3 {
        grid-template-columns: 1fr;
    }
}

/* ==================== Click demo Block ==================== */
/* Click areas reuse the hotgraphic hotspot styles (hotgraphic-shared.css:
   centre positioning, colour via --hg-color, pulsing glow). */

/* The demo itself is only focused to receive the arrow keys; the controls
   inside it keep their own focus styles. */
.clickdemo:focus {
    outline: none;
}

/* Medium width (shared with the interactive block, see .cometas-interactive-medium):
   on large external screens the demo may grow further; laptops keep 1100px. */
@media (min-width: 1800px) {
    .clickdemo-width-medium {
        width: min(1300px, calc(100vw - 32px));
        margin-left: calc(50% - min(650px, calc(50vw - 16px)));
        margin-right: calc(50% - min(650px, calc(50vw - 16px)));
    }
}

/* Stage and start-screen instructions share one grid cell, so the
   instructions lie over the bottom of the stage (below it on small screens). */
.clickdemo {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
}

.clickdemo-stage {
    grid-area: 1 / 1;
    position: relative;
    width: 100%;
    border-radius: 8px;
    overflow: hidden;
    background: #1a1a1a;
    container-type: size;
}

.clickdemo-screen,
.clickdemo-step {
    position: absolute;
    inset: 0;
    display: none;
}

.clickdemo-screen.is-active {
    display: block;
}

.clickdemo-step.is-active {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* The screenshot keeps its own format inside the stage ("contain"). */
.clickdemo-frame {
    position: relative;
    width: min(100cqw, calc(100cqh * var(--clickdemo-ar, 1.6)));
    aspect-ratio: var(--clickdemo-ar, 1.6);
    overflow: hidden;
}

.clickdemo-shot,
.clickdemo-screen-bg {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    user-select: none;
}

.clickdemo-screen-bg {
    position: absolute;
    inset: 0;
}

/* Click area */
.clickdemo .clickdemo-area {
    z-index: 2;
    cursor: pointer;
    padding: 0;
    font: inherit;
}

.clickdemo .clickdemo-area:focus-visible {
    outline: 3px solid var(--primary, #0f6cbf);
    outline-offset: 3px;
}

.hotgraphic-hotspot.hotgraphic-shape-rect.clickdemo-rounded {
    border-radius: 6px;
}

.hotgraphic-hotspot.clickdemo-dot {
    width: 28px;
    height: 28px;
    background: rgb(var(--hg-color));
    border: 3px solid #fff;
    box-shadow: 0 0 0 2px rgb(var(--hg-color));
}

/* Darkens everything outside the highlighted area. */
.clickdemo-focus {
    position: absolute;
    z-index: 1;
    transform: translate(-50%, -50%);
    border-radius: 8px;
    box-shadow: 0 0 0 9999px rgba(10, 16, 26, 0.55);
    pointer-events: none;
}

/* Tooltip and info box */
.clickdemo-tip {
    position: absolute;
    z-index: 3;
    width: max-content;
    max-width: min(300px, 80%);
    padding: 12px 14px;
    border-radius: 8px;
    background: #1a1a1a;
    color: #fff;
    font-size: var(--fs-sm);
    line-height: 1.5;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
}

.clickdemo-tip-text {
    margin: 0;
    white-space: pre-line;
}

.clickdemo-tip-text + .cometascreator-btn {
    margin-top: 10px;
}

/* Stacked above the pointer (.clickdemo-cursor): the pointer glides to the
   centre of the box and disappears behind it. */
.clickdemo-tip-info {
    z-index: 6;
    transform: translate(-50%, -50%);
}

/* Start and end screen: blurred screenshot with a glass card. */
.clickdemo-veil {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 16px;
    overflow: auto;
    background: rgba(255, 255, 255, 0.3);
    -webkit-backdrop-filter: blur(4px) saturate(1.3);
    backdrop-filter: blur(4px) saturate(1.3);
}

.clickdemo-glass {
    max-width: 440px;
    padding: 28px 30px;
    border: 1px solid rgba(255, 255, 255, 0.55);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.62);
    box-shadow: 0 12px 40px rgba(20, 28, 40, 0.25);
    text-align: center;
}

.clickdemo-glass-title {
    margin: 0 0 8px;
    font-size: var(--fs-lg);
    font-weight: 600;
}

.clickdemo-glass-text {
    margin: 0 0 18px;
    color: #374151;
    white-space: pre-line;
}

/* Outline buttons are transparent; on the frosted glass they need a solid
   background to stay readable (hover keeps the Moodle button style). */
.clickdemo-glass .btn-outline-secondary:not(:hover) {
    background-color: #fff;
}

/* Mouse pointer: glides from the previous click area to the next one, then
   fades out while the click area, tooltip and highlight fade in. */
.clickdemo-cursor {
    position: absolute;
    z-index: 5;
    width: 26px;
    height: 26px;
    margin: -3px 0 0 -4px;
    transform-origin: 4px 3px;
    filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.35));
    pointer-events: none;
    transition: left 1.3s cubic-bezier(0.65, 0, 0.3, 1), top 1.3s cubic-bezier(0.65, 0, 0.3, 1),
        opacity 0.3s, transform 0.3s;
}

.clickdemo-cursor svg {
    display: block;
}

/* Click ripple in the colour of the click area. */
.clickdemo-cursor::after {
    content: "";
    position: absolute;
    left: -10px;
    top: -11px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(var(--hg-color), 0.5);
    transform: scale(0);
    opacity: 0;
}

.clickdemo-cursor.is-gone {
    opacity: 0;
    transform: scale(0.6);
}

.clickdemo-cursor.is-clicking::after {
    animation: clickdemo-ripple 0.45s ease-out;
}

/* Puts the pointer at its start position without animating there. */
.clickdemo-cursor.is-placing {
    transition: none;
}

@keyframes clickdemo-ripple {
    from {
        transform: scale(0);
        opacity: 1;
    }
    to {
        transform: scale(1.6);
        opacity: 0;
    }
}

.clickdemo-step .clickdemo-area,
.clickdemo-step .clickdemo-tip {
    opacity: 0;
    transition: opacity 0.25s;
}

.clickdemo-step .clickdemo-focus {
    opacity: 0;
    transition: opacity 0.4s;
}

.clickdemo-step.is-arrived .clickdemo-area,
.clickdemo-step.is-arrived .clickdemo-tip,
.clickdemo-step.is-arrived .clickdemo-focus {
    opacity: 1;
}

/* Starting the demo dissolves the frosted veil of the start screen. */
.clickdemo-veil {
    transition: opacity 0.5s ease;
}

.clickdemo-veil.is-out {
    opacity: 0;
}

.clickdemo-veil .clickdemo-glass {
    transition: transform 0.5s;
}

.clickdemo-veil.is-out .clickdemo-glass {
    transform: scale(0.96);
}

/* Operating instructions of the start screen: frosted like the glass card, in
   the bottom zone of the stage where the timeline appears later. They dissolve
   together with the veil. */
.clickdemo-hints {
    grid-area: 1 / 1;
    align-self: end;
    position: relative;
    z-index: 7;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 4px 20px;
    margin: 0 12px 12px;
    padding: 8px 14px;
    border: 1px solid rgba(255, 255, 255, 0.55);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.62);
    box-shadow: 0 4px 16px rgba(20, 28, 40, 0.12);
    color: #374151;
    font-size: var(--fs-sm);
    transition: opacity 0.5s ease;
}

.clickdemo-hints[hidden] {
    display: none;
}

.clickdemo-hints.is-out {
    opacity: 0;
}

.clickdemo-hints-title {
    margin: 0;
    font-weight: 600;
    color: #1f2937;
}

.clickdemo-hints-list {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px 20px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.clickdemo-hints .fa {
    margin-right: 4px;
    color: var(--primary, #0f6cbf);
}

/* Touch devices have no arrow keys. */
@media (hover: none) {
    .clickdemo-hint-keys {
        display: none;
    }
}

/* Story timeline at the bottom of the stage: one segment per step. Done
   segments are filled, the current one fills in sync with the pointer glide,
   upcoming ones are translucent. */
.clickdemo-timeline {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 4;
    display: flex;
    gap: 6px;
    padding: 20px 14px 4px;
    background: linear-gradient(transparent, rgba(20, 28, 40, 0.45));
    pointer-events: none;
}

.clickdemo-timeline[hidden] {
    display: none;
}

.clickdemo-timeline-segment {
    flex: 1;
    padding: 8px 0;
    border: 0;
    background: none;
    cursor: pointer;
    pointer-events: auto;
}

.clickdemo-timeline-track {
    display: block;
    height: 4px;
    overflow: hidden;
    border-radius: 99px;
    background: rgba(255, 255, 255, 0.45);
    transition: height 0.15s;
}

.clickdemo-timeline-segment:hover .clickdemo-timeline-track,
.clickdemo-timeline-segment:focus-visible .clickdemo-timeline-track {
    height: 7px;
}

.clickdemo-timeline-segment:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.clickdemo-timeline-fill {
    display: block;
    width: 0;
    height: 100%;
    border-radius: 99px;
    background: #fff;
}

.clickdemo-timeline-segment.is-done .clickdemo-timeline-fill {
    width: 100%;
}

.clickdemo-timeline-segment.is-current .clickdemo-timeline-fill {
    animation: clickdemo-timeline-fill 1.3s ease-out forwards;
}

@keyframes clickdemo-timeline-fill {
    to {
        width: 100%;
    }
}

/* Navigation below the stage */
.clickdemo-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 12px;
}

.clickdemo-nav[hidden] {
    display: none;
}

.clickdemo-progress {
    color: #6b7280;
    font-size: var(--fs-sm);
}

@media (max-width: 576px) {
    .clickdemo-glass {
        padding: 16px 18px;
    }

    .clickdemo-glass-text {
        margin-bottom: 12px;
        font-size: var(--fs-sm);
    }

    /* Too little room on the stage: the instructions move below it. */
    .clickdemo-hints {
        grid-area: auto;
        flex-direction: column;
        align-items: flex-start;
        gap: 2px;
        margin: 8px 0 0;
        padding: 0;
        border: 0;
        background: none;
        box-shadow: none;
        color: #6b7280;
    }

    .clickdemo-hints-title {
        color: #374151;
    }

    .clickdemo-hints-list {
        justify-content: flex-start;
    }
}

@media (prefers-reduced-motion: reduce) {
    .clickdemo .clickdemo-area::after {
        animation: none;
    }

    .clickdemo-cursor {
        transition: none;
    }

    .clickdemo-timeline-segment.is-current .clickdemo-timeline-fill {
        width: 100%;
        animation: none;
    }
}
