/**
 * eXeLearning Module Styles
 */

/* ==========================================================================
   Theme integration
   --------------------------------------------------------------------------
   The viewer borrows its look from whatever Omeka is showing it in: every
   toolbar control is the active theme's own `.button` (the admin's in admin,
   the public theme's on the site), and fonts and sizes are inherited. The one
   themed accent is the icon colour, taken from `--accent`, which Omeka's
   Default theme sets from its "Main accent color" setting; themes without it
   keep the button's text colour.
   ========================================================================== */

.exelearning-viewer {
    --exelearning-border: var(--light, rgba(0, 0, 0, 0.15));
    --exelearning-icon: var(--accent, currentColor);

    position: relative;
    width: 100%;
    margin-bottom: 1rem;
    border: 1px solid var(--exelearning-border);
    border-radius: 3px;
    overflow: hidden;
}

/* ==========================================================================
   Toolbar
   ========================================================================== */

.exelearning-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 12px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--exelearning-border);
}

.exelearning-title {
    font-weight: bold;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    /* Keep enough of the title readable; the actions wrap below it first. */
    flex: 1 1 14em;
    min-width: 0;
}

.exelearning-toolbar-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
    align-items: center;
    margin-left: auto;
}

/* Layout glue only: colours, padding, borders and type come from the theme's
   `.button`. The admin theme gives buttons a bottom margin meant for forms. */
.exelearning-toolbar-actions .button {
    display: inline-flex;
    align-items: center;
    gap: 0.4em;
    margin: 0;
    white-space: nowrap;
    text-decoration: none;
}

/* ==========================================================================
   Iframe
   ========================================================================== */

.exelearning-iframe {
    display: block;
    width: 100%;
    border: none;
    background: white;
}

.exelearning-iframe:fullscreen {
    width: 100vw;
    height: 100vh;
}

.exelearning-iframe:-webkit-full-screen {
    width: 100vw;
    height: 100vh;
}

.exelearning-iframe:-moz-full-screen {
    width: 100vw;
    height: 100vh;
}

.exelearning-iframe:-ms-fullscreen {
    width: 100vw;
    height: 100vh;
}

/* ==========================================================================
   Fallback (no preview)
   ========================================================================== */

.exelearning-fallback {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
    border: 1px solid var(--light, rgba(0, 0, 0, 0.15));
    border-radius: 3px;
}

.exelearning-icon {
    width: 64px;
    height: 64px;
    margin-bottom: 16px;
    background: #6c757d;
    border-radius: 8px;
    position: relative;
}

.exelearning-icon::before {
    content: "EXE";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 14px;
    font-weight: bold;
}

.exelearning-filename {
    margin: 0 0 16px;
    font-size: 14px;
    opacity: 0.75;
    word-break: break-all;
}

/* ==========================================================================
   Icons
   --------------------------------------------------------------------------
   Omeka's icon font (Font Awesome 5, loaded from css/iconfonts.css) styles
   every `o-icon-*` class; the core ones used here are o-icon-external and
   o-icon-edit. The glyphs Omeka has no class for are defined below with the
   same font.
   ========================================================================== */

.exelearning-viewer [class*="o-icon-"],
.exelearning-fallback [class*="o-icon-"] {
    color: var(--exelearning-icon, var(--accent, currentColor));
}

.o-icon-exelearning-download::before,
.o-icon-exelearning-fullscreen::before,
.o-icon-exelearning-caret::before {
    font-family: "Font Awesome 5 Free";
    font-weight: 900;
}

.o-icon-exelearning-download::before {
    content: "\f019";
}

.o-icon-exelearning-fullscreen::before {
    content: "\f065";
}

.is-fullscreen .o-icon-exelearning-fullscreen::before {
    content: "\f066";
}

.o-icon-exelearning-caret::before {
    content: "\f0d7";
}

/* ==========================================================================
   Responsive
   ========================================================================== */

/* The toolbar already wraps; on narrow screens the actions start under the
   title instead of hanging off the right edge. */
