/* 16 Line Color Quran reader: styles of the reader page only (read.php). The navigation bar is in quran.css. */
/* ---------- Heading + surah line ---------- */
.reader-title {
    text-transform: none;      /* cancels the all-caps rule from the main CSS */
    letter-spacing: normal;
    color: #044770;
    margin: 0;
    font-size: 24px;
}
.surah-line { margin: 4px 0 0; font-size: 13px; font-weight: 600; color: var(--text-main); opacity: 0.8; }

/* ---------- Theme ---------- */
:root { --body-bg: #f4f1ea; --text-main: #2c3e50; }
[data-theme="dark"] { --body-bg: #121212; --text-main: #e0e0e0; }

#main {
    background-color: var(--body-bg);
    color: var(--text-main);
    transition: background-color 0.3s ease, color 0.3s ease;
}
[data-theme="dark"] .quran-page-img {
    filter: invert(90%) hue-rotate(180deg) brightness(90%) contrast(110%);
}
/* ---------- Page image + wrapper ---------- */
.quran-page-wrapper {
    position: relative;
    display: inline-block;
    -webkit-touch-callout: none;       /* no long-press image menu on phones */
    -webkit-user-select: none;
    user-select: none;
}
.quran-page-img { max-width: 100%; height: auto; -webkit-user-drag: none; }
@media (pointer: coarse) {
    .quran-page-img { pointer-events: none; }   /* touch screens only: desktop right-click is kept */
}
.quran-page-inner {
    display: inline-flex;
    align-items: flex-start;
    position: relative;
    text-align: left;
}

/* ---------- Side toolbar ---------- */
.action-icon-btn {
    border: 1px solid var(--toggle-border, #ccc);
    padding: 1px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 21px;
    height: 21px;
    border-radius: 3px;
    vertical-align: middle;
    background: var(--toggle-bg, #fff);
    color: var(--text-main);
    text-decoration: none;
    cursor: pointer;
}
.action-icon-btn.active {
    background-color: #044770 !important;
    color: #ffffff !important;
    border-color: #044770 !important;
}
[data-theme="dark"] .action-icon-btn { border-color: #444; background: #1e1e1e; }

.side-toolbar {
    position: sticky;
    top: 20px;
    margin-right: 10px;
    display: flex;
    flex-direction: column !important;
    gap: 8px;
    z-index: 30;
}
/* Color + thickness: only shown while the pen or the rectangle is switched on */
.side-toolbar .style-tool, .side-toolbar .pen-tool { display: none; }
.side-toolbar.style-open .style-tool { display: inline-flex; }
.side-toolbar.pen-open .pen-tool { display: inline-flex; }       /* scroll/zoom (pen pause) icon: only while the pen is on */

@media (max-width: 768px) {
    .quran-page-inner { flex-direction: column; align-items: center; }
    .side-toolbar {
        flex-direction: row !important;
        flex-wrap: wrap;
        justify-content: center;
        gap: 6px;
        max-width: 95vw;
        margin-bottom: 10px;
        margin-right: 0;
    }
}

/* ---------- Laser dot ---------- */
#laserDot {
    display: none;
    position: absolute;
    width: 15px;
    height: 15px;
    margin-left: -7.5px;
    margin-top: -7.5px;
    border-radius: 50%;
    background: rgba(255, 0, 0, 0.5);
    box-shadow: 0 0 10px 4px rgba(255, 0, 0, 0.45);
    pointer-events: none;
    z-index: 25;
    animation: laserPulse 1.4s ease-in-out infinite;
}
.quran-page-wrapper:not(.laser-active) #laserDot { display: none !important; }
@keyframes laserPulse {
    0%, 100% { box-shadow: 0 0 10px 4px rgba(255, 0, 0, 0.5); }
    50% { box-shadow: 0 0 15px 5px rgba(255, 0, 0, 0.7); }
}

/* ---------- Hifz strips ---------- */
.hifz-strip {
    position: absolute;
    left: 0;
    width: 100%;
    background-color: rgba(0, 0, 0, 0.92);
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    cursor: pointer;
    z-index: 10;
    transition: background-color 0.15s ease;
}
.hifz-strip.revealed { background-color: transparent; border-bottom: 1px dashed rgba(200, 200, 200, 0.2); }

/* ---------- Pen canvas ---------- */
.quran-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    touch-action: none;
    z-index: 20;
}
.quran-page-wrapper.drawing-active:not(.pen-paused) .quran-canvas { pointer-events: auto; cursor: crosshair; }   /* paused = touches pass through, so scroll and pinch-zoom work */

/* ---------- Text box ---------- */
.text-box {
    position: absolute;
    z-index: 22;                      /* above the drawing canvas (20), below the laser dot (25) */
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    min-width: 80px;
    min-height: 60px;                 /* bar 26px + border 8px + text area at least 26px (matters on small phones) */
    border: 4px solid #044770;
    border-radius: 6px;
    background: none;
    color: #111;
}
[data-theme="dark"] .text-box { border-color: #7fc4ee; }
[data-theme="dark"] .tb-body { color: #ff6b6b; }   /* lighter red so it stays readable on the dark page */
.tb-bar {
    display: flex; justify-content: space-between; align-items: center;
    flex: 0 0 auto; height: 26px; padding: 0 8px;
    background: rgba(4, 71, 112, 0.85); color: #fff; font-size: 12px;
    cursor: move; touch-action: none; user-select: none; -webkit-user-select: none;
}
.tb-body {
    flex: 1; padding: 4px 6px; font-size: 16px; line-height: 1.4;
    outline: none; overflow: auto; min-height: 0;
    background: rgba(192, 192, 192, 0.1);             /* silver, 90% transparent */
    font-weight: 800; color: #d00000;                 /* strong red text */
    -webkit-user-select: text; user-select: text;     /* typing inside the text box still works */
}
.tb-body:empty::before { content: attr(data-placeholder); opacity: 0.55; }
.tb-resize {
    position: absolute; right: 0; bottom: 0; width: 26px; height: 26px;
    cursor: nwse-resize; touch-action: none;
    background: linear-gradient(135deg, transparent 50%, #044770 50%);
    border-bottom-right-radius: 4px;
}

/* ---------- Rectangle + Highlighter: touch inside = move, invisible zones on edges/corners = resize ---------- */
.sh-box { position: absolute; z-index: 22; box-sizing: border-box; touch-action: none; cursor: move; }
.rect-box { outline: 4px solid #d9534f; outline-offset: 0; border-radius: 3px; }   /* outline grows outward, never narrows the line */
.hl-box { background: rgba(255, 235, 0, 0.2); border: 1px solid #ffeb00; }          /* yellow, 80% transparent, thin border of the same color */

.sh-box .z { position: absolute; touch-action: none; }                              /* grab zones are invisible */
.z-n, .z-n2 { top: -10px;    width: 35%; height: 20px; cursor: ns-resize; }   /* top: outer 35% on each side only */
.z-s, .z-s2 { bottom: -10px; width: 35%; height: 20px; cursor: ns-resize; }   /* bottom: same */
.z-n, .z-s { left: 0; }
.z-n2, .z-s2 { right: 0; }
.z-w  { left: -10px;   top: 0; bottom: 0;  width: 20px;  cursor: ew-resize; }
.z-e  { right: -10px;  top: 0; bottom: 0;  width: 20px;  cursor: ew-resize; }
.z-nw { top: -12px;    left: -12px;  width: 24px; height: 24px; cursor: nwse-resize; }
.z-ne { top: -12px;    right: -12px; width: 24px; height: 24px; cursor: nesw-resize; }
.z-sw { bottom: -12px; left: -12px;  width: 24px; height: 24px; cursor: nesw-resize; }
.z-se { bottom: -12px; right: -12px; width: 24px; height: 24px; cursor: nwse-resize; }
