/* =========================================
   DI.CSS — DI Calculator page
   ========================================= */

body { overflow-y: auto; }

.di-main {
    padding-top: calc(var(--nav-h) + 36px);
    padding-bottom: 80px;
    max-width: 1100px;
    margin: 0 auto;
    padding-left: 20px;
    padding-right: 20px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

/* Re-use tool nav pills from training.css */
.trainer-tools-row {
    display: flex;
    gap: 0.35rem;
}
.trainer-tool-link {
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.35em 0.9em;
    border-radius: 999px;
    border: 1px solid rgba(255,255,255,0.15);
    color: rgba(255,255,255,0.5);
    text-decoration: none;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
    letter-spacing: 0.03em;
}
.trainer-tool-link:hover  { color: #fff; border-color: rgba(255,255,255,0.35); }
.trainer-tool-link.active { background: rgba(0,200,255,0.12); color: #00c8ff; border-color: rgba(0,200,255,0.4); }

/* Header */
.trainer-header  { padding: 0 4px; }
.trainer-title-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}
.trainer-badge {
    display: inline-block;
    padding: 4px 14px;
    border-radius: 999px;
    border: 1px solid var(--accent-purple);
    color: var(--accent-purple);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    background: rgba(124,58,237,0.07);
    margin-bottom: 10px;
}
.trainer-header h1 {
    font-size: clamp(1.5rem, 4vw, 2.4rem);
    font-weight: 900;
    letter-spacing: -0.03em;
    background: linear-gradient(135deg, var(--text-primary) 0%, var(--accent-cyan) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
}
.trainer-sub { color: var(--text-muted); font-size: 0.92rem; line-height: 1.6; max-width: 520px; }
.trainer-sub strong { color: var(--text-primary); font-weight: 600; }

.trainer-status-wrap { display: flex; align-items: center; gap: 8px; padding-top: 6px; white-space: nowrap; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--text-muted); transition: background 0.3s, box-shadow 0.3s; }
.status-dot.connected { background: var(--accent-green); box-shadow: 0 0 8px var(--accent-green); }
.status-dot.adapter   { background: var(--accent-amber); box-shadow: 0 0 8px var(--accent-amber); }
.status-dot.failed    { background: var(--accent-red);   box-shadow: 0 0 8px var(--accent-red); }
.status-label { font-size: 0.8rem; color: var(--text-muted); letter-spacing: 0.04em; }
.status-dl-link {
    font-size: 0.8rem;
    color: #00c8ff;
    text-decoration: none;
    font-weight: 600;
    padding-left: 0.4rem;
    border-left: 1px solid rgba(255,255,255,0.12);
    white-space: nowrap;
    transition: color 0.15s;
}
.status-dl-link:hover { color: #fff; }
.status-dl-link[hidden] { display: none; }

/* ─── Config row ─────────────────────────────────────────────── */
.di-config {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding: 16px 20px;
    align-items: flex-end;
}

.di-config-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex: 1;
    min-width: 120px;
}

.di-config-group--percent { min-width: 160px; flex: 1.5; }

.di-label {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

.di-percent-val {
    font-size: 0.9rem;
    font-weight: 800;
    color: var(--accent-cyan);
    font-variant-numeric: tabular-nums;
}

.di-select {
    background: rgba(10,16,30,0.8);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.85rem;
    padding: 8px 10px;
    cursor: pointer;
    transition: border-color 0.15s;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' fill='%2364748b'%3E%3Cpath d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 28px;
}
.di-select:focus { outline: none; border-color: var(--accent-cyan); }

.di-slider {
    width: 100%;
    height: 4px;
    appearance: none;
    -webkit-appearance: none;
    background: linear-gradient(to right, var(--accent-cyan) var(--val, 32%), rgba(255,255,255,0.1) 0%);
    border-radius: 2px;
    cursor: pointer;
}
.di-slider::-webkit-slider-thumb {
    appearance: none;
    width: 16px; height: 16px;
    border-radius: 50%;
    background: var(--accent-cyan);
    box-shadow: 0 0 8px rgba(0,200,255,0.6);
    cursor: grab;
}
.di-slider::-moz-range-thumb {
    width: 16px; height: 16px;
    border-radius: 50%;
    background: var(--accent-cyan);
    border: none;
    cursor: grab;
}

/* ─── Body (stage + right panel) ────────────────────────────── */
.di-body {
    display: grid;
    grid-template-columns: 1fr 260px;
    gap: 16px;
    align-items: start;
}

/* Facing toggle */
.di-config-group--facing { min-width: 100px; flex: 0.8; }

.di-facing-btn {
    background: rgba(0,200,255,0.08);
    border: 1px solid rgba(0,200,255,0.35);
    border-radius: 8px;
    color: var(--accent-cyan);
    font-size: 0.85rem;
    font-weight: 700;
    padding: 8px 10px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    letter-spacing: 0.04em;
    white-space: nowrap;
}
.di-facing-btn:hover { background: rgba(0,200,255,0.15); }
.di-facing-btn--left {
    background: rgba(245,158,11,0.08);
    border-color: rgba(245,158,11,0.35);
    color: var(--accent-amber);
}
.di-facing-btn--left:hover { background: rgba(245,158,11,0.15); }

/* Stage canvas */
.di-stage-wrap {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow: hidden;
}

/* Stage controls (above legend) */
.di-stage-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 4px;
}

.di-stage-hint {
    font-size: 0.7rem;
    color: var(--text-muted);
    opacity: 0.6;
    font-style: italic;
}

.di-reset-btn {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 6px;
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 600;
    padding: 3px 10px;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
    letter-spacing: 0.05em;
}
.di-reset-btn:hover { border-color: rgba(255,255,255,0.35); color: var(--text-primary); }

.di-stage-canvas {
    width: 100%;
    display: block;
    border-radius: 6px;
    background: rgba(5,8,15,0.6);
}

.di-stage-legend {
    display: flex;
    gap: 16px;
    padding: 0 4px;
}
.di-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    color: var(--text-muted);
}
.di-legend-dot {
    width: 10px; height: 3px;
    border-radius: 2px;
    flex-shrink: 0;
}
.di-legend-dot--act {
    width: 8px; height: 8px;
    border-radius: 50%;
    border: 2px solid #ffdd00;
    background: transparent;
    box-shadow: 0 0 4px rgba(255,221,0,0.5);
}
.di-legend-dash {
    width: 14px; height: 0;
    border-top: 2px dashed rgba(0,255,136,0.6);
    flex-shrink: 0;
}

/* Defense toggles */
.di-toggle-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    min-height: 36px;
}
.di-check {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.78rem;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}
.di-check input {
    accent-color: #00c8ff;
    cursor: pointer;
}
.di-check:has(input:checked) {
    color: #00c8ff;
}
.di-check:has(input:disabled) {
    opacity: 0.35;
    cursor: not-allowed;
}

