.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid red;
}

.validation-message {
    color: red;
}

#blazor-error-ui {
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

    #blazor-error-ui .dismiss {
        cursor: pointer;
        position: absolute;
        right: 0.75rem;
        top: 0.5rem;
    }

.blazor-error-boundary {
    background: url('../content/system/') no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "An error has occurred."
    }

.loading-progress {
    position: relative;
    display: block;
    width: 8rem;
    height: 8rem;
    margin: 20vh auto 1rem auto;
}

    .loading-progress circle {
        fill: none;
        stroke: #e0e0e0;
        stroke-width: 0.6rem;
        transform-origin: 50% 50%;
        transform: rotate(-90deg);
    }

        .loading-progress circle:last-child {
            stroke: #1b6ec2;
            stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
            transition: stroke-dasharray 0.05s ease-in-out;
        }

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: bold;
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
}

    .loading-progress-text:after {
        content: var(--blazor-load-percentage-text, "Loading");
    }

code {
    color: #c02d76;
}

.rhk_sg_sighup, .rhk_tf_main_headers2, .rhk_tf_fa_pray, .rhk_tf_main_headers4, .rhk_tf_headers3, .rhk_tf_body,
.rhk_tf_footer, .rhk_tf_footer_body {
    font-size: clamp(var(--min), var(--val), var(--max));
}

/*Social Media*/
.rhk_social {
    position: absolute;
    left: 235px;
}

.icons-default {
    color: black;
}

/*FONTS*/
.raleway {
    font-family: "Raleway", sans-serif;
    font-optical-sizing: auto;
    font-weight: 700;
    font-style: normal;
}

.dancing-script {
    font-family: "Dancing Script", cursive;
    font-optical-sizing: auto;
    font-weight: 400;
    font-style: normal;
}

@font-face {
    font-family: 'FontAwesome';
    src: url('../lib/font-awesome/webfonts/fa-v4compatibility.ttf') format('truetype');
}

/*modal controls*/
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1050;
}

.modal-content {
    background: #fff;
    border-radius: 8px;
    max-width: 90vw;
    width: auto;           /* <-- This is the key change */
    min-width: 260px;
    max-height: 80vh;
    overflow-y: auto;
    padding: 1rem;
    position: relative;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

.modal-backdrop .modal-content {
    width: auto !important;
    max-width: 90vw;
    min-width: 260px;
}

.close-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: transparent;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
}
/*end modal controls*/

/*Code for verse link*/
.verse-link {
    color: #007bff;
    text-decoration: underline;
    cursor: pointer;
    -webkit-text-fill-color: #8BC34A;
}

    .verse-link:hover {
        color: #0056b3;
    }

.verse-modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1060;
    padding: clamp(10px, 2vw, 20px);
    overflow: hidden; /* Prevent scroll bars from appearing */
    /* Use container queries for responsive behavior */
    container-type: size;
}

.verse-modal-content {
    background: #fff;
    border-radius: clamp(12px, 2vw, 18px);
    /* Enhanced responsive width with better constraints */
    width: clamp(300px, 95vw, min(800px, 80vw));
    max-width: calc(100vw - 40px); /* Ensure it never exceeds viewport minus margins */
    min-width: 300px;
    /* Enhanced height constraints */
    max-height: clamp(400px, 90vh, calc(100vh - 40px));
    min-height: 200px; /* Minimum height to prevent it from being too small */
    overflow: hidden;
    /* Responsive padding */
    padding: clamp(1rem, 3vw, 2.5rem);
    position: relative;
    box-shadow: 0 clamp(2px, 1vw, 4px) rgba(0,0,0,0.3);
    border: clamp(2px, 0.5vw, 4px) solid #222;
    font-family: 'Comic Sans MS', 'Comic Sans', cursive, sans-serif;
    margin: auto;
    font-size: clamp(0.9rem, 1.5vw, 1.1rem);
    
    /* Ensure modal stays within viewport when positioned absolutely */
    box-sizing: border-box;
}

/* Special positioning class for when modal is positioned with JavaScript */
.verse-modal-content[style*="position:fixed"] {
    /* Override flexbox centering when using fixed positioning */
    margin: 0;
    
    /* Add transition for smooth repositioning */
    transition: left 0.2s ease-out, top 0.2s ease-out;
    
    /* Ensure boundaries are respected */
    left: clamp(20px, var(--modal-left, 50%), calc(100vw - 340px)) !important;
    top: clamp(20px, var(--modal-top, 50%), calc(100vh - 240px)) !important;
    
    /* Maximum constraints to prevent overflow */
    max-width: calc(100vw - 40px);
    max-height: calc(100vh - 40px);
}

