/*
Theme Name: Thichthucung WikiAnswerly Child
Template: thichthucung-wikianswerly
Description: Safe customization layer for the Thichthucung editorial theme.
Version: 1.0.0
Text Domain: thichthucung-wikianswerly-child
*/

/* Add site-specific visual overrides here. Parent styles remain untouched. */

/*
 * Mobile article hardening.
 *
 * Posts are often opened inside Telegram's in-app browser, where the available
 * width can be as small as 320px. Keep long editorial content inside the
 * viewport even when an editor, embed or third-party widget supplies a fixed
 * width of its own.
 */
.entry-content,
.entry-content > *,
.entry-header,
.entry-featured {
    min-width: 0;
    max-width: 100%;
}

.entry-content img,
.entry-content video,
.entry-content audio,
.entry-content canvas,
.entry-content svg {
    max-width: 100%;
    height: auto;
}

.entry-content figure {
    max-width: 100%;
    margin-inline: 0;
}

.entry-content figcaption {
    color: var(--muted);
    font-size: .875em;
    line-height: 1.45;
}

.entry-content table {
    display: block;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-collapse: collapse;
}

.entry-content th,
.entry-content td {
    min-width: 7rem;
    padding: .65rem .75rem;
    white-space: normal;
}

.entry-content pre,
.entry-content code {
    max-width: 100%;
}

.entry-content pre {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 1rem;
    border-radius: .6rem;
    background: var(--wash);
    font-size: .875em;
    line-height: 1.55;
    white-space: pre;
}

.entry-content :where(iframe, embed, object) {
    display: block;
    width: 100%;
    max-width: 100%;
    border: 0;
}

.entry-content .wp-block-embed__wrapper {
    position: relative;
    max-width: 100%;
    overflow: hidden;
    aspect-ratio: 16 / 9;
}

.entry-content .wp-block-embed__wrapper iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

/* Some in-app browsers expose a tablet-like CSS viewport (~980px) on phones.
 * Collapse the article before the two-column layout can overflow that viewport. */
@media (max-width: 1100px) {
    /* Telegram and some Android WebViews report a desktop-like width around
     * 980px. Use the compact header there as well, otherwise the full menu
     * plus the search field is wider than the actual phone viewport. */
    .menu-toggle {
        display: inline-flex;
        align-items: center;
        gap: 7px;
        margin-left: auto;
    }

    .primary-nav {
        display: none;
        position: absolute;
        left: 14px;
        right: 14px;
        top: calc(100% + 1px);
        z-index: 30;
        padding: 10px;
        border: 1px solid var(--line);
        border-radius: 10px;
        background: #fff;
        box-shadow: 0 12px 28px rgba(24, 50, 31, .12);
    }

    .primary-nav.is-open {
        display: block;
    }

    .primary-nav > ul,
    .primary-nav > .menu-main-menu-container > ul {
        display: block;
    }

    .primary-nav > ul > li,
    .primary-nav > .menu-main-menu-container > ul > li {
        border-bottom: 1px solid var(--line);
    }

    .primary-nav > ul > li:last-child,
    .primary-nav > .menu-main-menu-container > ul > li:last-child {
        border-bottom: 0;
    }

    .primary-nav > ul > li > a,
    .primary-nav > .menu-main-menu-container > ul > li > a {
        display: block;
        padding: 10px 8px;
    }

    .primary-nav .sub-menu,
    .primary-nav ul ul {
        position: static;
        display: block;
        min-width: 0;
        padding: 0 0 7px 14px;
        border: 0;
        border-radius: 0;
        box-shadow: none;
    }

    .primary-nav .sub-menu::before {
        display: none;
    }

    .primary-nav .sub-menu a {
        padding: 7px 8px;
        white-space: normal;
    }

    .header-search {
        flex: 0 0 42px;
        width: 42px;
        margin-left: 0;
        background: transparent;
        border: 0;
    }

    .header-search input {
        display: none;
    }

    .header-search button {
        width: 42px;
        height: 42px;
        padding: 0;
    }

    .entry-layout {
        grid-template-columns: minmax(0, 1fr);
        gap: 24px;
    }

    .entry-layout > article {
        min-width: 0;
        width: 100%;
    }

    .entry-toc {
        position: static;
        order: 0;
    }
}

