/* Pairwise Ranking Tool - follows site.css design system */

.tool-hero {
    padding: 60px 0 40px;
    border-bottom: 1px solid var(--line);
}

.tool-hero-inner {
    width: min(1180px, calc(100% - 40px));
    margin: 0 auto;
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
    font-size: 13px;
    font-weight: 600;
}

.breadcrumb a {
    color: var(--dim);
    text-decoration: none;
}

.breadcrumb a:hover {
    color: var(--text);
}

.breadcrumb span {
    color: var(--faint);
}

.breadcrumb span[aria-current] {
    color: var(--muted);
}

.tool-hero h1 {
    margin: 0 0 12px;
    font-size: 52px;
    line-height: 1.05;
    font-weight: 900;
    letter-spacing: 0;
}

.tool-subtitle {
    margin: 0;
    color: var(--muted);
    font-size: 20px;
    line-height: 1.5;
    max-width: 640px;
}

/* Tool Section */
.tool-section {
    padding: 48px 0;
    background: 
        linear-gradient(180deg, rgba(255, 255, 255, 0.025), rgba(255, 255, 255, 0)),
        var(--bg-soft);
    border-bottom: 1px solid var(--line);
}

.tool-inner {
    width: min(900px, calc(100% - 40px));
    margin: 0 auto;
}

.tool-app {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 32px;
}

/* Phase visibility */
.phase[hidden] {
    display: none;
}

/* Input Phase */
.input-header {
    margin-bottom: 24px;
}

.input-header h2 {
    margin: 0 0 8px;
    font-size: 24px;
    font-weight: 800;
    color: var(--text);
}

.input-header p {
    margin: 0;
    color: var(--muted);
    font-size: 15px;
}

.input-area {
    margin-bottom: 24px;
}

#items-input {
    width: 100%;
    min-height: 220px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    font-family: inherit;
    font-size: 15px;
    line-height: 1.6;
    resize: vertical;
    transition: border-color 0.15s ease;
}

#items-input::placeholder {
    color: var(--faint);
}

#items-input:focus {
    outline: none;
    border-color: var(--yellow);
}

.input-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-top: 16px;
    flex-wrap: wrap;
}

.file-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.file-label {
    cursor: pointer;
}

.file-label input {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
}

.file-hint {
    color: var(--dim);
    font-size: 13px;
}

.item-count {
    margin-top: 16px;
    padding: 12px 16px;
    background: var(--bg);
    border-radius: 6px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 600;
}

.item-count:empty {
    display: none;
}

.item-count.warning {
    background: rgba(255, 138, 34, 0.12);
    color: var(--orange);
}

.start-actions {
    display: flex;
    justify-content: center;
}

#start-ranking {
    min-width: 200px;
}

#start-ranking:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Comparison Phase */
.progress-section {
    margin-bottom: 32px;
}

.progress-bar {
    height: 8px;
    background: var(--bg);
    border-radius: 999px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--yellow);
    border-radius: 999px;
    transition: width 0.3s ease;
    width: 0%;
}

.progress-text {
    margin: 12px 0 0;
    text-align: center;
    color: var(--muted);
    font-size: 14px;
    font-weight: 600;
}

.comparison-area {
    text-align: center;
}

.compare-instruction {
    margin: 0 0 24px;
    color: var(--text);
    font-size: 20px;
    font-weight: 700;
}

.cards-container {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 20px;
    align-items: stretch;
}

.compare-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 180px;
    padding: 24px;
    border: 2px solid var(--line);
    border-radius: 12px;
    background: var(--bg);
    color: var(--text);
    font-family: inherit;
    cursor: pointer;
    transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.compare-card:hover,
.compare-card:focus {
    border-color: var(--yellow);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    outline: none;
}

.compare-card:active {
    transform: translateY(0);
}

.card-hint {
    display: block;
    margin-bottom: 12px;
    color: var(--dim);
    font-size: 12px;
    font-weight: 600;
}

.card-text {
    font-size: 18px;
    font-weight: 700;
    line-height: 1.4;
    text-align: center;
    word-break: break-word;
}

.vs-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--faint);
    font-size: 14px;
    font-weight: 800;
    text-transform: uppercase;
}

.compare-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 24px;
}

#undo-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.keyboard-hint {
    margin: 24px 0 0;
    text-align: center;
    color: var(--dim);
    font-size: 13px;
}

.keyboard-hint kbd {
    display: inline-block;
    padding: 2px 6px;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: var(--bg);
    color: var(--muted);
    font-family: inherit;
    font-size: 12px;
    font-weight: 700;
}

/* Results Phase */
.results-header {
    margin-bottom: 24px;
    text-align: center;
}

.results-header h2 {
    margin: 0 0 8px;
    font-size: 28px;
    font-weight: 800;
    color: var(--text);
}

#results-summary {
    margin: 0;
    color: var(--muted);
    font-size: 15px;
}

.results-list {
    margin: 0 0 32px;
    padding: 0;
    list-style: none;
    counter-reset: rank;
}

.results-list li {
    counter-increment: rank;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--bg);
    margin-bottom: 8px;
    transition: border-color 0.15s ease;
}

.results-list li:hover {
    border-color: var(--line-strong);
}

.results-list li::before {
    content: counter(rank);
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    border-radius: 999px;
    background: var(--yellow);
    color: #09090b;
    font-size: 14px;
    font-weight: 800;
}

