/* ============================================================
   NORHI Scribe — Dictate + Hide Widgets
   Self-contained, no Tailwind, no CSS variable dependencies.
   Ported from NUAMP source.css lines 1253-1472 (2026-05-14).

   Colors inlined for portability:
     --color-widget-dictate: #7c2d12  (terracotta)
     --color-widget-hide:    #5c6460  (gray, the fleet's muted text grey)
     --color-widget-success: #166534  (the fleet's success text green)
   ============================================================ */

/* Desktop FAB stack (right edge, vertical) */
#widget-fab-stack {
    position: fixed;
    right: 24px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 9990;
    display: flex;
    flex-direction: column;  /* hide on top, dictate on bottom */
    gap: 12px;
    align-items: flex-end;
    transition: opacity 0.25s ease;
}

#widget-fab-stack.widgets-hidden {
    opacity: 0 !important;
    pointer-events: none !important;
}

/* Stepped aside: a keyboard-focused control sits under the buttons (dictate.js, the last block); the stack's own
   opacity transition applies, and it comes back as soon as focus moves on */
#widget-fab-stack.widgets-aside,
#dictate-mobile-mount.widgets-aside {
    opacity: 0 !important;
    pointer-events: none !important;
}

/* ============================================================
   HIDE WIDGET BUTTON (top of FAB stack)
   ============================================================ */
.hw-fab {
    position: relative;
    z-index: 9990;
    width: 40px;
    height: 40px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    background: #5c6460;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    touch-action: manipulation;
    box-shadow: 0 4px 16px rgba(92, 100, 96, 0.2);
    opacity: 0.8;  /* at rest: the white icon clears 3:1 on its own fill (3.87:1 over white) */
}
@media (hover: hover) {
    .hw-fab:hover {
        box-shadow: 0 6px 20px rgba(92, 100, 96, 0.25);
        opacity: 1;
    }
}
/* full strength while it has keyboard focus: at the rest opacity the focus ring drew at 2.84:1 */
.hw-fab:focus-visible {
    opacity: 1;
}

/* ============================================================
   DICTATE WIDGET — direct-to-field voice dictation
   ============================================================ */
.dw-fab {
    position: relative;
    z-index: 9990;
    width: 48px;
    height: 48px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    background: #7c2d12;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    touch-action: manipulation;
    box-shadow: 0 4px 16px rgba(124, 45, 18, 0.25);
}
.dw-fab:hover {
    box-shadow: 0 6px 20px rgba(124, 45, 18, 0.3);
}
.dw-fab.recording {
    /* box-shadow driven by JS audio analyser; no CSS animation */
}
.dw-fab.processing {
    opacity: 0.7;
    cursor: wait;
}
.dw-fab.success-flash {
    background: #166534;
    transition: background 0.4s ease;
}

/* Field being targeted for dictation — subtle terracotta outline */
.dictate-target {
    outline: 2px solid #7c2d12 !important;
    outline-offset: 2px;
    transition: outline 0.2s ease;
}

/* ============================================================
   MOBILE DICTATE WIDGET
   Right-side ghost stack — hide button + dictate button
   Only visible on phones/PWA (max-width: 768px)
   Desktop FAB stack is hidden on mobile
   ============================================================ */

#dictate-mobile-mount {
    display: none;  /* shown on mobile via media query below */
    /* top transitions when dictate.js re-centers it around the keyboard */
    transition: opacity 0.25s ease, top 0.2s ease;
}

.dw-fab-mobile {
    width: 52px;
    height: 52px;
    border-radius: 9999px;
    border: none;
    cursor: pointer;
    background: #7c2d12;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(124, 45, 18, 0.35);
    opacity: 0.6;  /* at rest: the white icon clears 3:1 on its own fill (3.37:1 over white) */
    transition: opacity 0.2s ease, transform 0.15s ease;
    touch-action: manipulation;
}
.dw-fab-mobile:active {
    transform: scale(0.95);
    opacity: 1;
}
.dw-fab-mobile.recording,
.dw-fab-mobile.processing,
.dw-fab-mobile.success-flash {
    opacity: 1;
}
.dw-fab-mobile.processing {
    cursor: wait;
}
.dw-fab-mobile.success-flash {
    background: #166534;
    transition: background 0.4s ease, opacity 0.2s ease;
}

.hw-fab-mobile {
    width: 40px;
    height: 40px;
    border-radius: 9999px;
    border: none;
    cursor: pointer;
    background: #5c6460;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(92, 100, 96, 0.25);
    opacity: 0.8;  /* at rest: as the desktop hide button */
    transition: opacity 0.2s ease, transform 0.15s ease;
    touch-action: manipulation;
}
.hw-fab-mobile:active {
    transform: scale(0.95);
    opacity: 1;
}

#dictate-mobile-mount.mobile-widgets-hidden {
    opacity: 0 !important;
    pointer-events: none !important;
}

/* Mobile layout: show mobile mount, hide desktop stack */
@media (max-width: 768px) {
    #widget-fab-stack {
        display: none !important;
    }
    #dictate-mobile-mount {
        display: flex;
        flex-direction: column;
        gap: 10px;
        align-items: center;
        position: fixed;
        right: 12px;
        top: 50%;
        transform: translateY(-50%);
        z-index: 9995;
    }
}
