/* HoofRehab mobile Phase 3: scoped table and fixed-layout repairs. */
@media only screen and (max-width: 844px) {
    /* Six related book/DVD pages use one fixed table solely as a page frame. */
    table.mobile-phase3-page-layout {
        width: 100% !important;
        max-width: 100%;
        height: auto !important;
        table-layout: auto;
        box-sizing: border-box;
    }

    table.mobile-phase3-page-layout > tbody > tr > td {
        width: auto !important;
        max-width: 100%;
        box-sizing: border-box;
    }

    table.mobile-phase3-page-layout p {
        width: auto !important;
        max-width: 100%;
    }

    /* Preserve the nutrient table's columns and expose them by local scrolling. */
    .mobile-phase3-data-table {
        display: block;
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
        box-sizing: border-box;
        -webkit-overflow-scrolling: touch;
    }

    /* Screenshot groups keep their order while fitting phone and tablet widths. */
    table.mobile-phase3-gallery {
        width: 100% !important;
        max-width: 100%;
        table-layout: fixed;
        box-sizing: border-box;
    }

    table.mobile-phase3-gallery td {
        width: auto !important;
        max-width: 100%;
        box-sizing: border-box;
    }

    table.mobile-phase3-gallery img {
        max-width: 100% !important;
        height: auto !important;
    }

    /* The responsive grid is narrower than this page's inherited inline box. */
    .mobile-phase3-workshop-content {
        width: 100% !important;
        max-width: 100%;
        box-sizing: border-box;
    }

    section.content .row:has(.mobile-phase3-workshop-content) .grid_4 img {
        max-width: 100% !important;
        height: auto !important;
    }

    /* The rehab master tables are layout frames; nested case tables remain tables. */
    table.mobile-phase3-rehab-layout {
        width: 100% !important;
        max-width: 100%;
        height: auto !important;
        table-layout: fixed;
        box-sizing: border-box;
    }

    table.mobile-phase3-rehab-layout > tbody > tr > td {
        max-width: 100%;
        box-sizing: border-box;
    }

    table.mobile-phase3-rehab-layout table {
        width: 100% !important;
        max-width: 100%;
        table-layout: fixed;
        box-sizing: border-box;
    }

    table.mobile-phase3-rehab-layout table td {
        width: auto !important;
        max-width: 100%;
        box-sizing: border-box;
    }

    table.mobile-phase3-rehab-layout img:not([usemap]):not([onmouseover]):not([onmouseout]):not([onmousedown]):not([onmouseup]):not([fp-style]):not([fp-title]):not([src*="button" i]) {
        max-width: 100% !important;
        height: auto !important;
    }

    /* The archived Blogger copy has two independent fixed-width wrappers. */
    #outer-wrapper.mobile-phase3-pollitt-layout {
        width: 100% !important;
        max-width: 100%;
        box-sizing: border-box;
    }

    #outer-wrapper.mobile-phase3-pollitt-layout #main-wrapper {
        width: 100% !important;
        max-width: 100%;
        height: auto !important;
        float: none !important;
        overflow: visible !important;
        box-sizing: border-box;
    }

    /* Stack only the direct columns of the two rehab page frames. */
    table.mobile-phase3-rehab-layout,
    table.mobile-phase3-rehab-layout > tbody,
    table.mobile-phase3-rehab-layout > tbody > tr,
    table.mobile-phase3-rehab-layout > tbody > tr > td {
        display: block;
        width: 100% !important;
        max-width: 100%;
        height: auto !important;
    }
}

