/* Circuits DIY — mobile settings (2026-11-30).
   Every block is switched on by a class on <html> (cdm-…) that the theme adds from
   CircuitsDIY > Theme > Mobile view. Switch one off there and its rules stop applying. */

/* 1. Side-scrolling strips line up with the 16px page edge (no sideways slide). [cdm-strips] */
@media (max-width: 767.98px) {
  .cdm-strips .cd4 .max-w-site .-mx-5 { margin-left: -16px; margin-right: -16px; }
  .cdm-strips .cd4 .max-w-site .-mx-5.px-5 { padding-left: 16px; padding-right: 16px; }
}
@media (max-width: 639.98px) {
  .cdm-strips .cd4 .cd5-popular { margin-left: -16px; margin-right: -16px; padding-left: 16px; padding-right: 16px; }
  .cdm-strips .cd4 .cd5-rail .grid { margin-left: -16px; margin-right: -16px; padding-left: 16px; padding-right: 16px; scroll-padding: 0 16px; }
}

/* 2. Compact post title card on phones. [cdm-postcard] */
@media (max-width: 639.98px) {
  .cdm-postcard .cd4 .hx-crumbs { margin-bottom: 10px; }
  .cdm-postcard .cd4 .cd-pcard { gap: 14px; padding: 14px; border-radius: 14px; }
  .cdm-postcard .cd4 .cd-pcard__title { margin-top: 6px; }
  .cdm-postcard .cd4 .cd-pcard__meta { margin-top: 10px; gap: 4px 10px; font-size: 13px; }
  .cdm-postcard .cd4 .cd-pcard__author > :first-child, .cdm-postcard .cd4 .cd-pcard__author img { width: 26px !important; height: 26px !important; }
  .cdm-postcard .cd4 .cd-pcard__dates { margin-top: 6px; padding-top: 0; border-top: 0; gap: 2px 14px; font-size: 13px; }
  .cdm-postcard .cd4 .cd-pcard__media img { max-height: 220px; }
  .cdm-postcard .cd4 .cd-ptabs { margin-top: 10px; }
}

