/* SEO Optimizer - tool-specific styles on top of the shared
 * primitives in code/assets/css/tools.css.
 *
 * Mental model: checklist, not scorecard. Cards stack vertically,
 * each is a discrete task with a code snippet + effort badge + "mark
 * as done" checkbox. No category cards, no score header, no grade
 * letter.
 */

/* ========================================================================
   Form: URL + optional focus keyword (same shape as SEO Analyzer)
   ======================================================================== */
.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; }

.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
   ======================================================================== */
.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; }

/* ========================================================================
   Job header (URL + focus keyword - replaces the Analyzer score panel)
   ======================================================================== */
.job-header {
    background: #fff; border: 1px solid var(--ink-100);
    border-radius: var(--r-md); box-shadow: var(--shadow-sm);
    padding: 16px 20px; margin-bottom: 16px;
    display: grid; grid-template-columns: 1fr; gap: 8px;
}
.job-header-row {
    display: grid; grid-template-columns: 120px 1fr;
    gap: 12px; align-items: baseline;
}
.job-header-row[hidden] { display: none; }
.job-header-label {
    font-size: 11px; font-weight: 700;
    letter-spacing: 1.2px; text-transform: uppercase; color: var(--ink-500);
}
.job-header-value {
    font-size: 16px; font-weight: 600;
    color: var(--ink); word-break: break-all; min-width: 0;
}
#job-header-url { font-size: 17px; color: var(--brand-red); letter-spacing: -0.2px; }
#job-header-url a {
    color: inherit; text-decoration: none;
    border-bottom: 1px dashed currentColor; padding-bottom: 1px;
    transition: border-bottom-style 0.12s;
}
#job-header-url a:hover { border-bottom-style: solid; }
@media (max-width: 720px) {
    .job-header-row { grid-template-columns: 100px 1fr; gap: 8px; }
}

/* ========================================================================
   Checklist progress bar
   ======================================================================== */