@media (max-width: 600px) {
    .exelearning-title {
        flex-basis: 100%;
    }

    .exelearning-toolbar-actions {
        margin-left: 0;
        justify-content: flex-start;
    }
}

/* ==========================================================================
   Notifications (for editor)
   ========================================================================== */

.omeka-exe-notification {
    position: fixed;
    top: 60px;
    right: 10px;
    z-index: 10001;
    padding: 12px 20px;
    border-radius: 4px;
    font-size: 14px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: opacity 0.3s ease;
}

.omeka-exe-notification--success {
    background: #28a745;
    color: white;
}

.omeka-exe-notification--error {
    background: #dc3545;
    color: white;
}

.omeka-exe-notification--info {
    background: #17a2b8;
    color: white;
}

.omeka-exe-notification--fade {
    opacity: 0;
}

/* ----------------------------------------------------------------------
   Multi-format split download button
   --------------------------------------------------------------------
   The primary action and the caret are two theme buttons joined into one
   control; the menu entries are plain rows, so no theme button style is
   applied to them.
   ---------------------------------------------------------------- */
.exelearning-download {
    position: relative;
    display: inline-flex;
    align-items: stretch;
    /* Keep the dropdown above the preview iframe. */
    z-index: 100;
}

.exelearning-download[data-busy="1"] {
    opacity: 0.7;
    pointer-events: none;
}

.exelearning-download .exelearning-download__primary:not(:last-child) {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.exelearning-download .exelearning-download__toggle {
    margin-left: 1px;
    padding-left: 0.6em;
    padding-right: 0.6em;
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

.exelearning-download .exelearning-download__menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin: 4px 0 0;
    padding: 4px 0;
    list-style: none;
    min-width: 220px;
    background: #fff;
    color: #222;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 3px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    z-index: 1001;
}

/* Three classes so this beats the theme's bare `button` rule. */
.exelearning-download .exelearning-download__menu .exelearning-download__item {
    display: block;
    width: 100%;
    min-height: 0;
    margin: 0;
    padding: 8px 14px;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}

.exelearning-download .exelearning-download__menu .exelearning-download__item:hover,
.exelearning-download .exelearning-download__menu .exelearning-download__item:focus-visible {
    background: rgba(0, 0, 0, 0.06);
}

.exelearning-download__status {
    font-size: 12px;
    margin-left: 10px;
    opacity: 0.7;
    align-self: center;
}

.exelearning-download__item--disabled,
.exelearning-download__primary.exelearning-download__item--disabled {
    opacity: 0.55;
    cursor: not-allowed;
    pointer-events: none;
}

/* Busy spinner. While the orchestrator JS generates an export it sets
   data-busy="1" on the container; a spinner in the button's own text colour
   covers the primary action until the attribute is removed. */
.exelearning-download[data-busy="1"] .exelearning-download__primary {
    color: transparent !important;
    position: relative;
}
.exelearning-download[data-busy="1"] .exelearning-download__primary > * {
    visibility: hidden;
}
.exelearning-download[data-busy="1"] .exelearning-download__primary::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 14px;
    height: 14px;
    margin: -7px 0 0 -7px;
    border: 2px solid #555;
    border-top-color: transparent;
    border-radius: 50%;
    opacity: 0.85;
    animation: exelearning-spin 0.7s linear infinite;
    visibility: visible;
}
@keyframes exelearning-spin {
    to { transform: rotate(360deg); }
}
@media (prefers-reduced-motion: reduce) {
    .exelearning-download[data-busy="1"] .exelearning-download__primary::after {
        animation-duration: 2s;
    }
}

/* ==========================================================================
   Processing failure notice (admin)
   ========================================================================== */

.exelearning-process-error {
    margin: 1rem 0;
    padding: 0.75rem 1rem;
    border: 1px solid #d63638;
    border-left-width: 4px;
    border-radius: 3px;
    background: #fcf0f1;
}

.exelearning-process-error p {
    margin: 0 0 0.5rem;
}

.exelearning-process-error p:last-child {
    margin-bottom: 0;
}

.exelearning-process-error code {
    word-break: break-all;
}
