/**
 * @author    Sigmanortec SRL <office@sigmanortec.ro>
 * @copyright 2024 Sigmanortec SRL
 * @license   https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
 */

/* Selectors are flat on purpose: the panel is moved to the end of the body when
   the drawer opens, so it must keep its styling outside of the block wrapper. */

.scn {
    --scn-accent: #2fb5d2;
    --scn-line: rgba(0, 0, 0, .09);
    --scn-muted: #767676;
    --scn-hover: rgba(0, 0, 0, .04);
    --scn-radius: 6px;
    font-size: 1rem;
    line-height: 1.35;
}

.scn [hidden],
.scn-panel [hidden] {
    display: none !important;
}

.scn *,
.scn-panel * {
    box-sizing: border-box;
}

/* Mobile button ---------------------------------------------------------- */

.scn-open {
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    min-height: 48px;
    padding: 10px 2px;
    border: 0;
    border-bottom: 1px solid var(--scn-line);
    border-radius: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .02em;
    text-align: left;
    cursor: pointer;
}

.scn-open:hover,
.scn-open:focus {
    color: var(--scn-accent);
}

.scn-open[aria-expanded="true"] {
    color: var(--scn-accent);
}

.scn-open[aria-expanded="true"] .scn-open-caret {
    transform: rotate(180deg);
}

.scn-open--sticky {
    position: sticky;
    top: 8px;
    z-index: 20;
    background: #fff;
}

.scn-open-caret {
    width: 22px;
    height: 22px;
    flex: 0 0 auto;
    color: var(--scn-muted);
    transition: transform .15s ease;
}

.scn-open-label {
    flex: 1 1 auto;
}

/* Mobile state, switched by the configured breakpoint from the script ------ */

.scn--js.scn--mobile .scn-open {
    display: flex;
}

.scn--js.scn--mobile .scn-panel {
    display: none;
}

/* The row carries the name already, so the heading inside does not repeat it.
   In the drawer the panel sits on the body, where this rule cannot reach it. */

.scn--js.scn--mobile .scn-panel .scn-head {
    display: none;
}

.scn--js.scn--mobile .scn-panel.is-inline-open {
    display: block;
}

.scn--moved {
    display: block;
    width: 100%;
    margin: 0 0 16px;
}

/* Panel ------------------------------------------------------------------ */

.scn-panel {
    --scn-accent: #2fb5d2;
    --scn-line: rgba(0, 0, 0, .09);
    --scn-muted: #767676;
    --scn-hover: rgba(0, 0, 0, .04);
    --scn-radius: 6px;
    position: relative;
}

.scn-panel--sticky {
    position: sticky;
    top: var(--scn-top, 20px);
    max-height: calc(100vh - var(--scn-top, 20px) - 20px);
    overflow: auto;
    overscroll-behavior: contain;
}

.scn-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 0 10px;
    border-bottom: 1px solid var(--scn-line);
}

.scn-title {
    flex: 1 1 auto;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .02em;
    font-size: .95em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.scn-back {
    flex: 0 0 auto;
    margin-left: auto;
}

.scn-back,
.scn-close {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-height: 40px;
    padding: 4px 8px;
    margin: 0;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    cursor: pointer;
    border-radius: var(--scn-radius);
}

.scn-back svg,
.scn-close svg {
    width: 20px;
    height: 20px;
}

.scn-back:hover,
.scn-close:hover {
    background: var(--scn-hover);
}

.scn-back-label {
    font-size: .9em;
}

/* Filter ----------------------------------------------------------------- */

.scn-filter {
    position: relative;
    display: flex;
    align-items: center;
    margin: 10px 0 4px;
}

.scn-filter-icon {
    position: absolute;
    left: 10px;
    width: 16px;
    height: 16px;
    color: var(--scn-muted);
    pointer-events: none;
}

.scn-filter-input {
    width: 100%;
    min-height: 40px;
    padding: 6px 34px 6px 32px;
    border: 1px solid var(--scn-line);
    border-radius: var(--scn-radius);
    background: transparent;
    color: inherit;
    font: inherit;
    font-size: .95em;
}

.scn-filter-input:focus {
    outline: 0;
    border-color: var(--scn-accent);
}

.scn-filter-clear {
    position: absolute;
    right: 2px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: 0;
    background: transparent;
    color: var(--scn-muted);
    cursor: pointer;
}

.scn-filter-clear svg {
    width: 16px;
    height: 16px;
}

/* Close everything at once ----------------------------------------------- */

.scn-tools {
    display: flex;
    justify-content: flex-end;
    padding: 6px 0 2px;
}

.scn-collapse {
    border: 0;
    background: transparent;
    padding: 4px 2px;
    color: var(--scn-muted);
    font: inherit;
    font-size: .85em;
    cursor: pointer;
    text-decoration: underline;
}

.scn-collapse:hover {
    color: var(--scn-accent);
}

/* Body and lists --------------------------------------------------------- */

.scn-body {
    position: relative;
}

.scn-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.scn-item {
    position: relative;
    margin: 0;
    padding: 0;
    list-style: none;
}

.scn-row {
    display: flex;
    align-items: stretch;
    border-bottom: 1px solid var(--scn-line);
}

.scn-list .scn-item:last-child > .scn-row {
    border-bottom: 0;
}

.scn-link {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1 1 auto;
    min-height: 40px;
    padding: 7px 4px 7px 2px;
    color: inherit;
    text-decoration: none;
}

.scn-link:hover,
.scn-link:focus {
    color: var(--scn-accent);
    text-decoration: none;
}

.scn-name {
    flex: 1 1 auto;
}

.scn-thumb {
    flex: 0 0 auto;
    width: var(--scn-thumb, 32px);
    height: var(--scn-thumb, 32px);
    border-radius: 4px;
    object-fit: contain;
    background: transparent;
}

.scn-thumb--empty {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--scn-line);
    color: var(--scn-muted);
}