/* Final visual pass for the three preserved teaching pages. */
.ebook-content,
.pollitt-article-content { color: #69190f; font-family: Arial, Helvetica, sans-serif; }
.ebook-content > div,
.ebook-content div[style*="height:"],
.ebook-content p[style*="height:"] { height: auto !important; }
.ebook-content br + br { display: none; }
.ebook-content p.MsoNormal { margin: 0 0 18px; font-family: Arial, Helvetica, sans-serif; }
.ebook-content p.MsoNormal:has(a[name]),
.ebook-content div:has(> strong > span > a[name]) {
    margin: 40px 0 20px; padding-top: 18px; border-top: 2px solid #aaa55a;
    color: #69190f; font: 700 25px/1.25 Arial, Helvetica, sans-serif !important;
}
.ebook-content p.MsoNormal:has(> img),
.ebook-content table.mobile-phase3-gallery {
    margin: 12px 0 28px; padding: 18px; background: #f7f3e8;
    border: 1px solid #ddd5c4; text-align: center;
}
.ebook-content table.mobile-phase3-gallery { border-spacing: 10px; }

.rehab-history-content { max-width: 960px; }
.rehab-history-content table.mobile-phase3-rehab-layout,
.rehab-history-content table.mobile-phase3-rehab-layout > tbody,
.rehab-history-content table.mobile-phase3-rehab-layout > tbody > tr,
.rehab-history-content table.mobile-phase3-rehab-layout > tbody > tr > td {
    display: block; width: 100% !important; max-width: 100%; height: auto !important;
    box-sizing: border-box;
}
.rehab-history-content table.mobile-phase3-rehab-layout > tbody > tr > td:empty,
.rehab-history-content table.mobile-phase3-rehab-layout > tbody > tr > td[height]:not(:has(img, table, a)) { display: none; }
.rehab-history-content table.rehab-mobile-comparison,
.rehab-history-content table.rehab-complex-sequence {
    margin: 26px auto !important; padding: 12px; border: 1px solid #c9c2b3 !important;
    background: #f7f3e8; border-spacing: 8px;
}
.rehab-history-content table.rehab-mobile-comparison td,
.rehab-history-content table.rehab-complex-sequence td { border-color: transparent !important; vertical-align: top; }
.rehab-history-content a[href="/"] > img[id="img1"],
.rehab-history-content a[href="/about-us"] > img,
.rehab-history-content a[href="/workshops"] > img,
.rehab-history-content a[href="/articles"] > img { display: none; }
.rehab-history-content a[href*="making_natural_hoof_care_work_fo"] > img { display: none; }
.rehab-history-content a[href*="making_natural_hoof_care_work_fo"]::after {
    content: "Pete's Book"; display: inline-block; margin: 8px 0 22px; padding: 9px 14px;
    background: #807d3d; color: #fff; font: 700 15px/1.2 Arial, Helvetica, sans-serif;
}

.pollitt-article-content { max-width: 820px; }
.pollitt-article-content #outer-wrapper.mobile-phase3-pollitt-layout {
    width: 100% !important; max-width: 100%; margin: 0; padding: 0;
}
.pollitt-article-content .post-title { margin: 0 0 28px; font: 400 34px/1.25 Arial, Helvetica, sans-serif; }
.pollitt-article-content .post-title a { color: #69190f !important; }
.pollitt-article-content .post-body { color: #69190f; font: 17px/1.6 Arial, Helvetica, sans-serif; }
.pollitt-article-content .post-body p { max-width: 68ch; margin: 0 auto 24px; }
.pollitt-article-content .post-body img { margin-top: 22px !important; margin-bottom: 12px !important; }

@media (max-width: 844px) {
    .ebook-content p.MsoNormal:has(a[name]),
    .ebook-content div:has(> strong > span > a[name]) { font-size: 22px !important; }
    .pollitt-article-content .post-title { font-size: 27px; }
}

/* The archived Pollitt/Brumby article also inherited a 1227px desktop wrapper. */
#outer-wrapper.mobile-phase3-pollitt-layout {
    box-sizing: border-box;
    width: 680px !important;
    max-width: calc(100% - 24px);
}

#outer-wrapper.mobile-phase3-pollitt-layout #main-wrapper {
    box-sizing: border-box;
    float: none !important;
    width: 100% !important;
    max-width: 100%;
    height: auto !important;
    overflow: visible !important;
}

#outer-wrapper.mobile-phase3-pollitt-layout #main-wrapper img {
    box-sizing: border-box;
    max-width: 100%;
    height: auto;
}

/* Shared presentation for preserved educational pages that predate the current site shell. */
body.legacy-themed-page {
    background: #fff !important;
    color: #4f4f4f;
}

.legacy-page-shell { padding: 42px 16px 64px; }

.legacy-page-content {
    box-sizing: border-box;
    max-width: 960px;
    margin: 0 auto;
    padding: 32px 38px;
    background: #fff;
    border: 1px solid #e2ddd2;
    box-shadow: 0 2px 12px rgba(69, 58, 42, 0.08);
    font-family: Georgia, "Times New Roman", serif;
    font-size: 17px;
    line-height: 1.6;
}

.legacy-page-content h1,
.legacy-page-content h2,
.legacy-page-content h3 {
    color: #807d3d;
    font-family: Georgia, "Times New Roman", serif;
    line-height: 1.25;
}

.legacy-page-content a { overflow-wrap: anywhere; }

.ebook-content > div { height: auto !important; }

.ebook-content > .auto-style1:first-child {
    height: auto !important;
    margin-bottom: 28px;
    padding-bottom: 18px;
    border-bottom: 1px solid #d7cfbd;
}

.ebook-content > .auto-style1:first-child > p:first-child {
    margin-bottom: 20px;
    color: #807d3d;
    font-size: 32px;
    font-weight: 700;
    line-height: 1.25;
}

