/* ===== chute-manual site styles (appended by scripts/patch-language-selector.sh) ===== */
/* ============================================================
   Dark mode overrides for language-selector plugin
   The plugin's built-in CSS only supports light mode.
   These rules adapt the language selector to match the
   color-theme-2 (dark) sidebar color scheme:
     - Sidebar bg:        #2d3143
     - Sidebar text:      #bcc1d2
     - Active item bg:    #252737
     - Active item text:  #f4f4f5
     - Content dark bg:   #1c1f2b
     - Content dark text: #bdcadb
   ============================================================ */

/* --- Dark mode: summary sidebar language selector --- */
.book.color-theme-2 .summary-language-selector {
    background: transparent;
    border-color: #272a3a;
}

.book.color-theme-2 .summary-language-selector label {
    color: #bcc1d2;
}

.book.color-theme-2 .summary-language-selector select {
    background-color: #1c1f2b;
    color: #bdcadb;
    border-color: #373b4e;
}

.book.color-theme-2 .summary-language-selector select:focus {
    border-color: #3eb1d0;
    box-shadow: 0 0 0 0.2rem rgba(62, 177, 208, 0.25);
}

/* --- Dark mode: floating language selector (top-right corner) --- */
.book.color-theme-2 .language-selector {
    background: #2d3143;
    border-color: #373b4e;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.book.color-theme-2 .language-selector select {
    background-color: #1c1f2b;
    color: #bdcadb;
    border-color: #373b4e;
}

.book.color-theme-2 .language-selector select:focus {
    border-color: #3eb1d0;
    box-shadow: 0 0 0 0.2rem rgba(62, 177, 208, 0.25);
}

/* --- AI translation notice (non-en/zh languages) --- */
.translation-notice {
    margin-top: 2.5em;
    padding: 0.9em 1.1em;
    border-left: 3px solid #9aa0b4;
    background: rgba(127, 127, 127, 0.08);
    border-radius: 4px;
    font-size: 0.85em;
    color: #6b7280;
}

.translation-notice p {
    margin: 0.3em 0;
}

.translation-notice p:first-child {
    margin-top: 0;
}

.translation-notice p:last-child {
    margin-bottom: 0;
}

.book.color-theme-2 .translation-notice {
    border-left-color: #3eb1d0;
    background: rgba(62, 177, 208, 0.08);
    color: #9fb0c8;
}


/* ============================================================
   Long paths and identifiers inside tables
   The theme sets inline `code` to `white-space: pre`, so a long
   path in a table cell cannot break. The key column then stretches
   to the width of the longest path, the description column is
   squeezed into a narrow ribbon, and the row grows several lines
   tall. Let inline code wrap — but only inside tables, so code
   blocks and prose keep the theme's behaviour.
   ============================================================ */

.markdown-section table code {
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
}


/* ============================================================
   The gold PRO capsule
   Copied from ChuteWebsite (css/main.css), which draws the same
   capsule as ChuteiOS CIProBadge and the Mac, tvOS and Android
   badges made after it: the diagonal #FFEAAA / #F5C04A / #D69226
   gradient, a sheen on its upper half, a hairline edge, and dark
   rounded "PRO" lettering. The site's font-size is 0.64em; the
   clamp keeps the capsule between 10 and 13.5 px of lettering, so
   it stays close to the 15-22 pt the apps use even inside an H1
   (where 0.64em alone would draw a 32 px capsule).
   ============================================================ */

.pro-badge {
    /* inline, not inline-block: Chrome breaks a line before an
     * inline-block even after a no-break space, which drops the
     * capsule under a heading's last word */
    display: inline;
    padding: 0.3em 0.66em 0.3em 0.75em; /* the letter-spacing also trails the last letter */
    border-radius: 0.9em;
    font-family: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: clamp(10px, 0.64em, 13.5px);
    font-style: normal;
    font-weight: 800;
    line-height: 1;
    letter-spacing: 0.09em;
    text-transform: none;
    text-decoration: none;
    color: #4a2c00;
    background:
        linear-gradient(to bottom, rgba(255, 255, 255, 0.45), rgba(255, 255, 255, 0) 55%),
        linear-gradient(116deg, #ffeaaa 0%, #f5c04a 48%, #d69226 100%);
    box-shadow: inset 0 0 0 0.5px rgba(150, 96, 12, 0.45);
    vertical-align: 0.45em;
    white-space: nowrap;
    direction: ltr;
    unicode-bidi: isolate;
    -webkit-user-select: none;
    user-select: none;
}

/* After a title the capsule is a corner mark: raised past the line box's top
 * edge, so it hangs over the title rather than sitting beside it. In a
 * sentence it stays on the line, where a corner would collide with the line
 * above. */
.markdown-section h1 .pro-badge,
.markdown-section h2 .pro-badge,
.markdown-section h3 .pro-badge,
.markdown-section h4 .pro-badge,
.markdown-section h5 .pro-badge,
.markdown-section h6 .pro-badge {
    font-size: clamp(7.5px, 0.5em, 9.5px);
    vertical-align: 1.3em;
}

/* Sidebar summary: a page that is itself a Chute Pro feature carries the
 * capsule at the end of its row. The row keeps a slot for it, so a long
 * title ellipsizes instead of running underneath the badge. */
.book-summary ul.summary li.has-pro > a {
    padding-inline-end: 54px;
}

/* `body` outranks the theme's `.book.color-theme-2 ... li span` rule, which
 * is loaded again after this sheet and would otherwise turn the capsule into
 * a full-width row. */
body .book-summary ul.summary li.has-pro > a .pro-badge--summary {
    position: absolute;
    inset-inline-end: 12px;
    top: 50%;
    transform: translateY(-50%);
    padding: 0.22em 0.5em;
    font-size: 8px;
    line-height: 1.2;
    letter-spacing: 0.08em;
    vertical-align: baseline;
    /* the theme's `.book-summary ... li span` rule draws every span in a row
     * as a full-width link, so the capsule has to restate these three */
    color: #4a2c00;
    background:
        linear-gradient(to bottom, rgba(255, 255, 255, 0.45), rgba(255, 255, 255, 0) 55%),
        linear-gradient(116deg, #ffeaaa 0%, #f5c04a 48%, #d69226 100%);
    font-weight: 800;
}