.results-list li:nth-child(1)::before {
    background: var(--yellow);
}

.results-list li:nth-child(2)::before {
    background: var(--muted);
}

.results-list li:nth-child(3)::before {
    background: var(--orange);
}

.results-list li span {
    color: var(--text);
    font-size: 16px;
    font-weight: 600;
}

.results-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

.restart-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
    padding-top: 24px;
    border-top: 1px solid var(--line);
}

/* Darwin CTA */
.darwin-cta {
    margin-top: 32px;
    padding: 28px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: 
        linear-gradient(135deg, rgba(244, 207, 50, 0.08), rgba(36, 209, 154, 0.04) 50%, rgba(75, 148, 255, 0.06)),
        var(--bg);
    text-align: center;
}

.darwin-cta p {
    margin: 0 0 20px;
    color: var(--muted);
    font-size: 16px;
    line-height: 1.65;
}

.darwin-cta p strong {
    color: var(--text);
}

.darwin-cta .button {
    display: inline-flex;
}

.cta-byline {
    margin: 16px 0 0 !important;
    color: var(--dim) !important;
    font-size: 14px !important;
    font-style: italic;
}

/* Content Section */
.content-section {
    padding: 72px 0;
}

.content-inner {
    width: min(760px, calc(100% - 40px));
    margin: 0 auto;
}

.tool-article h2 {
    margin: 48px 0 20px;
    font-size: 28px;
    line-height: 1.2;
    font-weight: 800;
    color: var(--text);
}

.tool-article h2:first-child {
    margin-top: 0;
}

.tool-article p {
    margin: 0 0 20px;
    color: var(--muted);
    font-size: 17px;
    line-height: 1.75;
}

.tool-article p strong {
    color: var(--text);
    font-weight: 700;
}

.tool-article ul,
.tool-article ol {
    margin: 0 0 24px;
    padding-left: 24px;
    color: var(--muted);
}

.tool-article li {
    margin-bottom: 10px;
    font-size: 17px;
    line-height: 1.7;
}

.tool-article a {
    color: var(--yellow);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.tool-article a:hover {
    text-decoration: none;
}

.related-reading {
    margin-top: 40px;
    padding: 24px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
}

.related-reading h3 {
    margin: 0 0 12px;
    font-size: 16px;
    font-weight: 800;
    color: var(--text);
}

.related-reading ul {
    margin: 0;
    padding-left: 20px;
}

.related-reading li {
    margin-bottom: 6px;
    font-size: 15px;
}

/* FAQ Section */
.faq-section {
    margin-top: 56px;
    padding-top: 40px;
    border-top: 1px solid var(--line);
}

.faq-section h2 {
    margin: 0 0 28px;
    font-size: 24px;
    font-weight: 800;
    color: var(--text);
}

.faq-item {
    margin-bottom: 24px;
}

.faq-item h3 {
    margin: 0 0 8px;
    font-size: 17px;
    font-weight: 700;
    color: var(--text);
}

.faq-item p {
    margin: 0;
    color: var(--muted);
    font-size: 16px;
    line-height: 1.65;
}

/* Swipe support visual feedback */
.compare-card.swiping-left {
    transform: translateX(-10px) rotate(-2deg);
    border-color: var(--yellow);
}

.compare-card.swiping-right {
    transform: translateX(10px) rotate(2deg);
    border-color: var(--yellow);
}

/* Selection animation */
.compare-card.selected {
    border-color: var(--mint);
    background: rgba(36, 209, 154, 0.1);
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .progress-fill,
    .compare-card,
    .results-list li {
        transition: none;
    }
}

/* Mobile styles */
@media (max-width: 760px) {
    .tool-hero {
        padding: 40px 0 32px;
    }

    .tool-hero-inner {
        width: min(1180px, calc(100% - 28px));
    }

    .tool-hero h1 {
        font-size: 36px;
    }

    .tool-subtitle {
        font-size: 17px;
    }

    .tool-section {
        padding: 32px 0;
    }

    .tool-inner {
        width: min(900px, calc(100% - 28px));
    }

    .tool-app {
        padding: 24px 20px;
    }

    .input-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .file-actions {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    #try-example {
        width: 100%;
    }

    .cards-container {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .vs-divider {
        padding: 8px 0;
    }

    .compare-card {
        min-height: 120px;
        padding: 20px 16px;
    }

    .card-text {
        font-size: 16px;
    }

    .keyboard-hint {
        display: none;
    }

    .compare-actions {
        flex-direction: column;
    }

    .compare-actions button {
        width: 100%;
    }

    .results-actions,
    .restart-actions {
        flex-direction: column;
    }

    .results-actions button,
    .restart-actions button {
        width: 100%;
    }

    .content-inner {
        width: min(760px, calc(100% - 28px));
    }

    .tool-article h2 {
        font-size: 24px;
    }

    .tool-article p,
    .tool-article li {
        font-size: 16px;
    }

    .darwin-cta {
        padding: 24px 20px;
    }
}

@media (max-width: 480px) {
    .tool-hero h1 {
        font-size: 32px;
    }

    .breadcrumb {
        font-size: 12px;
    }

    .input-header h2 {
        font-size: 20px;
    }

    .results-header h2 {
        font-size: 24px;
    }
}
