/* -------------------------------------------------------
   Base layout
------------------------------------------------------- */
body {
    margin: 0;
    font-family: 'Inter', system-ui, sans-serif;
    background: #fafafa;
}

#blocks {
    padding: 16px;
    overflow: visible;   /* remove any scrolling */
    height: auto;        /* ensure it grows naturally */
}

/* -------------------------------------------------------
   Sentence block layout
------------------------------------------------------- */


.display-text {
    display: inline; /* match translation-line */
    line-height: 1.45;
    background: linear-gradient(
        90deg,
        rgba(92, 76, 183, 0.1) 0%,
        rgba(74, 144, 226, 0.1) 100%
    );
    padding: 4px 8px;
    backdrop-filter: blur(2px);
    border-radius: 6px;
    margin-bottom: 4px;
}

.display-text .icon-btn {
    display: inline-flex;
    vertical-align: middle;
    margin-left: 6px;
    user-select: none;
    caret-color: transparent;
}

.display-text-inner {
    white-space: pre-wrap;
}


.translation-line {
    display: inline;
    line-height: 1.45;
    background: rgb(255, 246, 195);
    padding: 4px 8px;
    border-radius: 6px;

}

.translation-line .icon-btn {
    display: inline-flex;
    vertical-align: middle;
    margin-left: 6px;
}

.translation-line .icon-btn img {
    width: 16px;
    height: 16px;
}

.translation-text-inner {
    white-space: pre-wrap;
}

/* -------------------------------------------------------
   RTL support
------------------------------------------------------- */
.rtl {
    direction: rtl;
    text-align: right;
}



#reader-controls {
    position: sticky;
    top: 0;
    z-index: 2000;
    background: #5c4cb7; /* or whatever matches your bars */
}

.right-side {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-left: auto;
}

/* -------------------------------------------------------
   Base icon button
------------------------------------------------------- */
.icon-btn {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;

    background: rgba(255,255,255,0.15);
    border: none;
    cursor: pointer;
}
.icon-btn img {
    width: 18px;
    height: 18px;
}

/* -------------------------------------------------------
   Sentence-level action buttons
------------------------------------------------------- */
.icon-btn.speak-btn {
    width: 22px;
    height: 22px;
    background: #7d6df0;
    border-radius: 50%;
}

.icon-btn.suggest-btn {
    width: 22px;
    height: 22px;
    background: #3aaed8;
    border-radius: 50%;
}

.icon-btn.speak-btn img,
.icon-btn.suggest-btn img {
    width: 16px;
    height: 16px;
}

.speak-btn img {
    content: url('images/play.png');
}

.speak-btn.speaking img {
    content: url('images/stop.png');
}

/* -------------------------------------------------------
   Player Bar (NEW SYSTEM)
------------------------------------------------------- */
#player-bar {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease;

    display: flex;
    justify-content: center;   /* centre the controls */
    align-items: center;
    gap: 12px;
    padding: 10px 14px;

    background: #ece7ff;       /* light tint of topbar */
    border-bottom: 1px solid #d3c8ff;
    flex-wrap: wrap;
}

#player-bar.visible {
    max-height: 200px;
    opacity: 1;
}

/* -------------------------------------------------------
   Language blocks (flag + toggle + speed)
------------------------------------------------------- */
.lang-block {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: #fafafa;
    border: 1px solid #ddd;
    border-radius: 8px;
}

.flag-icon {
    width: 28px;
    height: 20px;
    border-radius: 3px;
    object-fit: cover;
    border: 1px solid #ccc;
}

/* -------------------------------------------------------
   Player toggle button
------------------------------------------------------- */
/* .player-toggle {
    background: #f0f0f0;
    border: 1px solid #ccc;
    margin-right: 12px;
} */

/* 4. All speed buttons */
.readerbar-btn,
.speed-btn {
    width: 32px;
    height: 32px;
    padding: 0;          /* icons fill the box */
    border: 1px solid #ccc;
    background: #f0f0f0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.speed-btn.active {
    background: #4a90e2;
    border-color: #357ab8;
    color: white;
}