@media (max-width: 900px) {
    .header-inner {
        min-width: 0;
    }

    .site-brand {
        min-width: 0;
        overflow: hidden;
    }

    .site-brand .custom-logo {
        max-width: min(220px, 42vw);
    }

    .entry-layout {
        gap: 24px;
    }

    .entry-toc {
        order: 0;
        padding: 14px 16px;
        border: 1px solid var(--line);
        border-top: 3px solid var(--accent);
        border-radius: 10px;
        background: var(--wash);
    }
}

@media (max-width: 600px) {
    .container {
        width: min(var(--max), calc(100% - 28px));
    }

    .header-inner {
        gap: 8px;
    }

    .site-brand {
        flex: 1 1 auto;
        font-size: 16px;
    }

    .site-brand .custom-logo {
        max-width: 38vw;
        max-height: 38px;
    }

    .menu-toggle {
        flex: 0 0 auto;
        padding: 8px;
        font-size: 12px;
    }

    .header-search {
        flex: 0 0 42px;
        margin-left: 0;
    }

    .entry-wrap {
        padding: 30px 0 42px;
    }

    .breadcrumbs {
        margin-bottom: 12px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .entry-header h1 {
        margin-top: 6px;
        font-size: clamp(30px, 9vw, 40px);
        line-height: 1.1;
        letter-spacing: -.035em;
        overflow-wrap: anywhere;
    }

    .entry-summary {
        margin: 0 0 18px;
        font-size: 16px;
    }

    .entry-featured {
        margin: 20px 0;
        border-radius: 10px;
    }

    .entry-content {
        font-size: 16px;
        line-height: 1.7;
        overflow-wrap: anywhere;
    }

    .entry-content h2 {
        font-size: 26px;
    }

    .entry-content h3 {
        font-size: 21px;
    }

    .entry-content blockquote {
        margin-inline: 0;
        padding-inline: 16px;
    }

    .entry-content .alignwide,
    .entry-content .alignfull {
        width: auto;
        max-width: 100%;
        margin-inline: 0;
    }

    .entry-content a {
        overflow-wrap: anywhere;
    }

    .entry-toc strong {
        font-size: 18px;
    }
}

/* The article's health table has legacy inline rules that force a 620px
 * caption and 180px cells. Turn it into readable stacked cards on phones. */
@media (max-width: 700px) {
    .entry-content .wa-vet-table {
        display: block;
        width: 100% !important;
        max-width: 100% !important;
        overflow: visible;
        border: 0;
        border-radius: 0;
        background: transparent;
        box-shadow: none;
    }

    .entry-content .wa-vet-table caption {
        display: block;
        min-width: 0 !important;
        width: 100% !important;
        margin-bottom: 10px;
        padding: 12px 14px;
        border: 1px solid #bfd3e8;
        border-radius: 10px;
        font-size: 15px;
    }

    .entry-content .wa-vet-table thead {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
    }

    .entry-content .wa-vet-table tbody,
    .entry-content .wa-vet-table tr,
    .entry-content .wa-vet-table td {
        display: block;
        width: 100% !important;
        min-width: 0 !important;
    }

    .entry-content .wa-vet-table tr {
        margin: 0 0 12px;
        border: 1px solid #bfd3e8;
        border-radius: 10px;
        overflow: hidden;
        background: #fff;
    }

    .entry-content .wa-vet-table td {
        padding: 10px 14px 10px 14px;
        border: 0;
        border-bottom: 1px solid #d9e7f3;
        overflow-wrap: anywhere;
    }

    .entry-content .wa-vet-table td:last-child {
        border-bottom: 0;
    }

    .entry-content .wa-vet-table td::before {
        display: block;
        margin-bottom: 3px;
        color: #174a73;
        font-size: 12px;
        font-weight: 800;
        letter-spacing: .02em;
        text-transform: uppercase;
    }

    .entry-content .wa-vet-table td:nth-child(1)::before {
        content: "Tình trạng sức khỏe";
    }

    .entry-content .wa-vet-table td:nth-child(2)::before {
        content: "Đặc điểm phân và hành vi";
    }

    .entry-content .wa-vet-table td:nth-child(3)::before {
        content: "Hành động chăm sóc";
    }
}

/* Global overflow guard for in-app browsers (Telegram etc.): third-party
 * widgets (AdSense auto ads, Social Warfare, star ratings) inject fixed-width
 * elements that would otherwise widen the page and push content off screen. */
html,
body,
.site-shell,
.site-shell > main {
    max-width: 100%;
    overflow-x: clip;
}

.entry-content ins.adsbygoogle,
.entry-content .swp_social_panel,
.entry-content .kk-star-ratings,
.entry-layout .kk-star-ratings {
    max-width: 100% !important;
    box-sizing: border-box;
}

.entry-layout .kk-star-ratings {
    flex-wrap: wrap;
}

.entry-layout .swp_social_panel {
    display: flex;
    flex-wrap: wrap;
}

/* Wide legacy table: also stack it up to 1100px (Telegram can report ~980px). */
@media (min-width: 701px) and (max-width: 1100px) {
    .entry-content .wa-vet-table {
        display: block;
        max-width: 100%;
        overflow-x: auto;
    }
}

/* Larger, more readable type on phones. */
@media (max-width: 600px) {
    body {
        font-size: 17px;
        -webkit-text-size-adjust: 100%;
        text-size-adjust: 100%;
    }

    .entry-content {
        font-size: 18px;
        line-height: 1.75;
    }

    .entry-content h2 {
        font-size: 28px;
    }

    .entry-content h3 {
        font-size: 23px;
    }

    .entry-summary {
        font-size: 18px;
    }

    .entry-content .wa-vet-table,
    .entry-content .wa-vet-table caption {
        font-size: 17px;
    }

    .entry-content .wa-vet-table td::before {
        font-size: 13px;
    }

    .entry-meta,
    .post-meta,
    .breadcrumbs {
        font-size: 14px;
    }

    .entry-toc ol,
    .sitehbf-toc {
        font-size: 16px;
    }

    .post-card h3 {
        font-size: 22px;
    }

    .post-card p,
    .sidebar-box li,
    .section-head p {
        font-size: 16px;
    }

    .primary-nav a {
        font-size: 16px;
    }

    .site-footer,
    .site-footer a {
        font-size: 15px;
    }
}

/*
 * Brand palette synced with the logo: orange -> red -> crimson -> purple heart.
 * Parent theme variables are overridden here so the parent stays untouched.
 */
:root {
  --ink: #2a1b3d;
  --muted: #655a73;
  --line: #f0e2da;
  --wash: #fff6f0;
  --accent: #e8590c;
  --accent-dark: #c2410c;
  --accent-soft: #fde4d3;
  --brand-orange: #f26b21;
  --brand-red: #e8302a;
  --brand-crimson: #b0344f;
  --brand-purple: #5b3e96;
  --brand-night: #2a1740;
  --brand-gradient: linear-gradient(100deg, #f26b21 0%, #e8302a 38%, #b0344f 68%, #5b3e96 100%);
}
::selection { background: var(--brand-orange); color: #fff; }
a { color: var(--accent-dark); }
a:hover { color: var(--brand-purple); }
:focus-visible { outline: 3px solid var(--brand-orange); outline-offset: 2px; }

/* Header: logo-gradient rule under the sticky bar */
.site-header { border-bottom: 0; box-shadow: 0 1px 0 var(--line), 0 6px 20px rgba(91, 62, 150, .07); }
.site-header::after { content: ""; display: block; height: 4px; background: var(--brand-gradient); }
.primary-nav a { color: var(--ink); }
.primary-nav > ul > li > a, .primary-nav > .menu-main-menu-container > ul > li > a { padding: 6px 0; border-bottom: 2px solid transparent; }
.primary-nav > ul > li > a:hover, .primary-nav > ul > li.current-menu-item > a, .primary-nav > ul > li.current-menu-ancestor > a,
.primary-nav > .menu-main-menu-container > ul > li > a:hover, .primary-nav > .menu-main-menu-container > ul > li.current-menu-item > a { color: var(--accent-dark); border-bottom-color: var(--brand-orange); }
.primary-nav .sub-menu, .primary-nav ul ul { border-color: #f1d8c8; border-top: 3px solid var(--brand-orange); box-shadow: 0 14px 30px rgba(91, 62, 150, .14); }
.primary-nav .sub-menu::before { display: none; }
.primary-nav .sub-menu a:hover, .primary-nav .sub-menu a:focus, .primary-nav ul ul a:hover, .primary-nav ul ul a:focus { background: var(--accent-soft); color: var(--accent-dark); }
.header-search { border-color: #f1d8c8; background: var(--wash); }
.header-search:focus-within { border-color: var(--brand-orange); box-shadow: 0 0 0 3px rgba(242, 107, 33, .18); }
.header-search button { color: var(--brand-orange); }
.menu-toggle { border-color: var(--brand-orange); color: var(--accent-dark); font-weight: 700; }

/* Hero */
.hero { background: radial-gradient(circle at 85% 0%, rgba(242, 107, 33, .22) 0, transparent 42%), radial-gradient(circle at 5% 100%, rgba(91, 62, 150, .14) 0, transparent 45%), var(--wash); border-bottom: 1px solid #f1d8c8; }
.hero h1 { color: var(--brand-night); }
.eyebrow { color: var(--accent-dark); }
.eyebrow::before { content: ""; display: inline-block; width: 22px; height: 4px; margin-right: 8px; vertical-align: middle; border-radius: 3px; background: var(--brand-gradient); }
.hero p { color: var(--muted); }
.hero-search, .hero .header-search { border: 2px solid var(--brand-orange); box-shadow: 0 14px 36px rgba(232, 89, 12, .18); }
.hero-card { border: 1px solid #f6d6c2; border-top: 5px solid var(--brand-orange); box-shadow: 0 20px 50px rgba(176, 52, 79, .12); }
.hero-card li a::after { color: var(--brand-crimson); font-weight: 800; }
.hero-card li a:hover { color: var(--brand-purple); }

/* Buttons and primary actions */
.button, .hero-search button, .hero .header-search button, .no-results > .header-search button { background: var(--brand-gradient); background-size: 140% 100%; color: #fff; font-weight: 800; transition: background-position .25s ease, transform .15s ease, box-shadow .2s ease; }
.button:hover, .hero-search button:hover, .hero .header-search button:hover { background-position: 100% 0; color: #fff; box-shadow: 0 8px 20px rgba(176, 52, 79, .3); }
.button:active { transform: translateY(1px); }

/* Section headings get a short brand rule */
.section h2 { color: var(--brand-night); }
.section-head h2::after { content: ""; display: block; width: 54px; height: 5px; margin-top: 10px; border-radius: 4px; background: var(--brand-gradient); }

/* Category cards */
.category-card { position: relative; overflow: hidden; border: 1px solid #f1d8c8; background: linear-gradient(180deg, #fff 0%, var(--wash) 100%); }
.category-card::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 4px; background: var(--brand-gradient); }
.category-card:hover { border-color: var(--brand-orange); box-shadow: 0 14px 30px rgba(232, 89, 12, .2); }
.category-card:hover h3 { color: var(--accent-dark); }

/* Post cards */
.post-card-image { box-shadow: 0 0 0 1px #f1d8c8; transition: box-shadow .2s ease, transform .2s ease; }
.post-card:hover .post-card-image { box-shadow: 0 0 0 2px var(--brand-orange), 0 12px 26px rgba(232, 89, 12, .2); transform: translateY(-2px); }
.post-card h3 a { color: var(--brand-night); }
.post-card h3 a:hover { color: var(--accent-dark); }
.post-meta a { color: var(--brand-crimson); }
.post-meta a:hover { color: var(--brand-purple); }

/* Sidebar, TOC, quotes */
.sidebar-box, .entry-toc { border-top: 0; padding-top: 0; }
.sidebar-box::before, .entry-toc::before { content: ""; display: block; height: 4px; margin-bottom: 14px; border-radius: 3px; background: var(--brand-gradient); }
.sidebar-box h2, .entry-toc strong { color: var(--brand-night); }
.sidebar-box li a:hover { color: var(--brand-crimson); }
.entry-toc ol a:hover { color: var(--brand-crimson); }
.entry-content blockquote { border-left: 5px solid var(--brand-crimson); background: var(--wash); border-radius: 0 10px 10px 0; padding: 12px 22px; color: var(--ink); }
.entry-content a { text-decoration-color: #f7b88d; text-decoration-thickness: 2px; }
.entry-content a:hover { text-decoration-color: var(--brand-purple); }
.entry-content h2 { color: var(--brand-night); padding-left: 14px; border-left: 6px solid var(--brand-orange); }
.entry-content h3 { color: var(--brand-purple); }
.entry-content th { background: var(--accent-soft); color: var(--brand-night); }
.breadcrumbs a { color: var(--accent-dark); }

/* Archive header */
.archive-header { background: linear-gradient(120deg, var(--wash) 0%, #fdeadf 55%, #efe7f7 100%); border-bottom: 0; position: relative; }
.archive-header::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: var(--brand-gradient); }
.archive-header h1 { color: var(--brand-night); }

/* Pagination */
.pagination .page-numbers { border-color: #f1d8c8; color: var(--accent-dark); font-weight: 700; }
.pagination a.page-numbers:hover { border-color: var(--brand-orange); background: var(--accent-soft); }
.pagination .current { background: var(--brand-gradient); border-color: transparent; color: #fff; }

/* Footer in the logo's deep purple */
.site-footer { position: relative; background: var(--brand-night); color: #e9dff3; }
.site-footer::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 5px; background: var(--brand-gradient); }
.site-footer h2 { color: #fff; }
.site-footer p, .site-footer li { color: #cdbfdc; }
.site-footer a { color: #ffd2b5; }
.site-footer a:hover { color: #fff; text-decoration: underline; }
.footer-bottom { color: #b3a2c6; border-top-color: rgba(255, 255, 255, .15); }

@media (max-width: 900px) {
  .primary-nav { border-color: #f1d8c8; border-top: 3px solid var(--brand-orange); box-shadow: 0 14px 30px rgba(91, 62, 150, .16); }
  .primary-nav > ul > li > a, .primary-nav > .menu-main-menu-container > ul > li > a { border-bottom: 0; }
}
@media (max-width: 600px) {
  .hero-search input, .hero-search button, .hero .header-search input, .hero .header-search button { border: 2px solid var(--brand-orange); }
  .hero-search button, .hero .header-search button { border-color: transparent; }
}

/* Table of contents: no numbering, brand-colored bullets instead. */
.entry-toc ol { list-style: none; padding-left: 0; }
.entry-toc li { position: relative; margin: 0 0 8px; padding-left: 16px; }
.entry-toc li::before { content: ""; position: absolute; left: 0; top: .62em; width: 7px; height: 7px; border-radius: 50%; background: var(--brand-orange); }
.entry-toc .toc-level-3 { margin-left: 14px; }
.entry-toc .toc-level-3::before { background: var(--brand-purple); width: 6px; height: 6px; }

/* Larger, balanced header: bigger logo, readable menu, centered on one axis. */
.header-inner { min-height: 104px; gap: 36px; align-items: center; }
.site-brand .custom-logo { max-height: 84px; max-width: 300px; }

.primary-nav > ul, .primary-nav > .menu-main-menu-container > ul { gap: 30px; }
.primary-nav a { font-size: 16px; font-weight: 700; letter-spacing: .01em; }
.header-search { width: 250px; height: 46px; align-items: center; flex: 0 0 auto; }
.header-search input { padding: 10px 16px; font-size: 15px; }
.header-search button { padding: 0 16px; font-size: 16px; height: 100%; }

@media (max-width: 1100px) {
  .header-inner { min-height: 84px; gap: 14px; }
  .site-brand .custom-logo { max-height: 64px; max-width: 64px; }
  .menu-toggle { font-size: 15px; padding: 10px 14px; font-weight: 700; }
  .header-search { width: auto; height: 46px; margin-left: 0; }
}
@media (max-width: 600px) {
  .header-inner { min-height: 72px; gap: 8px; }
  .site-brand .custom-logo { max-height: 54px; max-width: 54px; }
  .menu-toggle { font-size: 14px; padding: 9px 12px; }
  .header-search { flex: 0 0 44px; width: 44px; height: 44px; }
}

/* Desktop menu stays on one line: sizes scale with the viewport instead of wrapping. */
@media (min-width: 1101px) {
  .header-inner { gap: clamp(14px, 2.2vw, 36px); flex-wrap: nowrap; }
  .site-brand { flex: 0 0 auto; }
  .primary-nav { display: flex; align-items: center; flex: 1 1 auto; min-width: 0; justify-content: flex-end; }
  .primary-nav > ul, .primary-nav > .menu-main-menu-container > ul { flex-wrap: nowrap; gap: clamp(14px, 1.9vw, 30px); }
  .primary-nav li { flex: 0 0 auto; }
  .primary-nav a { white-space: nowrap; font-size: clamp(14px, 1.3vw, 16px); }
  .header-search { flex: 0 0 auto; width: clamp(160px, 15vw, 250px); }
}

/* Featured image is not shown on single posts. */
.entry-featured { display: none; }

/* Mobile/tablet menu: collapsed by default, opened only by the toggle. */
@media (max-width: 1100px) {
  .primary-nav { display: none; }
  .primary-nav.is-open { display: block; }
}

/* Collapsible sub-categories (tap the arrow to expand). */
.submenu-toggle { display: none; }
@media (max-width: 1100px) {
  .primary-nav li.has-sub { display: flex; flex-wrap: wrap; align-items: center; }
  .primary-nav li.has-sub > a { flex: 1 1 0; min-width: 0; }
  .primary-nav .submenu-toggle { display: inline-grid; place-items: center; flex: 0 0 44px; width: 44px; height: 44px; margin: 0; padding: 0; border: 0; border-radius: 8px; background: transparent; cursor: pointer; }
  .primary-nav .submenu-toggle span { width: 9px; height: 9px; border-right: 2.5px solid var(--brand-orange); border-bottom: 2.5px solid var(--brand-orange); transform: rotate(45deg) translate(-2px, -2px); transition: transform .2s ease; }
  .primary-nav li.is-expanded > .submenu-toggle span { transform: rotate(-135deg) translate(-2px, -2px); }
  .primary-nav li.has-sub:not(.is-expanded) > ul { display: none; }
  .primary-nav li.has-sub.is-expanded > ul { display: block; flex: 0 0 100%; }
  .primary-nav li.is-expanded > a { color: var(--accent-dark); }
}
