/* Content Compare — single shared stylesheet */

:root {
    --bg: #f4f5f7;
    --card: #fff;
    --border: #d8dce3;
    --text: #1a1d24;
    --muted: #5c6370;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --error: #b91c1c;
    --match-bg: #e0f2fe;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    padding: 1.5rem;
}

body.cc-layout-centered {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.wrap {
    max-width: 1200px;
    margin: 0 auto;
}

main {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem 1.25rem;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
}

body.cc-layout-centered main {
    width: 100%;
    max-width: 32rem;
    padding: 1.75rem 1.5rem;
}

h1 {
    margin: 0 0 0.35rem;
    font-size: 1.35rem;
    font-weight: 600;
}

h2 {
    margin: 0 0 0.5rem;
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1.35;
    color: var(--accent);
}

body.cc-layout-centered h2 {
    margin-bottom: 1.25rem;
}

.hidden {
    display: none !important;
}

/* Step 1 */
.setup {
    margin: 0 0 1rem;
    padding: 0.65rem 0.75rem;
    font-size: 0.88rem;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 8px;
    color: #92400e;
}

.error {
    margin: 0 0 1rem;
    padding: 0.65rem 0.75rem;
    font-size: 0.9rem;
    color: var(--error);
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
}

/* Centered card forms (steps 1–2) */
body.cc-layout-centered label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 0.4rem;
}

body.cc-layout-centered input[type="text"] {
    width: 100%;
    padding: 0.65rem 0.75rem;
    font-size: 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 1.1rem;
}

body.cc-layout-centered input[type="text"]:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
    border-color: var(--accent);
}

body.cc-layout-centered input[type="text"]::placeholder {
    color: #9ca3af;
}

body.cc-layout-centered input[type="text"]:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

body.cc-layout-centered button[type="submit"] {
    width: 100%;
    margin-top: 0.25rem;
    padding: 0.7rem 1rem;
    font-size: 1rem;
    font-weight: 600;
    color: #fff;
    background: var(--accent);
    border: none;
    border-radius: 8px;
    cursor: pointer;
}

body.cc-layout-centered button[type="submit"]:hover:not(:disabled) {
    background: var(--accent-hover);
}

body.cc-layout-centered button[type="submit"]:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.back {
    display: inline-block;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    color: var(--accent);
    text-decoration: none;
}

.back:hover {
    text-decoration: underline;
}

.meta {
    font-size: 0.88rem;
    color: var(--muted);
    margin-bottom: 1rem;
    word-break: break-all;
}

.error-box {
    padding: 0.75rem 1rem;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    color: var(--error);
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

/* Demo crawl link (steps 2 & 4 domain form) */
.demo-crawl-wrap {
    text-align: center;
    margin-top: 0.65rem;
    font-size: 0.875rem;
}

.demo-crawl-link {
    color: var(--accent);
    text-decoration: none;
}

.demo-crawl-link:hover {
    text-decoration: underline;
}

.step4-demo-row {
    width: 100%;
    text-align: right;
    margin: 0 0 0.5rem;
    font-size: 0.875rem;
}

/* Step 3 header */
.step3-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem 1rem;
    margin-bottom: 0.5rem;
}

.step3-header h2 {
    margin: 0;
    flex: 1 1 auto;
    min-width: min(100%, 14rem);
}

.step3-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    justify-content: flex-end;
}

.step3-demo-row {
    width: 100%;
    text-align: right;
    margin: 0 0 0.5rem;
    font-size: 0.875rem;
}

/* Steps 4–5 & preview header */
.step-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem 1rem;
    margin-bottom: 0.5rem;
}

.step-header h2 {
    margin: 0;
    flex: 1 1 auto;
    min-width: min(100%, 14rem);
}

.step-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    justify-content: flex-end;
}

.btn-step {
    padding: 0.45rem 0.9rem;
    font-size: 0.875rem;
    font-weight: 600;
    font-family: inherit;
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text);
    line-height: 1.2;
}

.btn-step:hover:not(:disabled) {
    background: #f9fafb;
    border-color: #c4c9d4;
}

.btn-step.primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.btn-step.primary:hover:not(:disabled) {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

.btn-step:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Step 4 domain form */
.form-domain label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 0.4rem;
}

