/* Shared components of the PHP site (loaded on every public page after site-ui.css).
   Everything here reuses the prototype design tokens (--surface, --ui-line, --accent…), so light/dark/palette
   settings apply automatically. */

/* ---------- Skeleton loading: same outline as the shared ad card (components/ad-card-skeleton) ----------
   The placeholder uses the real card classes, so only the grey shapes are styled here. .sk-text is one line of the
   surrounding text size (the ZWSP gives it the line height), with a bar a little shorter than the line inside. */
.sk{display:block;border-radius:8px;background:color-mix(in srgb,var(--text-muted) 14%,var(--surface-soft));position:relative;overflow:hidden}
.sk::after{content:"";position:absolute;inset:0;transform:translateX(100%);background:linear-gradient(90deg,transparent,color-mix(in srgb,var(--surface) 55%,transparent),transparent);animation:site-shimmer 1.3s ease-in-out infinite}
@keyframes site-shimmer{to{transform:translateX(-100%)}}
@media (prefers-reduced-motion:reduce){.sk::after{animation:none}}
.sk-text{display:flex;align-items:center;white-space:nowrap}
.sk-text::before{content:"\200b"}
.sk-text>.sk{flex:none;width:100%;height:.8em;border-radius:6px}
.sk-text>.sk-wide{width:78%}
.sk-text>.sk-short{width:55%}
.product-photo-skeleton{position:absolute;inset:0;border-radius:inherit}
.product-photo:not([aria-busy="true"])>.product-photo-skeleton{display:none}
.is-skeleton{pointer-events:none}
.is-skeleton .sk-narrow{display:none}
@media (max-width:700px){.ad-card.is-skeleton .sk-narrow{display:flex}}
.is-skeleton .card-meta>.sk{border-radius:50%}
.is-skeleton .card-meta>.sk-text{flex:1 1 30%}
[data-ad-feed][aria-busy="true"]{align-content:start}
/* Map list row: the thumbnail is an <img> in the real row (76x66, 66x62 on tiny screens, see reference-pages.css). */
.is-skeleton .sk-thumb{flex:none;width:76px;height:66px;border-radius:9px}
@media (max-width:380px){.is-skeleton .sk-thumb{width:66px;height:62px}}
.is-skeleton .map-row-detail{width:84px;height:28px;border:0}
.is-skeleton .map-row-footer>.sk-text{flex:1}
.is-skeleton .card-media{background:none}
.is-skeleton .sk-media{position:absolute;inset:0;border-radius:inherit}
.sk-chip{width:72px;height:22px;border-radius:999px}
.is-skeleton .card-open-arrow{background:none;border:0;box-shadow:none}
.is-skeleton .card-open-arrow .sk{width:100%;height:100%;border-radius:50%}
.is-skeleton .card-price>.sk-text{flex:1;min-width:0}

/* Photo area while a lazy image loads, and ads without a photo. <picture> (components/picture) must not take part in layout. */
picture{display:contents}
.ad-card .card-media,.list-card .card-media{background:color-mix(in srgb,var(--text-muted) 10%,var(--surface-soft))}
.card-media-empty{display:grid;place-items:center;width:100%;height:100%;min-height:120px;color:var(--text-muted)}
.card-media-empty .icon{width:38px;height:38px;opacity:.55}
.latest-results[aria-busy="true"] .latest-more-button{pointer-events:none}
/* "نمایش آگهی‌های بیشتر" is a link to the next page on lists (works without JavaScript), a button on the home page. */
a.latest-more-button{text-decoration:none}
.latest-more-button[aria-disabled="true"]{pointer-events:none;opacity:.7}

/* ---------- Content pages (CMS) ---------- */
.site-breadcrumb{display:flex;flex-wrap:wrap;gap:8px;margin-bottom:12px;font-size:13px;color:var(--text-muted)}
.site-breadcrumb a{color:inherit}
.site-breadcrumb a:hover{color:var(--accent)}
.cms-content{max-width:920px;padding:32px;line-height:2.3;font-size:15px}
.cms-content>:first-child{margin-top:0}
.cms-content h2{margin:30px 0 12px;font-size:20px;line-height:1.7}
.cms-content h3{margin:22px 0 8px;font-size:16px;line-height:1.7}
.cms-content p{margin:0 0 14px}
.cms-content ul,.cms-content ol{margin:0 0 16px;padding-inline-start:24px;display:grid;gap:6px}
.cms-content li::marker{color:var(--accent)}
.cms-content a{color:var(--accent);text-decoration:underline;text-underline-offset:4px}
.cms-content strong{color:var(--text-main)}
@media (max-width:700px){.cms-content{padding:20px;font-size:14px}.cms-content h2{font-size:18px}}