.scn-thumb--empty svg {
    width: 62%;
    height: 62%;
}

.scn-result-thumb {
    float: left;
    width: var(--scn-thumb, 32px);
    height: var(--scn-thumb, 32px);
    margin: 0 8px 0 0;
    border-radius: 4px;
    object-fit: contain;
}

.scn-toggle {
    display: inline-flex;
    user-select: none;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 40px;
    min-height: 40px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: var(--scn-radius);
    background: transparent;
    color: var(--scn-muted);
    cursor: pointer;
}

.scn-toggle:hover {
    background: var(--scn-hover);
    color: var(--scn-accent);
}

.scn-chevron {
    width: 18px;
    height: 18px;
    transition: transform .15s ease;
}

.scn-toggle[aria-expanded="true"] .scn-chevron,
.scn-toggle.is-open .scn-chevron {
    transform: rotate(180deg);
}

.scn-toggle[aria-expanded="true"],
.scn-toggle.is-open {
    color: var(--scn-accent);
}

.scn-current > .scn-row > .scn-link,
.scn-path > .scn-row > .scn-link {
    color: var(--scn-accent);
    font-weight: 600;
}

.scn-current > .scn-row {
    box-shadow: inset 2px 0 0 var(--scn-accent);
}

.scn-current > .scn-row > .scn-link {
    padding-left: 8px;
}

.scn-children {
    display: none;
}

.scn-children.is-open {
    display: block;
}

.scn-children > .scn-list {
    margin-left: 10px;
    padding-left: 8px;
    border-left: 1px solid var(--scn-line);
}

.scn-extra {
    display: none;
}

.scn-list.is-expanded > .scn-extra {
    display: block;
}

.scn-more > .scn-more-btn {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    padding: 4px 2px;
    border: 0;
    background: transparent;
    color: var(--scn-accent);
    font: inherit;
    font-size: .9em;
    cursor: pointer;
    text-decoration: underline;
}

.scn-loading {
    padding: 8px 2px;
    color: var(--scn-muted);
    font-size: .9em;
}

/* Filter results --------------------------------------------------------- */

.scn-results {
    padding: 4px 0;
}

.scn-result {
    display: block;
    padding: 8px 2px;
    min-height: 44px;
    border-bottom: 1px solid var(--scn-line);
    color: inherit;
    text-decoration: none;
}

.scn-result:hover {
    color: var(--scn-accent);
    text-decoration: none;
}

.scn-result-name {
    display: block;
    font-weight: 600;
}

.scn-result-path {
    display: block;
    color: var(--scn-muted);
    font-size: .82em;
}

.scn-empty {
    padding: 12px 2px;
    color: var(--scn-muted);
    font-size: .9em;
}

/* Drill down panes ------------------------------------------------------- */

.scn-drillbar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 4px;
    border-bottom: 1px solid var(--scn-line);
}

.scn-allrow {
    display: flex;
    align-items: center;
    flex: 1 1 auto;
    min-width: 0;
    min-height: 44px;
    padding: 8px 2px;
    color: var(--scn-accent);
    font-weight: 600;
    text-decoration: none;
}

.scn-allrow:hover {
    text-decoration: underline;
}

.scn-panes > .scn-list {
    margin: 0;
    padding: 0;
    border: 0;
}

.scn-slide-in {
    animation: scn-slide-in .18s ease;
}

