/*
 * RMV - Rate My Vet
 * Custom styles to supplement Tailwind CSS.
 * Keep this minimal; prefer Tailwind utility classes in templates.
 */

/* HTMX loading indicator */
.htmx-indicator {
    display: none;
}
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
    display: flex;
}

/* Disable submit buttons during HTMX requests to prevent double-submission */
.htmx-request button[type="submit"],
.htmx-request [hx-get],
.htmx-request [hx-post] {
    pointer-events: none;
    opacity: 0.6;
}

/* Smooth transitions for HTMX swaps */
.htmx-swapping {
    opacity: 0;
    transition: opacity 150ms ease-out;
}
.htmx-settling {
    opacity: 1;
    transition: opacity 150ms ease-in;
}

/* Auth-required content: hidden until JS confirms authentication.
   Prevents flash of protected content before client-side redirect. */
.auth-required {
    display: none;
}
.auth-required.auth-verified {
    display: block;
}

/* Form field error state (applied by JS validation) */
input.ring-red-500,
select.ring-red-500,
textarea.ring-red-500 {
    --tw-ring-color: var(--rmv-destructive);
    box-shadow: var(--tw-ring-inset) 0 0 0 2px var(--tw-ring-color);
}

/* Focus styles for accessibility */
:focus-visible {
    outline: 2px solid var(--rmv-brand-strong);
    outline-offset: 2px;
}

/* Star rating interactive styling */
.star-rating input:checked ~ label svg,
.star-rating label:hover svg,
.star-rating label:hover ~ label svg {
    color: #facc15;
}

/* Mobile menu smooth open/close transition.
   The collapsed state lives here rather than in a `style=` attribute on the
   drawer: an inline declaration beats every selector, so `max-height:0` in the
   markup was overriding the open rule below and the drawer opened to zero
   height — the nav was unusable on any phone, silently, because the class and
   aria-expanded both flipped correctly. */
#mobile-menu {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    transition:
        max-height 0.2s ease-out,
        opacity 0.15s ease-out;
}

/* Tall enough for the signed-in drawer, which is 370px with the business link
   showing and so lost its "Log Out" button behind the old 20rem cap, and
   scrollable for the short viewports (landscape phones) where even this is not
   enough: a menu item that cannot be reached is the same as a missing one. */
#mobile-menu.mobile-menu-open {
    max-height: calc(100vh - 4rem); /* 4rem = the sticky header */
    opacity: 1;
    overflow-y: auto;
}

/* Active vet card highlight (map hover sync) */
.vet-card-active {
    box-shadow: 0 0 0 2px var(--rmv-brand-strong);
    border-radius: 0.75rem;
}

/* Respect reduced-motion preference (accessibility) */
@media (prefers-reduced-motion: reduce) {
    .htmx-swapping,
    .htmx-settling {
        transition: none;
    }
    #mobile-menu {
        transition: none !important;
    }
    .animate-pulse {
        animation: none;
    }
    .transition-colors,
    .transition-all {
        transition: none;
    }
    .rmv-clinic-view-notice[data-visible="true"],
    .rmv-map-dot-enter {
        animation: none;
    }
}

/* Search page two-column layout (sidebar + map panel) */
#search-layout {
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 4rem);
}
@media (min-width: 1024px) {
    #search-layout { flex-direction: row; }
    #search-sidebar { width: 420px; min-width: 420px; overflow-y: auto; max-height: calc(100vh - 4rem); }
    #search-map-wrap { flex: 1; position: sticky; top: 4rem; height: calc(100vh - 4rem); }
}

/* Leaflet popup — follows the active theme via the design tokens */
.leaflet-popup-content-wrapper { border-radius: 0.75rem; background: var(--rmv-bg-surface); color: var(--rmv-ink-primary); }
.leaflet-popup-tip { background: var(--rmv-bg-surface); }
.leaflet-popup-content { margin: 12px 16px; font-size: 0.875rem; }
.vet-popup-name { font-weight: 600; color: var(--rmv-ink-primary); }
/* The popup's stars use .rmv-star-filled / .rmv-star-empty, the same two
   classes every other star on the site uses — a second definition here was
   how the empty star ended up a hardcoded #d1d5db. */
.vet-popup-link { color: var(--rmv-brand); font-weight: 500; }
.vet-popup-link:hover { text-decoration: underline; }

/* Leaflet z-index fixes (below sticky header) */
.leaflet-top,
.leaflet-bottom {
    z-index: 30 !important;
}
.leaflet-pane {
    z-index: 20 !important;
}
.leaflet-popup-pane {
    z-index: 35 !important;
}

/* Force-hide nav elements when auth JS overrides responsive Tailwind classes.
   Using !important so this wins over md:flex and other responsive utilities. */
.nav-auth-hidden {
    display: none !important;
}

/* Clinics-in-view scale badge (search-map.js, UX11). A Leaflet control, not a
   template element, so its look lives here rather than inline — the class
   name stays `.rmv-clinic-view-notice` because tests/e2e locate it by that
   name; this only changes how it is drawn, not what it is. The pill shape
   and bold count are the "there is a lot of data here" signal: the same text
   the old quiet gray box carried, read as a stat instead of a caption. */
.rmv-clinic-view-notice {
    display: none;
    align-items: center;
    gap: 0.4rem;
    background: var(--rmv-bg-surface);
    color: var(--rmv-ink-primary);
    padding: 0.5rem 0.75rem;
    border-radius: 9999px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.22);
    font-size: 0.8125rem;
    font-weight: 600;
    line-height: 1.3;
    max-width: 230px;
}
.rmv-clinic-view-notice[data-visible="true"] {
    display: flex;
    animation: rmv-badge-in 0.25s ease-out;
}
.rmv-clinic-view-notice-count {
    color: var(--rmv-brand-strong);
}

@keyframes rmv-badge-in {
    from { opacity: 0; transform: translateY(-4px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Each clinics-in-view dot fades and scales in as it is added, rather than
   appearing all at once — the motion itself is part of advertising how many
   there are, the way a counter ticking up reads as "more" than a static
   number. */
@keyframes rmv-dot-in {
    from { opacity: 0; transform: scale(0.3); }
    to { opacity: 1; transform: scale(1); }
}
.rmv-map-dot-enter {
    animation: rmv-dot-in 0.22s ease-out both;
}
