/* =====================================================================
   Maccar Medical — cookie card + preferences dialog and click-to-load video embeds (Sanitizer::gateEmbeds).
   Both can appear on every storefront page, so layouts/main.php loads this file everywhere; pages.css loads only
   on the content pages. Owner: WS5 (content). Design: DESIGN-DIRECTION.md ("Calibrated").
   ===================================================================== */

/* the cookie lists reuse the content-page accordion toggle (pages.css .pg-acc-toggle) */
.cc-cookies > summary { display: grid; grid-template-columns: minmax(0, 1fr) 12px; gap: 16px; align-items: center; cursor: pointer; list-style: none; }
.cc-cookies > summary::-webkit-details-marker { display: none; }
.cc .pg-acc-toggle { position: relative; width: 12px; height: 12px; justify-self: end; color: var(--text); }
.cc .pg-acc-toggle::before, .cc .pg-acc-toggle::after {
  content: ""; position: absolute; inset-inline-start: 0; inset-block-start: 5.5px; width: 12px; height: 1px; background: currentColor;
}
.cc .pg-acc-toggle::after { transform: rotate(90deg); transition: transform var(--t-ui) var(--ease-standard); }
.cc details[open] > summary .pg-acc-toggle::after { transform: rotate(0deg); }

/* ================================================================ 13. Cookie card + preferences dialog */
.cc-bar { position: fixed; inset-inline: 0; inset-block-end: 0; z-index: var(--z-cookie, 80); padding: 0; pointer-events: none; }
.cc-bar[hidden] { display: none; }
.cc-bar-inner {
  pointer-events: auto; display: grid; gap: 12px; max-height: 80vh; max-height: 80svh; overflow-y: auto;
  padding: 20px 16px calc(16px + env(safe-area-inset-bottom)); background: var(--paper); color: var(--text-body);
  box-shadow: var(--elev-float); border-radius: 0;
}
html.js .cc-bar-inner { transition: opacity 220ms var(--ease-exit), transform 220ms var(--ease-exit); }
html.js .cc-bar:not(.is-visible) .cc-bar-inner { opacity: 0; transform: translateY(16px); animation: cc-failsafe 0s 4s forwards; }
html.js .cc-bar.is-visible .cc-bar-inner { opacity: 1; transform: none; transition: opacity 360ms var(--ease-precise), transform 360ms var(--ease-precise); }
@keyframes cc-failsafe { to { opacity: 1; transform: none; } }
.cc-bar-kicker { margin: 0; }
.cc-bar-title { margin: 0; font-size: var(--fs-h4); font-weight: 520; line-height: 1.3; color: var(--text); }
:lang(ar) .cc-bar-title { font-weight: 600; }
.cc-bar-text { margin: 0; font-size: .875rem; line-height: 1.55; color: var(--text-body); }
.cc-bar-text a, .cc-intro a { color: var(--link); text-decoration: underline; text-underline-offset: 3px; }
.cc-bar-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 8px 0 0; }
.cc-btn { min-height: 44px; padding-inline: 8px; white-space: normal; font-size: .875rem; line-height: 1.2; }
@media (max-width: 339.98px) { .cc-bar-actions { grid-template-columns: minmax(0, 1fr); } }
@media (min-width: 768px) {
  .cc-bar { inset-inline: 24px auto; inset-block-end: 24px; width: 400px; max-width: calc(100vw - 48px); }
  .cc-bar-inner { padding: 24px; }
}
/* dialog */
.cc-modal { z-index: calc(var(--z-cookie, 95) + 1); align-items: end; padding: 0; }
.cc-modal[hidden] { display: none; }
.cc-backdrop { background: rgb(10 15 23 / .32); transition: opacity var(--t-ui) var(--ease-standard); }
.cc-panel {
  position: relative; display: flex; flex-direction: column; width: 100%; max-width: 640px; max-height: 92vh; max-height: 92svh; padding: 0; overflow: hidden;
  border-radius: 0; background: var(--paper); box-shadow: var(--elev-float);
  opacity: 0; transform: translateY(16px); transition: opacity var(--t-panel) var(--ease-precise), transform var(--t-panel) var(--ease-precise);
}
.cc-modal.is-open .cc-panel { opacity: 1; transform: none; }
.cc-panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 20px 16px 16px; border-block-end: 1px solid var(--rule); }
.cc-panel-kicker { margin: 0 0 6px; }
.cc-title { margin: 0; font-size: var(--fs-h3); font-weight: 400; line-height: 1.2; color: var(--text); }
.cc-close { display: grid; place-items: center; flex: none; width: 44px; height: 44px; margin: -8px; border: 0; border-radius: 2px; background: none; color: var(--text); cursor: pointer; transition: background-color var(--t-hover) var(--ease-hover); }
.cc-close:hover { background: var(--paper-2); }
.cc-prefs { display: flex; flex-direction: column; min-height: 0; flex: 1 1 auto; }
.cc-panel-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 16px; }
.cc-intro { margin: 0 0 16px; font-size: var(--fs-small); color: var(--text-body); }
.cc-cat { padding-block: 16px; border-block-start: 1px solid var(--rule); }
.cc-cat-row { display: grid; grid-template-columns: 2rem minmax(0, 1fr) auto; gap: 8px; align-items: center; min-height: 44px; }
.cc-cat-title { margin: 0; font-size: 1rem; font-weight: 500; color: var(--text); }
.cc-always { color: var(--text-muted); white-space: nowrap; }
.cc-cat-text { margin: 4px 0 0; padding-inline-start: calc(2rem + 8px); font-size: .875rem; line-height: 1.55; color: var(--text-muted); }
.cc-switch { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 52px; height: 44px; cursor: pointer; }
.cc-switch input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.cc-switch-track { position: relative; width: 40px; height: 22px; border: 1px solid var(--rule-strong); border-radius: 999px; background: var(--paper); transition: background-color var(--t-hover) var(--ease-hover), border-color var(--t-hover) var(--ease-hover); }
.cc-switch-thumb { position: absolute; inset-block-start: 3px; inset-inline-start: 3px; width: 14px; height: 14px; border-radius: 50%; background: var(--text-muted); transition: transform var(--t-ui) var(--ease-precise), background-color var(--t-hover) var(--ease-hover); }
.cc-switch input:checked + .cc-switch-track { background: var(--signal); border-color: var(--signal); }
.cc-switch input:checked + .cc-switch-track .cc-switch-thumb { background: #fff; transform: translateX(calc(18px * var(--dir))); }
.cc-switch input:focus-visible + .cc-switch-track { outline: 2px solid var(--focus); outline-offset: 3px; }
.cc-cookies { margin-block-start: 8px; padding-inline-start: calc(2rem + 8px); }
.cc-cookies > summary { min-height: 44px; font-size: .8125rem; font-weight: 500; color: var(--text); }
.cc-cookie-list { margin: 0; padding: 0; list-style: none; border-block-start: 1px solid var(--rule); }
.cc-cookie { padding-block: 10px; border-block-end: 1px solid var(--rule); }
.cc-cookie-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; margin: 0 0 4px; }
.cc-cookie-head code { font-family: var(--font-mono); font-size: .8125rem; color: var(--text); background: none; padding: 0; }
.cc-cookie-purpose { margin: 0; font-size: .8125rem; line-height: 1.55; color: var(--text-muted); }
.cc-none { margin: 8px 0 0; padding-inline-start: calc(2rem + 8px); }
.cc-panel-foot { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-block-start: 1px solid var(--rule); background: var(--paper); }
.cc-foot-btn { min-height: 44px; white-space: normal; }
.cc-foot-save { grid-column: 1 / -1; }
@media (min-width: 640px) {
  .cc-modal { align-items: center; padding: 24px; }
  .cc-panel { max-height: min(760px, calc(100vh - 48px)); }
  .cc-panel-head { padding: 24px 28px 20px; }
  .cc-panel-body { padding: 20px 28px 8px; }
  .cc-panel-foot { grid-template-columns: auto auto 1fr; padding: 16px 28px; }
  .cc-foot-save { grid-column: auto; justify-self: end; }
}