/* 5. Both switch buttons */
.switch-btn {
    padding: 6px 10px;
    background: #eee;
    border: 1px solid #ccc;
}


/* 6. Both flags */
.flag-icon {
    width: 28px;
    height: 20px;
    border-radius: 3px;
    border: 1px solid #ccc;
}

/* 7. Both ticks - to play language */
.tick-btn {
    padding: 4px 8px;
    background: #f0f0f0;
    border: 1px solid #ccc;
}

.tick-btn.active {
    background: #4a90e2;
    border-color: #357ab8;
    color: white;
}

/* 8. Toggle button to change colour when active */
.toggle-btn.active {
    background: #4a90e2;
    border-color: #357ab8;
    color: white;
}

/* 9. Play and pause buttons */

.play-btn,
.pause-btn {
    padding: 6px 10px;
    background: #eee;
    border: 1px solid #ccc;
}

/* 10. Lang controls */
.lang-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}
.lang-block {
    justify-content: center;
}

/* 11. speed buttons hold together in a group */
/* .speed-group {
    display: inline-flex;
    align-items: center;
    gap: 6px;

    white-space: nowrap;
    flex-shrink: 0;
} */

/* 12. button group */
.button-group {
    display: inline-flex;
    align-items: center;
    gap: 0px;

    /* Prevent the group from breaking apart */
    white-space: nowrap;
    flex-shrink: 0;
}

/* 13 speak button speaking  */
.speak-btn.speaking {
    background: #d9534f; /* red */
    border-color: #b52b27;
}

.speak-btn.speaking img.icon {
    filter: none; /* ensure the icon isn't inverted */
}



/* == END OF ADDITIONS ==*/

/* -------------------------------------------------------
   Play button
------------------------------------------------------- */
#player-play img.icon {
    width: 20px;
    height: 20px;
}

#player-play.active {
    background: #d9534f;
    border-color: #b52b27;
}

#player-play.active img.icon {
    filter: brightness(0) invert(1);
}

/* -------------------------------------------------------
   Pause button
------------------------------------------------------- */
#player-pause img.icon {
    width: 20px;
    height: 20px;
}
#player-pause img.icon {
    content: url('images/pause.png');
}
#player-pause.active img.icon {
    content: url('images/paused.png');
}

/* -------------------------------------------------------
   Switch button
------------------------------------------------------- */
.ui-btn img.icon {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    pointer-events: none; 
}


/* -------------------------------------------------------
   Mobile tweaks
------------------------------------------------------- */
@media (max-width: 600px) {
    .lang-select .lang-text {
        display: none;
    }

    .nav-btn {
        padding: 6px 8px;
        font-size: 0.8rem;
    }

    #header-bar {
        gap: 8px;
        padding: 6px 10px;
    }

    .flag-icon {
        width: 22px;
        height: 16px;
    }
}
@media (max-width: 600px) {
    #player-bar {
        gap: 10px;
        padding: 6px 8px;
    }

    .lang-block {
        gap: 4px;
        padding: 4px 6px;
    }

    .lang-block .flag-icon {
        width: 22px;
        height: 16px;
    }

    .square-button {
        width: 28px;
        height: 28px;
    }

    .square-button img.icon {
        width: 18px;
        height: 18px;
    }
}
@media (max-width: 400px) {
    #help-btn {
        display: none;
    }
}
@media (max-width: 600px) {
    #swap-btn img {
        width: 20px;
        height: 20px;
    }
}

/* -------------------------------------------------------
   HEADER BUTTON — simple square action button
------------------------------------------------------- */
/* -------------------------------------------------------
   HEADER BUTTON — square, non-toggle, topbar action button
------------------------------------------------------- */
.square-button {
    width: 32px;
    height: 32px;
    border-radius: 6px;

    display: flex;
    align-items: center;
    justify-content: center;

    cursor: pointer;
    user-select: none;
    caret-color: transparent;

    transition: background 0.15s ease, border-color 0.15s ease;
}

