/* ── Chapter Directory v3 Styles ──────────────────────────────────────── */

.chdir-wrapper {
    font-family: inherit;
    color: inherit;
    max-width: 100%;
}

/* ── Toolbar ─────────────────────────────────────────────────────────── */

.chdir-toolbar {
    margin-bottom: 16px;
}

.chdir-search-wrap {
    display: flex;
    align-items: center;
    position: relative;
    max-width: 640px;
}

.chdir-input-icon {
    position: absolute;
    left: 13px;
    font-size: 0.95rem;
    pointer-events: none;
    z-index: 1;
    line-height: 1;
}

/* Unified search input */
.chdir-search {
    flex: 1;
    padding: 10px 14px 10px 42px !important;
    font-size: 0.95rem;
    border: 2px solid #ddd;
    border-right: none;
    border-radius: 8px 0 0 8px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box !important;
    min-width: 0;
}

.chdir-search:focus {
    border-color: #0073aa;
    box-shadow: 0 0 0 3px rgba(0,115,170,0.15);
    z-index: 1;
    position: relative;
}

.chdir-nearest-btn {
    padding: 10px 16px;
    font-size: 0.9rem;
    font-weight: 600;
    background: #0073aa;
    color: #fff;
    border: 2px solid #0073aa;
    border-radius: 0 8px 8px 0;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
    white-space: nowrap;
    line-height: 1.4;
    flex-shrink: 0;
}

.chdir-nearest-btn:hover  { background: #005177; border-color: #005177; }
.chdir-nearest-btn:disabled { background: #7ab3cc; border-color: #7ab3cc; cursor: not-allowed; }

.chdir-clear-btn {
    margin-left: 8px;
    padding: 9px 12px;
    font-size: 0.85rem;
    background: transparent;
    color: #666;
    border: 1px solid #ccc;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
    flex-shrink: 0;
}

.chdir-clear-btn:hover { background: #f5f5f5; color: #333; }

.chdir-search-hint {
    margin: 7px 0 0;
    font-size: 0.8rem;
    color: #888;
    line-height: 1.4;
}

@media (max-width: 600px) {
    .chdir-search-wrap { flex-wrap: wrap; max-width: 100%; }
    .chdir-search      { border-right: 2px solid #ddd; border-radius: 8px; width: 100%; margin-bottom: 8px; }
    .chdir-nearest-btn { border-radius: 8px; width: 100%; }
    .chdir-clear-btn   { width: 100%; margin-left: 0; margin-top: 6px; text-align: center; }
}

/* ── Result banner ───────────────────────────────────────────────────── */

.chdir-nearest-result {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 14px;
    font-size: 0.95rem;
    line-height: 1.5;
}

.chdir-nearest-result--success {
    background: #eaf6fb;
    border: 1px solid #b3dff0;
    color: #004d6e;
}

.chdir-nearest-result--error {
    background: #fff4f4;
    border: 1px solid #f5c0c0;
    color: #7a1a1a;
}

/* ── Map ─────────────────────────────────────────────────────────────── */

.chdir-map-container {
    width: 100%;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid #ddd;
    margin-bottom: 28px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    background: #e8eaed;
}

/* Regular chapter pin — red heart */
.chdir-pin { background: transparent; border: none; }

.chdir-pin-dot {
    width: 22px;
    height: 22px;
    font-size: 22px;
    line-height: 1;
    text-align: center;
    filter: drop-shadow(0 2px 3px rgba(0,0,0,0.35));
    transition: transform 0.15s;
}
.chdir-pin-dot::before { content: '❤️'; }

.chdir-pin:hover .chdir-pin-dot { transform: scale(1.25); }

/* Nearest chapter pin — slightly larger with pulse */
.chdir-pin--nearest .chdir-pin-dot,
.chdir-pin-dot--nearest {
    font-size: 28px;
    width: 28px;
    height: 28px;
    animation: chdir-pulse 1.4s ease-out 2;
}

@keyframes chdir-pulse {
    0%   { filter: drop-shadow(0 0 0px rgba(220,20,60,0.8)); }
    70%  { filter: drop-shadow(0 0 10px rgba(220,20,60,0)); }
    100% { filter: drop-shadow(0 0 0px rgba(220,20,60,0)); }
}

/* "You are here" dot */
.chdir-you-icon { background: transparent; border: none; }

.chdir-you-dot {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #3b82f6;
    border: 3px solid #fff;
    box-shadow: 0 0 0 3px rgba(59,130,246,0.4);
    animation: chdir-you-pulse 2s infinite;
}

@keyframes chdir-you-pulse {
    0%, 100% { box-shadow: 0 0 0 3px rgba(59,130,246,0.4); }
    50%       { box-shadow: 0 0 0 8px rgba(59,130,246,0.0); }
}

/* Popup */
.chdir-popup {
    font-family: inherit;
    font-size: 0.9rem;
    line-height: 1.5;
    min-width: 180px;
}

.chdir-popup-name {
    display: block;
    font-size: 1rem;
    font-weight: 700;
    color: #1a1a1a;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 2px solid #f0f0f0;
}

.chdir-popup p {
    margin: 4px 0;
    color: #444;
    display: flex;
    align-items: flex-start;
    gap: 6px;
}

.chdir-popup a { color: #0073aa; text-decoration: none; word-break: break-all; overflow-wrap: anywhere; }
.chdir-popup .chdir-email-link {
    white-space: nowrap;
}
.chdir-popup a:hover { text-decoration: underline; }

/* ── Grid ────────────────────────────────────────────────────────────── */

.chdir-grid { display: grid; gap: 20px; }

.chdir-cols-1 { grid-template-columns: 1fr; }
.chdir-cols-2 { grid-template-columns: repeat(2, 1fr); }
.chdir-cols-3 { grid-template-columns: repeat(3, 1fr); }

@media (max-width: 768px) {
    .chdir-cols-2,
    .chdir-cols-3 { grid-template-columns: 1fr; }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .chdir-cols-3 { grid-template-columns: repeat(2, 1fr); }
}

/* ── Card ────────────────────────────────────────────────────────────── */

.chdir-card {
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    background: #fff;
    transition: box-shadow 0.2s, transform 0.2s, border-color 0.2s;
}

.chdir-card:hover {
    box-shadow: 0 6px 20px rgba(0,0,0,0.12);
    transform: translateY(-2px);
}

/* Nearest chapter card highlight */
.chdir-card--nearest {
    border-color: #e05c00 !important;
    box-shadow: 0 0 0 3px rgba(224,92,0,0.25), 0 6px 20px rgba(0,0,0,0.10) !important;
}

.chdir-card-body { padding: 18px 20px; }

.chdir-chapter-name {
    margin: 0 0 12px;
    font-size: 1.1rem;
    font-weight: 700;
    color: #1a1a1a;
    border-bottom: 2px solid #f0f0f0;
    padding-bottom: 10px;
    line-height: 1.3;
}

.chdir-card-body p {
    margin: 0 0 8px;
    font-size: 0.9rem;
    line-height: 1.5;
    color: #444;
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.chdir-card-body p:last-child { margin-bottom: 0; }
.chdir-icon { flex-shrink: 0; line-height: 1.5; }

.chdir-card-body a { color: #0073aa; text-decoration: none; word-break: break-word; }
.chdir-card-body a:hover { text-decoration: underline; color: #005177; }

/* ── States ──────────────────────────────────────────────────────────── */

.chdir-no-results,
.chdir-empty {
    text-align: center;
    color: #666;
    font-style: italic;
    padding: 32px 0;
}
