/* ============================================================
   CCRS motion.css : Phase 1 (foundation)
   Additive file. Load AFTER style-new.css and after the inline
   <style> block in <head>. Changes no HTML text, alt text or schema.
   Everything works with JavaScript off; JS only adds the tilt.
   ============================================================ */

/* ---------- 1. Motion tokens ---------- */
:root {
  --motion-fast: 160ms;
  --motion-standard: 220ms;
  --motion-reveal: 500ms;
  --motion-ease: cubic-bezier(0.22, 1, 0.36, 1);

  --card-lift: -4px;          /* hub / service cards */
  --card-lift-subtle: -2px;   /* repair-option cards */
  --card-tilt-max: 2deg;      /* read by card-motion.js */
}

/* ---------- 2. Hub cards (.hub-card): lift, border, optional tilt ---------- */
.hub-card {
  --tilt-x: 0deg;
  --tilt-y: 0deg;
  box-shadow: var(--shadow-sm);
  /* explicit properties only, no "transition: all" */
  transition:
    transform var(--motion-standard) var(--motion-ease),
    border-color var(--motion-fast) var(--motion-ease),
    box-shadow var(--motion-standard) var(--motion-ease);
}
.hub-card .hub-arrow {
  transition: transform var(--motion-fast) var(--motion-ease);
}

/* Keyboard focus: the global :focus-visible sets border-radius:6px, which
   would square off these 18px cards. Restore the radius and strengthen border. */
.hub-card:focus-visible {
  border-radius: var(--radius);
  border-color: var(--brand);
  box-shadow: var(--shadow-md);
  transform: translateY(var(--card-lift));
}

/* Hover lift only on devices that really hover (no sticky hover on touch) */
@media (hover: hover) and (pointer: fine) {
  .hub-card:hover {
    transform: translateY(var(--card-lift));
    border-color: var(--brand);
    box-shadow: var(--shadow-md);
  }
  /* Added by card-motion.js on first pointer move; tilt is capped at 2deg */
  .hub-card.is-tilting:hover {
    transform:
      translateY(var(--card-lift))
      perspective(900px)
      rotateX(var(--tilt-x))
      rotateY(var(--tilt-y));
  }
}

/* Touch / no-hover: normal tap, no lift, no lingering hover border */
@media (hover: none) {
  .hub-card:hover {
    transform: none;
    box-shadow: var(--shadow-sm);
  }
  .hub-card:not(.highlight):hover { border-color: var(--border); }
  .hub-card:hover .hub-arrow { transform: none; }
  .hub-card:active { border-color: var(--brand); }
}

/* ---------- 3. Repair-option cards (.sm-card): elevation + border only ----------
   The inline <style> block styles .sm-card:hover with var(--sm-accent), but the
   markup uses .sm-card-1..4 and --sm-accent is never defined on them. That hover
   therefore resolves to currentColor borders and no shadow, with a 6px lift.
   This block fixes that with a separate --card-accent variable (so no other
   inline rule that reads --sm-accent changes appearance). */
.service-modes-grid .sm-card-1 { --card-accent: var(--brand);  --card-rest: 0 8px 30px rgba(37, 99, 235, .08); }
.service-modes-grid .sm-card-2 { --card-accent: var(--green);  --card-rest: 0 8px 30px rgba(34, 197, 94, .08); }
.service-modes-grid .sm-card-3 { --card-accent: var(--amber);  --card-rest: 0 8px 30px rgba(245, 158, 11, .08); }
.service-modes-grid .sm-card-4 { --card-accent: var(--accent); --card-rest: 0 8px 30px rgba(124, 58, 237, .08); }

.service-modes-grid .sm-card {
  transition:
    transform var(--motion-standard) var(--motion-ease),
    box-shadow var(--motion-standard) var(--motion-ease),
    border-color var(--motion-fast) var(--motion-ease);
}
/* Baseline hover: keeps the accent border and resting shadow (no lift) */
.service-modes-grid .sm-card:hover {
  transform: none;
  border-color: var(--card-accent);
  box-shadow: var(--card-rest);
}
@media (hover: hover) and (pointer: fine) {
  .service-modes-grid .sm-card:hover {
    transform: translateY(var(--card-lift-subtle));
    box-shadow: 0 16px 36px -18px color-mix(in srgb, var(--card-accent) 55%, transparent);
  }
}
/* Card is not a link; show the group when its CTA / links are focused */
.service-modes-grid .sm-card:focus-within {
  border-color: var(--card-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--card-accent) 30%, transparent), var(--card-rest);
}
/* Global :focus-visible forces border-radius:6px; keep the pill shape */
.service-modes-grid .sm-cta:focus-visible,
.service-modes-grid .btn:focus-visible {
  border-radius: var(--radius-pill);
}

/* ---------- 4. Reduced motion ----------
   Covers the OS setting AND the site's own "Reduce motion" toggle
   (html[data-motion="reduced"]). Borders and focus rings stay; movement goes. */
@media (prefers-reduced-motion: reduce) {
  .hub-card,
  .hub-card:hover,
  .hub-card:focus-visible,
  .hub-card.is-tilting:hover,
  .service-modes-grid .sm-card,
  .service-modes-grid .sm-card:hover {
    transform: none !important;
  }
  .hub-card:hover .hub-arrow { transform: none; }
  .hub-card,
  .service-modes-grid .sm-card {
    transition: border-color var(--motion-fast) linear, box-shadow var(--motion-fast) linear;
  }
}
html[data-motion="reduced"] .hub-card,
html[data-motion="reduced"] .hub-card:hover,
html[data-motion="reduced"] .hub-card:focus-visible,
html[data-motion="reduced"] .hub-card.is-tilting:hover,
html[data-motion="reduced"] .service-modes-grid .sm-card,
html[data-motion="reduced"] .service-modes-grid .sm-card:hover {
  transform: none !important;
}
html[data-motion="reduced"] .hub-card:hover .hub-arrow { transform: none; }