.ebook-content p.MsoNormal,
.ebook-content .auto-style3 {
    height: auto !important;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 17px;
    line-height: 1.6;
}

.ebook-content img { max-width: 100%; height: auto; }

.ebook-content table.mobile-phase3-gallery {
    width: 100% !important;
    max-width: 100%;
    table-layout: fixed;
}

.ebook-content table.mobile-phase3-gallery td {
    box-sizing: border-box;
    width: auto !important;
    padding: 8px;
    text-align: center;
    vertical-align: middle;
}

.rehab-history-content { max-width: 1040px; }

.rehab-history-content > p:first-child { display: none; }

.rehab-history-content > div[align="center"] > table.mobile-phase3-rehab-layout {
    width: 100% !important;
    max-width: 920px;
    height: auto !important;
    margin: 0 auto;
}

.rehab-history-content table img:not([id^="img"]) {
    max-width: 100%;
    height: auto;
}

@media (max-width: 844px) {
    .legacy-page-shell { padding: 22px 8px 44px; }
    .legacy-page-content { padding: 22px 14px; font-size: 16px; }
    .ebook-content > .auto-style1:first-child > p:first-child { font-size: 26px; }
}

@media (max-width: 600px) {
    .ebook-content table.mobile-phase3-gallery,
    .ebook-content table.mobile-phase3-gallery tbody,
    .ebook-content table.mobile-phase3-gallery tr,
    .ebook-content table.mobile-phase3-gallery td {
        display: block;
        width: 100% !important;
    }
    .ebook-content table.mobile-phase3-gallery td { padding: 10px 0; }
    .ebook-content table.mobile-phase3-gallery img {
        width: auto !important;
        max-width: 100%;
    }
}

@media (max-width: 480px) {
    .rehab-history-content table.rehab-mobile-comparison,
    .rehab-history-content table.rehab-mobile-comparison > tbody {
        display: block;
        width: 100% !important;
        max-width: 100%;
    }
    .rehab-history-content table.rehab-mobile-comparison > tbody {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas: "image-one" "caption-one" "image-two" "caption-two" "details";
        gap: 0.5rem;
    }
    .rehab-history-content table.rehab-mobile-comparison > tbody > tr { display: contents; }
    .rehab-history-content table.rehab-mobile-comparison > tbody > tr:first-child > td:first-child { grid-area: image-one; }
    .rehab-history-content table.rehab-mobile-comparison > tbody > tr:first-child > td:last-child { grid-area: image-two; }
    .rehab-history-content table.rehab-mobile-comparison > tbody > tr:nth-child(2) > td:first-child { grid-area: caption-one; }
    .rehab-history-content table.rehab-mobile-comparison > tbody > tr:nth-child(2) > td:last-child { grid-area: caption-two; }
    .rehab-history-content table.rehab-mobile-comparison > tbody > tr:nth-child(-n+2) > td:not(:first-child):not(:last-child) { display: none; }
    .rehab-history-content table.rehab-mobile-comparison > tbody > tr:nth-child(n+3) > td { grid-column: 1; }
    .rehab-history-content table.rehab-mobile-comparison td {
        width: 100% !important;
        max-width: 100%;
        box-sizing: border-box;
        text-align: center;
    }
    .rehab-history-content table.rehab-mobile-comparison img {
        float: none !important;
        display: block;
        width: 100% !important;
        max-width: 20rem !important;
        height: auto !important;
        margin: 0 auto;
        object-fit: contain;
    }
    .rehab-history-content table.rehab-mobile-comparison td,
    .rehab-history-content table.rehab-mobile-comparison td[height],
    .rehab-history-content table.rehab-mobile-comparison p {
        height: auto !important;
        min-height: 0;
    }
}

