/* ==========================================================================
   Rhymes page (/rhymes, /rhymes/word/*, /rhymes/suffix/*)

   Previously ~215 lines inlined in public/pages/rhymes.php, which meant it
   could not be cache-busted by ASSETS_VERSION or shared with any other page.
   ========================================================================== */

/* --- search box ---------------------------------------------------------- */

.searchHolder {
    margin: 30px 0;
    background: linear-gradient(135deg, #F3EADF 0%, #D6EEFC 100%);
    padding: 30px;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 180, 240, 0.1);
    border: 2px solid rgba(96, 142, 201, 0.2);
}
.searchHolder h1 {
    margin-bottom: 8px;
    font-size: 32px;
    color: #504F4F;
    font-weight: 700;
    text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.5);
}
.searchHolder p {
    color: #8093A8;
    font-size: 16px;
    margin-bottom: 20px;
}
.searchHolder form {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 15px;
    max-width: 700px;
}
.searchHolder input[type="search"] {
    flex: 1 1 200px;
    min-width: 0; /* lets the field shrink instead of pushing the button off-screen */
    padding: 16px 20px;
    font-size: 18px;
    border: 3px solid #608EC9;
    border-radius: 12px;
    background: white;
    color: #504F4F;
    transition: all 0.3s ease;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
}
.searchHolder input[type="search"]:focus {
    outline: none;
    border-color: #00B4F0;
    box-shadow: 0 0 0 4px rgba(0, 180, 240, 0.15), inset 0 2px 4px rgba(0, 0, 0, 0.05);
    transform: translateY(-1px);
}
.searchHolder input[type="search"]::placeholder {
    color: #8093A8;
    opacity: 0.8;
}
.searchHolder input[type="submit"] {
    padding: 16px 32px;
    background: linear-gradient(135deg, #00B4F0 0%, #608EC9 100%);
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-size: 18px;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 180, 240, 0.3);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}
.searchHolder input[type="submit"]:hover {
    background: linear-gradient(135deg, #00B4F0 0%, #00B4F0 100%);
    box-shadow: 0 6px 16px rgba(0, 180, 240, 0.4);
    transform: translateY(-2px);
}
.searchHolder input[type="submit"]:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(0, 180, 240, 0.3);
}

/* --- results grid --------------------------------------------------------

   This replaces `float: right` boxes locked to 145x36px. Long words
   (פרספקטיבה, אלטרנטיבה, תלמידים) used to overflow the fixed height and
   collide with their neighbours, and on a 390px phone only two 145px columns
   fitted, wasting ~60px. A track-based grid sizes itself instead.
   -------------------------------------------------------------------------- */

/* Was `overflow:hidden; padding-left:5px` inline -- the overflow existed only
   to clear the old floats, and the padding was a physical side on an RTL page. */
.rhyme-results {
    padding-inline-start: 5px;
}

.rhyme-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 8px;
    margin: 0 0 8px;
}

.echo_rhyme_ex {
    transition: opacity 0.2s;
    min-width: 0; /* grid items default to min-content; without this long words overflow */
}

.echo_rhyme_in {
    display: flex;
    flex-direction: column;   /* word above the vote buttons -- on mobile they
                                 used to sit on one line and overlap */
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: 52px;
    height: 100%;
    padding: 6px 4px;
    border-radius: 8px;
    box-sizing: border-box;
}

.echo_rhyme_in .rhyme-word {
    font-size: 16px;
    text-decoration: none;
    color: #8A5A44;
    font-weight: 500;
    text-align: center;
    line-height: 1.25;
    overflow-wrap: anywhere; /* a very long word wraps instead of escaping the box */
    hyphens: auto;
}
.echo_rhyme_in .rhyme-word:hover {
    text-decoration: underline;
    color: #00B4F0;
}

/* --- quality sections (phonetic engine) ---------------------------------- */

.rhyme-section {
    margin: 0 0 26px;
}
.rhyme-section-title {
    margin: 22px 0 4px;
    font-size: 20px;
    font-weight: 700;
    color: #504F4F;
    padding-bottom: 8px;
    border-bottom: 3px solid #00B4F0;
}
.rhyme-section-count {
    font-size: 14px;
    font-weight: 500;
    color: #8093A8;
}
.rhyme-section-hint {
    margin: 0 0 12px;
    font-size: 13px;
    color: #8093A8;
}