.checklist-progress {
    background: #fff; border: 1px solid var(--ink-100);
    border-radius: var(--r-md); box-shadow: var(--shadow-sm);
    padding: 14px 20px; margin-bottom: 16px;
}
.checklist-progress[hidden] { display: none; }
.checklist-progress-row {
    display: flex; align-items: baseline; justify-content: space-between;
    margin-bottom: 10px; gap: 12px; flex-wrap: wrap;
}
.checklist-progress-text {
    font-size: 16px; font-weight: 700;
    color: var(--ink); font-feature-settings: var(--tnum);
}
.checklist-progress-counts {
    font-size: 12px; color: var(--ink-500);
    font-feature-settings: var(--tnum);
}
.checklist-progress-bar { height: 8px; background: var(--ink-100); border-radius: 999px; overflow: hidden; }
.checklist-progress-fill {
    height: 100%; width: 0%;
    background: linear-gradient(90deg, #2da7a7 0%, #16a34a 100%);
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}
.checklist-progress.is-complete .checklist-progress-fill {
    background: linear-gradient(90deg, #16a34a 0%, #22c55e 100%);
}

/* ========================================================================
   Effort filter chips
   ======================================================================== */
.effort-filter {
    display: flex; flex-wrap: wrap; align-items: center;
    gap: 8px; margin-bottom: 14px;
}
.effort-filter[hidden] { display: none; }
.effort-chip {
    appearance: none; border: 1px solid var(--ink-200);
    background: #fff; color: var(--ink-700);
    font-size: 12px; font-weight: 600;
    padding: 5px 12px; border-radius: 999px;
    cursor: pointer;
    transition: border-color 0.12s, background 0.12s, color 0.12s;
}
.effort-chip:hover { border-color: var(--brand-red); color: var(--brand-red); }
.effort-chip.is-active { background: var(--ink); border-color: var(--ink); color: #fff; }
.effort-chip:focus-visible { outline: 2px solid var(--brand-red); outline-offset: 2px; }
.effort-filter-counts { margin-left: auto; font-size: 11px; color: var(--ink-500); }

/* ========================================================================
   Checklist region (header + action cards)
   ======================================================================== */
.checklist-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;
    scroll-margin-top: 16px;
}
.checklist-region[hidden] { display: none; }
.checklist-toolbar {
    display: flex; justify-content: space-between; align-items: center;
    gap: 12px; margin-bottom: 14px; flex-wrap: wrap;
}
.section-h {
    font-size: 17px; font-weight: 700;
    color: var(--ink); margin: 0 0 12px 0; letter-spacing: -0.2px;
}
.checklist-toolbar .section-h { margin: 0; }
.export-form { display: inline-flex; gap: 8px; flex-wrap: wrap; }

/* ========================================================================
   Action card
   ======================================================================== */
.action-card {
    display: grid; grid-template-columns: 24px 1fr auto;
    gap: 4px 14px;
    padding: 14px 0;
    border-top: 1px solid var(--ink-50);
    align-items: start;
}
.action-card:first-child { border-top: 0; }
.action-card[hidden] { display: none; }
.action-card.is-done { opacity: 0.55; padding: 8px 0; }
.action-card.is-done .action-summary,
.action-card.is-done .action-expander,
.action-card.is-done .action-excerpt,
.action-card.is-done .action-meta { display: none; }
.action-card.is-done .action-label {
    text-decoration: line-through; font-weight: 500;
}

.action-check { grid-row: 1 / span 4; grid-column: 1; margin-top: 2px; }
.action-check input[type="checkbox"] {
    appearance: none;
    width: 22px; height: 22px;
    border: 2px solid var(--ink-200);
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
    position: relative;
    transition: background 0.12s, border-color 0.12s;
}
.action-check input[type="checkbox"]:hover { border-color: var(--brand-red); }
.action-check input[type="checkbox"]:checked {
    background: rgb(22, 163, 74);
    border-color: rgb(22, 163, 74);
}
.action-check input[type="checkbox"]:checked::after {
    content: ''; position: absolute;
    left: 5px; top: 1px;
    width: 6px; height: 12px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.action-body { grid-row: 1; grid-column: 2; min-width: 0; }
.action-label {
    font-size: 15px; font-weight: 700;
    color: var(--ink); margin-bottom: 2px;
    display: flex; align-items: center; gap: 8px;
}
.action-label::before {
    content: ''; display: inline-block;
    width: 4px; height: 14px;
    border-radius: 2px; flex: 0 0 auto;
}
.action-card.severity-critical .action-label::before { background: rgb(220, 38, 38); }
.action-card.severity-important .action-label::before { background: #f59e0b; }
.action-card.severity-minor .action-label::before { background: var(--ink-300); }

.action-summary {
    grid-row: 2; grid-column: 2;
    font-size: 13.5px; color: var(--ink-700);
    line-height: 1.5; margin-top: 2px;
}
.action-excerpt {
    grid-row: 3; grid-column: 2;
    margin-top: 6px; 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: 12.5px; color: var(--ink);
    line-height: 1.4; word-break: break-word;
}

.action-meta {
    grid-row: 1; grid-column: 3;
    display: flex; flex-direction: column;
    align-items: flex-end; gap: 4px; margin-left: 8px;
}
.effort-badge {
    display: inline-block;
    font-size: 10px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.8px;
    padding: 3px 8px;
    border-radius: var(--r-sm);
    background: var(--ink-100);
    color: var(--ink-700);
}
.effort-badge.effort-5min  { background: rgba(22, 163, 74, 0.16);  color: rgb(15, 109, 49); }
.effort-badge.effort-30min { background: rgba(45, 167, 167, 0.16); color: rgb(20, 110, 110); }
.effort-badge.effort-1hr   { background: rgba(217, 119, 6, 0.18);  color: rgb(146, 64, 14); }
.effort-badge.effort-project { background: rgba(124, 58, 237, 0.16); color: rgb(91, 33, 182); }

.impact-pill {
    font-size: 10px; font-weight: 700;
    color: var(--ink-500); font-feature-settings: var(--tnum);
}

.action-expander { grid-row: 4; grid-column: 2 / span 2; margin-top: 8px; }
.action-expander summary {
    cursor: pointer; list-style: none;
    font-size: 12.5px; font-weight: 600;
    color: var(--brand-red);
    display: inline-flex; align-items: center; gap: 6px;
    user-select: none;
}
.action-expander summary::-webkit-details-marker { display: none; }
.action-expander summary::before {
    content: '\25B8';
    display: inline-block;
    transition: transform 0.15s;
    color: var(--ink-400);
}
.action-expander[open] summary::before {
    transform: rotate(90deg); color: var(--brand-red);
}
.action-expander-body {
    margin-top: 8px; padding: 12px 14px;
    background: var(--ink-50);
    border-radius: var(--r-sm);
}
.action-fix-line {
    font-size: 13px; color: var(--ink-700);
    line-height: 1.45; margin: 0 0 10px 0;
}
.action-fix-line .fix-prefix { font-weight: 700; color: var(--brand-red); }
.action-snippet-wrap { position: relative; }
.action-snippet {
    margin: 0; padding: 10px 12px;
    background: #1f2937;
    color: #e5e7eb;
    border-radius: var(--r-sm);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 12px; line-height: 1.5;
    white-space: pre-wrap; word-break: break-word;
    overflow-x: auto;
}
.action-snippet-copy {
    position: absolute; top: 6px; right: 6px;
    appearance: none; border: 0;
    background: rgba(255,255,255,0.12);
    color: #e5e7eb;
    font-size: 11px; font-weight: 600;
    padding: 4px 10px; border-radius: 4px;
    cursor: pointer;
    transition: background 0.12s;
}
.action-snippet-copy:hover { background: rgba(255,255,255,0.24); }
.action-snippet-copy.is-copied { background: rgb(22, 163, 74); }

.action-details-btn {
    /* Sits as a top-level card child (peer of the "Show how to fix"
       expander) so users see it without expanding anything. */
    grid-row: 5; grid-column: 2 / span 2;
    justify-self: start;
    appearance: none;
    background: transparent;
    border: 1px solid var(--ink-200);
    border-radius: var(--r-sm);
    padding: 5px 12px;
    margin-top: 8px;
    font-size: 12px;
    font-weight: 600;
    color: var(--ink-700);
    cursor: pointer;
    transition: border-color 0.12s, color 0.12s;
}
.action-details-btn:hover { border-color: var(--brand-red); color: var(--brand-red); }
.action-card.is-done .action-details-btn { display: none; }
@media (max-width: 720px) {
    .action-details-btn { grid-column: 2; }
}

.checklist-done-banner {
    margin: 20px 0 0 0; padding: 14px 18px;
    background: rgba(22, 163, 74, 0.08);
    border: 1px solid rgba(22, 163, 74, 0.25);
    border-radius: var(--r-md);
    color: rgb(15, 109, 49);
    font-weight: 600; text-align: center;
}
.checklist-done-banner[hidden] { display: none; }

@media (max-width: 720px) {
    .action-card { grid-template-columns: 24px 1fr; }
    .action-meta {
        grid-row: 2; grid-column: 2;
        flex-direction: row;
        align-items: center;
        margin-left: 0;
        margin-top: 6px;
    }
    .action-summary { grid-row: 3; }
    .action-excerpt { grid-row: 4; }
    .action-expander { grid-row: 5; grid-column: 2; }
}

/* ========================================================================
   "Already correct" tail
   ======================================================================== */
.already-correct {
    background: #fff; border: 1px solid var(--ink-100);
    border-radius: var(--r-md); box-shadow: var(--shadow-sm);
    padding: 16px 24px; margin-bottom: 20px;
}
.already-correct[hidden] { display: none; }
.already-correct-summary {
    cursor: pointer; list-style: none;
    font-size: 14px; font-weight: 700;
    color: var(--ink);
    display: flex; align-items: center; gap: 10px;
    user-select: none;
}
.already-correct-summary::-webkit-details-marker { display: none; }
.already-correct-marker { color: var(--ink-400); transition: transform 0.15s; }
.already-correct[open] .already-correct-marker { transform: rotate(90deg); color: var(--brand-red); }
.already-correct-list {
    margin-top: 12px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 6px 16px;
}
.already-correct-item {
    font-size: 13px; color: var(--ink-700);
    display: flex; align-items: baseline; gap: 8px;
}
.already-correct-item::before {
    content: '\2713';
    color: rgb(22, 163, 74);
    font-weight: 700;
}

/* ========================================================================
   Notice + Errors
   ======================================================================== */
.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 {
    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); }

/* ========================================================================
   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-count {
    display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px;
    font-weight: 800; font-size: 14px;
    border-radius: 50%;
    background: var(--ink-100); color: var(--ink-700);
    font-feature-settings: var(--tnum);
}
.history-item-count.is-clear {
    background: rgba(22, 163, 74, 0.16);
    color: rgb(15, 109, 49);
}
.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-meta { font-size: 11px; color: var(--ink-500); }
.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);
}

/* ========================================================================
   Back-to-top button
   ======================================================================== */
.back-to-top {
    position: fixed;
    bottom: 90px; right: 20px;
    z-index: 50;
    width: 44px; height: 44px;
    border-radius: 50%;
    background: var(--brand-red); color: #fff;
    border: 0;
    box-shadow: 0 4px 14px rgba(0,0,0,0.18);
    cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.18s ease, transform 0.18s ease, background 0.12s;
}
.back-to-top.is-visible { opacity: 1; transform: translateY(0); }
.back-to-top[hidden] { display: none; }
.back-to-top:hover { background: var(--brand-red-dark, #a32626); }
.back-to-top:focus-visible { outline: 2px solid var(--brand-red); outline-offset: 3px; }
@media (max-width: 480px) {
    .back-to-top { bottom: 78px; right: 14px; width: 40px; height: 40px; }
}

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