/* Floating Controls — portable hamburger quick-links menu.
   Drop this file + floating-controls.js into any project and include both:
     <link rel="stylesheet" href="floating-controls/floating-controls.css">
     <script src="floating-controls/floating-controls.js" defer></script>
   No build step, no framework. See demo.html for a working example. */

/* Icon color follows prefers-color-scheme directly rather than inheriting currentColor —
   the host page's own text color isn't guaranteed to track its theme, so relying on
   inheritance risks black-on-black (or white-on-white) icons. Override with
   --fc-icon-color on :root if a project wants a fixed color instead. */
:root {
    --fc-icon-color-auto: #14161c;
}
@media (prefers-color-scheme: dark) {
    :root {
        --fc-icon-color-auto: #f5f5f4;
    }
}

.fc-controls {
    position: fixed;
    top: var(--fc-offset-top, 30px);
    right: var(--fc-offset-right, 30px);
    display: flex;
    align-items: center;
    gap: var(--fc-gap, 20px);
    z-index: var(--fc-z, 9999);
    color: #fff;
    transition: color 0.3s ease;
}

.fc-btn {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    padding: 0;
    color: inherit;
    cursor: pointer;
    transition:
        opacity 0.15s ease,
        transform 0.1s ease;
}
.fc-btn:hover {
    opacity: 0.7;
}
.fc-btn:active {
    transform: scale(0.9);
}
.fc-btn:focus-visible {
    outline: 2px solid var(--fc-accent, #34d399);
    outline-offset: 2px;
    border-radius: 4px;
}

/* hamburger, morphs into a close mark when open */
.fc-menu-btn {
    flex-direction: column;
    gap: 5px;
}
.fc-line {
    display: block;
    width: 22px;
    height: 1px;
    border-radius: 1px;
    background: currentColor;
    transition:
        transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        opacity 0.2s ease;
}
.fc-menu-btn.fc-open .fc-line-1 {
    transform: translateY(6px) rotate(45deg);
}
.fc-menu-btn.fc-open .fc-line-2 {
    opacity: 0;
}
.fc-menu-btn.fc-open .fc-line-3 {
    transform: translateY(-6px) rotate(-45deg);
}

/* dark blurred scrim behind the open menu */
.fc-overlay {
    position: fixed;
    inset: 0;
    background: var(--fc-overlay-bg, rgba(6, 9, 14, 0.32));
    -webkit-backdrop-filter: blur(var(--fc-overlay-blur, 7px));
    backdrop-filter: blur(var(--fc-overlay-blur, 7px));
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: calc(var(--fc-z, 9999) - 5);
}
.fc-overlay.fc-open {
    opacity: 1;
    pointer-events: auto;
}

/* menu: no card chrome — a vertically expanding stack of items over the scrim */
.fc-menu {
    position: fixed;
    top: calc(var(--fc-offset-top, 16px) + 50px);
    right: var(--fc-offset-right, 16px);
    width: var(--fc-menu-width, 250px);
    z-index: var(--fc-z, 9999);
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.38s cubic-bezier(0.4, 0, 0.2, 1);
}
.fc-menu.fc-open {
    grid-template-rows: 1fr;
}
.fc-menu-inner {
    overflow: hidden;
    min-height: 0;
}
.fc-menu-list {
    display: flex;
    flex-direction: column;
    padding-top: 4px;
}

.fc-menu-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px 2px;
    color: var(--fc-menu-text, rgba(255, 255, 255, 1));
    text-decoration: none;
    font-family: var(--fc-menu-font, "Roboto", system-ui, sans-serif);
    font-size: var(--fc-menu-font-size, 20px);
    font-weight: var(--fc-menu-font-weight, 100);
    cursor: pointer;
    border: none;
    background: none;
    text-align: left;
    width: 100%;
    transition:
        color 0.15s ease,
        transform 0.15s ease;
}
.fc-menu-item:hover {
    color: var(--fc-menu-text-hover, #fff);
    transform: translateX(3px);
}
.fc-menu-item:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
    border-radius: 4px;
}

.fc-menu-icon {
    width: 17px;
    height: 17px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.fc-menu-icon svg {
    width: 16px;
    height: 16px;
}
.fc-menu-icon.fc-deva {
    font-size: 14px;
    font-weight: 700;
    line-height: 1;
}
.fc-menu-label {
    flex: 1;
    min-width: 0;
}

/* external-link arrow: one CSS-drawn mark shared by every item, instead of an inline
   svg duplicated per link — add/drop it from an item just by adding/removing this class */
.fc-menu-item::after {
    content: "";
    width: 12px;
    height: 12px;
    flex-shrink: 0;
    background-color: currentColor;
    opacity: 0.45;
    transition: opacity 0.15s ease;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 17L17 7M8 7h9v9'/%3E%3C/svg%3E")
        no-repeat center / contain;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 17L17 7M8 7h9v9'/%3E%3C/svg%3E")
        no-repeat center / contain;
}
.fc-menu-item:hover::after {
    opacity: 0.9;
}

@media (prefers-reduced-motion: reduce) {
    .fc-menu,
    .fc-overlay {
        transition-duration: 0.05s;
    }
    .fc-line {
        transition: none;
    }
}
