/* ================================================
   Opening Intelligence page — opening.css
   Extends the base style.css variables/components
   ================================================ */

/* ── Layout ──────────────────────────────────── */
.op-container {
    max-width: 900px;
    margin: 28px auto 60px;
    padding: 0 20px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* ── Input panel ─────────────────────────────── */
.op-input-panel {
    padding: 30px 32px 26px;
}

.op-input-header {
    margin-bottom: 24px;
}

.op-title-group {
    display: flex;
    align-items: flex-start;
    gap: 18px;
}

.op-icon {
    font-size: 2.2rem;
    color: var(--accent);
    margin-top: 4px;
    flex-shrink: 0;
}

.op-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 6px;
}

.op-subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.5;
    margin: 0;
}

/* ── PGN textarea ────────────────────────────── */
.op-pgn-area {
    margin-bottom: 18px;
}

.op-demo-link {
    margin: 6px 0 0;
    font-size: 0.8rem;
    text-align: right;
}

.op-demo-link a {
    color: var(--text-secondary);
    text-decoration: none;
    opacity: 0.75;
}

.op-demo-link a:hover {
    opacity: 1;
    text-decoration: underline;
}

.op-label {
    display: block;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
    font-size: 0.9rem;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.op-label i {
    color: var(--accent);
    margin-right: 6px;
}

.op-textarea {
    width: 100%;
    padding: 14px 16px;
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 2px solid var(--border);
    border-radius: 14px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 13px;
    line-height: 1.6;
    resize: vertical;
    transition: border-color 0.25s, box-shadow 0.25s;
}

.op-textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.14);
}

.op-textarea::placeholder {
    color: var(--text-secondary);
    opacity: 0.6;
}

/* ── Action buttons ──────────────────────────── */
.op-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.op-sample-btn {
    flex: 0 0 auto;
}

.op-analyze-btn {
    flex: 1;
}

/* ── Error banner ────────────────────────────── */
.op-error {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 16px;
    padding: 12px 16px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.35);
    border-radius: 10px;
    color: #ef4444;
    font-size: 0.9rem;
}

.op-error i {
    flex-shrink: 0;
    font-size: 1rem;
}

/* ── Loading ─────────────────────────────────── */
.op-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 28px;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.op-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: op-spin 0.8s linear infinite;
    flex-shrink: 0;
}

@keyframes op-spin {
    to { transform: rotate(360deg); }
}

/* ── Header row: ECO + book depth ────────────── */
.op-header-row {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 18px;
}

.op-eco-card,
.op-book-card {
    padding: 22px 24px;
}

.op-eco-code {
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--accent);
    line-height: 1;
    margin-bottom: 6px;
}

.op-eco-name {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-style: italic;
}

.op-book-stat {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 10px;
}

.op-stat-num {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1;
}

.op-stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.op-book-moves {
    font-family: 'Courier New', monospace;
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.7;
    word-break: break-word;
}

.op-move-num {
    color: var(--text-secondary);
    font-size: 0.75rem;
    opacity: 0.7;
}

.op-move-san {
    color: var(--text-primary);
}

/* ── Generic section shell ───────────────────── */
.op-section {
    padding: 26px 28px;
}

.op-section-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
}

.op-section-title i {
    color: var(--accent);
}

.op-eval-badge {
    margin-left: auto;
    padding: 4px 14px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-primary);
    font-family: 'Courier New', monospace;
}

/* ── Notice (no deviation) ───────────────────── */
.op-notice {
    padding: 16px 22px;
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.op-notice i {
    color: #22c55e;
    font-size: 1.1rem;
    flex-shrink: 0;
}

/* ── Deviation section ───────────────────────── */
.op-deviation-meta {
    font-size: 0.88rem;
    color: var(--text-secondary);
    margin-bottom: 18px;
}

.op-deviation-grid {
    display: flex;
    align-items: flex-start;
    gap: 20px;
}

.op-deviation-col {
    flex: 1;
}

.op-col-label {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.op-played-move {
    display: inline-block;
    padding: 8px 20px;
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.35);
    border-radius: 10px;
    font-family: 'Courier New', monospace;
    font-size: 1.15rem;
    font-weight: 700;
    color: #ef4444;
}

.op-vs {
    flex: 0 0 auto;
    align-self: center;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding-top: 26px;
}

/* Book alternatives list */
.op-alternatives {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.op-alt-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.op-alt-san {
    font-family: 'Courier New', monospace;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    width: 52px;
    flex-shrink: 0;
}

.op-alt-bar-wrap {
    flex: 1;
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
}

.op-alt-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent-glow));
    border-radius: 4px;
    transition: width 0.5s ease;
}

