/*
Theme Name: China Medical Search
Theme URI: https://www.neijuanwang.com/
Author: China Medical Search
Description: Server-rendered English directory of major public hospitals in China.
Version: 1.0.0
Requires at least: 6.4
Tested up to: 7.1
Requires PHP: 8.0
Text Domain: cms-directory
*/

:root {
    --paper: #f4efe6;
    --paper-deep: #e7e0d2;
    --ink: #1c2430;
    --muted: #5e564c;
    --line: #d9d0c2;
    --teal: #0e4f4a;
    --teal-ink: #f6f3ec;
    --clay: #8a3e2c;
    --card: #fffdf8;
    --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Songti SC", serif;
    --sans: "Segoe UI", "Helvetica Neue", Arial, "PingFang SC", "Noto Sans SC", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    color: var(--ink);
    background: linear-gradient(180deg, #fbf8f2 0%, var(--paper) 280px);
    font-family: var(--sans);
    font-size: 17px;
    line-height: 1.6;
}
img { max-width: 100%; height: auto; }
a { color: var(--teal); }
a:hover { color: var(--clay); }
h1, h2, h3, .brand-type {
    font-family: var(--serif);
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.15;
}
h1 { font-size: clamp(2.1rem, 4vw, 3.6rem); margin: 0 0 0.4em; }
h2 { font-size: clamp(1.6rem, 2.5vw, 2.1rem); margin: 0; }
h3 { font-size: 1.25rem; margin: 0 0 0.35em; }
p { margin: 0 0 0.8em; }
.wrap { width: min(1120px, calc(100% - 32px)); margin: 0 auto; }
.skip {
    position: absolute;
    left: 12px;
    top: -40px;
    background: var(--ink);
    color: white;
    padding: 8px 12px;
    z-index: 5;
}
.skip:focus { top: 12px; }

.site-header {
    border-bottom: 1px solid var(--line);
    background: #fbf8f2;
    position: sticky;
    top: 0;
    z-index: 2;
}
.crumbs ol {
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    list-style: none;
    margin: 0 0 14px;
    padding: 0;
    color: var(--muted);
    font-size: 0.92rem;
}
.crumbs li { display: flex; align-items: center; }
.crumbs li + li::before {
    content: "/";
    margin: 0 8px;
    color: var(--line);
}
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--teal); }
.header-row {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    align-items: center;
    padding: 16px 0;
}
.brand { text-decoration: none; color: inherit; display: flex; flex-direction: column; }
.brand-type { font-size: 1.35rem; }
.brand-sub { color: var(--muted); font-size: 0.82rem; letter-spacing: 0.04em; text-transform: uppercase; }
.nav-list { display: flex; flex-wrap: wrap; gap: 8px 16px; list-style: none; margin: 0; padding: 0; }
.nav-list a { text-decoration: none; color: var(--ink); font-size: 0.95rem; }
.nav-list a:hover, .nav-list .current-menu-item a { color: var(--clay); }
.lang-switch { margin-left: auto; }
.lang-switch ul { display: flex; gap: 6px; list-style: none; margin: 0; padding: 0; }
.lang-switch a {
    display: inline-block;
    min-width: 1.75rem;
    text-align: center;
    text-decoration: none;
    color: var(--muted);
    font-size: 0.78rem;
    letter-spacing: 0.04em;
    border-bottom: 1px solid transparent;
    padding: 2px 0;
}
.lang-switch .is-active a,
.lang-switch a:hover { color: var(--ink); border-bottom-color: var(--clay); }

.hero { padding: 48px 0 20px; }
.hero-grid { display: grid; grid-template-columns: 1.5fr 0.7fr; gap: 36px; align-items: end; }
.kicker {
    margin: 0 0 8px;
    color: var(--clay);
    font-size: 0.78rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}