/* ---------- Dialog menus (انتخاب شهر; the «بیشتر» menu is .site-menu-links in site-ui.css) ---------- */
.site-city-list button{display:flex;gap:12px;align-items:center;padding:13px;border-radius:10px;background:var(--surface-soft);color:inherit;text-align:right}
.site-city-list button:hover{background:var(--accent-pale);color:var(--accent-strong)}
.site-city-list button[aria-pressed="true"]{background:var(--accent-pale);color:var(--accent-strong);font-weight:700}
.site-city-list .icon{width:22px;height:22px}

/* Form errors next to a field (login, sign-up and later every form). */
.app-field-error{display:block;margin-top:2px;font-size:11px;line-height:1.8;color:#a82748}
.app-field input[aria-invalid="true"],.app-check input[aria-invalid="true"]{border-color:#c23a4b;outline-color:#c23a4b}

/* User panel additions (prototype classes cover the rest). */
.profile-photo-pick:focus-within{outline:2px solid var(--accent);outline-offset:3px}
.account-sidebar-logout{display:contents}
.account-sidebar-logout .app-button{width:100%}
.service-session form{display:contents}
.site-confirm p{margin:0 0 18px;line-height:2}
.site-confirm .app-form-actions{display:flex;gap:10px;justify-content:flex-end}

/* Header/nav links rendered as <a> where the prototype used <button>. */
.desktop-nav a[aria-current="page"]{color:var(--accent)}
.header-actions a.icon-button{display:inline-grid;place-items:center}

/* Development error details (APP_DEBUG only). */
.site-debug{margin-top:18px;padding:16px;border-radius:12px;background:var(--surface-soft);font-size:12px;line-height:1.7;white-space:pre-wrap;overflow:auto;text-align:left}

/* Unread counters on the header bell and the mobile messages tab (shell.js refreshBadges). */
.site-header .notification-action,.bottom-nav a{position:relative}
.header-badge{position:absolute;top:3px;inset-inline-end:3px;min-width:15px;height:15px;padding:0 4px;border-radius:8px;background:#e5484d;color:#fff;font-size:9.5px;font-weight:700;line-height:15px;text-align:center;box-shadow:0 0 0 2px var(--surface,#fff)}
.bottom-nav .header-badge{top:0;inset-inline-end:calc(50% - 22px)}
.header-badge[hidden]{display:none}

/* Paid banners (components/banner.php); the image keeps its placement ratio. */
.site-banner{position:relative;margin:20px 0;border:1px solid var(--ui-line);border-radius:16px;overflow:hidden;background:var(--surface-soft)}
.site-banner a{display:block}
/* A slim strip instead of the full-size picture: the same height range on every page, the artwork is cropped to fit. */
.site-banner img{display:block;width:100%;height:clamp(104px,16vw,190px);object-fit:cover;object-position:center;transition:transform .5s ease}
.site-banner a:hover img{transform:scale(1.02)}
/* Side column (ad page): keeps the placement's tall ratio instead of the slim strip, capped so it never fills a phone screen. */
.site-banner--side{margin:18px 0 0}.site-banner--side img{height:auto;max-height:340px}
.site-banner-label{position:absolute;top:10px;inset-inline-start:10px;padding:2px 9px;border:1px solid var(--ui-line);border-radius:7px;background:color-mix(in srgb,var(--surface) 84%,transparent);backdrop-filter:blur(6px);-webkit-backdrop-filter:blur(6px);color:var(--text-muted);font-size:10px;line-height:1.7}

/* Account navigation uses the same two-tone icon pack as the main navigation. */
body.panel-page .account-menu-icon{background:transparent;color:var(--accent-strong)}
body.panel-page .account-menu-icon>.pack-icon{width:28px;height:28px;object-fit:contain}
body.panel-page .account-sidebar nav a[aria-current=page] .account-menu-icon{background:transparent}
@media(max-width:700px){body.panel-page .account-menu-icon>.pack-icon{width:26px;height:26px}}

#main-content:target{scroll-margin-top:24px}

/* Shared row tracks align complete titles, metadata and prices without cutting title text. */
body.home-page #latest-results>.ad-card{display:grid;grid-template-rows:auto 1fr}
body.home-page #latest-results :is(.ad-card,.list-card)>.card-body{align-self:stretch;display:grid;align-content:start;gap:7px 10px;min-width:0}
body.home-page #latest-results .list-card>.card-body{grid-template-columns:minmax(0,1fr);grid-template-rows:auto 1fr auto auto auto}
body.home-page #latest-results .card-body>:is(h3,.card-topline,.card-description,.card-meta,.card-price){margin:0;min-width:0}
body.home-page #latest-results .card-body>.card-price{align-self:end;padding-top:10px}
body.home-page #latest-results .card-meta{align-self:start;min-height:1.8em;flex-wrap:wrap;white-space:normal}
body.home-page #latest-results h3{overflow-wrap:anywhere}
@media(max-width:360px){body.home-page .latest-heading{grid-template-columns:minmax(0,1fr);row-gap:12px}body.home-page .latest-heading .latest-tools{justify-self:stretch;justify-content:space-between}}
@supports(grid-template-rows:subgrid){
 body.home-page #latest-results.latest-cards>.ad-card{grid-row:span 5;grid-template-rows:subgrid;row-gap:0}
 body.home-page #latest-results.latest-cards>.ad-card>.card-media{grid-row:1;align-self:start}
 body.home-page #latest-results.latest-cards>.ad-card>.card-body{grid-row:2/span 4;grid-template-rows:subgrid}
 body.home-page #latest-results.latest-cards .card-description{grid-row:2}
 body.home-page #latest-results.latest-cards .card-meta{grid-row:3}
 body.home-page #latest-results.latest-cards .card-price{grid-row:4}
 body.home-page #latest-results.latest-list>.list-card{grid-row:span 5;grid-template-rows:subgrid;row-gap:0}
 body.home-page #latest-results.latest-list>.list-card>.card-media{grid-column:1;grid-row:1/span 5}
 body.home-page #latest-results.latest-list>.list-card>.card-body{grid-column:2;grid-row:1/span 5;grid-template-rows:subgrid}
}

/* Compact install invitation; update notices have priority in this fixed slot. */
.pwa-install-bar{position:fixed;z-index:29;inset-inline:12px;bottom:calc(98px + env(safe-area-inset-bottom,0px));display:flex;align-items:center;gap:8px;width:calc(100% - 24px);max-width:420px;margin-inline:auto;padding:9px 10px;border:1px solid var(--ui-line);border-radius:18px;background:var(--surface,#fff);color:var(--text-main);box-shadow:0 6px 24px #142d461a}
.pwa-install-bar[hidden],body.pwa-update-visible .pwa-install-bar,body:has(#modal[open]) .pwa-install-bar{display:none}
.pwa-install-bar>img{flex:none;width:36px;height:36px;object-fit:contain;border-radius:10px}
.pwa-install-copy{display:grid;gap:1px;min-width:0;flex:1}
.pwa-install-copy strong{font-size:12px;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.pwa-install-copy small{font-size:10px;color:var(--text-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.pwa-install-bar button{flex:none;display:inline-flex;align-items:center;justify-content:center;min-height:36px;border-radius:10px;font-size:11px;white-space:nowrap}
.pwa-install-action{padding:6px 14px;background:var(--accent);color:#fff}
html:is([data-appearance=dark],[data-appearance=charcoal]) .pwa-install-action{color:#102235}
.pwa-install-help{padding:6px 4px;background:transparent;color:var(--text-muted)}
.pwa-install-close{width:28px;padding:0;background:transparent;color:var(--text-muted)}
.pwa-install-close :is(.icon,.pack-icon){width:18px;height:18px}
.pwa-install-bar button:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
.pwa-install-guide{line-height:2;font-size:13px}
.pwa-install-guide ol{padding-inline-start:22px;margin:12px 0;display:grid;gap:8px}
.pwa-install-guide p{margin:8px 0}
@media(min-width:701px){.pwa-install-bar{bottom:24px;inset-inline-start:auto;inset-inline-end:24px;width:390px}}
@media(max-width:360px){.pwa-install-bar{gap:6px}.pwa-install-copy small{font-size:9px}.pwa-install-action{padding-inline:11px}}

/* Four-card desktop feeds next to the account/filter sidebar, matching the home grid. */
@media(min-width:1051px){
 body.site-shell :is(#favorite-ads,#browse-results-list,.community-recent-grid).latest-cards{grid-template-columns:repeat(4,minmax(0,1fr));gap:12px}
 body.site-shell :is(#favorite-ads,#browse-results-list,.community-recent-grid).latest-cards>.ad-card{display:grid;grid-template-rows:auto 1fr;min-width:0;align-content:start}
 body.site-shell :is(#favorite-ads,#browse-results-list,.community-recent-grid).latest-cards .card-body{display:grid;grid-template-columns:minmax(0,1fr);gap:6px;align-content:start;align-self:stretch;padding:12px;min-width:0}
 body.site-shell :is(#favorite-ads,#browse-results-list,.community-recent-grid).latest-cards .card-topline{grid-column:1;grid-row:1;margin:0;padding:0;justify-content:flex-start}
 body.site-shell :is(#favorite-ads,#browse-results-list,.community-recent-grid).latest-cards .card-body h3{grid-column:1;grid-row:2;display:block;min-height:0;margin:0;font-size:12px;line-height:1.8;white-space:normal;overflow:visible;overflow-wrap:anywhere}
 body.site-shell :is(#favorite-ads,#browse-results-list,.community-recent-grid).latest-cards .card-description{grid-column:1;grid-row:3;min-width:0;margin:0;font-size:10.5px;line-height:1.8;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
 body.site-shell :is(#favorite-ads,#browse-results-list,.community-recent-grid).latest-cards .card-meta{grid-column:1;grid-row:4;min-width:0;min-height:1.8em;margin:0;gap:3px;font-size:10px;line-height:1.8;flex-wrap:wrap;white-space:normal}
 body.site-shell :is(#favorite-ads,#browse-results-list,.community-recent-grid).latest-cards .card-meta :is(.icon,.pack-icon){width:14px;height:14px;flex-shrink:0}
 body.site-shell :is(#favorite-ads,#browse-results-list,.community-recent-grid).latest-cards .card-price{grid-column:1;grid-row:5;margin:0;padding-top:9px;gap:4px;font-size:13px;align-self:end}
 body.site-shell :is(#favorite-ads,#browse-results-list,.community-recent-grid).latest-cards .card-price>span:first-child{display:flex;flex:1;flex-wrap:wrap;align-items:baseline;gap:3px;min-width:0}
 body.site-shell :is(#favorite-ads,#browse-results-list,.community-recent-grid).latest-cards .card-price small{font-size:9px}
 body.site-shell :is(#favorite-ads,#browse-results-list,.community-recent-grid).latest-cards .card-open-arrow{width:24px;height:24px;flex:none}
 body.site-shell :is(#favorite-ads,#browse-results-list,.community-recent-grid).latest-cards .card-open-arrow :is(.icon,.pack-icon){width:14px;height:14px}
 @supports(grid-template-rows:subgrid){
  body.site-shell :is(#favorite-ads,#browse-results-list,.community-recent-grid).latest-cards>.ad-card{grid-row:span 6;grid-template-rows:subgrid;row-gap:0}
  body.site-shell :is(#favorite-ads,#browse-results-list,.community-recent-grid).latest-cards>.ad-card>.card-media{grid-row:1;align-self:start}
  body.site-shell :is(#favorite-ads,#browse-results-list,.community-recent-grid).latest-cards .card-body{grid-row:2/span 5;grid-template-rows:subgrid}
 }
}

/* The shared no-photo artwork stays fully visible in every ad thumbnail. */
body.site-shell img[src*="/images/ad-placeholder.webp"]{object-fit:contain!important;background:#fff}

/* Related ads use the same four-card desktop rhythm as the main feed. */
@media(min-width:1051px){
 body.site-shell .product-related-cards.latest-cards{grid-template-columns:repeat(4,minmax(0,1fr));gap:18px}
}
body.site-shell .product-related-cards>.ad-card{display:grid;grid-template-rows:auto 1fr}
body.site-shell .product-related-cards .card-body{align-self:stretch;display:grid;align-content:start;gap:7px 10px;min-width:0}
body.site-shell .product-related-cards .card-body>:is(h3,.card-topline,.card-description,.card-meta,.card-price){margin:0;min-width:0}
body.site-shell .product-related-cards .card-price{align-self:end;padding-top:10px}
body.site-shell .product-related-cards .card-meta{align-self:start;min-height:1.8em;flex-wrap:wrap;white-space:normal}
body.site-shell .product-related-cards h3{overflow-wrap:anywhere}
@supports(grid-template-rows:subgrid){
 body.site-shell .product-related-cards>.ad-card{grid-row:span 5;grid-template-rows:subgrid;row-gap:0}
 body.site-shell .product-related-cards>.ad-card>.card-media{grid-row:1;align-self:start}
 body.site-shell .product-related-cards>.ad-card>.card-body{grid-row:2/span 4;grid-template-rows:subgrid}
 body.site-shell .product-related-cards .card-description{grid-row:2}
 body.site-shell .product-related-cards .card-meta{grid-row:3}
 body.site-shell .product-related-cards .card-price{grid-row:4}
}