/* ================================================================ 14. Click-to-load video embeds (Sanitizer::gateEmbeds) */
.embed-consent { display: grid; place-items: center; width: 100%; aspect-ratio: 16 / 9; margin: 1.6em 0; padding: 24px; border: 1px solid var(--rule); border-radius: 0; background: var(--plate); color: var(--text); text-align: center; }
.embed-consent-body { display: grid; justify-items: center; gap: 12px; max-width: 46ch; }
.embed-consent-play { min-height: 44px; }
.embed-consent-play .icon { width: 18px; height: 18px; }
.embed-consent-text { margin: 0; font-size: .875rem; line-height: 1.5; color: var(--text-muted); }
.embed-consent-link { font-size: .875rem; color: var(--link); text-decoration: underline; text-underline-offset: 3px; }
.embed-consent.is-loaded { display: block; padding: 0; border: 0; background: var(--s-bg); }
.embed-consent.is-loaded iframe { display: block; width: 100%; height: 100%; border: 0; }
@media (max-width: 479.98px) { .embed-consent { aspect-ratio: auto; min-height: 220px; padding: 20px 16px; } }

/* Reduced motion, print */
html.motion-reduced :is(.cc-panel, .cc-switch-thumb) { transition-duration: 0s !important; }
html.motion-reduced .cc-bar-inner { transition: opacity 160ms linear !important; transform: none !important; }
@media print { .cc { display: none !important; } }
