/* ==========================================================================
   Water Sheep Survey — Stylesheet
   Scholarly, minimal, modern. Handles Tibetan + Chinese script gracefully.
   ========================================================================== */

/* ---------- Reset & base ---------- */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    font-family: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
    font-size: 18px;
    line-height: 1.65;
    color: #1f2328;
    background: #fbfaf7;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Tibetan text helper — apply class="tib" to spans/paragraphs containing Tibetan
   script. Falls through a stack of the most reliable dbu-can fonts. */
.tib,
:lang(bo) {
    font-family: "Jomolhari", "Tibetan Machine Uni", "Himalaya", "Noto Sans Tibetan",
                 "Noto Serif Tibetan", "Microsoft Himalaya", "Kailasa", sans-serif;
    font-size: 1.05em;
    line-height: 2.0;
}

/* Chinese text */
:lang(zh),
.zh {
    font-family: "Songti SC", "PingFang SC", "Noto Serif CJK SC", "Source Han Serif SC",
                 "Microsoft YaHei", serif;
}

/* ---------- Typography ---------- */
h1, h2, h3, h4 {
    font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
    color: #1a1a1a;
    line-height: 1.25;
    margin-top: 1.8em;
    margin-bottom: 0.6em;
    font-weight: 600;
}

h1 {
    font-size: 2.1rem;
    margin-top: 0;
    letter-spacing: -0.01em;
    border-bottom: 1px solid #d4cfc2;
    padding-bottom: 0.4em;
}

h2 {
    font-size: 1.5rem;
    color: #5a3a1f;
}

h3 {
    font-size: 1.2rem;
    color: #2a2a2a;
}

p {
    margin: 0 0 1.1em 0;
}

a {
    color: #8b3a1f;
    text-decoration: none;
    border-bottom: 1px solid rgba(139, 58, 31, 0.3);
    transition: color 0.15s, border-color 0.15s;
}

a:hover {
    color: #c94a1f;
    border-bottom-color: #c94a1f;
}

strong {
    font-weight: 600;
    color: #1a1a1a;
}

em {
    font-style: italic;
    color: #3a3a3a;
}

code, pre {
    font-family: "SF Mono", "Menlo", Consolas, "Courier New", monospace;
    font-size: 0.92em;
}

blockquote {
    margin: 1.5em 0;
    padding: 0.8em 1.4em;
    border-left: 3px solid #8b3a1f;
    background: #f5f0e8;
    color: #3a3a3a;
    font-style: italic;
}

ul, ol {
    margin: 0 0 1.1em 0;
    padding-left: 1.6em;
}

li {
    margin-bottom: 0.4em;
}

hr {
    border: none;
    border-top: 1px solid #d4cfc2;
    margin: 2.5em 0;
}

/* ---------- Site header / banner ---------- */
.site-header {
    background: linear-gradient(135deg, #3a1f0f 0%, #5a3a1f 100%);
    color: #f5f0e8;
    border-bottom: 3px solid #8b3a1f;
}

.site-header__inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem 2rem 1.2rem 2rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.site-title {
    font-size: 1.6rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    margin: 0;
}

.site-title a {
    color: #f5f0e8;
    border-bottom: none;
}

.site-title a:hover {
    color: #ffd9b3;
}

.site-title__tib {
    font-family: "Jomolhari", "Tibetan Machine Uni", "Himalaya", "Noto Sans Tibetan",
                 "Microsoft Himalaya", sans-serif;
    font-size: 1.5rem;
    font-weight: normal;
    margin-left: 0.4em;
    opacity: 0.9;
}

.site-subtitle {
    font-size: 0.95rem;
    font-style: italic;
    opacity: 0.85;
    margin: 0;
}

/* ---------- Navigation ---------- */
.site-nav {
    background: #2a1808;
    border-bottom: 1px solid #0f0803;
    position: sticky;
    top: 0;
    z-index: 50;
}

.site-nav__inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

.site-nav__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
}