.dek { font-size: 1.12rem; max-width: 42rem; color: var(--ink); }
.fine { color: var(--muted); font-size: 0.92rem; }
.search-bar label { display: block; font-weight: 600; margin-bottom: 8px; }
.search-row { display: flex; gap: 8px; }
.search-row input[type="search"] {
    flex: 1;
    border: 1px solid var(--ink);
    background: white;
    color: var(--ink);
    font: inherit;
    padding: 14px 16px;
    border-radius: 0;
    min-width: 0;
}
.search-row button, .contact-form button {
    border: 0;
    background: var(--teal);
    color: var(--teal-ink);
    font: inherit;
    padding: 14px 22px;
    cursor: pointer;
}
.search-row button:hover, .contact-form button:hover { background: #0a3d39; }
.hero-panel {
    background: var(--teal);
    color: var(--teal-ink);
    padding: 22px 22px 18px;
}
.hero-stat {
    font-family: var(--serif);
    font-size: 3.2rem;
    line-height: 1;
    margin: 0 0 8px;
}
.hero-panel a, .text-link { color: inherit; }
.hero-panel .text-link { color: #f0d7a2; }

.band { padding: 28px 0 10px; }
.band-alt { background: rgba(255, 253, 248, 0.7); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.section-head { display: flex; justify-content: space-between; gap: 16px; align-items: baseline; margin: 8px 0 16px; }
.section-head a { white-space: nowrap; }
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 14px;
    align-items: start;
}
.card, .result, .empty {
    background: var(--card);
    border: 1px solid var(--line);
    padding: 16px 16px 12px;
}
.card-has-media { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.card-media {
    display: block;
    aspect-ratio: 16 / 10;
    background: #ddd6c8;
    overflow: hidden;
}
.card-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.card-media-portrait {
    aspect-ratio: auto;
    background: transparent;
}
/* Doctor cards: portrait floats inside the body so text wraps under it. */
.card-doctor.card-has-media {
    display: block;
}
.card-doctor .card-body {
    overflow: visible;
}
.card-doctor .card-media-portrait {
    float: left;
    width: 88px;
    height: auto;
    max-height: none;
    min-height: 0;
    aspect-ratio: auto;
    margin: 0 12px 6px 0;
}
.card-doctor .card-media-portrait img {
    width: 100%;
    height: auto;
    max-height: 112px;
    object-fit: contain;
    object-position: center top;
    display: block;
}
.card-doctor .card-body::after {
    content: "";
    display: table;
    clear: both;
}
.card-has-media .card-body { padding: 14px 16px 12px; }
@media (max-width: 560px) {
    .card-doctor .card-media-portrait {
        width: 72px;
        margin: 0 10px 4px 0;
    }
    .card-doctor .card-media-portrait img {
        max-height: 96px;
    }
}
.card h3 a, .result h2 a { color: var(--ink); text-decoration: none; }
.card h3 a:hover, .result h2 a:hover { color: var(--teal); }
.card-meta { color: var(--muted); font-size: 0.92rem; }
.empty { background: transparent; }
.entry-media {
    margin: 0 0 22px;
    max-width: 52rem;
    background: #ddd6c8;
}
.entry-media img {
    display: block;
    width: 100%;
    height: auto;
    max-height: 420px;
    object-fit: cover;
}
.entry-media-portrait {
    max-width: 220px;
}
.entry-media-portrait img {
    max-height: 280px;
}

.split { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; }
.index-list { list-style: none; margin: 0; padding: 0; }
.index-list li { padding: 12px 0; border-top: 1px solid var(--line); }
.index-list a { font-family: var(--serif); font-size: 1.25rem; text-decoration: none; color: var(--ink); }
.index-list a:hover { color: var(--teal); }
.index-list span { display: block; color: var(--muted); font-size: 0.92rem; }

.page-intro { margin-bottom: 18px; max-width: 46rem; }
.entry h2 { margin: 28px 0 12px; }
.prose { max-width: 42rem; }
.prose a { text-underline-offset: 2px; }
.facts { margin: 0 0 22px; }
.facts div {
    display: grid;
    grid-template-columns: 190px 1fr;
    gap: 12px;
    padding: 11px 0;
    border-top: 1px solid var(--line);
}
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.results { display: grid; gap: 12px; }
.result h2 { font-size: 1.45rem; }
.pagination { margin: 20px 0; }
.pagination .nav-links { display: flex; gap: 12px; flex-wrap: wrap; }

.contact-form { display: grid; gap: 8px; max-width: 36rem; margin-top: 12px; }
.contact-form input, .contact-form textarea {
    font: inherit;
    border: 1px solid var(--ink);
    padding: 12px;
    background: white;
    width: 100%;
}
.form-hint { margin: 0; color: var(--muted); font-size: 0.92rem; }
.hp { position: absolute; left: -9999px; height: 0; overflow: hidden; }
.form-note { padding: 12px 14px; border: 1px solid var(--line); }
.form-note-ok { background: #e5f0ea; }
.form-note-bad { background: #f8e8e2; }

.consult-fab {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 40;
    background: var(--teal);
    color: var(--teal-ink);
    text-decoration: none;
    padding: 12px 16px;
    font: 600 0.95rem/1.2 var(--sans, Georgia, serif);
    border: 1px solid rgba(0, 0, 0, 0.18);
    box-shadow: 0 8px 18px rgba(20, 28, 24, 0.18);
}
.consult-fab:hover { background: #0a3d39; color: var(--teal-ink); }
.consult-dialog {
    border: 1px solid var(--line);
    padding: 0;
    width: min(420px, calc(100vw - 24px));
    background: var(--paper, #f7f1e6);
    color: var(--ink);
}
.consult-dialog::backdrop { background: rgba(18, 24, 22, 0.45); }
.consult-dialog-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin: 0;
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 253, 248, 0.9);
}
.consult-dialog-bar button {
    border: 0;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font: inherit;
}
.consult-lead {
    margin: 0;
    padding: 12px 16px 0;
    color: var(--muted);
    font-size: 0.95rem;
}
.consult-dialog .contact-form {
    margin: 0;
    padding: 12px 16px 18px;
    max-width: none;
}
.cms-chat-error { margin: 12px 16px 0; }
.cms-chat-pane { padding: 0 0 12px; }
.cms-chat-log {
    height: min(340px, 50vh);
    overflow: auto;
    padding: 12px 16px;
    background: rgba(255, 253, 248, 0.65);
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}
.consult-dialog .cms-chat-bubble {
    max-width: 88%;
    margin: 0 0 10px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    background: #fff;
    white-space: pre-wrap;
    font-size: 0.95rem;
}
.consult-dialog .cms-chat-bubble.staff {
    margin-left: auto;
    background: #e7f0ec;
    border-color: #b7cfc4;
}
.consult-dialog .cms-chat-bubble .who {
    display: block;
    color: var(--muted);
    font-size: 0.75rem;
    margin-bottom: 4px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.cms-chat-compose-front {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    padding: 12px 16px 16px;
    align-items: end;
}
.cms-chat-compose-front textarea {
    font: inherit;
    border: 1px solid var(--ink);
    padding: 10px;
    background: white;
    width: 100%;
    resize: vertical;
}
.cms-chat-compose-front button {
    border: 0;
    background: var(--teal);
    color: var(--teal-ink);
    font: inherit;
    padding: 12px 16px;
    cursor: pointer;
}
.screen-reader-text {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.site-footer {
    margin-top: 36px;
    background: var(--ink);
    color: #efe8dc;
    padding: 32px 0 18px;
}
.site-footer a { color: #f0d7a2; }
.footer-grid { display: grid; grid-template-columns: 1.4fr 0.8fr 0.8fr; gap: 24px; }
.footer-name { font-family: var(--serif); font-size: 1.4rem; margin-bottom: 8px; }
.footer-label { letter-spacing: 0.08em; text-transform: uppercase; font-size: 0.75rem; color: #c8bfb0; }
.site-footer ul { list-style: none; margin: 0; padding: 0; }
.site-footer li { margin: 0 0 6px; }
.footer-base {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    margin-top: 18px;
    padding-top: 14px;
    color: #c8bfb0;
    font-size: 0.92rem;
}

:focus-visible { outline: 2px solid var(--clay); outline-offset: 2px; }

@media (max-width: 800px) {
    .hero-grid, .split, .footer-grid, .facts div { grid-template-columns: 1fr; }
    .header-row { align-items: flex-start; flex-direction: column; }
    .search-row { flex-direction: column; }
    .search-row button { width: 100%; }
    .hero { padding-top: 28px; }
    .consult-fab { right: 12px; bottom: 12px; }
}
