/* ==========================================================================
   Mashhur — UX enhancement layer (loaded AFTER app.css)
   Purely additive: no existing class, markup or layout is renamed or removed.
   Delete this file + its <link> in partials/head.blade.php to roll back.
   Sections:
     1. Base polish (text wrapping, selection, tap feedback)
     2. Mobile form inputs (no iOS zoom on focus)
     3. Focus visibility for search fields and stretched-link cards
     4. Touch devices: no sticky hover, press feedback, bigger tap targets
     5. Sticky header "scrolled" state (style existed, now switched on by enhance.js)
     6. Disclosure / FAQ chevrons + smooth open
     7. Overlays: drawer, sheet, autocomplete, menus, dialogs
     8. Anchors under the sticky header + tabs
     9. Images fade in when loaded, scroll reveal
    10. Busy state on submit buttons
    11. Viewport units, safe areas, scrollbars, performance
   ========================================================================== */

:root {
  --mh-ease-out: cubic-bezier(.22, 1, .36, 1);
  --mh-dur-1: 120ms;
  --mh-dur-2: 200ms;
  --mh-dur-3: 320ms;
}

/* 1. Base polish ---------------------------------------------------------- */
h1, h2, h3, .display, .profile-hero h1 { text-wrap: balance; }
p, .lead, .hint, .sub, dd { text-wrap: pretty; }
::selection { background: var(--purple-100); color: var(--ink); }
a, button, summary, label, .chip, .btn, [role="button"] { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
.btn { transition: background var(--mh-dur-1) var(--ease), border-color var(--mh-dur-1) var(--ease), color var(--mh-dur-1) var(--ease), box-shadow var(--mh-dur-2) var(--ease), transform var(--mh-dur-1) var(--ease), opacity var(--mh-dur-1); }
.btn:active { transform: scale(.97); }
.chip { transition: border-color var(--mh-dur-1), background var(--mh-dur-1), color var(--mh-dur-1), transform var(--mh-dur-1) var(--ease); }
.chip:active { transform: scale(.96); }
.link-arrow .i-sm, .link-arrow .i, .ask-link .i-sm, .quicklinks a .i-sm, .prompt-card .go { transition: transform var(--mh-dur-2) var(--mh-ease-out); }
@media (hover: hover) {
  .link-arrow:hover .i-sm, .link-arrow:hover .i, .ask-link:hover .i-sm, .prompt-card:hover .go { transform: translateX(3px); }
  .cat-tile:hover .cat-icon { transform: translateY(-2px); }
}
.cat-icon { transition: transform var(--mh-dur-2) var(--mh-ease-out); }
.prompt-card { transition: border-color var(--mh-dur-2), background var(--mh-dur-2), color var(--mh-dur-2); }

/* 2. Mobile form inputs: 16px stops iOS Safari zooming the page on focus -- */
@media (pointer: coarse) {
  .input, .select, .textarea,
  .searchbar input, .searchbar select,
  .searchbox input, .searchbox select,
  .header-search input, .ask-input input,
  .cmdk input, form.filters .input, form.filters .select { font-size: 16px; }
}

/* 3. Focus visibility ------------------------------------------------------ */
.searchbar { transition: border-color var(--mh-dur-2), box-shadow var(--mh-dur-2); }
.searchbar:focus-within { border-color: #c9b5fb; box-shadow: 0 12px 40px -18px rgba(106, 46, 232, .35), 0 0 0 4px var(--purple-50); }
.header-search input { transition: border-color var(--mh-dur-1), background var(--mh-dur-1), box-shadow var(--mh-dur-1); }
.header-search input:focus { outline: none; border-color: var(--purple); background: #fff; box-shadow: 0 0 0 3px var(--purple-100); }
.ask-input { transition: box-shadow var(--mh-dur-2); }
.ask-input:focus-within { box-shadow: 0 0 0 3px rgba(167, 139, 250, .55); }
/* Cards whose title link covers the whole card: ring the card, not just the title */
@supports selector(:has(*)) {
  .pcard:has(h3 a:focus-visible), .biz-card:has(h3 a:focus-visible), .result:has(h3 a:focus-visible),
  .ocard:has(h3 a:focus-visible), .offer-card:has(h3 a:focus-visible) { outline: 2px solid var(--purple); outline-offset: 2px; }
  .pcard h3 a:focus-visible, .biz-card h3 a:focus-visible, .result h3 a:focus-visible,
  .ocard h3 a:focus-visible, .offer-card h3 a:focus-visible { outline: none; }
}

/* 4. Touch devices -------------------------------------------------------- */
@media (hover: none) {
  /* hover lifts/zooms "stick" after a tap on phones; turn them off */
  .pcard:hover { transform: none; box-shadow: none; }
  .biz-card:hover .media img, .tile:hover img, .em:hover img { transform: none; }
  .bubble:hover .b { transform: none; }
  /* press feedback instead */
  .pcard, .biz-card, .result, .cat-tile, .tile, .ocard, .offer-card, .em, .gcard, .prompt-card, .svc-card, .req-card { transition: transform var(--mh-dur-1) var(--ease), box-shadow var(--mh-dur-2), border-color var(--mh-dur-2); }
  .pcard:active, .biz-card:active, .result:active, .cat-tile:active, .tile:active, .ocard:active, .offer-card:active, .em:active, .gcard:active, .prompt-card:active, .req-card:active { transform: scale(.985); }
  .bubble:active .b { transform: scale(.94); }
}
@media (pointer: coarse) {
  /* WCAG 2.2 target size — expand hit areas without moving anything */
  .why-box summary { display: inline-flex; align-items: center; min-height: 32px; }
  details.card-pad > summary { margin-block: -10px; padding-block: 10px; }
  .faq-item summary { margin-block: -12px; padding-block: 12px; }
  .contact-card a.row { min-height: 32px; }
  .drawer-panel nav a { min-height: 48px; }
  .bottom-nav a { min-height: 54px; justify-content: center; }
  .pcard .heart, .biz-card .save { width: 40px; height: 40px; }
  .check { min-height: 32px; }
}

/* Bottom nav: clearer current tab + press feedback */
.bottom-nav { background: rgba(255, 255, 255, .96); backdrop-filter: saturate(180%) blur(12px); }
.bottom-nav a { position: relative; transition: color var(--mh-dur-1); }
.bottom-nav a::before { content: ""; position: absolute; top: 0; left: 50%; width: 22px; height: 3px; margin-left: -11px; border-radius: 0 0 3px 3px; background: var(--purple); transform: scaleX(0); transition: transform var(--mh-dur-2) var(--mh-ease-out); }
.bottom-nav a.is-active::before { transform: scaleX(1); }
.bottom-nav .i { transition: transform var(--mh-dur-1) var(--ease); }
.bottom-nav a:active .i { transform: scale(.88); }

/* 5. Sticky header — subtle depth once the page scrolls -------------------- */
.site-header { transition: border-color var(--mh-dur-2), box-shadow var(--mh-dur-2), background var(--mh-dur-2); }
.site-header.is-scrolled { box-shadow: 0 8px 24px -18px rgba(16, 22, 58, .35); }
.dtop.is-scrolled { box-shadow: 0 8px 24px -20px rgba(16, 22, 58, .35); }
.nav a { transition: color var(--mh-dur-1), background var(--mh-dur-1); }
.tabs a, .tabs button { transition: color var(--mh-dur-1), border-color var(--mh-dur-2); }

/* 6. Disclosures ---------------------------------------------------------- */
/* Replace the browser's ▶ triangle on FAQ cards with a chevron that rotates */
details.card-pad > summary, details.card > summary { list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
details.card-pad > summary::-webkit-details-marker, details.card > summary::-webkit-details-marker { display: none; }
details.card-pad > summary::after, details.card > summary::after {
  content: ""; flex: none; width: 18px; height: 18px;
  background: currentColor; color: var(--purple);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") center / contain no-repeat;
  transition: transform var(--mh-dur-2) var(--mh-ease-out);
}
details.card-pad[open] > summary::after, details.card[open] > summary::after { transform: rotate(180deg); }
details.card-pad > summary:hover, details.card > summary:hover { color: var(--purple-600); }
.faq-item summary::after { transition: transform var(--mh-dur-2) var(--mh-ease-out); }
/* Smooth height animation where the browser supports it (Chrome/Edge 131+); others open instantly as before */
@supports (interpolate-size: allow-keywords) {
  :root { interpolate-size: allow-keywords; }
  details:not(.menu)::details-content {
    block-size: 0; overflow-y: clip; opacity: 0;
    transition: block-size var(--mh-dur-3) var(--mh-ease-out), opacity var(--mh-dur-2), content-visibility var(--mh-dur-3) allow-discrete;
  }
  details:not(.menu)[open]::details-content { block-size: auto; opacity: 1; }
}

/* 7. Overlays ------------------------------------------------------------- */
.drawer-panel, .sheet-panel, .ac, .filters, .sidenav, .dside, .menu-pop, .acct-side nav { overscroll-behavior: contain; }
.drawer-backdrop, .sheet-backdrop { transition: opacity var(--mh-dur-3) var(--ease); }
.drawer-panel { transition: transform var(--mh-dur-3) var(--mh-ease-out); box-shadow: 24px 0 48px -24px rgba(16, 22, 58, .35); }
.sheet-panel { transition: transform var(--mh-dur-3) var(--mh-ease-out); }
.drawer-panel.is-dragging, .sheet-panel.is-dragging { transition: none; }
.sheet-grip { cursor: grab; }
.drawer-panel nav a { transition: background var(--mh-dur-1), color var(--mh-dur-1); }
.drawer-panel nav a:active { background: var(--surface-2); }
@keyframes mh-pop { from { opacity: 0; transform: translateY(-4px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes mh-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes mh-dialog { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
.ac.is-open { animation: mh-pop var(--mh-dur-2) var(--mh-ease-out); transform-origin: top center; }
.menu[open] > .menu-pop { animation: mh-pop var(--mh-dur-2) var(--mh-ease-out); transform-origin: top right; }
dialog.modal[open] { animation: mh-dialog var(--mh-dur-3) var(--mh-ease-out); }
dialog.modal[open]::backdrop { animation: mh-fade var(--mh-dur-3) var(--ease); }
.toast { transition: opacity var(--mh-dur-2) var(--ease), transform var(--mh-dur-3) var(--mh-ease-out); }
@media (max-width: 1023.98px) {
  body.has-sticky-cta .toast { bottom: calc(88px + env(safe-area-inset-bottom)); }
  .toast { bottom: calc(84px + env(safe-area-inset-bottom)); }
}

/* 8. Anchors land below the sticky header (and the profile tab bar) ------- */
html { scroll-padding-top: calc(var(--header-h) + 16px); }
.profile-body .block[id], .profile-body section[id] { scroll-margin-top: calc(var(--header-h) + 64px); }

/* 9. Images & reveal ------------------------------------------------------ */
img.mh-fade { opacity: 0; }
img.mh-fade.is-loaded { opacity: 1; transition: opacity 400ms var(--ease); }
.mh-reveal { opacity: 0; transform: translateY(12px); }
.mh-reveal.is-in { opacity: 1; transform: none; transition: opacity 520ms var(--mh-ease-out), transform 520ms var(--mh-ease-out); transition-delay: var(--mh-d, 0ms); }
@media print { .mh-reveal, img.mh-fade { opacity: 1 !important; transform: none !important; } }

/* 10. Busy submit buttons (app.js disables them after submit) ------------- */
@keyframes mh-spin { to { transform: rotate(360deg); } }
.btn[disabled][data-label] { opacity: .8; }
.btn[disabled][data-label]::after { content: ""; width: 14px; height: 14px; flex: none; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: mh-spin .7s linear infinite; }

/* 11. Viewport units, safe areas, scrollbars, performance ----------------- */
@supports (height: 100dvh) {
  .sheet-panel { max-height: 88dvh; }
  .map-mobile { height: 70dvh; }
  .portal-dark, .dside { min-height: 100dvh; }
  .dside { height: 100dvh; }
}
@supports (padding: max(0px)) {
  .site-header .container, .site-footer .container { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
  @media (min-width: 768px) { .site-header .container, .site-footer .container { padding-left: max(24px, env(safe-area-inset-left)); padding-right: max(24px, env(safe-area-inset-right)); } }
  .drawer-panel { padding-top: max(16px, env(safe-area-inset-top)); padding-bottom: max(16px, env(safe-area-inset-bottom)); }
  .sheet-panel { padding-bottom: max(20px, env(safe-area-inset-bottom)); }
}
.ac, .filters, .sidenav, .menu-pop, .table-wrap, .table-scroll, .icon-grid, .icon-picker { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
.dside { scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, .18) transparent; }
/* Horizontal strips: fade the edge that has more content (class set by enhance.js) */
.mh-ovx { -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 var(--mh-fl, 0px), #000 calc(100% - var(--mh-fr, 0px)), transparent 100%); mask-image: linear-gradient(90deg, transparent 0, #000 var(--mh-fl, 0px), #000 calc(100% - var(--mh-fr, 0px)), transparent 100%); }
/* Maps: keep the map's internal z-indexes from floating over the sticky header / CTA bar */
.map, .leaflet-container { isolation: isolate; }
/* Skip layout/paint work for the footer until it is near the viewport */
.site-footer { content-visibility: auto; contain-intrinsic-size: auto 640px; }

@media (prefers-reduced-motion: reduce) {
  .mh-reveal { opacity: 1 !important; transform: none !important; }
  img.mh-fade { opacity: 1 !important; }
  .btn:active, .chip:active { transform: none; }
}

/* ==========================================================================
   12. Image upload guide (logo / cover recommended size + live crop preview)
   ========================================================================== */
.img-guide { margin-top: 8px; display: grid; gap: 8px; }
.img-guide-spec { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; color: var(--text); background: var(--purple-50); border: 1px solid var(--purple-100); border-radius: 10px; padding: 9px 11px; line-height: 1.45; }
.img-guide-spec > .i-sm { color: var(--purple); margin-top: 2px; flex: none; }
.img-guide-check { font-size: 12.5px; border-radius: 8px; padding: 7px 10px; }
.img-guide-check.is-ok { background: var(--green-50); color: #0b5e41; }
.img-guide-check.is-warn { background: var(--amber-50); color: #7c3d07; }
.img-guide-previews { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.img-guide-previews figure { margin: 0; display: grid; gap: 4px; min-width: 0; }
.img-guide-previews figcaption { font-size: 11.5px; color: var(--subtle); }
.img-guide-previews .ig-wide { flex: 1 1 100%; }
.ig-frame { position: relative; overflow: hidden; background: var(--surface-2); border: 1px solid var(--line); }
.ig-frame img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ig-logo-lg { width: 92px; height: 92px; border-radius: 16px; }
.ig-logo-sm { width: 44px; height: 44px; border-radius: 11px; }
.ig-cover-desktop { width: 100%; aspect-ratio: 4.5 / 1; border-radius: 10px; }
.ig-cover-desktop::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(18, 17, 39, .7) 0%, rgba(18, 17, 39, .35) 45%, rgba(18, 17, 39, .05) 100%); }
.ig-cover-mobile { width: 96px; aspect-ratio: 1 / 1; border-radius: 10px; }
.ig-cover-mobile::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(18, 17, 39, .35), rgba(18, 17, 39, .7)); }
.ig-cover-card { width: 154px; aspect-ratio: 16 / 10; border-radius: 10px; }

/* ==========================================================================
   13. Google Maps (pins, info popup, keyless embed fallback)
   ========================================================================== */
.gm-pin { position: absolute; width: 0; height: 0; }
.gm-pin .map-pin { font: inherit; font-size: 12px; font-weight: 700; line-height: 1.35; cursor: pointer; }
.gm-pin .map-pin:focus-visible { outline: 2px solid var(--purple); outline-offset: 2px; }
.gm-info { font-family: var(--font); font-size: 13px; line-height: 1.5; color: var(--text); max-width: 220px; }
.gm-info strong { color: var(--ink); }
.gm-info a { color: var(--purple); font-weight: 600; }
.map-embed { position: relative; }
.map-embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.map-empty { display: grid; place-items: center; height: 100%; color: var(--subtle); font-size: 14px; }

/* ==========================================================================
   14. Claim steps
   ========================================================================== */
.claim-steps { margin: 0 0 18px; }
.claim-steps ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; grid-template-columns: 1fr; counter-reset: s; }
@media (min-width: 768px) { .claim-steps ol { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.claim-steps li { display: flex; gap: 10px; align-items: flex-start; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; }
.claim-steps .n { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--surface-2); color: var(--muted); font-weight: 700; font-size: 13px; }
.claim-steps strong { display: block; color: var(--ink); font-size: 14px; }
.claim-steps small { display: block; color: var(--muted); font-size: 12.5px; line-height: 1.45; margin-top: 2px; }
.claim-steps li.is-current { border-color: var(--purple); box-shadow: 0 0 0 1px var(--purple); }
.claim-steps li.is-current .n { background: var(--purple); color: #fff; }
.claim-steps li.is-done .n { background: var(--green); color: #fff; }

/* ==========================================================================
   15. Admin "View as customer / business" banner
   ========================================================================== */
.view-as-bar { position: sticky; top: 0; z-index: 90; background: #b45309; color: #fff; font-size: 13.5px; box-shadow: 0 2px 10px rgba(0, 0, 0, .15); }
.view-as-in { max-width: 1240px; margin: 0 auto; padding: 8px 16px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.view-as-ic { width: 26px; height: 26px; border-radius: 50%; background: rgba(255, 255, 255, .18); display: grid; place-items: center; flex: none; }
.view-as-txt { flex: 1 1 280px; min-width: 0; line-height: 1.45; }
.view-as-sub { display: block; font-size: 12px; opacity: .85; }
.view-as-btn { background: #fff; color: #7c2d12; border: 0; }
.view-as-btn:hover { background: #fff7ed; color: #7c2d12; }
body:has(.view-as-bar) .site-header, body:has(.view-as-bar) .dtop { top: var(--view-as-h, 52px); }
@media (max-width: 640px) { body:has(.view-as-bar) .site-header, body:has(.view-as-bar) .dtop { top: var(--view-as-h, 76px); } }

/* ==========================================================================
   16. Signed-in identity (header account menu + drawer)
   ========================================================================== */
.user-chip { display: inline-flex; align-items: center; gap: 8px; padding: 3px 8px 3px 3px; border-radius: 999px; border: 1px solid transparent; transition: border-color var(--mh-dur-1), background var(--mh-dur-1); }
.user-chip:hover, .user-menu[open] .user-chip { border-color: var(--line-2); background: #fff; }
.user-chip-name { font-size: 14px; font-weight: 600; color: var(--ink); max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 1023.98px) { .user-chip { padding: 0; } }
.user-menu .menu-pop { min-width: 240px; }
.user-menu-head { padding: 8px 12px 10px; border-bottom: 1px solid var(--line); margin-bottom: 6px; display: grid; gap: 2px; }
.user-menu-head strong { color: var(--ink); font-size: 14px; }
.user-menu-head span { color: var(--subtle); font-size: 12.5px; overflow-wrap: anywhere; }
.drawer-user { display: flex; gap: 10px; align-items: center; padding: 10px; margin-bottom: 6px; border-radius: 12px; background: var(--surface); }
.drawer-user strong { display: block; color: var(--ink); font-size: 14px; }
.drawer-user small { display: block; color: var(--subtle); font-size: 12px; overflow-wrap: anywhere; }
.quick-go { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: -4px 0 16px; padding-bottom: 2px; }
.quick-go::-webkit-scrollbar { display: none; }
.quick-go a { flex: none; display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 13px; border-radius: 999px; background: #fff; border: 1px solid var(--line-2); font-size: 13.5px; font-weight: 600; color: var(--ink); transition: border-color var(--mh-dur-1), color var(--mh-dur-1); }
.quick-go a:hover { border-color: var(--purple); color: var(--purple); }
.quick-go a .i-sm { color: var(--purple); }
body:has(.view-as-bar) .dside { top: var(--view-as-h, 52px); height: calc(100vh - var(--view-as-h, 52px)); }

/* Charts: let the legend sit under the plot instead of overlapping the next element */
.chart { height: auto; min-height: 220px; }
.chart > .row-wrap { margin-top: 8px !important; gap: 6px 14px; }