.square-button img.icon {
    width: 20px;
    height: 20px;
    object-fit: contain;
    pointer-events: none;
}

.header-button {
    background: #f0f0f0;
    border: 1px solid #ccc;
}

.header-button:hover {
    background: #e4e4e4;
    border-color: #b5b5b5;
}

/* -------------------------------------------------------
   TOGGLE BUTTON — square button with active state
------------------------------------------------------- */
.toggle-button {
    background: #f0f0f0;
    border: 1px solid #ccc;
}

.toggle-button:hover {
    background: #e4e4e4;
    border-color: #b5b5b5;
}

.toggle-button.active {
    background: #4a90e2;
    border-color: #357ab8;
    color: white;
}

/* -------------------------------------------------------
   PLAYER-TOGGLE — layout helper for the ear button
------------------------------------------------------- */
.player-toggle {
    height:32px;
    margin-right: 12px;   /* aligns it with the speed-group */
    margin-left: 12px;
    display: flex; 
    align-items: center;
}

/* -------------------------------------------------------
   SPEED GROUP — keeps speed buttons together
------------------------------------------------------- */
.speed-group {
    display: inline-flex;
    align-items: center;
    gap: 6px;

    white-space: nowrap;   /* prevents wrapping */
    flex-shrink: 0;        /* prevents collapsing */
}
/* -------------------------------------------------------
   SPEED BUTTON — toggle button inside a group
------------------------------------------------------- */
.speed-button {
    /* no size here — inherited from square-button */
    /* no colours here — inherited from toggle-button */
    /* no behaviour here — inherited from toggle-button */

    /* ensure consistent spacing inside the group */
    margin: 0;
    padding: 0;
}

/* -------------------------------------------------------
   ICON GROUP — keep ear + speed buttons aligned
------------------------------------------------------- */
.icon-group {
    display: flex;
    align-items: center;   /* vertical alignment */
    height: 32px;          /* match square-button height */
    gap: 6px;              /* spacing between ear and speed group */
}

/* The marker itself */
/* The vertical marker */
/* The vertical marker */
.line-marker {
    position: absolute;
    left: -8px;          /* ⭐ adjust to taste */
    top: 0;
    bottom: 0;           /* ⭐ full height */
    width: 4px;
    background: transparent;
    border-radius: 2px;
    transition: background 0.2s ease;
}

/* Selected line (blue) */
.sentence-block.selected .line-marker {
    background: #4a90e2;
}

/* Currently reading (orange) */
.sentence-block.reading .line-marker {
    background: #ff9800;
}

/* Ensure the sentence-block aligns horizontally */
/* Your original layout — KEEP THIS */
.sentence-block {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 18px;
    min-width: 0;
    cursor: pointer;
    position: relative; /* ⭐ allows absolute marker */
}
/* .lang-select {
    user-select: none;
    caret-color: transparent;
} */

.lang-block.disabled {
    opacity: 0.4;
    pointer-events: none;
}

#player-bar {
    display: none; /* default hidden */
}

#player-bar.visible {
    display: flex;
}

.sentence-block {
    scroll-margin-top: 134px; /* adjust to height of your sticky header */
}

.topbar {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 12px;

    background: #5c4cb7;
    color: white;
    padding: 14px 18px;
}

.reader-title {
    font-size: 1.35rem;
font-weight: 650;
letter-spacing: -0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 0.9;
    user-select: none;
    caret-color: transparent;}

@media (max-width: 480px) {
    .reader-title {
        display: none;
    }
}

/* Prevent text cursor on non-text UI elements */
button,
.icon-btn,
.ui-btn,
#player-bar button,
#reader-bar button,
.topbar button,
.flag-btn,
.flag-icon,
#title,
#title * {
    cursor: pointer;
    user-select: none;
}

