/* ==========================================================================
   Labplus Knowledge Base aggregation site - site-level custom styles
   Tweaks for sphinx_rtd_theme: portal home-page cards, the three highlight
   sections, and small CJK typography fixes
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Global fonts and CJK typography
   -------------------------------------------------------------------------- */
/* Global fonts: fix the "not smooth" rendering of CJK text on Chinese Windows.
   sphinx_rtd_theme declares pure-Latin fonts (Lato, Roboto Slab, SFMono, ...)
   directly on body / headings / code elements; they contain no CJK glyphs, so
   CJK text falls back to the browser default -- on Chinese Windows usually
   SimSun, which looks blurry and jagged at small sizes.
   Declaring the fonts on html alone does not work: the theme's declarations on
   body are more specific than inheritance from html.
   custom.css loads after theme.css, so here we override body / headings /
   code / forms one by one with selectors of the "same specificity" as the
   theme: keep the original Latin fonts and append quality CJK fonts per
   platform, so CJK characters render with:
     - Chinese Windows -> Microsoft YaHei (ClearType smoothing)
     - Chinese macOS   -> PingFang SC / Hiragino Sans GB
     - Linux / fallback -> Source Han Sans SC / Noto Sans CJK SC / WenQuanYi Micro Hei
   The three font stacks are centralized as CSS variables and reused for body
   text / headings / monospace respectively. */
:root {
    /* Body text and UI: keep the theme's Lato Latin stack + CJK fonts */
    --labplus-font-sans: Lato, "proxima-nova", "Helvetica Neue", Arial,
        "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
        "Source Han Sans SC", "Noto Sans CJK SC", "WenQuanYi Micro Hei",
        sans-serif;
    /* Headings: keep the theme's Roboto Slab Latin stack + CJK sans-serif (serif SimSun blurs at small sizes) */
    --labplus-font-heading: "Roboto Slab", "ff-tisa-web-pro", Georgia, Arial,
        "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
        "Source Han Sans SC", "Noto Sans CJK SC", sans-serif;
    /* Monospace / code: keep the theme's SFMono Latin stack + CJK fallback (smooth CJK comments inside code) */
    --labplus-font-mono: "SFMono-Regular", Menlo, Monaco, Consolas,
        "Liberation Mono", "Courier New", Courier,
        "PingFang SC", "Microsoft YaHei", monospace;
}

/* Body text: navigation, paragraphs, lists and all other inheriting text come from body */
html, body {
    font-family: var(--labplus-font-sans);
}

/* Headings and toctree captions (overrides the theme's pure-Latin Roboto Slab stack) */
.rst-content .toctree-wrapper > p.caption,
h1, h2, h3, h4, h5, h6, legend {
    font-family: var(--labplus-font-heading);
}

/* Sidebar titles */
.rst-content .sidebar .sidebar-title {
    font-family: var(--labplus-font-heading);
}

/* Code and monospace text: inline code/tt, code blocks pre, line-number gutter, etc. */
.rst-content code, .rst-content tt, .rst-content kbd, .rst-content samp,
.rst-content pre, .rst-content pre.literal-block,
.rst-content .linenodiv pre, .rst-content div[class^="highlight"] pre,
code, kbd, pre, samp, tt {
    font-family: var(--labplus-font-mono);
}

/* Buttons / forms / version switcher and other UI elements (overrides the theme's Lato stack; buttons containing CJK text also render smoothly) */
.btn, .rst-versions,
.wy-side-nav-search input[type="text"],
input[type="button"], input[type="submit"], input[type="reset"],
textarea, select {
    font-family: var(--labplus-font-sans);
}

/* Wrap long CJK strings and long URLs inside tables so they cannot blow out the content area */
.rst-content table.docutils td,
.rst-content table.docutils th {
    word-break: break-word;
    overflow-wrap: anywhere;
}

/* Slightly relaxed line height for paragraphs and lists, more comfortable for CJK reading */
.rst-content p,
.rst-content li,
.rst-content dd {
    line-height: 1.75;
}

/* --------------------------------------------------------------------------
   2. Portal home page - product line entry cards
   Usage: index.rst inserts the .portal-cards structure via .. raw:: html
   -------------------------------------------------------------------------- */
.portal-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
    gap: 16px;
    margin: 24px 0 8px 0;
}

.portal-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 18px 18px 16px 18px;
    border: 1px solid #d8dde2;
    border-radius: 8px;
    background: #fff;
    color: #40474f;
    text-decoration: none;
    overflow: hidden;
    transition: transform 0.15s ease, box-shadow 0.15s ease,
        border-color 0.15s ease;
}

.portal-card::before {
    /* Top brand-color bar */
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--card-accent, #0e7c86);
}

.portal-card:hover,
.portal-card:focus-visible {
    transform: translateY(-3px);
    border-color: var(--card-accent, #0e7c86);
    box-shadow: 0 6px 16px rgba(30, 41, 51, 0.12);
    text-decoration: none;
}

/* Card content */
.portal-card-chip {
    align-self: flex-start;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: #fff;
    background: var(--card-accent, #0e7c86);
    border-radius: 999px;
    padding: 2px 10px;
}

.portal-card-title {
    font-size: 18px;
    font-weight: 700;
    color: #1c2b33;
    line-height: 1.35;
}

.portal-card-desc {
    font-size: 14px;
    color: #55606a;
    line-height: 1.6;
    flex-grow: 1;
}

.portal-card-keywords {
    font-size: 13px;
    color: #75828c;
    line-height: 1.7;
    border-top: 1px dashed #d8dde2;
    padding-top: 8px;
    margin-top: 4px;
}

.portal-card-keywords::before {
    content: "Keywords";
    font-weight: 600;
    color: #9aa4ac;
    margin-right: 8px;
    font-size: 12px;
}

/* Per-product-line brand color variables (each card provides --card-accent via inline style) */

/* --------------------------------------------------------------------------
   3. Portal home page - the three highlight sections
   -------------------------------------------------------------------------- */
.portal-sections {
    margin: 8px 0;
}

.portal-sections .portal-section {
    display: flex;
    gap: 14px;
    padding: 14px 16px;
    margin-bottom: 12px;
    border: 1px solid #e2e6ea;
    border-left: 4px solid #0e7c86;
    border-radius: 6px;
    background: #fafbfc;
}

.portal-sections .portal-section-icon {
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #0e7c86;
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.portal-sections .portal-section-body h4 {
    margin: 0 0 4px 0;
    font-size: 16px;
    font-weight: 700;
    color: #1c2b33;
}

.portal-sections .portal-section-body p {
    margin: 0;
    font-size: 14px;
    color: #55606a;
    line-height: 1.7;
}

/* --------------------------------------------------------------------------
   4. Selection guide page - link column pointing to detailed docs (optional tweak)
   -------------------------------------------------------------------------- */
.rst-content table.docutils td a.reference.internal {
    white-space: nowrap;
}
