/* SEO Analyzer - tool-specific styles on top of the shared
 * primitives in code/assets/css/tools.css.
 *
 * Composes:
 *   - .tool-form-card, .input-row, .text-input, .primary-btn, .ghost-btn
 *   - .progress-region, .errors-region, .history-region
 *   - .toasts, .quota-region/.quota-chip
 *   - .modal-backdrop, .modal-card chrome
 *
 * Adds:
 *   1. Focus-keyword collapsible.
 *   2. Score panel (overall + 6-category grid).
 *   3. Recommendations card.
 *   4. Per-category findings (<details> blocks).
 *   5. History list with grade badge.
 *   6. Quota chip override (same as DAC/WAC/SSC).
 */

/* ========================================================================
   Form: single URL + optional focus keyword
   ======================================================================== */
.input-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: stretch;
}
.input-row .text-input { flex: 1 1 320px; min-width: 240px; }
.input-row .primary-btn { flex: 0 0 auto; }

@media (max-width: 720px) {
    .input-row { gap: 8px; }
    .input-row .text-input,
    .input-row .primary-btn { flex-basis: 100%; }
    .input-row .primary-btn { justify-content: center; }
}

.focus-keyword-details {
    margin-top: 14px;
    border-top: 1px dashed var(--ink-100);
    padding-top: 12px;
}
.focus-keyword-details summary {
    cursor: pointer;
    font-size: 13px;
    color: var(--ink-500);
    font-weight: 600;
    user-select: none;
}
.focus-keyword-details summary:hover { color: var(--brand-red); }
.focus-keyword-row {
    margin-top: 10px;
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
}
.focus-keyword-row .text-input { width: 100%; }
.focus-keyword-help {
    font-size: 12px;
    color: var(--ink-500);
    line-height: 1.4;
}

/* Keyword volume chip - appears under the focus-keyword input
   when KE returns vol > 0 for the entered term. */
.kw-volume {
    margin-top: 12px;
    padding: 12px 14px;
    background: var(--ink-50);
    border: 1px solid var(--ink-100);
    border-radius: var(--r-sm);
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}
.kw-volume[hidden] { display: none; }
.kw-volume-row {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.kw-volume-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--ink-500);
}
.kw-volume-value {
    font-size: 16px;
    font-weight: 700;
    color: var(--ink);
    font-feature-settings: var(--tnum);
}
@media (max-width: 480px) {
    .kw-volume { grid-template-columns: 1fr 1fr; }
}

/* ========================================================================
   Quota chip (same as DAC/WAC/SSC; reused verbatim)
   ======================================================================== */