.form-domain input[type="text"] {
    width: 100%;
    max-width: 32rem;
    padding: 0.65rem 0.75rem;
    font-size: 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 1.1rem;
}

.form-domain input[type="text"]:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
    border-color: var(--accent);
}

.form-domain .hint {
    font-size: 0.85rem;
    color: var(--muted);
    margin: -0.35rem 0 1rem;
    max-width: 36rem;
    line-height: 1.4;
}

.form-domain .hint .mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.92em;
    word-break: break-all;
}

/* Loading panels & crawl/compare spinners */
.loading-panel {
    margin: 1rem 0 1.5rem;
}

.loading-panel > p,
.loading-panel .cc-visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.loading-logo-wrap {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 0.5rem;
    padding: 1rem 0 0.5rem;
}

@keyframes cc-baseball-spin {
    to {
        transform: rotate(360deg);
    }
}

.cc-baseball-spinner {
    display: inline-block;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    background: url('../_img/baseball.png') center / contain no-repeat;
    animation: cc-baseball-spin 0.8s linear infinite;
    transform-origin: 50% 50%;
    cursor: pointer;
}

/* Comic loading bubble (JS injects .cc-loading-bubble) — hover baseball to show */
.cc-loading-bubble-host {
    position: relative;
    cursor: pointer;
}

.press-start-2p-regular {
    font-family: "Press Start 2P", system-ui;
    font-weight: 400;
    font-style: normal;
}

.cc-loading-bubble {
    position: absolute;
    bottom: calc(100% + 18px);
    left: 50%;
    transform: translateX(-50%);
    max-width: 18rem;
    padding: 0.55rem 0.75rem;
    background: #ffffff;
    border: 2px solid #6E00B3;
    border-radius: 0.4em;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
    font-size: clamp(0.42rem, 1.1vw, 0.55rem);
    line-height: 1.75;
    color: #111111;
    text-align: center;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.12s ease, visibility 0.12s ease;
    z-index: 20;
}

.cc-loading-bubble.is-visible {
    opacity: 1;
    visibility: visible;
}

.cc-loading-bubble::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 0;
    border: 14px solid transparent;
    border-top-color: #ffffff;
    border-bottom: 0;
    border-left: 0;
    margin-left: -10px;
    margin-bottom: -14px;
}

.cc-loading-bubble::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 0;
    border: 16px solid transparent;
    border-top-color: #6E00B3;
    border-bottom: 0;
    border-left: 0;
    margin-left: -12px;
    margin-bottom: -18px;
    z-index: -1;
}

/* Crawl results tables */
.table-scroll {
    overflow-x: auto;
    margin-top: 0.5rem;
}