.site-nav__item {
    position: relative;
    margin: 0;
}

.site-nav__link {
    display: block;
    padding: 0.85rem 1.1rem;
    color: #e8dfce;
    font-size: 0.95rem;
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-weight: 500;
    border-bottom: none;
    border-top: 3px solid transparent;
    transition: background 0.15s, color 0.15s;
}

.site-nav__link:hover,
.site-nav__link.active {
    background: #3a1f0f;
    color: #ffd9b3;
    border-top-color: #c94a1f;
}

/* Dropdown for nested items */
.site-nav__item--has-children:hover .site-nav__submenu,
.site-nav__item--has-children:focus-within .site-nav__submenu {
    display: block;
}

.site-nav__submenu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 240px;
    background: #2a1808;
    border: 1px solid #0f0803;
    border-top: none;
    list-style: none;
    margin: 0;
    padding: 0.4rem 0;
    z-index: 10;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.site-nav__submenu .site-nav__link {
    padding: 0.55rem 1.1rem;
    border-top: none;
    border-left: 3px solid transparent;
}

.site-nav__submenu .site-nav__link:hover,
.site-nav__submenu .site-nav__link.active {
    border-top: none;
    border-left-color: #c94a1f;
}

/* Mobile nav toggle */
.site-nav__toggle {
    display: none;
    background: none;
    border: none;
    color: #e8dfce;
    font-size: 1.4rem;
    padding: 0.75rem 1rem;
    cursor: pointer;
    font-family: inherit;
}

/* ---------- Main content ---------- */
.site-main {
    max-width: 860px;
    margin: 0 auto;
    padding: 2.5rem 2rem 4rem 2rem;
}

.page-meta {
    font-size: 0.85rem;
    color: #7a6a55;
    margin-bottom: 2rem;
    font-style: italic;
}

/* ---------- Images ---------- */
figure {
    margin: 2em 0;
    text-align: center;
}

figure img {
    max-width: 100%;
    height: auto;
    border: 1px solid #d4cfc2;
    background: #fff;
    padding: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

figcaption {
    font-size: 0.88rem;
    color: #5a5a5a;
    font-style: italic;
    margin-top: 0.6em;
}

/* Placeholder for missing images */
.image-placeholder {
    display: block;
    max-width: 100%;
    min-height: 200px;
    background: repeating-linear-gradient(
        45deg,
        #f0ebe0,
        #f0ebe0 10px,
        #e8e1d2 10px,
        #e8e1d2 20px
    );
    border: 2px dashed #b8a984;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    color: #7a6a55;
    font-style: italic;
    text-align: center;
    margin: 1em 0;
}

/* ---------- Callout boxes ---------- */
.callout {
    margin: 1.5em 0;
    padding: 1em 1.3em;
    border-radius: 4px;
    border-left: 4px solid;
    background: #fff;
}

.callout--warning {
    border-left-color: #c94a1f;
    background: #faf2ee;
}

.callout--note {
    border-left-color: #4a6a8a;
    background: #eef2f7;
}

.callout__title {
    font-weight: 600;
    margin: 0 0 0.4em 0;
    color: #1a1a1a;
}

/* ---------- Download card ---------- */
.download-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.3rem;
    background: #fff;
    border: 1px solid #d4cfc2;
    border-radius: 4px;
    margin: 1.2em 0;
    transition: border-color 0.15s, transform 0.15s;
}

.download-card:hover {
    border-color: #8b3a1f;
    transform: translateY(-1px);
}

.download-card a {
    border-bottom: none;
}

.download-card__icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    background: #0f7b40;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    font-weight: 700;
    font-size: 0.85rem;
    font-family: "Inter", sans-serif;
}

