/*
 * Jeff Harris Books: responsive layer for tablet and mobile.
 * The page markup is styled inline, so these rules match the inline values
 * and use !important to adjust them per screen size.
 */

/* ---------- every size ---------- */

/* Grids never ask for columns wider than the screen. */
[style*="minmax(200px, 1fr)"] { grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)) !important; }
[style*="minmax(220px, 1fr)"] { grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)) !important; }
[style*="minmax(240px, 1fr)"] { grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)) !important; }
[style*="minmax(260px, 1fr)"] { grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)) !important; }
[style*="minmax(280px, 1fr)"] { grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)) !important; }
[style*="minmax(340px, 1fr)"] { grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)) !important; }

img { max-width: 100%; }
a[href^="mailto:"] { overflow-wrap: anywhere; }

/* Safety net: never scroll sideways. */
body { overflow-x: clip; }

/* ---------- tablet and below (under 1024px) ---------- */
@media (max-width: 1023px) {
  [style*="padding: 104px 32px"],
  [style*="padding: 112px 32px"],
  [style*="padding: 96px 32px"],
  [style*="padding: 88px 32px"] { padding-top: 88px !important; padding-bottom: 88px !important; }

  /* Hero book stays a sensible size once the columns stack. */
  #top img[style*="max-width: 580px"] { max-width: 460px !important; }
}

/* Tablet: rows of three sit side by side instead of two plus one. */
@media (min-width: 760px) and (max-width: 1023px) {
  [style*="display: grid"]:has(> :nth-child(3):last-child) { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }

  /* Format cards in three columns: slimmer padding so "Buy on Amazon" stays on one line. */
  div[data-group][style*="padding: 34px 30px 30px"] { padding: 28px 18px 24px !important; }
  div[data-group] a[style*="border-radius: 999px"] { padding-left: 12px !important; padding-right: 12px !important; font-size: 15px !important; white-space: nowrap; }
}

/* ---------- small tablets and large phones (under 768px) ---------- */
@media (max-width: 767px) {
  [style*="margin: 0 auto; padding:"] { padding-left: 24px !important; padding-right: 24px !important; }
  .site-nav { padding-left: 24px !important; padding-right: 24px !important; }

  [style*="padding: 104px 32px"],
  [style*="padding: 112px 32px"],
  [style*="padding: 96px 32px"],
  [style*="padding: 88px 32px"] { padding-top: 72px !important; padding-bottom: 72px !important; }

  [style*="gap: 64px"], [style*="gap: 56px"] { gap: 40px !important; }
}

/* ---------- phones (under 601px) ---------- */
@media (max-width: 600px) {
  [style*="margin: 0 auto; padding:"] { padding-left: 20px !important; padding-right: 20px !important; }
  .site-nav { padding: 14px 20px !important; }

  /* Section spacing */
  [style*="padding: 104px 32px"],
  [style*="padding: 112px 32px"],
  [style*="padding: 96px 32px"],
  [style*="padding: 88px 32px"] { padding-top: 60px !important; padding-bottom: 60px !important; }
  [style*="padding: 72px 32px"] { padding-top: 52px !important; padding-bottom: 52px !important; }
  [style*="padding: 48px 32px"] { padding-top: 40px !important; padding-bottom: 40px !important; }

  /* Hero spacing (comes after the rules above on purpose) */
  [style*="padding: 72px 32px 104px"] { padding-top: 36px !important; padding-bottom: 60px !important; }
  [style*="padding: 40px 32px 104px"],
  [style*="padding: 40px 32px 96px"] { padding-top: 24px !important; padding-bottom: 60px !important; }

  /* Tighter gaps between stacked blocks */
  [style*="gap: 64px"], [style*="gap: 56px"], [style*="gap: 48px"] { gap: 32px !important; }
  [style*="margin-top: 64px"], [style*="margin-top: 56px"], [style*="margin-top: 52px"],
  [style*="margin-top: 48px"], [style*="margin-top: 44px"] { margin-top: 32px !important; }

  /* About Jeff: keep the "40+" badge inside the photo, stats two per row. */
  [style*="left: -22px"] { left: 12px !important; bottom: 16px !important; }
  section[aria-label="Jeff at a glance"] > div { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 28px 20px !important; }

  /* Footer call to action: smaller book next to the text. */
  footer img[style*="width: 132px"] { width: 92px !important; }

  /* Bigger tap areas on small inline links (no layout change). */
  nav[aria-label="Breadcrumb"] a,
  [style*="width: 100%; background: #0F1115"] > div[style*="#F2A93B"] a { padding-block: 10px; }
}

/* ---------- narrow phones (under 481px) ---------- */
@media (max-width: 480px) {
  /* Speaking page COMPASS facts: one row each instead of three squeezed columns. */
  [style*="repeat(3, minmax(0, 1fr))"] { grid-template-columns: 1fr !important; gap: 10px !important; }
  [style*="repeat(3, minmax(0, 1fr))"] > div { display: flex; align-items: center; gap: 14px; padding: 14px 16px !important; }
  [style*="repeat(3, minmax(0, 1fr))"] > div > :first-child { flex: none; min-width: 32px; }
  [style*="repeat(3, minmax(0, 1fr))"] > div > div[style*="margin-top: 8px"] { margin-top: 0 !important; }
}

/* ---------- small phones (under 401px) ---------- */
@media (max-width: 400px) {
  h1[style*="clamp(120px"] { font-size: 30vw !important; }
  h2[style*="Anton"] { font-size: clamp(32px, 10.4vw, 42px) !important; }
}

/* ---------- touch screens: no sticky hover states after a tap ---------- */
@media (hover: none) {
  .jhb-btn:hover, .jhb-card:hover, .jhb-pick:hover, .jhb-photo:hover, .jhb-flink:hover { translate: none !important; box-shadow: none; }
  .jhb-btn:hover::before { transform: translateX(-130%); }
  .jhb-card:hover::after { opacity: 0; }
  .jhb-icon:hover { rotate: none !important; }
  .jhb-zoom-wrap:hover .jhb-zoom, .jhb-card:hover .jhb-zoom, .jhb-play:hover { scale: none !important; }
}