.quota-region {
    background: #fff;
    border: 1px solid var(--ink-100);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-sm);
    padding: 12px 16px;
    margin-bottom: 16px;
}
.quota-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 8px;
}
.quota-title {
    font-size: 11px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 1.4px;
    color: var(--ink-500);
}
.quota-upgrade { font-size: 12px; font-weight: 600; color: var(--brand-red); }
.quota-chips { display: grid; grid-template-columns: 1fr; gap: 10px; }
.quota-chip {
    display: flex; flex-direction: column; gap: 4px;
    padding: 10px 12px;
    border-radius: var(--r-sm);
    background: var(--ink-50);
    border: 1px solid var(--ink-100);
}
.quota-chip-label {
    font-size: 11px; font-weight: 700;
    letter-spacing: 0.6px; text-transform: uppercase;
    color: var(--ink-500);
}
.quota-chip-text {
    font-feature-settings: var(--tnum);
    font-size: 13px; font-weight: 600;
    color: var(--ink);
}
.quota-chip-bar {
    display: block; height: 4px;
    background: var(--ink-200);
    border-radius: 999px; overflow: hidden;
}
.quota-chip-fill {
    display: block; height: 100%; width: 0%;
    background: linear-gradient(90deg, var(--brand-red) 0%, var(--brand-red-light) 100%);
    transition: width 0.4s ease;
}
.quota-chip.is-warning .quota-chip-fill { background: linear-gradient(90deg, #d97706 0%, #f59e0b 100%); }
.quota-chip.is-danger  .quota-chip-fill { background: linear-gradient(90deg, var(--bad-fg) 0%, #ef4444 100%); }
.quota-chip.is-warning .quota-chip-text { color: #b45309; }
.quota-chip.is-danger  .quota-chip-text { color: var(--bad-fg); }

/* ========================================================================
   Score panel - overall score + letter grade + 6 category cards
   ======================================================================== */
.score-region {
    background: #fff;
    border: 1px solid var(--ink-100);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-sm);
    padding: 24px;
    margin-bottom: 20px;
    scroll-margin-top: 16px;
}
.score-header {
    display: grid;
    grid-template-columns: minmax(220px, 280px) 1fr;
    gap: 24px;
    align-items: center;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--ink-100);
    margin-bottom: 20px;
}
.score-overall {
    display: grid;
    grid-template-columns: auto auto;
    grid-template-rows: auto auto;
    gap: 4px 16px;
    align-items: end;
    text-align: left;
}
.score-overall-number {
    grid-row: 1; grid-column: 1;
    font-size: 72px; font-weight: 800; line-height: 1;
    font-feature-settings: var(--tnum);
    color: var(--ink);
    letter-spacing: -3px;
}
.score-overall-grade {
    /* Span both rows so the circle is vertically centered against the
       full "number + SEO SCORE label" stack, not just the number. */
    grid-row: 1 / span 2;
    grid-column: 2;
    align-self: center;
    /* Circular grade badge sized to sit next to the 72px score number
       as a visual peer. 84x84 circle with 44px letter (~50% fill) is
       legible without overwhelming the number beside it. */
    width: 84px; height: 84px;
    border-radius: 50%;
    font-size: 44px;
    font-weight: 800;
    line-height: 1;
    background: var(--ink-100);
    color: var(--ink);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    letter-spacing: -1px;
}
.score-overall-grade.grade-A { background: rgba(22, 163, 74, 0.14); color: rgb(15, 109, 49); }
.score-overall-grade.grade-B { background: rgba(45, 167, 167, 0.14); color: rgb(20, 110, 110); }
.score-overall-grade.grade-C { background: rgba(217, 119, 6, 0.16); color: rgb(146, 64, 14); }
.score-overall-grade.grade-D { background: rgba(234, 88, 12, 0.18); color: rgb(154, 52, 18); }
.score-overall-grade.grade-F { background: rgba(220, 38, 38, 0.18); color: rgb(159, 18, 18); }
.score-overall-label {
    /* Sit under the number only; the grade circle now spans rows 1-2
       in column 2 next to this stack. */
    grid-row: 2; grid-column: 1;
    font-size: 12px; font-weight: 700;
    letter-spacing: 1.4px;
    text-transform: uppercase;
    color: var(--ink-500);
}
.score-meta {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    align-content: center;
    min-width: 0;
}
.score-meta-row {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 12px;
    align-items: baseline;
}
/* `display: grid` beats the UA `[hidden]` rule on specificity, so the
   focus-keyword row stays visible without this explicit override. */
.score-meta-row[hidden] { display: none; }
.score-meta-label {
    font-size: 11px; font-weight: 700;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: var(--ink-500);
}
.score-meta-value {
    font-size: 16px;
    font-weight: 600;
    color: var(--ink);
    word-break: break-all;
    min-width: 0;
    line-height: 1.45;
}
#score-meta-url {
    font-size: 17px;
    font-weight: 600;
    color: var(--brand-red);
    letter-spacing: -0.2px;
}
#score-meta-url a {
    color: inherit;
    text-decoration: none;
    border-bottom: 1px dashed currentColor;
    padding-bottom: 1px;
    transition: border-bottom-style 0.12s;
}
#score-meta-url a:hover {
    border-bottom-style: solid;
}

@media (max-width: 720px) {
    .score-header {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    .score-meta-row {
        grid-template-columns: 100px 1fr;
        gap: 8px;
    }
}

.category-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
}
@media (max-width: 720px) {
    .category-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
    .category-grid { grid-template-columns: 1fr; }
}

.cat-card {
    background: var(--ink-50);
    border: 1px solid var(--ink-100);
    border-radius: var(--r-md);
    padding: 14px;
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    gap: 4px 12px;
    transition: transform 0.12s, box-shadow 0.12s, border-color 0.12s;
    cursor: pointer;
}
.cat-card:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}
.cat-card:focus-visible {
    outline: 2px solid var(--brand-red);
    outline-offset: 2px;
}
/* One distinct accent color per category (not per grade), so the
   six widgets are visually distinguishable at a glance even when
   their scores are similar. The grade letter still color-codes
   inside its own badge. */