/* Right panel */
.di-right {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* DI circle */
.di-circle-wrap {
    padding: 14px 14px 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.di-circle-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.di-circle-title {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.di-no-controller {
    font-size: 0.68rem;
    color: var(--text-muted);
    opacity: 0.6;
    font-style: italic;
}

.di-circle-canvas {
    display: block;
    cursor: crosshair;
    border-radius: 50%;
}

/* Stats */
.di-stats {
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.di-stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.82rem;
}

.di-stat-label {
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.di-stat-value {
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    font-size: 0.88rem;
    transition: color 0.2s;
}

/* Survival badge */
.di-survival {
    text-align: center;
    font-size: 1.15rem;
    font-weight: 900;
    letter-spacing: 0.05em;
    line-height: 1.3;
    border-radius: 12px;
    padding: 14px;
    border: 1px solid var(--border-subtle);
    background: rgba(10,16,30,0.5);
    transition: background 0.25s, color 0.25s, border-color 0.25s;
}

.di-survival--lives {
    background: rgba(0,255,136,0.08);
    color: #00ff88;
    border-color: rgba(0,255,136,0.3);
    box-shadow: 0 0 20px rgba(0,255,136,0.15);
}

.di-survival--dies {
    background: rgba(255,51,102,0.08);
    color: #ff3366;
    border-color: rgba(255,51,102,0.3);
    box-shadow: 0 0 20px rgba(255,51,102,0.15);
}

.di-survival--tech {
    background: rgba(255,149,0,0.08);
    color: #ff9500;
    border-color: rgba(255,149,0,0.3);
    box-shadow: 0 0 20px rgba(255,149,0,0.15);
}

/* Credit */
.di-credit {
    margin-top: 10px;
    padding: 0 6px 4px;
    font-size: 0.72rem;
    color: var(--text-muted);
    opacity: 0.75;
}
.di-credit a {
    color: #00c8ff;
    text-decoration: none;
}
.di-credit a:hover {
    text-decoration: underline;
}

/* Sakurai info tooltip */
.di-sakurai {
    cursor: help;
    border-bottom: 1px dotted rgba(148,163,184,0.7);
}

/* Tip */
.di-tip {
    padding: 14px 20px;
    font-size: 0.82rem;
    color: var(--text-muted);
    line-height: 1.65;
}
.di-tip-label {
    font-weight: 700;
    color: var(--text-primary);
    margin-right: 4px;
}
.di-tip strong { color: var(--accent-cyan); }

/* ─── Responsive ─────────────────────────────────────────────── */
@media (max-width: 700px) {
    .di-body {
        grid-template-columns: 1fr;
    }

    .di-right {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }

    .di-circle-wrap {
        grid-column: 1 / -1;
    }

    .di-survival {
        align-self: center;
        font-size: 1.2rem;
        padding: 10px;
    }

    .di-config { gap: 10px; }
    .di-config-group { min-width: 100px; }
}

@media (max-width: 460px) {
    .di-right { grid-template-columns: 1fr; }
}