@media (min-width: 1000px) {
    .verse-modal-content[style*="position:fixed"] {
        max-width: calc(100vw - 60px);
        left: auto !important;
        right: auto !important;
    }
}

/* Enhanced speech bubble tail with better positioning */
.verse-modal-content::after {
    content: "";
    position: absolute;
    left: clamp(20px, 5vw, 40px);
    bottom: clamp(-20px, -3vw, -30px);
    width: 0;
    height: 0;
    border: clamp(10px, 2vw, 20px) solid transparent;
    border-top: clamp(10px, 2vw, 20px) solid #fff;
    border-bottom: 0;
    border-right: 0;
    filter: drop-shadow(0 2px 2px rgba(0,0,0,0.15));
    z-index: 1;
    pointer-events: none;
    /* Hide on very small screens or when modal is repositioned */
    opacity: min(1, max(0, (100vw - 400px) / 200));
}

.verse-modal-content::before {
    content: "";
    position: absolute;
    left: calc(clamp(20px, 5vw, 40px) - 2px);
    bottom: calc(clamp(-20px, -3vw, -30px) - 4px);
    width: 0;
    height: 0;
    border: clamp(12px, 2.2vw, 22px) solid transparent;
    border-top: clamp(12px, 2.2vw, 22px) solid #222;
    border-bottom: 0;
    border-right: 0;
    z-index: 0;
    pointer-events: none;
    /* Hide on very small screens or when modal is repositioned */
    opacity: min(1, max(0, (100vw - 400px) / 200));
}

/* Hide speech bubble when modal is near edges */
.verse-modal-content[style*="left: 20px"]::after,
.verse-modal-content[style*="left: 20px"]::before,
.verse-modal-content[style*="top: 20px"]::after,
.verse-modal-content[style*="top: 20px"]::before {
    display: none;
}

.modal-body {
    /* Enhanced dynamic max-height */
    max-height: clamp(200px, calc(90vh - 8rem), calc(80vh - clamp(6rem, 10vw, 12rem)));
    overflow-y: auto;
    padding: clamp(0.25rem, 1vw, 0.5rem) 0;
    margin-right: clamp(-4px, -1vw, -8px);
    padding-right: clamp(4px, 1vw, 8px);
    line-height: clamp(1.4, 1.6, 1.8);
    
    /* Ensure scrollable content doesn't break out */
    overflow-wrap: break-word;
    word-wrap: break-word;
}

/* Enhanced responsive behavior for extreme cases */
@container (max-width: 350px) {
    .verse-modal-content {
        border-radius: 8px;
        padding: 0.75rem;
        font-size: 0.85rem;
        min-width: calc(100vw - 40px);
    }
    
    .verse-modal-content::after,
    .verse-modal-content::before {
        display: none;
    }
}

/* Fallback positioning for browsers without container query support */
@supports not (container-type: size) {
    .verse-modal-backdrop {
        align-items: safe center; /* Use 'safe' to prevent overflow */
        justify-content: safe center;
        padding: max(10px, 2vmin);
    }
    
    .verse-modal-content {
        width: min(95vw, max(300px, calc(100vw - 40px)));
        max-height: min(90vh, calc(100vh - 40px));
        
        /* Ensure it never goes outside viewport */
        position: relative;
        left: auto !important;
        top: auto !important;
    }
}

/* Emergency fallback for very small screens */
@media (max-width: 320px), (max-height: 480px) {
    .verse-modal-content[style*="position:fixed"] {
        left: 10px !important;
        top: 10px !important;
        right: 10px !important;
        bottom: 10px !important;
        width: calc(100vw - 20px) !important;
        max-width: calc(100vw - 20px) !important;
        height: calc(100vh - 20px) !important;
        max-height: calc(100vh - 20px) !important;
    }
    
    .verse-modal-content::after,
    .verse-modal-content::before {
        display: none !important;
    }
}

@media (max-width: 600px) {
    .verse-modal-content p,
    .verse-modal-content .verse-content {
        margin-left: 0;
        margin-right: 0;
        padding-left: 0.5em;
        padding-right: 0.5em;
        text-align: left; /* or center, if you prefer */
    }
}

/* Verse formatting styles */
.verse-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.25em;
    margin-bottom: 0.5em;
    align-items: baseline;
}

.verse-number {
    font-size: 0.9em; /* Increased from 0.8em to make superscript bigger */
    vertical-align: super;
    font-weight: bold;
    color: #666;
    min-width: 2em;
    text-align: right;
}

.verse-content {
    line-height: 1.5;
    text-align: justify;
}

.verse-multi {
    margin: 0.5em 0;
}

.verse-multi .verse-grid {
    margin-bottom: 0.25em;
}

.verse-multi .verse-grid:last-child {
    margin-bottom: 0.5em;
}