.cat-card.cat-content     { background: rgba(37, 99, 235, 0.06);  border-color: rgba(37, 99, 235, 0.22);  }
.cat-card.cat-technical   { background: rgba(124, 58, 237, 0.06); border-color: rgba(124, 58, 237, 0.22); }
.cat-card.cat-performance { background: rgba(5, 150, 105, 0.06);  border-color: rgba(5, 150, 105, 0.22);  }
.cat-card.cat-mobile      { background: rgba(217, 119, 6, 0.07);  border-color: rgba(217, 119, 6, 0.22);  }
.cat-card.cat-social      { background: rgba(225, 29, 72, 0.06);  border-color: rgba(225, 29, 72, 0.22);  }
.cat-card.cat-off_page    { background: rgba(13, 148, 136, 0.06); border-color: rgba(13, 148, 136, 0.22); }
/* Per-category accent on the label so the row reads as a coordinated
   set at a glance. The numeric score stays in the neutral ink color. */
.cat-card.cat-content     .cat-card-label { color: rgb(29, 78, 216); }
.cat-card.cat-technical   .cat-card-label { color: rgb(91, 33, 182); }
.cat-card.cat-performance .cat-card-label { color: rgb(4, 120, 87);  }
.cat-card.cat-mobile      .cat-card-label { color: rgb(146, 64, 14); }
.cat-card.cat-social      .cat-card-label { color: rgb(159, 18, 57); }
.cat-card.cat-off_page    .cat-card-label { color: rgb(15, 118, 110);}

.cat-card-label {
    grid-row: 1; grid-column: 1;
    font-size: 12px; font-weight: 700;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: var(--ink-500);
}
.cat-card-grade {
    grid-row: 1 / span 2; grid-column: 2;
    align-self: center;
    width: 40px; height: 40px;
    border-radius: 50%;
    font-size: 20px; font-weight: 800;
    color: var(--ink);
    background: rgba(0, 0, 0, 0.06);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.cat-card-score {
    grid-row: 2; grid-column: 1;
    font-size: 28px; font-weight: 700;
    font-feature-settings: var(--tnum);
    color: var(--ink);
    line-height: 1;
}

/* ========================================================================
   Recommendations card
   ======================================================================== */
.recommendations-region {
    background: #fff;
    border: 1px solid var(--ink-100);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-sm);
    padding: 20px 24px;
    margin-bottom: 20px;
}
.section-h {
    font-size: 17px;
    font-weight: 700;
    color: var(--ink);
    margin: 0 0 12px 0;
    letter-spacing: -0.2px;
}
.recommendations-list {
    margin: 0;
    padding-left: 22px;
    list-style: decimal;
}
.recommendations-list li {
    padding: 6px 0;
    font-size: 14px;
    color: var(--ink-700);
    line-height: 1.5;
}
.recommendations-list .rec-label {
    font-weight: 600;
    color: var(--ink);
}
.recommendations-list .rec-summary { color: var(--ink-500); }

/* ========================================================================
   Findings (per-category collapsible)
   ======================================================================== */
.findings-region {
    background: #fff;
    border: 1px solid var(--ink-100);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-sm);
    padding: 20px 24px;
    margin-bottom: 20px;
}
.findings-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}
.findings-toolbar .section-h { margin: 0; }
.findings-actions .export-form { display: inline-flex; gap: 8px; flex-wrap: wrap; }

