/* =============================================================================
   TRUTH ABOUT NURSING — READ ALOUD (styles)
   Pairs with read-aloud.js. Everything is namespaced .ra-* so it cannot
   collide with the site's own styles or the blog theme.
   ========================================================================== */

.ra-root {
    --ra-navy:   #2d4a6e;
    --ra-navy-2: #4a7a9c;
    --ra-orange: #e27c2e;
    --ra-orange-d: #c55a1a;
    --ra-border: #dee5ea;
    --ra-soft:   #eef2f5;
    --ra-muted:  #64748b;

    position: fixed;
    right: 1.25rem;
    bottom: 1.25rem;
    z-index: 9000;
    font-family: 'Inter', -apple-system, 'Segoe UI', sans-serif;
}

/* ------------------------------------------------------------------- button */
.ra-fab {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.7rem 1.15rem;
    border: 0;
    border-radius: 40px;
    background: linear-gradient(135deg, var(--ra-navy) 0%, var(--ra-navy-2) 100%);
    color: #fff;
    font-size: 0.85rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(45, 74, 110, 0.28);
    transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
}
.ra-fab:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 26px rgba(45, 74, 110, 0.34);
}
.ra-fab:focus-visible {
    outline: 3px solid var(--ra-orange);
    outline-offset: 3px;
}
.ra-fab-icon { display: inline-flex; color: #f2c94c; }

/* Gentle pulse on the icon only while actually speaking */
.ra-root.speaking .ra-fab { background: var(--ra-orange); }
.ra-root.speaking .ra-fab-icon { color: #fff; animation: ra-pulse 1.4s ease-in-out infinite; }
@keyframes ra-pulse { 0%,100% { opacity: 1 } 50% { opacity: .45 } }

/* -------------------------------------------------------------------- panel */
.ra-panel {
    position: absolute;
    right: 0;
    bottom: calc(100% + 0.65rem);
    width: 290px;
    background: #fff;
    border: 1px solid var(--ra-soft);
    border-radius: 18px;
    box-shadow: 0 18px 44px rgba(45, 74, 110, 0.22);
    padding: 1.1rem 1.2rem 1rem;
}
.ra-panel[hidden] { display: none; }

.ra-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.9rem;
}
.ra-head strong {
    font-family: 'Bitter', Georgia, serif;
    font-size: 0.95rem;
    color: var(--ra-navy);
}
.ra-x {
    border: 0;
    background: none;
    font-size: 1.4rem;
    line-height: 1;
    color: var(--ra-muted);
    cursor: pointer;
    padding: 0 0.15rem;
    border-radius: 6px;
}
.ra-x:hover { color: var(--ra-orange); }
.ra-x:focus-visible { outline: 2px solid var(--ra-orange); outline-offset: 2px; }

/* ---------------------------------------------------------------- transport */
.ra-transport {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.9rem;
}
.ra-btn {
    flex: 0 0 auto;
    border: 1px solid var(--ra-border);
    background: #fff;
    color: var(--ra-navy);
    border-radius: 10px;
    padding: 0.5rem 0.6rem;
    font-size: 0.75rem;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.ra-btn:hover {
    background: var(--ra-navy);
    border-color: var(--ra-navy);
    color: #fff;
}
.ra-btn:focus-visible { outline: 2px solid var(--ra-orange); outline-offset: 2px; }

.ra-play {
    flex: 1 1 auto;
    background: var(--ra-orange);
    border-color: var(--ra-orange);
    color: #fff;
    font-weight: 600;
    font-size: 0.82rem;
    padding: 0.55rem 0.7rem;
}
.ra-play:hover { background: var(--ra-orange-d); border-color: var(--ra-orange-d); }

/* --------------------------------------------------------------- rate/voice */
.ra-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.65rem;
}
.ra-row > label {
    flex: 0 0 46px;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--ra-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.ra-rates { display: flex; gap: 0.25rem; flex: 1; }
.ra-rate {
    flex: 1;
    border: 1px solid var(--ra-border);
    background: #fff;
    color: var(--ra-navy);
    border-radius: 8px;
    padding: 0.32rem 0;
    font-size: 0.72rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
}
.ra-rate.on { background: var(--ra-navy); border-color: var(--ra-navy); color: #fff; }
.ra-rate:focus-visible { outline: 2px solid var(--ra-orange); outline-offset: 1px; }

.ra-select {
    flex: 1;
    min-width: 0;
    border: 1px solid var(--ra-border);
    border-radius: 8px;
    padding: 0.35rem 0.45rem;
    font-size: 0.75rem;
    font-family: inherit;
    color: var(--ra-navy);
    background: #fff;
}
.ra-select:focus-visible { outline: 2px solid var(--ra-orange); outline-offset: 1px; }

.ra-note {
    margin: 0.75rem 0 0;
    font-size: 0.68rem;
    line-height: 1.45;
    color: var(--ra-muted);
}

/* ------------------------------------------------- the sentence being read */
.ra-reading {
    background: linear-gradient(transparent 12%, #fdf0dd 12%, #fdf0dd 88%, transparent 88%);
    box-shadow: inset 3px 0 0 var(--ra-orange);
    padding-left: 0.55rem !important;
    border-radius: 3px;
    transition: background 0.2s;
}

/* screen-reader-only live region */
.ra-live {
    position: absolute;
    width: 1px; height: 1px;
    margin: -1px; padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* ------------------------------------------------------------------ mobile */
@media (max-width: 600px) {
    .ra-root { right: 0.8rem; bottom: 0.8rem; }
    .ra-fab-text { display: none; }          /* icon-only, keeps clear of GTranslate */
    .ra-fab { padding: 0.8rem; border-radius: 50%; }
    .ra-panel {
        width: calc(100vw - 1.6rem);
        max-width: 320px;
        right: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ra-fab, .ra-btn, .ra-reading { transition: none; }
    .ra-root.speaking .ra-fab-icon { animation: none; }
}

@media print {
    .ra-root { display: none !important; }
    .ra-reading { background: none; box-shadow: none; padding-left: 0 !important; }
}

/* =============================================================================
   VOICE INPUT (microphone) — pairs with voice-input.js
   ========================================================================== */

.ra-root .vi-fab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    margin-left: 0.4rem;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: #fff;
    color: var(--ra-navy);
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(45, 74, 110, 0.22);
    transition: transform 0.2s, box-shadow 0.2s, background 0.2s, color 0.2s;
    vertical-align: middle;
}
.ra-root .vi-fab:hover {
    transform: translateY(-2px);
    background: var(--ra-navy);
    color: #fff;
}
.ra-root .vi-fab:focus-visible { outline: 3px solid var(--ra-orange); outline-offset: 3px; }

/* Standalone (read-aloud.js not present) */
.ra-root.vi-only { display: flex; align-items: center; }

/* Actively listening */
.ra-root.vi-listening .vi-fab {
    background: #c0392b;
    color: #fff;
    animation: vi-pulse 1.3s ease-in-out infinite;
}
@keyframes vi-pulse {
    0%,100% { box-shadow: 0 0 0 0 rgba(192,57,43,.55) }
    50%     { box-shadow: 0 0 0 12px rgba(192,57,43,0) }
}

/* Transcript / status bubble */
.vi-bubble {
    position: absolute;
    right: 0;
    bottom: calc(100% + 0.6rem);
    max-width: 290px;
    background: var(--ra-navy);
    color: #fff;
    font-size: 0.8rem;
    line-height: 1.45;
    padding: 0.6rem 0.85rem;
    border-radius: 12px;
    box-shadow: 0 10px 28px rgba(45,74,110,.3);
}
.vi-bubble[hidden] { display: none; }

@media (max-width: 600px) {
    .ra-root .vi-fab { width: 46px; height: 46px; }
    .vi-bubble { max-width: calc(100vw - 2rem); }
}
@media (prefers-reduced-motion: reduce) {
    .ra-root.vi-listening .vi-fab { animation: none; }
    .ra-root .vi-fab { transition: none; }
}
@media print { .vi-bubble { display: none !important; } }