.scn-slide-back {
    animation: scn-slide-back .18s ease;
}

@keyframes scn-slide-in {
    from { transform: translateX(14px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes scn-slide-back {
    from { transform: translateX(-14px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Drawer ----------------------------------------------------------------- */

.scn-overlay {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 100000;
    background: rgba(0, 0, 0, .45);
    opacity: 0;
    transition: opacity .2s ease;
}

.scn-overlay.is-visible {
    opacity: 1;
}

.scn-panel.is-drawer {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100001;
    display: flex;
    flex-direction: column;
    width: 86vw;
    max-width: 380px;
    max-height: none;
    padding: 12px 14px calc(14px + env(safe-area-inset-bottom, 0px));
    background: #fff;
    color: #232323;
    box-shadow: 0 0 24px rgba(0, 0, 0, .25);
    transform: translateX(-100%);
    transition: transform .22s ease;
    overflow: hidden;
}

.scn-panel.is-drawer.is-open {
    transform: translateX(0);
}

.scn-panel.is-drawer .scn-head {
    flex: 0 0 auto;
}

.scn-panel.is-drawer .scn-body {
    flex: 1 1 auto;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.scn-panel.is-drawer .scn-link,
.scn-panel.is-drawer .scn-toggle {
    min-height: 48px;
}

.scn-panel.is-drawer .scn-toggle {
    width: 48px;
}

.scn-panel.is-drawer .scn-result,
.scn-panel.is-drawer .scn-allrow {
    min-height: 48px;
}

.scn-panel.is-drawer .scn-thumb,
.scn-panel.is-drawer .scn-result-thumb {
    width: calc(var(--scn-thumb, 32px) + 6px);
    height: calc(var(--scn-thumb, 32px) + 6px);
}

.scn-result {
    overflow: hidden;
}

html.scn-locked,
body.scn-locked {
    overflow: hidden !important;
}

@media (prefers-reduced-motion: reduce) {
    .scn-chevron,
    .scn-children,
    .scn-overlay,
    .scn-panel.is-drawer {
        transition: none !important;
    }

    .scn-slide-in,
    .scn-slide-back {
        animation: none !important;
    }
}

/* Links, account and switchers under the tree. They belong to the drawer, so
   they stay out of sight while the panel sits in the column of the page. */

.scn-foot {
    display: none;
    margin-top: 10px;
    border-top: 1px solid var(--scn-line);
}

.scn-panel.is-drawer .scn-foot {
    /* the script decides when this shows; the rule is only a safety net for a
       drawer opened on a small screen */
    margin-top: 10px;
}

.scn--drawer-only {
    display: none;
}

.scn-foot-contact {
    display: flex;
    justify-content: center;
    padding: 16px 8px;
    border-top: 1px solid var(--scn-line);
}

.scn-contact {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    padding: 8px 12px;
    color: inherit;
    text-decoration: none;
}

.scn-contact:hover {
    color: var(--scn-accent);
    text-decoration: none;
}

.scn-foot-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.scn-foot-list li {
    margin: 0;
    list-style: none;
    border-bottom: 1px solid var(--scn-line);
}

.scn-foot-list a {
    display: flex;
    align-items: center;
    min-height: 48px;
    padding: 8px 2px;
    color: inherit;
    text-decoration: none;
}

.scn-foot-list a:hover {
    color: var(--scn-accent);
    text-decoration: none;
}

.scn-foot-account {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 14px;
    padding: 16px 8px;
    border-top: 1px solid var(--scn-line);
}

.scn-account {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    padding: 8px 18px;
    border: 1px solid var(--scn-line);
    border-radius: var(--scn-radius);
    color: inherit;
    text-decoration: none;
}

.scn-account svg {
    width: 18px;
    height: 18px;
}

.scn-account:hover {
    border-color: var(--scn-accent);
    color: var(--scn-accent);
    text-decoration: none;
}

.scn-account--logout {
    border: 0;
    padding: 8px 4px;
    color: #c0392b;
}

.scn-account--logout:hover {
    color: #c0392b;
    text-decoration: underline;
}

.scn-foot-switch {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    padding: 14px 8px;
    border-top: 1px solid var(--scn-line);
}

.scn-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 46px;
    min-height: 40px;
    padding: 6px 14px;
    border: 0;
    border-radius: 3px;
    background: transparent;
    color: inherit;
    font-size: .95em;
    text-decoration: none;
}

.scn-chip:hover {
    color: var(--scn-accent);
    text-decoration: none;
}

.scn-chip.is-current {
    background: var(--scn-accent);
    border-color: var(--scn-accent);
    color: #fff;
}