.cat-details {
    border-top: 1px solid var(--ink-100);
    padding: 8px 0;
}
.cat-details:first-of-type { border-top: 0; }
.cat-details summary {
    cursor: pointer;
    list-style: none;
    padding: 10px 0;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.cat-details summary::-webkit-details-marker { display: none; }
.cat-details-title {
    display: flex; align-items: center; gap: 10px;
}
.cat-details-marker {
    display: inline-block;
    transition: transform 0.15s;
    color: var(--ink-400);
}
.cat-details[open] .cat-details-marker { transform: rotate(90deg); color: var(--brand-red); }
.cat-details-name {
    font-weight: 600;
    color: var(--ink);
    font-size: 15px;
}
.cat-details-meta {
    font-size: 12px;
    color: var(--ink-500);
    font-feature-settings: var(--tnum);
}
.cat-details-meta .meta-pass { color: rgb(15, 109, 49); }
.cat-details-meta .meta-warn { color: rgb(146, 64, 14); }
.cat-details-meta .meta-fail { color: rgb(159, 18, 18); }
.cat-details-score {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    font-feature-settings: var(--tnum);
    font-size: 18px;
    font-weight: 700;
    color: var(--ink);
}
.cat-details-score .cat-details-grade {
    width: 24px; height: 24px;
    border-radius: 50%;
    font-size: 11px;
    font-weight: 800;
    line-height: 1;
    background: var(--ink-100);
    color: var(--ink);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.cat-details-grade.grade-A { background: rgba(22, 163, 74, 0.16); color: rgb(15, 109, 49); }
.cat-details-grade.grade-B { background: rgba(45, 167, 167, 0.16); color: rgb(20, 110, 110); }
.cat-details-grade.grade-C { background: rgba(217, 119, 6, 0.18); color: rgb(146, 64, 14); }
.cat-details-grade.grade-D { background: rgba(234, 88, 12, 0.18); color: rgb(154, 52, 18); }
.cat-details-grade.grade-F { background: rgba(220, 38, 38, 0.2); color: rgb(159, 18, 18); }

.findings-rows {
    margin-top: 6px;
    margin-bottom: 12px;
}
/* Sub-section header within a category (Important / Other). Only
   rendered when the category contains a mix of severities; when
   everything is the same level, the header is suppressed by JS. */
.findings-sub-h {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.4px;
    color: var(--ink-500);
    margin: 14px 0 4px 0;
    padding-top: 6px;
    border-top: 1px solid var(--ink-50);
}
.findings-rows .findings-sub-h:first-child {
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
}
.finding-row {
    display: grid;
    grid-template-columns: 22px 1fr;
    gap: 0 12px;
    padding: 8px 0;
    border-top: 1px solid var(--ink-50);
    align-items: start;
}
.finding-row:first-child { border-top: 0; }
.finding-row .finding-icon {
    grid-row: 1 / span 2;
    grid-column: 1;
    margin-top: 2px;
    width: 18px; height: 18px;
    border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    flex: 0 0 auto;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
}
.finding-row.status-pass .finding-icon { background: rgba(22, 163, 74, 0.2); color: rgb(15, 109, 49); }
.finding-row.status-warn .finding-icon { background: rgba(217, 119, 6, 0.22); color: rgb(146, 64, 14); }
.finding-row.status-fail .finding-icon { background: rgba(220, 38, 38, 0.22); color: rgb(159, 18, 18); }
.finding-row .finding-label {
    grid-row: 1; grid-column: 2;
    font-weight: 600;
    color: var(--ink);
    font-size: 14px;
}
.finding-row .finding-summary {
    grid-row: 2; grid-column: 2;
    font-size: 13px;
    color: var(--ink-500);
    line-height: 1.5;
}
/* Quoted snippet of the actual content (title, description, canonical
   URL, OG values, H1 text, etc.). Sits between the summary and the
   fix/details. */
.finding-row .finding-excerpt {
    grid-row: 3; grid-column: 2;
    margin-top: 4px;
    padding: 6px 10px;
    background: var(--ink-50);
    border-left: 3px solid var(--ink-200);
    border-radius: 0 var(--r-sm) var(--r-sm) 0;
    font-size: 13px;
    color: var(--ink);
    line-height: 1.45;
    word-break: break-word;
    overflow-wrap: anywhere;
}
.finding-row .finding-value {
    /* Pin to column 2 explicitly. Without this, auto-placement drops
       the value into column 1 (the 22px icon column) and breaks every
       word onto its own line. */
    grid-row: 3; grid-column: 2;
    font-size: 12px;
    color: var(--ink-500);
    font-feature-settings: var(--tnum);
    margin-top: 2px;
    word-break: break-word;
    overflow-wrap: anywhere;
}
.finding-row .finding-fix {
    grid-row: 4; grid-column: 2;
    font-size: 12.5px;
    color: var(--ink-700);
    margin-top: 4px;
    padding-top: 6px;
    border-top: 1px dashed var(--ink-100);
}
.finding-row .finding-fix .fix-prefix {
    font-weight: 700;
    color: var(--brand-red);
}
.finding-row .finding-details-btn {
    grid-row: 5; grid-column: 2;
    appearance: none;
    background: transparent;
    border: 1px solid var(--ink-200);
    border-radius: var(--r-sm);
    padding: 4px 10px;
    margin-top: 6px;
    justify-self: start;
    font-size: 12px;
    font-weight: 600;
    color: var(--ink-700);
    cursor: pointer;
    transition: border-color 0.12s, color 0.12s;
}
.finding-row .finding-details-btn:hover {
    border-color: var(--brand-red);
    color: var(--brand-red);
}

/* Details-modal body styles (.modal-body max-height, .detail-list,
   .detail-tag, .detail-main) lifted to shared code/assets/css/tools.css
   when SEO Optimizer started consuming the same modal. */
/* The "critical" severity badge was misleading because it
   coloured the label red even when the check passed - users
   read it as "this is failing". Severity now only affects
   ordering in the recommendations list. */

/* ========================================================================
   History strip
   ======================================================================== */
.history-region {
    margin-top: 32px;
    padding: 20px 24px;
    border-top: 1px solid var(--ink-100);
}
.history-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 10px;
}
.history-item {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: #fff;
    border: 1px solid var(--ink-100);
    border-radius: var(--r-sm);
    cursor: pointer;
    transition: border-color 0.15s, transform 0.15s;
}
.history-item:hover { border-color: var(--brand-red); transform: translateY(-1px); }
.history-item-grade {
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px;
    font-weight: 800;
    font-size: 14px;
    border-radius: 50%;
    background: var(--ink-100); color: var(--ink);
}
.history-item-grade.grade-A { background: rgba(22, 163, 74, 0.18); color: rgb(15, 109, 49); }
.history-item-grade.grade-B { background: rgba(45, 167, 167, 0.18); color: rgb(20, 110, 110); }
.history-item-grade.grade-C { background: rgba(217, 119, 6, 0.2); color: rgb(146, 64, 14); }
.history-item-grade.grade-D { background: rgba(234, 88, 12, 0.2); color: rgb(154, 52, 18); }
.history-item-grade.grade-F { background: rgba(220, 38, 38, 0.22); color: rgb(159, 18, 18); }
.history-item-body { min-width: 0; }
.history-item-url {
    font-size: 13px; font-weight: 600;
    color: var(--ink);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.history-item-kw {
    font-size: 11px;
    color: var(--ink-700);
    font-style: italic;
    margin-top: 1px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.history-item-kw::before { content: ''; }
.history-item-meta { font-size: 11px; color: var(--ink-500); }

/* `.detail-main mark` lifted to shared tools.css. */

.history-item-delete {
    appearance: none; border: 0; background: transparent;
    color: var(--ink-400);
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 4px 6px;
    border-radius: 4px;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s, background 0.15s;
}
.history-item:hover .history-item-delete { opacity: 1; }
.history-item-delete:hover { color: rgb(159, 18, 18); background: rgba(220, 38, 38, 0.1); }

/* ========================================================================
   Notice banner (SPA detected, HTTP error, etc.)
   ======================================================================== */
.notice-region {
    display: grid;
    grid-template-columns: 40px 1fr;
    gap: 16px;
    align-items: start;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: var(--r-md);
    padding: 14px 18px;
    margin-bottom: 16px;
}
.notice-region[hidden] { display: none; }
.notice-region.notice-http_error {
    background: rgba(220, 38, 38, 0.06);
    border-color: rgba(220, 38, 38, 0.2);
}
.notice-icon {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: #f59e0b;
    color: #fff;
    font-weight: 800;
    font-size: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    margin-top: 2px;
}
.notice-region.notice-http_error .notice-icon {
    background: rgb(220, 38, 38);
}
.notice-title {
    margin: 0 0 4px 0;
    font-size: 14px;
    font-weight: 700;
    color: #92400e;
}
.notice-region.notice-http_error .notice-title { color: rgb(159, 18, 18); }
.notice-msg {
    margin: 0;
    font-size: 13px;
    color: var(--ink-700);
    line-height: 1.5;
}

/* ========================================================================
   Errors region
   ======================================================================== */
.errors-region {
    background: rgba(220, 38, 38, 0.06);
    border: 1px solid rgba(220, 38, 38, 0.2);
    border-radius: var(--r-md);
    padding: 16px 20px;
    margin-bottom: 16px;
}
.errors-title {
    margin: 0 0 6px 0;
    font-size: 14px;
    font-weight: 700;
    color: rgb(159, 18, 18);
}
.errors-msg { margin: 0; font-size: 13px; color: var(--ink-700); }

/* Back-to-top styles live in shared code/assets/css/tools.css (lifted
   2026-05-21 when the homepage became a second consumer). */

/* ========================================================================
   Disabled buttons
   ======================================================================== */
.primary-btn:disabled,
.ghost-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
