/* ==========================================================
   Pavilla Global UX — applied to every page
   Handles: focus states, micro-interactions, transitions,
   animations, reduced-motion.
   ========================================================== */

/* ── Box model ── */
*,
*::before,
*::after {
    box-sizing: border-box;
}

/* ── Text size adjust (prevents iOS auto-zoom) ── */
html {
    -webkit-text-size-adjust: 100%;
}

/* ── Consistent focus-visible across every page ── */
:focus {
    outline: none;
}

:focus-visible {
    outline: 2.5px solid #ff715e;
    outline-offset: 3px;
    border-radius: 6px;
}

/* ── Global interactive transitions (NO transform — avoids composer jitter) ── */
button,
[role="button"],
a,
input,
textarea,
select,
label[for],
summary {
    transition:
        background-color 0.18s ease,
        color            0.18s ease,
        border-color     0.18s ease,
        box-shadow       0.18s ease,
        opacity          0.18s ease;
}

/* ── Button hover lift — pointer devices only, NOT touch (avoids tap shake) ── */
@media (hover: hover) and (pointer: fine) {
    button:not(:disabled):not(.no-lift):hover {
        transform: translateY(-1px);
        box-shadow: 0 4px 14px rgba(0, 0, 0, 0.1);
    }

    button:not(:disabled):not(.no-lift):active {
        transform: translateY(0px);
        box-shadow: none;
    }
}

/* ── Back / icon-only buttons: slide left — pointer devices only ── */
@media (hover: hover) and (pointer: fine) {
    [class*="-back"]:hover,
    .app-back-button:hover,
    .js-back:hover {
        transform: translateX(-2px);
        box-shadow: none;
    }

    [class*="-back"]:active,
    .app-back-button:active,
    .js-back:active {
        transform: translateX(0);
    }
}

/* ── Disabled states ── */
button:disabled,
input:disabled,
select:disabled,
textarea:disabled,
[aria-disabled="true"] {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
    pointer-events: none;
}

/* ── Form field smooth focus (border/shadow only — no transform) ── */
input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]):not([type="reset"]),
textarea,
select {
    transition:
        border-color  0.18s ease,
        box-shadow    0.18s ease,
        background    0.18s ease,
        outline-color 0.18s ease;
}

/* ── Error messages — fade-in entrance ── */
@keyframes pv-fade-down {
    from { opacity: 0; transform: translateY(-5px); }
    to   { opacity: 1; transform: translateY(0);    }
}

[class*="inline-error"]:not([hidden]),
[class*="-error"]:not([hidden]),
[class*="field-error"]:not([hidden]),
[class*="-status"][class*="error"]:not([hidden]) {
    animation: pv-fade-down 0.2s ease both;
}

/* ── Toast messages — slide-up entrance ── */
@keyframes pv-slide-up {
    from { opacity: 0; }
    to   { opacity: 1; }
}

[class*="-toast"].is-visible,
[class*="toast"].is-visible {
    animation: pv-slide-up 0.22s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

/* ── Skeleton loader ── */
@keyframes pv-pulse {
    0%, 100% { opacity: 1;    }
    50%       { opacity: 0.4; }
}

.pv-skeleton {
    background: rgba(0, 0, 0, 0.07);
    border-radius: 8px;
    animation: pv-pulse 1.6s ease-in-out infinite;
}

/* ── Interest / tag chips — smooth select animation ── */
[class*="interest-chip"],
[class*="-chip"],
[class*="-tag"] {
    transition:
        background-color 0.15s ease,
        color            0.15s ease,
        border-color     0.15s ease,
        transform        0.15s ease,
        box-shadow       0.15s ease;
}

/* Only apply chip hover lift on pointer devices — prevents
   a "stuck hover" flash on touch screens                   */
@media (hover: hover) and (pointer: fine) {
    [class*="interest-chip"]:not(:disabled):hover,
    [class*="-chip"]:not(:disabled):hover {
        transform: translateY(-1px);
    }
}

[class*="interest-chip"].is-selected,
[class*="-chip"].is-selected {
    transform: scale(1.03);
}

/* ── Card hover ── */
[class*="-card"]:not([class*="home-card"]):not([class*="chat-"]) {
    transition: box-shadow 0.22s ease, transform 0.22s ease;
}

/* ── Loading spinner (universal) ── */
@keyframes pv-spin {
    to { transform: rotate(360deg); }
}

.pv-spinner {
    width:  20px;
    height: 20px;
    border: 2.5px solid rgba(255, 113, 94, 0.25);
    border-top-color: #ff715e;
    border-radius: 50%;
    animation: pv-spin 0.7s linear infinite;
    display: inline-block;
}

/* ── Smooth details/FAQ open animation ── */
details[open] > *:not(summary) {
    animation: pv-fade-down 0.2s ease both;
}

summary {
    cursor: pointer;
    list-style: none;
}

summary::-webkit-details-marker {
    display: none;
}

/* ── Scrollbar polish ── */
::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(100, 150, 140, 0.35);
    border-radius: 99px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(100, 150, 140, 0.55);
}

/* ── Selection highlight ── */
::selection {
    background: rgba(255, 113, 94, 0.22);
    color: #1a2730;
}

/* ── Placeholder text ── */
::placeholder {
    opacity: 0.5;
}

/* ── Consistent link styling within plain copy ── */
a:not([class]):not([role]) {
    color: #ff715e;
    text-decoration: underline;
    text-decoration-skip-ink: auto;
    text-underline-offset: 2px;
}