@media (max-width: 767px) {
    .rehab-history-content table.rehab-complex-sequence,
    .rehab-history-content table.rehab-complex-sequence > tbody {
        display: block;
        width: 100% !important;
        max-width: 100%;
        height: auto !important;
    }
    .rehab-history-content table.rehab-complex-sequence > tbody {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        gap: 0.5rem;
    }
    .rehab-history-content table.rehab-complex-sequence > tbody > tr { display: contents; }
    .rehab-history-content table.rehab-complex-sequence > tbody > tr:first-child > td:first-child { grid-area: image-one; }
    .rehab-history-content table.rehab-complex-sequence > tbody > tr:first-child > td:last-child { grid-area: image-two; }
    .rehab-history-content table.rehab-complex-sequence > tbody > tr:nth-child(2) > td:first-child { grid-area: caption-one; }
    .rehab-history-content table.rehab-complex-sequence > tbody > tr:nth-child(2) > td:last-child { grid-area: caption-two; }
    .rehab-history-content table.rehab-complex-sequence > tbody > tr:nth-child(-n+2) > td:not(:first-child):not(:last-child) { display: none; }
    .rehab-history-content table.rehab-complex-sequence td {
        width: 100% !important;
        max-width: 100%;
        height: auto !important;
        box-sizing: border-box;
        text-align: center;
    }
    .rehab-history-content table.rehab-complex-sequence img {
        float: none !important;
        display: block;
        width: auto;
        max-width: 100% !important;
        height: auto !important;
        margin: 0 auto;
    }
    .rehab-history-content table.rehab-three-stage > tbody {
        grid-template-areas: "image-one" "caption-one" "image-two" "caption-two" "final-stage";
    }
    .rehab-history-content table.rehab-three-stage > tbody > tr:nth-child(3) > td { grid-area: final-stage; }
    .rehab-history-content table.rehab-four-image-sequence > tbody {
        grid-template-areas: "image-one" "caption-one" "image-two" "caption-two" "details" "image-three" "image-four";
    }
    .rehab-history-content table.rehab-four-image-sequence > tbody > tr:nth-child(3) > td { grid-area: details; }
    .rehab-history-content table.rehab-four-image-sequence > tbody > tr:nth-child(4) > td:first-child { grid-area: image-three; }
    .rehab-history-content table.rehab-four-image-sequence > tbody > tr:nth-child(4) > td:last-child { grid-area: image-four; }
}

/* These final overrides intentionally follow the inherited legacy rules. */
.ebook-content,
.ebook-content p.MsoNormal,
.ebook-content .auto-style3,
.ebook-content > .auto-style1:first-child > p:first-child {
    font-family: Arial, Helvetica, sans-serif;
}
.rehab-history-content td[height] { height: auto !important; }
.rehab-history-content td[height]:not(:has(img, table, a, strong, span:not(:empty))) {
    display: none;
}

/* The archived page carried FrontPage font tags, spacer paragraphs and button art.
   Keep its teaching content and destinations, but use the current site's reading flow. */
.rehab-history-content,
.rehab-history-content font {
    color: #69190f !important;
    font-family: Arial, Helvetica, sans-serif !important;
    font-size: 17px !important;
    line-height: 1.55 !important;
}
.rehab-history-content .rehab-history-page-title {
    display: block;
    margin: 0 0 20px;
    color: #69190f !important;
    font: 400 34px/1.2 Arial, Helvetica, sans-serif !important;
    text-align: left;
}
.rehab-history-content .rehab-history-page-title .style2 {
    color: inherit !important;
    font: inherit !important;
}
.rehab-history-content .rehab-history-title-rule { display: none; }
.rehab-history-content .rehab-history-intro-copy {
    display: block;
    max-width: 68ch;
    margin: 0 0 28px;
    color: #69190f !important;
    font: 17px/1.6 Arial, Helvetica, sans-serif !important;
}
.rehab-history-content .rehab-history-related {
    margin: 0 0 28px;
    text-align: left;
}
.rehab-history-content .rehab-history-related a {
    display: inline-block;
    padding: 9px 14px;
    background: #807d3d;
    color: #fff;
    font: 700 15px/1.2 Arial, Helvetica, sans-serif;
    text-decoration: none;
}
.rehab-history-content .rehab-history-related a:hover { background: #6f6c35; }
.rehab-history-content .rehab-history-related a::after { content: none; display: none; }
.rehab-history-content .rehab-history-related a:focus-visible { outline: 2px solid #69190f; outline-offset: 3px; }
.rehab-history-content .rehab-history-legacy-links {
    height: auto !important;
    margin: 0 0 28px !important;
    padding: 0;
    font-size: 0 !important;
    line-height: 0 !important;
    text-align: left !important;
}
.rehab-history-content .rehab-history-legacy-links a { display: none; }
.rehab-history-content .rehab-history-legacy-links a[href*="making_natural_hoof_care_work_fo"] {
    display: inline-block;
    font-size: 0;
    line-height: 1;
}
.rehab-history-content .rehab-history-legacy-links-secondary,
.rehab-history-content .rehab-history-legacy-links-secondary + p,
.rehab-history-content .rehab-history-legacy-links-secondary + p + p { display: none; }
.rehab-history-content .rehab-history-primary > div:first-of-type,
.rehab-history-content .rehab-history-primary > table:first-of-type { margin-top: 0 !important; }

@media (max-width: 600px) {
    .rehab-history-content .rehab-history-page-title { font-size: 30px !important; }
    .rehab-history-content,
    .rehab-history-content font,
    .rehab-history-content .rehab-history-intro-copy { font-size: 16px !important; }
}