.table-scroll table.crawl-results {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.table-scroll table.crawl-results th,
.table-scroll table.crawl-results td {
    width: calc(100% / 6);
    border: 1px solid var(--border);
    padding: 0.5rem 0.6rem;
    vertical-align: top;
    text-align: left;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.table-scroll table.crawl-results th {
    background: #f0f2f5;
    font-weight: 600;
    white-space: normal;
}

.table-scroll table.crawl-results td.num {
    white-space: normal;
}

.table-scroll table.crawl-results td.url {
    word-break: break-all;
}

.table-scroll table.crawl-results .content-wrap {
    max-width: 100%;
}

.table-scroll table.crawl-results a {
    color: var(--accent);
}

.table-scroll table.crawl-results a:hover {
    color: var(--accent-hover);
}

.content-preview {
    max-height: calc(1.45em * 3);
    overflow: hidden;
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.45;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.8rem;
}

.content-wrap.expanded .content-preview {
    max-height: none;
}

.expand-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    margin-top: 0.35rem;
    padding: 0.25rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #f9fafb;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    color: var(--muted);
}

.expand-toggle:hover {
    background: #f3f4f6;
    color: var(--text);
}

/* Step 5 match panel */
.old-block {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.old-block:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.match-panel {
    margin-top: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--match-bg);
    border: 1px solid #bae6fd;
    border-radius: 10px;
}

.match-panel-title {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    margin: 0 0 0.65rem;
}

.match-table-scroll {
    margin-top: 0;
}

.match-results {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    table-layout: fixed;
}

.match-results td {
    border: 1px solid rgba(37, 99, 235, 0.22);
    padding: 0.5rem 0.55rem;
    vertical-align: top;
    text-align: left;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.match-col-radio {
    width: 2.5rem;
    text-align: center;
    vertical-align: top;
    padding-top: 0.55rem;
}

.match-col-radio input {
    width: 1.1rem;
    height: 1.1rem;
    cursor: pointer;
}

.match-col-url {
    width: 22%;
    word-break: break-all;
    font-size: 0.85rem;
}

.match-col-h1 {
    width: 16%;
    font-weight: 600;
    font-size: 0.9rem;
}

.match-col-content {
    min-width: 0;
}

.match-col-content .content-preview {
    font-size: 0.8rem;
}

.match-col-score {
    min-width: 5.5rem;
    text-align: right;
    font-weight: 700;
    white-space: nowrap;
    vertical-align: top;
    overflow: visible;
}

.match-results td.match-col-score {
    overflow: visible;
}

.score-longest-run-trigger {
    position: relative;
    display: inline-block;
    font-weight: 600;
    color: var(--muted);
    cursor: help;
    outline: none;
}

.score-longest-run-trigger:focus-visible .score-longest-run-num {
    text-decoration: underline;
}

.score-longest-run-tip {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    min-width: 11rem;
    max-width: min(22rem, 85vw);
    padding: 0.5rem 0.65rem;
    font-size: 0.8rem;
    font-weight: 500;
    line-height: 1.4;
    color: var(--text);
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
    white-space: normal;
    word-break: break-word;
    z-index: 100;
    text-align: left;
    pointer-events: none;
}

.score-longest-run-trigger:hover .score-longest-run-tip,
.score-longest-run-trigger:focus .score-longest-run-tip {
    display: block;
}

.match-results a {
    color: var(--accent);
}

.match-results a:hover {
    color: var(--accent-hover);
}

.match-row-none .match-none-label {
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
}

.empty-matches {
    font-size: 0.9rem;
    color: var(--muted);
    margin: 0;
}

/* Preview page */
#page-loading {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    padding: 1.5rem;
}

#page-loading > p {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.step-actions h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    color: var(--accent);
}

.redirect-file-actions {
    flex-direction: column;
    align-items: flex-end;
    align-self: flex-start;
    text-align: right;
    max-width: min(100%, 22rem);
}

.redirect-file-actions .redirect-hint {
    margin: 0.35rem 0 0;
    font-size: 0.8rem;
    color: var(--muted);
    text-align: right;
    line-height: 1.35;
}

.form-generate-csv {
    margin: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.5rem;
}

.form-generate-csv fieldset {
    border: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    align-items: flex-start;
    width: 100%;
}

.form-generate-csv .radio-row {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.875rem;
    cursor: pointer;
    text-align: left;
}

.form-generate-csv .radio-row input {
    width: 1rem;
    height: 1rem;
    cursor: pointer;
    flex-shrink: 0;
}

.custom-url-wrap {
    width: 100%;
    text-align: left;
}

.custom-url-wrap label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--muted);
    margin-bottom: 0.3rem;
}

.custom-url-wrap input[type="text"] {
    width: 100%;
    max-width: 22rem;
    padding: 0.5rem 0.55rem;
    font-size: 0.875rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
}

.custom-url-wrap input[type="text"]:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
    border-color: var(--accent);
}

.form-generate-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-top: 0.15rem;
    align-self: flex-end;
}

.btn-generate {
    padding: 0.45rem 1rem;
    font-size: 0.875rem;
    font-weight: 700;
    font-family: inherit;
    border-radius: 8px;
    cursor: pointer;
    background: var(--accent);
    color: #fff;
    border: 1px solid var(--accent);
}

.btn-generate:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

table.preview-map {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    table-layout: fixed;
}

table.preview-map th,
table.preview-map td {
    border: 1px solid var(--border);
    padding: 0.55rem 0.65rem;
    vertical-align: top;
    text-align: left;
    word-break: break-all;
    overflow-wrap: anywhere;
}

table.preview-map th {
    background: #f0f2f5;
    font-weight: 700;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
}

table.preview-map td a {
    color: var(--accent);
}

table.preview-map td a:hover {
    color: var(--accent-hover);
}

.preview-empty {
    margin: 0;
    font-size: 0.9rem;
    color: var(--muted);
}