.op-alt-pct {
    font-size: 0.78rem;
    color: var(--text-secondary);
    width: 38px;
    text-align: right;
    flex-shrink: 0;
}

/* ── Opening plan ────────────────────────────── */
.op-plan-body {
    margin-bottom: 24px;
}

.op-best-move {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-bottom: 14px;
}

.op-best-move strong {
    font-family: 'Courier New', monospace;
    color: var(--text-primary);
    font-size: 1.05rem;
}

.op-plan-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.op-plan-list li {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 0.92rem;
    color: var(--text-primary);
    line-height: 1.55;
    padding: 10px 14px;
    background: var(--bg-secondary);
    border-radius: 10px;
    border-left: 3px solid var(--accent);
}

.op-plan-list li:first-child {
    border-left-color: #22c55e;
    font-weight: 600;
}

.op-plan-list li::before {
    content: '▸';
    color: var(--accent);
    font-size: 0.8rem;
    margin-top: 2px;
    flex-shrink: 0;
}

.op-plan-list li:first-child::before {
    content: '★';
    color: #22c55e;
}

/* ── Engine lines ────────────────────────────── */
.op-sub-title {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.op-sub-title i {
    color: var(--accent);
}

.op-lines {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.op-line-row {
    display: flex;
    align-items: baseline;
    gap: 10px;
    padding: 10px 14px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 0.88rem;
}

.op-line-rank {
    font-size: 0.72rem;
    color: var(--text-secondary);
    width: 16px;
    flex-shrink: 0;
}

.op-line-move {
    font-family: 'Courier New', monospace;
    font-weight: 700;
    color: var(--accent);
    min-width: 52px;
    flex-shrink: 0;
}

.op-line-eval {
    font-family: 'Courier New', monospace;
    font-size: 0.82rem;
    color: var(--text-secondary);
    min-width: 52px;
    flex-shrink: 0;
}

.op-line-pv {
    font-family: 'Courier New', monospace;
    color: var(--text-secondary);
    font-size: 0.82rem;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

/* ── Similar games ───────────────────────────── */
.op-games {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.op-game-card {
    padding: 16px 18px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 12px;
}

.op-game-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.op-game-players {
    font-weight: 700;
    color: var(--text-primary);
    font-size: 0.95rem;
    flex: 1;
}

.op-game-result {
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.78rem;
    font-weight: 700;
    flex-shrink: 0;
}

.op-game-result.white-win  { background: rgba(34,197,94,0.15);  color: #16a34a; }
.op-game-result.black-win  { background: rgba(239,68,68,0.12);  color: #dc2626; }
.op-game-result.draw       { background: rgba(156,163,175,0.2); color: #6b7280; }

.op-game-meta {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.op-game-tag {
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.op-game-tag strong {
    color: var(--accent);
    font-family: 'Courier New', monospace;
}

.op-game-moves {
    font-family: 'Courier New', monospace;
    font-size: 0.78rem;
    color: var(--text-secondary);
    line-height: 1.5;
    border-top: 1px solid var(--border);
    padding-top: 8px;
    word-break: break-word;
}

/* ── P28: game card action buttons ────────────── */
.op-game-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.op-replay-btn,
.op-download-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.78rem;
    padding: 4px 11px;
    transition: border-color 0.15s, color 0.15s;
}

.op-replay-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.op-download-btn:hover {
    border-color: #22c55e;
    color: #22c55e;
}

/* ── Utility ─────────────────────────────────── */
.hidden { display: none !important; }

/* ── Dark theme tweaks ───────────────────────── */
[data-theme="dark"] .op-textarea {
    background: var(--bg-secondary);
}

[data-theme="dark"] .op-line-row,
[data-theme="dark"] .op-game-card {
    background: var(--bg-secondary);
}

[data-theme="dark"] .op-plan-list li {
    background: var(--bg-secondary);
}

/* ── Responsive ──────────────────────────────── */
@media (max-width: 600px) {
    .op-header-row {
        grid-template-columns: 1fr;
    }

    .op-deviation-grid {
        flex-direction: column;
        gap: 16px;
    }

    .op-vs {
        align-self: flex-start;
        padding-top: 0;
    }

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

    .op-analyze-btn,
    .op-sample-btn {
        width: 100%;
    }
}
