/*
 * 2.26.21: "How We Grade Stocks" (includes/method-page.php, page-how-we-grade-stocks.php).
 * The line under a stock list's ranked table, the link in the Canadian Stocks header, and the page's own touches.
 * Loaded on section pages, articles and the page itself. Named category-… so the optimizer's "used CSS" leaves it alone.
 */

/* Stock lists: the plugin's table frame leaves 28px under it; the line sits in that gap, close to the Grade column */
.sta .st-content .sta-gradelink { margin: -16px 0 28px; font-size: 14.5px; line-height: 1.5; color: var(--sta-muted); }
.sta .st-content .sta-gradelink a { font-weight: 600; }

/* Canadian Stocks section header: one more pill in the facts row, and this one is a link */
.stc .stc-meta li.stc-meta-link { padding: 0; }
.stc .stc-meta li.stc-meta-link a { display: flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 14px; border-radius: 999px; font-weight: 600; color: var(--stc-text); text-decoration: none; }
.stc .stc-meta li.stc-meta-link a::after { content: "\2192"; color: var(--stc-gold); }
.stc .stc-meta li.stc-meta-link:hover { border-color: var(--stc-gold); }
@media (max-width: 760px) {
    .stc .stc-meta li.stc-meta-link a { padding: 0 12px; }
}

/* The page itself. It borrows the article layout; these are the few places a reference page differs. */
.sta-method .sta-crumbs span[aria-current] { color: var(--sta-muted); }
/* Seven questions in a row read better at a smaller size than an article's sub-headings */
.sta-method .st-content h3 { margin: 30px 0 8px; font-size: 21px; line-height: 1.3; }
/* The editor's "fixed width" tables give a one-word column a third of the row; let the text decide */
.sta-method .st-content table.has-fixed-layout { table-layout: auto; }
.sta-method .st-content .sta-tw tr > :first-child { white-space: nowrap; }
/* Two-column tables (the example and the scale) do not need the full width */
.sta-method .st-content .sta-tw:not(:has(th:nth-child(3))) { max-width: 440px; }
/* The three-column table keeps a readable third column on a phone and scrolls in its frame */
.sta-method .st-content .sta-tw table:has(th:nth-child(3)) { min-width: 640px; }
.sta-method .st-content .sta-tw table:has(th:nth-child(3)) td:nth-child(2) { min-width: 12em; }

/* On a phone the three-column table becomes one block per grade: name, the question, then what goes into it.
   Scrolling sideways through three sentences a row is harder to read than stacking them. */
@media (max-width: 640px) {
    .sta-method .st-content .sta-tw table:has(th:nth-child(3)) { min-width: 0; }
    .sta-method .st-content .sta-tw table:has(th:nth-child(3)),
    .sta-method .st-content .sta-tw table:has(th:nth-child(3)) tbody,
    .sta-method .st-content .sta-tw table:has(th:nth-child(3)) tr,
    .sta-method .st-content .sta-tw table:has(th:nth-child(3)) td { display: block; }
    /* The column names stay for screen readers */
    .sta-method .st-content .sta-tw table:has(th:nth-child(3)) thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
    .sta-method .st-content .sta-tw table:has(th:nth-child(3)) tbody tr { padding: 14px 16px 16px; border-bottom: 1px solid var(--sta-row); }
    .sta-method .st-content .sta-tw table:has(th:nth-child(3)) tbody tr:last-child { border-bottom: 0; }
    .sta-method .st-content .sta-tw table:has(th:nth-child(3)) td { min-width: 0; padding: 0; border: 0; }
    .sta-method .st-content .sta-tw table:has(th:nth-child(3)) td:first-child { position: static; background: none; box-shadow: none; font-size: 17px; font-weight: 700; white-space: normal; color: var(--sta-text); }
    .sta-method .st-content .sta-tw table:has(th:nth-child(3)) td:nth-child(2) { min-width: 0; margin-top: 2px; font-size: 15.5px; color: var(--sta-text); }
    .sta-method .st-content .sta-tw table:has(th:nth-child(3)) td:nth-child(3) { margin-top: 8px; font-size: 14.5px; line-height: 1.5; color: var(--sta-text2); }
    /* The facts row on the Canadian Stocks page is 32px tall on a phone; the link pill matches it */
    .stc .stc-meta li.stc-meta-link a { min-height: 30px; }
}
