/* ==========================================================================
   DigitalAccessoriesHub — dynamic-feature styles (extends style.css tokens)
   Live search · inline feedback · AJAX listing · saved list · deals toolbar
   ========================================================================== */

/* Chips used as links that show the current selection */
.chip[aria-current="true"] { background: var(--ink-900); border-color: var(--ink-900); color: #fff; }
.active-filters .chip .icon { width: 14px; height: 14px; margin-left: 2px; }

/* Flash + form feedback */
.flash { display: flex; align-items: center; gap: 10px; margin: 16px 0 0; padding: 14px 16px; border-radius: var(--radius-sm); background: var(--accent-50); color: #087a54; font-weight: 600; }
.flash .icon { flex: none; }
/* Staff previewing an unpublished product, guide or page */
.preview-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin: 16px 0 0; padding: 12px 16px; border-radius: var(--radius-sm); background: #fff7e0; border: 1px solid #f5d27a; color: #7a5300; font-size: 14.5px; }
.preview-bar .icon { flex: none; }
.preview-bar span { flex: 1 1 260px; }
.preview-bar a { font-weight: 700; color: inherit; text-decoration: underline; }
.form-error { padding: 14px 16px; border-radius: var(--radius-sm); background: var(--hot-50); color: #b4123a; font-weight: 600; }
.form-error[hidden] { display: none; }
.field-error { margin: 6px 0 0; font-size: 13.5px; color: #b4123a; font-weight: 500; }
.input.is-invalid { border-color: var(--hot); box-shadow: 0 0 0 4px var(--hot-50); }
.hp-field { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0; opacity: 0; pointer-events: none; }
form.is-busy button[type="submit"] { opacity: .65; pointer-events: none; }

/* Live search suggestions */
.search-field { position: relative; }
.suggest {
  position: absolute; z-index: 120; top: calc(100% + 8px); left: 0; right: 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 8px; max-height: min(70vh, 520px); overflow-y: auto; text-align: left;
}
.suggest[hidden] { display: none; }
.suggest-group { padding: 6px 0; }
.suggest-group + .suggest-group { border-top: 1px solid var(--line); }
.suggest-label { display: block; padding: 4px 10px 6px; font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-500); }
.suggest-item { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: var(--radius-xs); color: var(--ink-900); }
.suggest-item:hover, .suggest-item[aria-selected="true"] { background: var(--surface-2); }
.suggest-item img { width: 44px; height: 44px; flex: none; border-radius: 10px; background: var(--grad-media); object-fit: contain; padding: 4px; }
.suggest-item .s-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.suggest-item strong { font-size: 14.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.suggest-item small { color: var(--ink-500); font-size: 12.5px; }
.suggest-item .s-price { font-weight: 700; font-size: 14px; white-space: nowrap; }
.suggest-item mark { background: var(--brand-50); color: var(--brand-600); border-radius: 3px; padding: 0 1px; }
.suggest-all { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 4px; padding: 10px; border-radius: var(--radius-xs); font-weight: 600; font-size: 14px; color: var(--brand); background: var(--brand-50); }
.suggest-all:hover, .suggest-all[aria-selected="true"] { background: var(--brand-100); }
.suggest-empty { padding: 14px 10px; color: var(--ink-500); font-size: 14px; }
.search-overlay .suggest { top: calc(100% + 6px); }

/* AJAX listing: soft loading state while filters apply */
[data-listing-results] { transition: opacity .2s var(--ease); }
.is-loading [data-listing-results] { opacity: .45; pointer-events: none; }

/* Product page: save + share row */
.save-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0 4px; }
.save-btn .icon { transition: transform .2s var(--ease), fill .2s; }
.save-btn[aria-pressed="true"] { border-color: var(--hot); color: var(--hot); background: var(--hot-50); }
.save-btn[aria-pressed="true"] .icon { fill: currentColor; transform: scale(1.08); }

/* Deals toolbar: chips + client-side sort */
.deals-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.deals-tools .chip-row { flex: 1; min-width: 0; }
.deals-tools .select { width: auto; min-width: 210px; }

/* Live ad code container */
.ad-slot.ad-live { background: none; border: 0; min-height: 0; padding: 0; }

/* Small toast for share / save feedback */
.toast { position: fixed; left: 50%; bottom: 24px; z-index: 200; transform: translate(-50%, 20px); opacity: 0; transition: all .25s var(--ease); background: var(--ink-900); color: #fff; padding: 12px 18px; border-radius: var(--radius-pill); font-weight: 600; font-size: 14px; box-shadow: var(--shadow-lg); pointer-events: none; }
.toast.is-visible { transform: translate(-50%, 0); opacity: 1; }
body.has-mobile-buy .toast { bottom: 96px; }

@media (prefers-reduced-motion: reduce) {
  [data-listing-results], .toast, .save-btn .icon { transition: none; }
}

/* Contact sidebar: inline links */
.contact-item span a { color: var(--brand); font-weight: 600; }
.contact-item span a:hover { text-decoration: underline; }

/* ==========================================================================
   Affiliate links: price history, deal timers, product comparison
   ========================================================================== */
.offer-sale { display: inline-flex; align-items: center; gap: 4px; color: var(--hot); font-weight: 600; font-size: 12.5px; }
.price-low-badge { margin-top: 6px; }
.store-mark.sm { width: 26px; height: 26px; font-size: 12px; display: inline-grid; vertical-align: middle; margin-right: 6px; }

.price-history { margin-top: 18px; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); }
.ph-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 8px; }
.ph-head h3 { font-size: 15px; margin: 0; }
.ph-head h3 span { color: var(--ink-500); font-weight: 500; }
.ph-range { font-size: 13px; font-weight: 600; color: var(--ink-700); }
.ph-chart { width: 100%; height: 64px; display: block; overflow: visible; }
.ph-area { fill: var(--brand-50); }
.ph-line { fill: none; stroke: var(--brand); stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.ph-dot { fill: var(--brand); stroke: #fff; stroke-width: 2; vector-effect: non-scaling-stroke; }
.ph-foot { display: flex; justify-content: space-between; gap: 8px; margin-top: 6px; font-size: 12px; color: var(--ink-500); }

/* Compare toggle on cards + product page */
.pc-compare { position: absolute; left: 12px; bottom: 12px; z-index: 2; display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px; border-radius: var(--radius-pill); border: 1px solid var(--line); background: rgba(255,255,255,.92); color: var(--ink-700); font-size: 12.5px; font-weight: 600; cursor: pointer; opacity: 0; transform: translateY(4px); transition: opacity .2s, transform .2s, background .2s; }
.product-card:hover .pc-compare, .product-card:focus-within .pc-compare, .pc-compare[aria-pressed="true"] { opacity: 1; transform: none; }
.pc-compare[aria-pressed="true"], .compare-btn[aria-pressed="true"] { background: var(--ink-900); border-color: var(--ink-900); color: #fff; }
@media (hover: none) { .pc-compare { opacity: 1; transform: none; } .pc-compare span { display: none; } }

/* Floating compare tray */
.compare-tray { position: fixed; left: 0; right: 0; bottom: 0; z-index: 95; background: var(--surface); border-top: 1px solid var(--line); box-shadow: 0 -12px 32px -16px rgba(11,16,32,.25); padding: 10px 0; }
.compare-tray[hidden] { display: none; }
.ct-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.ct-items { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; min-width: 0; }
.ct-chip { height: 34px; gap: 6px; max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ct-chip button { display: inline-grid; place-items: center; border: 0; background: none; padding: 0; cursor: pointer; color: inherit; }
.ct-hint { font-size: 13px; color: var(--ink-500); }
.ct-actions { display: flex; gap: 8px; flex: none; }
.btn.is-disabled { opacity: .5; }
body.has-compare-tray { padding-bottom: 72px; }
body.has-compare-tray.has-mobile-buy .compare-tray { bottom: 76px; }
body.has-compare-tray .to-top { bottom: 92px; }
@media (max-width: 640px) { .ct-chip { max-width: 140px; } .ct-hint { display: none; } }

/* Compare page */
.compare-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
.compare-table { min-width: calc(180px + var(--cols) * 220px); margin: 0; }
.compare-table th[scope="row"] { width: 180px; position: sticky; left: 0; background: var(--surface); z-index: 1; }
.compare-table td, .compare-table thead th { vertical-align: top; min-width: 200px; }
.cmp-product { position: relative; text-align: left; padding-top: 16px; }
.cmp-product .badge { margin: 6px 6px 0 0; }
.cmp-media { display: block; width: 120px; height: 120px; margin-bottom: 10px; border-radius: var(--radius-sm); background: var(--grad-media); }
.cmp-media img { width: 100%; height: 100%; object-fit: contain; padding: 8px; }
.cmp-name { display: block; font-weight: 700; color: var(--ink-900); line-height: 1.35; margin-top: 2px; }
.cmp-name:hover { color: var(--brand); }
.cmp-remove { position: absolute; top: 10px; right: 10px; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; border: 1px solid var(--line); color: var(--ink-500); background: var(--surface); }
.cmp-remove:hover { color: var(--hot); border-color: var(--hot); }
.cmp-price { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; color: var(--ink-900); padding: 4px 10px; border-radius: var(--radius-pill); border: 1px solid var(--line); }
.cmp-price:hover { border-color: var(--brand); color: var(--brand); }
.cmp-price.is-low { background: var(--accent-50); border-color: var(--accent); color: #087a54; }
.cmp-na { color: var(--ink-300); }
.cmp-list { margin: 0; padding-left: 18px; font-size: 14px; }
.cmp-list li + li { margin-top: 4px; }
.cmp-list.pros li::marker { color: var(--accent); }
.cmp-list.cons li::marker { color: var(--hot); }

/* ==========================================================================
   Advertising slots: space reserved per device (no layout shift), collapse
   on devices without an ad, small "Advertisement" label.
   Breakpoints match app.js: phone < 640px ≤ tablet < 1024px ≤ desktop.
   ========================================================================== */
.ad-unit { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; overflow: hidden; }
.ad-unit .ad-frame { width: 100%; min-height: var(--ad-h-mobile, 0px); display: flex; align-items: center; justify-content: center; }
.ad-unit .ad-frame > * { max-width: 100%; }
.ad-unit[data-off-mobile] { display: none; }
@media (min-width: 640px) {
  .ad-unit .ad-frame { min-height: var(--ad-h-tablet, 0px); }
  .ad-unit[data-off-mobile] { display: flex; }
  .ad-unit[data-off-tablet] { display: none; }
}
@media (min-width: 1024px) {
  .ad-unit .ad-frame { min-height: var(--ad-h-desktop, 0px); }
  .ad-unit[data-off-tablet] { display: flex; }
  .ad-unit[data-off-desktop] { display: none; }
}
.ad-label { display: block; margin-bottom: 4px; font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-300); }
.ad-banner { display: inline-block; line-height: 0; border-radius: var(--radius-xs); overflow: hidden; }
.ad-banner img { width: auto; max-width: 100%; height: auto; }
.ad-in-content { margin: 28px auto; clear: both; }
.ad-below-header { margin-top: 16px; }
.ad-unit ins.adsbygoogle { width: 100%; }

/* Staff preview of a slot (real ads are hidden for logged-in staff) */
.ad-preview { min-height: max(90px, var(--ad-h-mobile, 90px)); text-transform: none; letter-spacing: 0; font-size: 12.5px; line-height: 1.6; padding: 12px; border-color: var(--brand-100); background: repeating-linear-gradient(-45deg, var(--surface-2), var(--surface-2) 10px, #fff 10px, #fff 20px); }
.ad-preview strong { color: var(--ink-700); }
.ad-preview small { display: block; color: var(--ink-300); }
.ad-preview [data-only] { display: none; }
.ad-preview [data-only="mobile"] { display: inline; }
.ad-preview[data-off-mobile] { display: none; }
@media (min-width: 640px) {
  .ad-preview { min-height: max(90px, var(--ad-h-tablet, 90px)); }
  .ad-preview[data-off-mobile] { display: grid; }
  .ad-preview[data-off-tablet] { display: none; }
  .ad-preview [data-only="mobile"] { display: none; }
  .ad-preview [data-only="tablet"] { display: inline; }
}
@media (min-width: 1024px) {
  .ad-preview { min-height: max(90px, var(--ad-h-desktop, 90px)); }
  .ad-preview[data-off-tablet] { display: grid; }
  .ad-preview[data-off-desktop] { display: none; }
  .ad-preview [data-only="tablet"] { display: none; }
  .ad-preview [data-only="desktop"] { display: inline; }
}

/* ---------- Responsive fixes ---------- */

/* Images keep their proportions when CSS sets only a width (e.g. `.rank-thumb img { width: 72% }`):
   without this the HTML height attribute stays fixed and uploaded photos get stretched.
   Rules that set a height on purpose (with object-fit) are more specific and still apply. */
img { height: auto; }

/* Brand logo (image lockup, 710×132): sized by height, width follows. */
.logo picture { display: block; }
.logo-img { display: block; height: 44px; width: auto; max-width: none; }
.site-footer .logo-img { height: 46px; }
.drawer-head .logo-img { height: 36px; }
@media (max-width: 400px) {
  .site-header .logo-img { height: 38px; }
}
/* Small phones (≤ 360px, e.g. iPhone SE 1st gen): logo + search + menu must fit 288px. */
@media (max-width: 360px) {
  .site-header .logo { flex: 0 1 auto; min-width: 0; }
  .site-header .logo-img { height: 34px; }
  .header-actions { gap: 0; }
  .header-main { gap: 8px; }
}

/* Tablets: three-card sections (guides, reader reviews, related guides) left one card alone on a second row. */
@media (min-width: 700px) and (max-width: 1023.98px) {
  .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
}

/* Guide cards: the image (drawn later, with a drop-shadow) covered the "Buying guide" badge in narrow cards. */
.ac-media .badge { z-index: 1; }
.ac-media img { max-height: 66%; object-fit: contain; }
/* Meta line: each "•" travels with the item after it, so a line never ends on a dangling dot. */
.ac-meta-item { display: inline-flex; align-items: center; gap: 8px; }
/* …and a dot that starts a wrapped line is clipped: the row is shifted 11px (dot + gap) left and that strip hidden. */
.ac-meta:has(.ac-meta-item) { margin-left: -11px; clip-path: inset(-6px -6px -6px 11px); }
.ac-meta:has(.ac-meta-item) > :first-child { margin-left: 11px; }

/* Category toolbar: the filter button and sort menu share the full row on phones instead of overflowing. */
@media (max-width: 480px) {
  .toolbar-right { width: 100%; }
  .toolbar-right .select { flex: 1; min-width: 0; }
}

/* Newsletter on phones: in the stacked layout `flex: 1` collapsed the email field to its text height (19px). */
@media (max-width: 480px) {
  .nl-form input { flex: none; height: 46px; }
}

/* Touch screens: footer links get a finger-sized hit area (≥ 24px) without changing the look. */
@media (pointer: coarse) {
  .footer-col a, .footer-bottom nav a { display: inline-block; padding: 6px 0; }
  .footer-col li + li { margin-top: 0; }
  .footer-bottom nav { gap: 4px 18px; }
  /* Checkbox rows (filters, "Remember me") and login links: the whole row is the target. */
  .check { min-height: 36px; }
  .check input { width: 20px; height: 20px; }
  .auth-row a, .auth-foot a { display: inline-block; padding: 8px 0; }
}

/* ---------- Software & tool reviews: quick facts under the summary, free plan / trial line ---------- */
.quick-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin: -6px 0 22px; }
.quick-facts div { padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface, transparent); min-width: 0; }
.quick-facts dt { font-size: 12px; color: var(--ink-500); margin: 0 0 2px; }
.quick-facts dd { margin: 0; font-weight: 600; font-size: 14px; color: var(--ink-900, inherit); overflow-wrap: anywhere; }
.offer-trial { display: flex; align-items: center; gap: 6px; margin: 10px 0 0; font-size: 13.5px; font-weight: 600; color: var(--accent, var(--brand)); }
.offer-trial .icon { flex: none; }