.download-card__icon--xlsx { background: #0f7b40; }
.download-card__icon--csv { background: #1a5a8a; }
.download-card__icon--preview { background: #8b3a1f; }

.download-card__body {
    flex: 1;
    min-width: 0;
}

.download-card__title {
    font-weight: 600;
    color: #1a1a1a;
    margin: 0 0 0.15em 0;
    font-size: 1rem;
}

.download-card__meta {
    font-size: 0.85rem;
    color: #7a6a55;
    margin: 0;
}

/* ---------- Tables ---------- */
.data-table-wrapper {
    overflow-x: auto;
    margin: 1.5em 0;
    border: 1px solid #d4cfc2;
    border-radius: 4px;
}

table.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
    background: #fff;
}

.data-table th,
.data-table td {
    padding: 0.55em 0.85em;
    text-align: left;
    border-bottom: 1px solid #e4dfd2;
    vertical-align: top;
}

.data-table th {
    background: #f5f0e8;
    font-weight: 600;
    color: #3a1f0f;
    border-bottom: 2px solid #b8a984;
    position: sticky;
    top: 0;
}

.data-table tbody tr:hover {
    background: #faf6ef;
}

.data-table tbody tr:nth-child(even) {
    background: #fdfbf6;
}

.data-table tbody tr:nth-child(even):hover {
    background: #faf6ef;
}

/* ---------- Preformatted AI prompt blocks ---------- */
.prompt-block {
    background: #f5f0e8;
    border: 1px solid #d4cfc2;
    border-left: 4px solid #8b3a1f;
    border-radius: 2px;
    padding: 1.2em 1.4em;
    margin: 1.2em 0;
    font-size: 0.93rem;
    line-height: 1.55;
    overflow-x: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* ---------- Footer ---------- */
.site-footer {
    background: #2a1808;
    color: #b8a984;
    padding: 2rem;
    font-size: 0.85rem;
    text-align: center;
    border-top: 3px solid #8b3a1f;
}

.site-footer a {
    color: #ffd9b3;
    border-bottom-color: rgba(255, 217, 179, 0.3);
}

.site-footer__inner {
    max-width: 1200px;
    margin: 0 auto;
}

/* ---------- Footnotes ---------- */
.footnotes {
    font-size: 0.9rem;
    margin-top: 3em;
    padding-top: 1em;
    border-top: 1px solid #d4cfc2;
    color: #3a3a3a;
}

.footnotes ol {
    padding-left: 1.4em;
}

.footnote-ref {
    font-size: 0.75em;
    vertical-align: super;
    line-height: 0;
    border-bottom: none;
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
    body { font-size: 17px; }
    h1 { font-size: 1.7rem; }
    h2 { font-size: 1.3rem; }

    .site-header__inner { padding: 1.2rem 1rem 1rem 1rem; }
    .site-title { font-size: 1.3rem; }
    .site-title__tib { font-size: 1.2rem; display: block; margin-left: 0; }
    .site-subtitle { font-size: 0.85rem; }

    .site-main { padding: 1.8rem 1.2rem 3rem 1.2rem; }

    /* Collapse nav to mobile menu */
    .site-nav__toggle { display: block; }
    .site-nav__list {
        display: none;
        flex-direction: column;
        padding-bottom: 0.5rem;
    }
    .site-nav__list.open { display: flex; }
    .site-nav__item { width: 100%; }
    .site-nav__link { padding: 0.75rem 1.2rem; }
    .site-nav__item--has-children .site-nav__submenu {
        position: static;
        display: block;
        box-shadow: none;
        border: none;
        background: #1a0f05;
        padding: 0;
    }
    .site-nav__submenu .site-nav__link {
        padding-left: 2.4rem;
        font-size: 0.9rem;
    }

    .download-card { flex-wrap: wrap; }
}

@media print {
    .site-nav, .site-footer, .site-header { display: none; }
    body { background: white; font-size: 11pt; }
    .site-main { max-width: none; padding: 0; }
    a { color: #000; border-bottom: none; }
    a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 0.85em; color: #555; }
}