.rhyme-section--perfect .echo_rhyme_in {
    background: linear-gradient(135deg, rgba(0, 180, 240, 0.12) 0%, rgba(96, 142, 201, 0.12) 100%);
    border: 1px solid rgba(0, 180, 240, 0.4);
}
.rhyme-section--perfect .rhyme-word {
    color: #006fa6;
    font-weight: 700;
    font-size: 17px;
}
.rhyme-section--good .echo_rhyme_in {
    background: rgba(0, 180, 240, 0.05);
    border: 1px solid rgba(0, 180, 240, 0.2);
}
.rhyme-section--good .rhyme-word {
    color: #00B4F0;
    font-weight: 600;
}
.rhyme-section--near .rhyme-word {
    color: #8A5A44;
}
.rhyme-section--inflection {
    opacity: 0.8;
}
.rhyme-section--inflection .rhyme-section-title {
    border-bottom-color: #D6D6D6;
    font-size: 18px;
}
.rhyme-section--inflection .rhyme-word {
    color: #8A8A8A;
    font-weight: 400;
    font-size: 15px;
}

/* --- legacy tiers (fallback engine) -------------------------------------- */

.echo_rhyme_ex.tier-best .echo_rhyme_in {
    background: linear-gradient(135deg, rgba(0, 180, 240, 0.12) 0%, rgba(96, 142, 201, 0.12) 100%);
    border: 1px solid rgba(0, 180, 240, 0.4);
}
.echo_rhyme_ex.tier-best .rhyme-word { color: #006fa6; font-weight: 700; font-size: 17px; }
.echo_rhyme_ex.tier-strong .rhyme-word { color: #00B4F0; font-weight: 600; }
.echo_rhyme_ex.tier-medium .rhyme-word { color: #8A5A44; font-weight: 500; }
.echo_rhyme_ex.tier-weak .rhyme-word { color: #999; font-weight: 400; font-size: 14px; }
.echo_rhyme_ex.tier-weak { opacity: 0.75; }

/* --- length filter chips ------------------------------------------------- */

.length-filter {
    margin: 16px 0 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}
.length-filter .label {
    color: #666;
    font-size: 14px;
    margin-inline-end: 4px;
}
.length-filter button {
    background: #fff;
    color: #608EC9;
    border: 2px solid #608EC9;
    padding: 6px 14px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    font-family: inherit;
}
.length-filter button:hover { background: rgba(0, 180, 240, 0.1); }
.length-filter button.active {
    background: linear-gradient(135deg, #00B4F0 0%, #608EC9 100%);
    color: #fff;
    border-color: #00B4F0;
    box-shadow: 0 2px 8px rgba(0, 180, 240, 0.3);
}
.length-filter .count { font-size: 11px; opacity: 0.8; margin-inline-start: 4px; }

.echo_rhyme_ex.filtered-out { display: none; }

/* Shown when a length chip filters every result out of a section. */
.rhyme-empty-filter {
    display: none;
    margin: 8px 0 0;
    padding: 12px 16px;
    background: #FFF8E5;
    border-inline-start: 4px solid #FFC107;
    border-radius: 8px;
    color: #6b5a2a;
    font-size: 14px;
}
.rhyme-section.is-empty .rhyme-empty-filter { display: block; }
.rhyme-section.is-empty .rhyme-grid { display: none; }

/* --- browse landing: suffix clusters ------------------------------------- */

.suffix-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
    margin-top: 16px;
}
.suffix-cluster {
    background: linear-gradient(135deg, #F3EADF 0%, #D6EEFC 100%);
    border: 2px solid #608EC9;
    border-radius: 10px;
    padding: 12px 16px;
    text-decoration: none;
    color: #504F4F;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}
.suffix-cluster:hover {
    background: linear-gradient(135deg, #00B4F0 0%, #608EC9 100%);
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 4px 14px rgba(0, 180, 240, 0.35);
    text-decoration: none;
}
.suffix-cluster .suffix-key { font-weight: 700; font-size: 22px; line-height: 1.1; }
.suffix-cluster .suffix-count { font-size: 12px; opacity: 0.85; margin-top: 4px; }
.suffix-cluster:hover .suffix-key,
.suffix-cluster:hover .suffix-count { color: #fff; }

.browse-section { margin-top: 30px; }
.browse-section h2 {
    font-size: 22px;
    color: #504F4F;
    font-weight: 700;
    border-bottom: 3px solid #00B4F0;
    padding-bottom: 8px;
    margin: 0 0 8px;
}
.browse-section .browse-hint { color: #666; font-size: 14px; margin: 0 0 8px; }

/* --- headings and cross-links -------------------------------------------- */

#title_results {
    margin: 20px 0 12px;
    width: 100%;
    font-size: 22px;
    font-weight: bold;
    color: #504F4F;
    padding-bottom: 10px;
    border-bottom: 3px solid #00B4F0;
}

.more_propositions {
    margin: 20px 0;
    padding: 20px;
    background: rgba(214, 238, 252, 0.3);
    border-radius: 12px;
    border: 2px solid rgba(96, 142, 201, 0.3);
}
.more_propositions_link {
    background: linear-gradient(135deg, #F3EADF 0%, #D6EEFC 100%);
    color: #504F4F;
    padding: 10px 20px;
    margin-inline-end: 10px;
    border-radius: 8px;
    text-decoration: none;
    display: inline-block;
    border: 2px solid #608EC9;
    font-weight: 500;
    transition: all 0.3s ease;
}
.more_propositions_link:hover {
    background: linear-gradient(135deg, #00B4F0 0%, #608EC9 100%);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 180, 240, 0.3);
}

/* --- recent searches sidebar --------------------------------------------- */

#right_content {
    float: left;
    border: 3px solid #608EC9;
    background: linear-gradient(135deg, #F3EADF 0%, rgba(214, 238, 252, 0.5) 100%);
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(96, 142, 201, 0.2);
}
#right_content h3 {
    margin-top: 0;
    font-size: 18px;
    color: #504F4F;
    font-weight: 700;
    border-bottom: 2px solid #00B4F0;
    padding-bottom: 8px;
    margin-bottom: 15px;
}
#right_content a {
    font-size: 15px;
    text-decoration: none;
    line-height: 2;
    color: #8A5A44;
    font-weight: 500;
    transition: color 0.2s ease;
}
#right_content a:hover {
    color: #00B4F0;
    text-decoration: none;
}

/* --- vote buttons -------------------------------------------------------- */

.like-dislike {
    display: inline-flex;
    gap: 2px;
}
.like-btn,
.dislike-btn {
    cursor: pointer;
    padding: 2px 5px;
    border: 0;
    background: none;
    border-radius: 6px;
    opacity: 0.65;
    transition: all 0.2s ease;
    font-size: 13px;
    line-height: 1;
    font-family: inherit;
}
.like-btn:hover,
.dislike-btn:hover {
    opacity: 1;
    transform: scale(1.25);
}
.like-btn:focus-visible,
.dislike-btn:focus-visible {
    outline: 2px solid #00B4F0;
    outline-offset: 2px;
    opacity: 1;
}
.like-btn.is-voted,
.dislike-btn.is-voted {
    opacity: 1;
    transform: scale(1.15);
}
.echo_rhyme_ex.is-voting { opacity: 0.5; }

/* --- intro --------------------------------------------------------------- */

.intro-text {
    background: linear-gradient(135deg, #F3EADF 0%, #D6EEFC 100%);
    padding: 25px;
    border-radius: 12px;
    margin: 20px 0;
    line-height: 1.8;
    border-inline-start: 5px solid #00B4F0;
    box-shadow: 0 4px 15px rgba(96, 142, 201, 0.15);
    color: #504F4F;
}

/* --- small screens ------------------------------------------------------- */

@media (max-width: 640px) {
    .searchHolder { padding: 20px; }
    .searchHolder h1 { font-size: 26px; }
    .searchHolder input[type="search"],
    .searchHolder input[type="submit"] { padding: 13px 16px; font-size: 16px; }

    /* Narrower tracks so a phone fits three columns instead of two. */
    .rhyme-grid { grid-template-columns: repeat(auto-fill, minmax(94px, 1fr)); gap: 6px; }
    .echo_rhyme_in { min-height: 48px; }
    .echo_rhyme_in .rhyme-word { font-size: 15px; }
    .rhyme-section-title { font-size: 18px; }

    /* The sidebar float collapses to a full-width block rather than being
       squeezed into a ~50px column beside the results. */
    #right_content { float: none; width: auto; margin-bottom: 20px; }
}

/* Shown when the rhymes come from the base form of the typed word
   (והחלום -> חלום). */
.rhyme-base-note {
    margin: 4px 0 12px;
    padding: 8px 12px;
    font-size: 14px;
    color: #504F4F;
    background: #f4fafe;
    border-right: 3px solid #00B4F0;
    border-radius: 6px;
}
.rhyme-base-note a {
    color: #006fa6;
    font-weight: 700;
}
