/* ClearQuran search (mobile): a page of its own, in place of the reader.
   At the top, a blue bar like the reader's header: the back arrow and the search box. Below it, the results. */

#search-page {
    display: none;
}

/*-------- The bar at the top: back arrow and search box --------*/
#search-top {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    height: 60px;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 10px 0 4px;
    background-color: #3a569e;          /* the header blue */
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

#search-page-exit-button {
    flex: none;
    padding: 8px;                       /* a bigger tap area */
    line-height: 0;
    cursor: pointer;
}

#search-page-exit-button svg {
    width: 26px;
    height: 26px;
    fill: none;
    stroke: #ffffff;
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

#search-form {
    flex: 1;
    min-width: 0;
    margin: 0;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 42px;
    padding: 0 4px 0 12px;
    border-radius: 21px;
    background-color: #ffffff;
    cursor: text;
}

.search-box-icon {
    flex: none;
    width: 20px;
    height: 20px;
    fill: none;
    stroke: #888888;
    stroke-width: 2.4;
    stroke-linecap: round;
}

#search-input {
    flex: 1;
    min-width: 0;
    height: 100%;
    padding: 0;
    border: none;
    outline: none;
    background: transparent;
    font-size: 17px;                    /* 16px or more: iPhones don't zoom in when it is tapped */
    color: #222222;
    -webkit-appearance: none;
    appearance: none;
}

#search-input::placeholder {
    color: #999999;
}

#search-input::-webkit-search-cancel-button {
    -webkit-appearance: none;           /* the browser's own x: we have ours */
    display: none;
}

/* The x that empties the box: a plain gray x, like the magnifier at the other end */
#search-clear {
    flex: none;
    width: 34px;
    height: 34px;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
}

#search-clear span {
    position: relative;
    display: block;             /* (a block, so it centers in the button rather than sitting on the text line) */
    margin: 0 auto;
    width: 22px;
    height: 22px;
    font-size: 0;               /* the x character in the page is hidden; the x is drawn below, the same on every phone */
    color: transparent;
}
#search-clear span::before,
#search-clear span::after {     /* the two strokes of the x */
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: 16px;
    height: 2px;
    border-radius: 1px;
    background-color: #777777;  /* the magnifier's gray, a shade stronger */
}
#search-clear span::before { transform: translate(-50%, -50%) rotate(45deg); }
#search-clear span::after  { transform: translate(-50%, -50%) rotate(-45deg); }

/*-------- Below the bar: the count, and the results --------*/
#search-page-search-container {
    max-width: calc(var(--content-w) + 40px);   /* with the 20 px padding: the results as wide as the reader's text (reader.css) */
    margin: 0 auto;
    padding: 72px 20px 160px;           /* room for the bar at the top, and for scrolling past the last result */
}

#search-status {
    padding: 4px 0 6px;
    color: #777777;
    font-size: 14px;
}

.search-result {
    margin: 0 -16px;                    /* the tap area and the line between results reach the screen edges */
    padding: 12px 16px;
    border-bottom: 1px solid #eeeeee;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.search-result:active {
    background-color: #f4f7fd;          /* a soft blue tint while tapped */
}

.search-result-info-a {
    display: inline;
    font-weight: 500;
}

.not-visited {
    color: #3a569e;
}

.visited {
    color: #660099;                     /* results already opened */
}

.search-result-text {
    display: inline;
    line-height: 1.55;
    color: #212121;
}

.search-result-text b {
    font-weight: normal;                /* the words found: a highlighter background, not bold */
    background-color: #ffe36e;          /* highlighter yellow, the same as QuranFul */
    border-radius: 3px;
    padding: 0 2px;
    margin: 0 -2px;
}

/* Where each new batch of results starts (after See More), e.g. "Results 51–100" */
.search-batch-divider {
    margin: 0 -16px;
    padding: 8px 16px;
    background-color: #f1f2f4;
    color: #555555;
    font-size: 14px !important;         /* stays small; the script sets the result text sizes */
    font-weight: 500;
}

/* See More */
.search-btn {
    width: 160px;
    margin: 18px auto;
    padding: 10px;
    border-radius: 21px;
    background-color: #eef1f8;
    color: #3a569e;
    font-weight: 500;
    font-size: 16px;
    text-align: center;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
}

/* The spinner, while the text downloads (the first search only) */
.search-spinner-container {
    padding: 16px 4px;
}

.search-spinner {
    width: 30px;
    height: 30px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #3a569e;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/*-------- Night mode (set from the Aa panel) --------*/
html.night #search-top {
    background-color: #34496b;          /* the same steel blue as the reader's header at night */
}
html.night .search-box {
    background-color: #2a3138;
}
html.night #search-input {
    color: #e6e9ec;
}
html.night #search-input::placeholder {
    color: #8f9aa3;
}
html.night #search-clear span::before,
html.night #search-clear span::after {
    background-color: #a3adb6;          /* a soft light gray on the dark box */
}
html.night #search-status {
    color: #8f9aa3;
}
html.night .search-result {
    border-bottom-color: #2c343b;
}
html.night .search-result:active {
    background-color: #22282e;
}
html.night .not-visited {
    color: #8fb0ec;
}
html.night .visited {
    color: #b48fd9;
}
html.night .search-result-text {
    color: #c9cfd5;
}
html.night .search-result-text b {
    background-color: #6a5517;          /* a muted amber, so it doesn't glare (the same as QuranFul) */
    color: #ffffff;
}
html.night .search-batch-divider {
    background-color: #22282e;
    color: #a3adb6;
}
html.night .search-btn {
    background-color: #2a3138;
    color: #a9bdf0;
}
html.night .search-spinner {
    border-color: #2c343b;
    border-top-color: #8fb0ec;
}