a:not([class]):not([role]):hover {
    color: #ef5c49;
}

/* Shared feed-style topbar */
.pavilla-shared-topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.8rem;
    padding: calc(env(safe-area-inset-top, 0px) + 0.7rem) 1rem 0.7rem;
    background: rgba(255, 255, 255, 0.94);
    border-bottom: 1px solid rgba(232, 237, 235, 0.96);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    align-self: stretch;
    width: auto;
    margin-left: calc(var(--pavilla-shell-pad-x, 0px) * -1);
    margin-right: calc(var(--pavilla-shell-pad-x, 0px) * -1);
    padding-left: var(--pavilla-shell-pad-x, 1rem);
    padding-right: var(--pavilla-shell-pad-x, 1rem);
    border-radius: 0;
    box-sizing: border-box;
}

.pavilla-shared-topbar.is-mobile-only {
    display: none;
}

.pavilla-shared-topbar-brand {
    min-width: 0;
    display: inline-flex;
    align-items: center;
    gap: 0.72rem;
    color: inherit;
    text-decoration: none;
}

.pavilla-shared-topbar-logo {
    width: 28px;
    height: 28px;
    object-fit: contain;
    flex-shrink: 0;
}

.pavilla-shared-topbar-title {
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    white-space: nowrap;
}

.pavilla-shared-topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    flex-shrink: 0;
}

.pavilla-shared-topbar-icon-link,
.pavilla-shared-topbar-icon-btn {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: rgba(255, 255, 255, 0.76);
    border: 1px solid rgba(232, 237, 235, 0.96);
    text-decoration: none;
    color: inherit;
    overflow: hidden;
}

.pavilla-shared-topbar-icon-btn {
    font: inherit;
    cursor: pointer;
}

.pavilla-shared-topbar-icon {
    width: 17px;
    height: 17px;
    object-fit: contain;
    display: block;
}

.pavilla-shared-topbar-icon-link img {
    width: 17px;
    height: 17px;
    object-fit: contain;
    display: block;
}

/* Current section — highlight the icon for the page you're on so the
   topbar reads as a clear, consistent directory across every screen. */
.pavilla-shared-topbar-icon-link.is-active {
    background: #ff715e;
    border-color: #ff715e;
    color: #fff;
}

.pavilla-shared-topbar-icon-link.is-active svg {
    stroke: #fff;
}

.pavilla-shared-topbar-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    text-decoration: none;
    overflow: hidden;
    background: rgba(245, 248, 247, 1);
    border: 1.5px solid rgba(232, 237, 235, 0.96);
    flex-shrink: 0;
}

.pavilla-shared-topbar-avatar img,
.pavilla-shared-topbar-avatar-icon {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.pavilla-shared-topbar-avatar-icon {
    padding: 6px;
}

.pavilla-shared-topbar-avatar-placeholder {
    width: 18px;
    height: 18px;
    display: grid;
    place-items: center;
    font-size: 0.9rem;
    color: #5e6681;
}

@media (max-width: 900px) {
    .pavilla-shared-topbar.is-mobile-only {
        display: flex;
    }
}

/* ── Notification dot badge ── */
@keyframes pv-badge-pop {
    0%   { transform: scale(0.5); opacity: 0; }
    70%  { transform: scale(1.15); }
    100% { transform: scale(1);   opacity: 1; }
}

[class*="badge"]:not(:empty),
[class*="-count"]:not(:empty) {
    animation: pv-badge-pop 0.28s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

/* ── Shared topbar performance ── */
/* backdrop-filter: blur is expensive on mobile; removing it
   on small screens while keeping a near-opaque background
   prevents scroll jank on lower-end Android devices        */
@media (max-width: 700px) {
    .pavilla-shared-topbar {
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        background: rgba(255, 255, 255, 0.99);
    }

    /* Dark mode — keep it dark on mobile (overrides the white above) */
    body.theme-super-admin .pavilla-shared-topbar {
        background: rgba(11, 18, 26, 0.99);
    }

    /* touch-action: manipulation removes the 300ms tap
       delay from all topbar interactive elements           */
    .pavilla-shared-topbar a,
    .pavilla-shared-topbar button,
    .pavilla-shared-topbar-icon-link,
    .pavilla-shared-topbar-icon-btn {
        touch-action: manipulation;
    }
}

/* Dark mode: make shared topbar surfaces dark */
body.theme-super-admin .pavilla-shared-topbar {
    background: rgba(14, 22, 30, 0.97);
    border-color: rgba(255, 255, 255, 0.07);
}

body.theme-super-admin .pavilla-shared-topbar-brand,
body.theme-super-admin .pavilla-shared-topbar-title {
    color: rgba(230, 245, 240, 0.92);
}

body.theme-super-admin .pavilla-shared-topbar-icon-link,
body.theme-super-admin .pavilla-shared-topbar-icon-btn {
    background: rgba(255, 255, 255, 0.07);
    border-color: rgba(255, 255, 255, 0.07);
}

body.theme-super-admin .pavilla-shared-topbar-avatar {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.07);
}

/* ======================================================
   Reduced-motion: disable all non-essential animation
   ====================================================== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration:        0.01ms !important;
        animation-iteration-count: 1      !important;
        transition-duration:       0.01ms !important;
        scroll-behavior:           auto   !important;
    }
}