/* 3. Sidebar under the content: Categories list and tag cloud folded (cdiy-mobile.js adds .cd-fold). [cdm-fold] */
@media (max-width: 1023.98px) {
  .cdm-fold .cd4 .cd-fold--list:not(.cd-fold--open) ul > li:nth-child(n+9) { display: none; }
  .cdm-fold .cd4 .cd-fold--cloud:not(.cd-fold--open) .widget-term-cloud { max-height: 128px; overflow: hidden;
    -webkit-mask-image: linear-gradient(#000 70%, transparent); mask-image: linear-gradient(#000 70%, transparent); }
  .cdm-fold .cd4 .cd-fold__btn { display: flex; align-items: center; justify-content: center; gap: 6px; width: 100%; min-height: 44px; margin-top: 12px;
    border: 1px solid rgb(var(--cd-line)); border-radius: 10px; background: rgb(var(--cd-raised, 255 255 255)); color: var(--cd-primary-ink);
    font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
  .cdm-fold .cd4 .cd-fold__btn:hover { border-color: var(--cd-primary); }
  .cdm-fold .cd4 .cd-fold--open .cd-fold__btn svg { transform: rotate(180deg); }
}

/* 4. Footer in two columns with bigger tap areas. [cdm-footer] */
@media (max-width: 639.98px) {
  .cdm-footer .cd4 .hx-footer > div > .grid { grid-template-columns: 1fr 1fr; gap: 28px 20px; padding-top: 36px; padding-bottom: 28px; }
  .cdm-footer .cd4 .hx-footer .cd-foot__brand { grid-column: 1 / -1; }
  .cdm-footer .cd4 .hx-footer nav[aria-label="Legal"] { grid-column: 1 / -1; }
  .cdm-footer .cd4 .hx-footer nav[aria-label="Legal"] ul { grid-template-columns: 1fr 1fr; column-gap: 20px; }
  .cdm-footer .cd4 .hx-footer nav h2 { margin-bottom: 6px; }
  .cdm-footer .cd4 .hx-footer nav ul { gap: 0; }
  .cdm-footer .cd4 .hx-footer nav ul a { display: block; padding: 10px 0; line-height: 1.4; }
  .cdm-footer .cd4 .hx-footer nav[aria-label="Footer utility"] a { display: inline-block; padding: 10px 0; }
  .cdm-footer .cd4 .hx-footer .cd-foot__social a { min-width: 44px; min-height: 44px; }
}

/* 5. Tables keep words whole (wide tables scroll sideways in their box). [cdm-tables] */
.cdm-tables .cd4 .bh-block-table th, .cdm-tables .cd4 .bh-block-table td,
.cdm-tables .cd4 .cd-prose table th, .cdm-tables .cd4 .cd-prose table td { overflow-wrap: break-word; word-break: normal; }

/* 6. Long category / tag intro: 3 lines and "Read more" (markup from archive.php, CSS only). [cdm-readmore] */
.cd4 .cd-more-cb { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.cd4 .cd-more { display: none; }
@media (max-width: 1023.98px) {
  .cdm-readmore .cd4 .cd-more-cb:not(:checked) + .cd-clamp { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; }
  .cdm-readmore .cd4 .cd-more { display: inline-flex; align-items: center; min-height: 40px; margin-top: 2px; color: var(--cd-primary-ink); font-size: 14px; font-weight: 600; cursor: pointer; user-select: none; }
  .cdm-readmore .cd4 .cd-more-cb:checked ~ .cd-more .cd-more__open, .cdm-readmore .cd4 .cd-more-cb:not(:checked) ~ .cd-more .cd-more__close { display: none; }
  .cdm-readmore .cd4 .cd-more-cb:focus-visible ~ .cd-more { outline: 2px solid var(--cd-primary); outline-offset: 2px; border-radius: 4px; }
}

/* 7. Bigger tap areas for small links (the extra space is invisible, the layout does not move). [cdm-tap] */
@media (max-width: 639.98px) {
  .cdm-tap .cd4 .hx-crumbs a { padding-top: 10px; padding-bottom: 10px; margin-top: -10px; margin-bottom: -10px; }
  .cdm-tap .cd4 .hx-card__foot > a { padding-top: 10px; padding-bottom: 10px; margin-top: -10px; margin-bottom: -10px; }
  .cdm-tap .cd4 .cd5-chip, .cdm-tap .cd4 .hx-chip { min-height: 36px; }
  .cdm-tap .cd4 .dh-person h4 a { padding-top: 10px; padding-bottom: 10px; }
  .cdm-tap .cd4 .dh-apply { padding-top: 10px; padding-bottom: 10px; margin-top: -10px; margin-bottom: -10px; }
}

/* 8. Soft fade on the right edge of side-scrolling rows (cdiy-mobile.js adds .cd-fade). [cdm-fade] */
@media (max-width: 1023.98px) {
  .cdm-fade .cd4 .cd-fade:not(.cd-fade--end) { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 36px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 36px), transparent); }
}

/* 13. Logo in the centre of the header on phones and tablets. [cdm-logo] */
@media (max-width: 1023.98px) {
  .cdm-logo .cd4 .hx-header > .max-w-site { position: relative; }
  .cdm-logo .cd4 .hx-header > .max-w-site > .mr-auto { position: absolute; left: 50%; top: 50%; margin: 0; transform: translate(-50%, -50%); }
  .cdm-logo .cd4 .hx-header .hx-hright { margin-left: auto; }
}

/* 14. One search icon per search box (all screens). [cdm-oneicon] */
.cdm-oneicon .cd4 .cd5-search .cd5-search__icon { display: none; }
.cdm-oneicon .cd4 .cd5-search .cd5-search__input { padding-left: 14px; }

/* 15. Nothing makes a page wider than the phone (iPhone ignores max-width on centred "table" image boxes). [cdm-fit] */
@media (max-width: 1023.98px) {
  .cdm-fit .cd4 .cd-prose figure[style*="width"] { display: block !important; max-width: 100% !important; box-sizing: border-box; }
  html.cdm-fit, html.cdm-fit body { overflow-x: clip; }
}

/* 16. Home page on phones: no hero block (the headline stays in the page for search engines, just not shown). [cdm-hero] */
@media (max-width: 767.98px) {
  .cdm-hero body.is-home .cd5-hero__text, .cdm-hero body.is-home .cd5-stats, .cdm-hero body.is-home .cd5-hero__find { display: none; }
  .cdm-hero body.is-home .cd5-hero__title { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0; }
  .cdm-hero body.is-home .cd5-hero, .cdm-hero body.is-home .cd5-hero__in { padding-top: 0; padding-bottom: 0; min-height: 0; }
}

/* 17. Search icon opens a full-screen search under the header; the page behind cannot scroll. [cdm-search] */
@media (max-width: 1279.98px) {
  .cdm-search .cd4 .hx-hsearch { height: calc(100dvh - var(--cd-header-h, 64px)); padding: 14px 12px 0; overflow-y: auto; overscroll-behavior: contain; background: rgb(var(--cd-bg)); pointer-events: auto; }
  .cdm-search .cd4 .hx-hsearch .cd5-search { box-shadow: none; }
  html.cdm-search:has(#hx-msearch:not([hidden])), html.cdm-search:has(#hx-msearch:not([hidden])) body { overflow: hidden; }
}

/* 18. No breadcrumb row on phones (Google still reads the breadcrumb from the page data). [cdm-nocrumbs] */
@media (max-width: 767.98px) {
  .cdm-nocrumbs .cd4 .hx-crumbs { display: none; }
}

/* 19. No "jump to section" buttons under the post title card on phones. [cdm-notabs] */
@media (max-width: 767.98px) {
  .cdm-notabs .cd4 .cd-ptabs { display: none; }
}

/* 20. Smaller gaps between home page sections. [cdm-gaps] */
.cdm-gaps body.is-home .cd5-sec { padding-top: 8px; padding-bottom: 2px; }
@media (max-width: 639.98px) {
  .cdm-gaps body.is-home .cd5-rail .grid { padding-bottom: 6px; }
}
@media (min-width: 768px) {
  .cdm-gaps body.is-home .cd5-sec { padding-top: 18px; padding-bottom: 12px; }
}

/* 21. No icons in front of the home page section headings. [cdm-noicons] */
.cdm-noicons body.is-home .cd5-head__icon { display: none; }

/* 22. "Featured" badge on cards: a plain gold star instead of the yellow lightning circle. [cdm-featbadge] */
.cdm-featbadge .cd5-feat { width: auto; height: auto; padding: 0; display: block; border: 0; border-radius: 0; background: none; box-shadow: none; }
.cdm-featbadge .cd5-feat svg { display: none; }
.cdm-featbadge .cd5-feat::before { content: "\2605"; display: block; color: #fbbf24; font-size: 26px; line-height: 1; text-shadow: 0 1px 2px rgba(0, 0, 0, .55), 0 0 6px rgba(0, 0, 0, .25); }
/* 23. Category rows on the home page: the project count as a small number badge next to the heading (all screens). [cdm-shelfcount] */
.cdm-shelfcount body.is-home .cd5-shelf .cd5-head__title { display: inline; }
.cdm-shelfcount body.is-home .cd5-shelf .cd5-head__sub { display: inline-flex; align-items: center; height: 26px; margin: 0 0 0 10px; vertical-align: 3px; padding: 0 10px; border-radius: 999px;
  background: var(--cd-primary); color: #fff; font-size: 14px; font-weight: 700; letter-spacing: .01em; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ===== Theme audit fixes (2026-11-30) ===== */
/* 24. Ad boxes Google left empty (data-ad-status="unfilled", Google's documented attribute) are not shown as blank cards. Filled ads are untouched. */
.cdm-adfill .cd-widget:has(ins.adsbygoogle[data-ad-status="unfilled"]):not(:has(ins.adsbygoogle[data-ad-status="filled"])) { display: none; }
/* 25. Home category rows: the count badge stays on the line with the heading's last word. */
.cdm-badgejoin.cdm-shelfcount body.is-home .cd5-shelf .cd5-head > .min-w-0 { white-space: nowrap; }
.cdm-badgejoin.cdm-shelfcount body.is-home .cd5-shelf .cd5-head__title { white-space: normal; }
/* 26. Bigger invisible tap area on the small "View all" links of the home lists (looks the same). */
@media (max-width: 1023.98px) { .cdm-listtap .cd5-list__more { display: inline-block; padding: 12px 6px; margin: -12px -6px; } }
/* 27. Phones/tablets: "More projects you might like" right after the article, before the sidebars (moved by cdiy-mobile.js). */
@media (max-width: 1023.98px) {
  .cdm-relfirst .cd-related--in { order: 1; grid-area: rel; margin-left: calc(50% - 50vw); margin-right: calc(50% - 50vw); }
  .cdm-relfirst .hx-grid--both:has(> .cd-related--in) { grid-template-areas: "main" "rel" "left" "right"; }
}
/* 30. Card titles as h2 on list pages: same look as before. */
.cd4 .hx-card h2.hx-t-card { font-weight: 600 !important; }
/* 32. Home top block centred (tablet and desktop): headline, intro, a wide search bar in the middle, then the counts. */
@media (min-width: 768px) {
  .cdm-herocenter body.is-home .cd5-hero__in { grid-template-columns: minmax(0, 1fr); justify-items: center; gap: 0; text-align: center; padding-top: 40px; padding-bottom: 32px; }
  .cdm-herocenter body.is-home .cd5-hero__copy { display: contents; }
  .cdm-herocenter body.is-home .cd5-hero__title { order: 1; max-width: 26ch; }
  .cdm-herocenter body.is-home .cd5-hero__text { order: 2; margin: 10px auto 0; max-width: 62ch; }
  .cdm-herocenter body.is-home .cd5-hero__find { order: 3; width: 100%; max-width: 760px; margin-top: 22px; text-align: left; }
  .cdm-herocenter body.is-home .cd5-stats { order: 4; justify-content: center; margin-top: 14px; }
}
/* 33. Home headline on one line (tablet and desktop; part of switch 32). */
@media (min-width: 768px) {
  .cdm-herocenter body.is-home .cd5-hero__title { max-width: none; }
}
@media (min-width: 1024px) {
  .cdm-herocenter body.is-home .cd5-hero__title { white-space: nowrap; }
}
/* 34. Search boxes: the blue button sits as far from the right edge as from the top and bottom. */
.cdm-searchpad .cd5-search .cd5-search__btn { margin-right: 4px; }
.cdm-searchpad .hx-isearch .cd5-search__btn, .cdm-searchpad .hx-hsearch__form .cd5-search__btn { margin-right: 3px; }
/* 35. Home counts: bigger numbers in a row, more of them (reads, authors, founded). */
.cdm-herostats body.is-home .cd5-stats { gap: 0; margin-top: 24px; padding: 0; }
.cdm-herostats body.is-home .cd5-stats li { flex-direction: column; align-items: center; gap: 3px; padding: 2px 22px; color: rgb(var(--cd-muted)); font-size: .74rem; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; white-space: nowrap; }
.cdm-herostats body.is-home .cd5-stats li + li { border-left: 1px solid rgb(var(--cd-line-2)); }
.cdm-herostats body.is-home .cd5-stats li + li::before { display: none; }
.cdm-herostats body.is-home .cd5-stats b { color: var(--cd-primary-ink, var(--cd-primary)); font-size: 1.55rem; font-weight: 800; line-height: 1.1; letter-spacing: -.02em; text-transform: none; }
@media (min-width: 768px) {
  .cdm-herostats.cdm-herocenter body.is-home .cd5-stats { justify-content: center; }
}
@media (min-width: 768px) and (max-width: 1023.98px) {
  .cdm-herostats body.is-home .cd5-stats { display: grid; grid-template-columns: repeat(3, auto); row-gap: 14px; justify-content: center; }
  .cdm-herostats body.is-home .cd5-stats li:nth-child(3n+1) { border-left: 0; }
}
