/* ============================================================================
   routes.css — 사용자 추천 코스 전용 스타일
   - community.css 의 기본 토큰·컴포넌트 재활용
   ============================================================================ */

/* 지역 가로 스크롤 칩 */
.ro-region-strip {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 6px 2px;
    margin-bottom: 4px;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
}
.ro-region-strip::-webkit-scrollbar { height: 6px; }
.ro-region-strip::-webkit-scrollbar-thumb { background: var(--ro-gray-300); border-radius: 3px; }

.ro-region-chip {
    flex: 0 0 auto;
    padding: 8px 14px;
    border: 1px solid var(--ro-border);
    border-radius: 999px;
    background: var(--ro-surface);
    color: var(--ro-text);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    scroll-snap-align: start;
    transition: all 160ms;
}
.ro-region-chip:hover { border-color: var(--ro-primary-300); }
.ro-region-chip.active {
    background: var(--ro-primary-500);
    color: white;
    border-color: var(--ro-primary-500);
    font-weight: 700;
}

/* 코스 카드 그리드 */
.ro-route-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
    gap: 16px;
    margin-top: 16px;
}
.ro-route-card {
    display: flex;
    flex-direction: column;
    background: var(--ro-surface);
    border: 1px solid var(--ro-border);
    border-radius: var(--ro-radius-lg);
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    transition: transform 180ms, box-shadow 180ms, border-color 180ms;
}
.ro-route-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 28px rgba(0,0,0,0.08);
    border-color: var(--ro-primary-300);
}
.ro-route-card__thumb {
    position: relative;
    width: 100%;
    aspect-ratio: 16/9;
    background: var(--ro-gray-100) center/cover no-repeat;
}
.ro-route-card__dist {
    position: absolute;
    bottom: 10px; left: 10px;
    padding: 4px 10px;
    background: rgba(0,0,0,0.65);
    color: white;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}
.ro-route-card__body {
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}
.ro-route-card__title {
    margin: 0;
    font-size: var(--ro-text-md);
    font-weight: 700;
    color: var(--ro-text);
    line-height: 1.4;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
.ro-route-card__meta {
    display: flex; gap: 10px; flex-wrap: wrap;
    color: var(--ro-text-sub);
    font-size: 13px;
}
.ro-route-card__foot {
    margin-top: auto;
    display: flex; justify-content: space-between; align-items: center;
    font-size: 12px;
    color: var(--ro-text-sub);
}
.ro-route-card__author { font-weight: 600; color: var(--ro-text); }

/* 등록 폼 — 입력 모드 탭 (세그먼티드 컨트롤) */
.ro-mode-tabs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    padding: 4px;
    background: var(--ro-bg);
    border: 1px solid var(--ro-border);
    border-radius: 14px;
    margin-bottom: 20px;
}
.ro-mode-tab {
    padding: 10px 12px;
    background: transparent;
    border: none;
    border-radius: 10px;
    color: var(--ro-text-sub);
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    transition: background 160ms, color 160ms;
    text-align: center;
    white-space: nowrap;
}
.ro-mode-tab.active {
    background: var(--ro-surface);
    color: var(--ro-text);
    box-shadow: 0 1px 2px rgba(0,0,0,0.06), 0 2px 8px rgba(0,0,0,0.04);
}
.ro-mode-tab:hover:not(.active) { color: var(--ro-text); }

/* 비활성 패널은 완전히 숨김 — defensive (다른 규칙이 display 덮어쓰지 못하도록) */
.ro-mode-pane { display: none !important; }
.ro-mode-pane.active { display: block !important; }

/* GPX 업로드 영역 (drag&drop) — 점선·배경 다크모드 호환 */
.ro-gpx-drop {
    position: relative;
    display: flex;                /* ★ label 기본 display:inline 이라 가로로 쪼그라들던 버그 수정 */
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    box-sizing: border-box;
    min-height: 180px;
    border: 2px dashed var(--ro-primary-300, rgba(34,197,94,0.45));
    border-radius: 14px;
    padding: 40px 20px;
    text-align: center;
    background: var(--ro-primary-50, rgba(34,197,94,0.06));
    cursor: pointer;
    transition: border-color 160ms, background 160ms, transform 160ms;
}
.ro-gpx-drop:hover {
    border-color: var(--ro-primary-500);
    background: var(--ro-primary-100, rgba(34,197,94,0.10));
}
.ro-gpx-drop.dragging {
    border-color: var(--ro-accent-500);
    background: var(--ro-accent-50);
    transform: scale(1.01);
}
.ro-gpx-drop input[type=file] {
    position: absolute; inset: 0;
    width: 100%; height: 100%;
    opacity: 0; cursor: pointer;
}
.ro-gpx-drop__icon {
    font-size: 36px;
    opacity: 0.7;
    line-height: 1;
}
.ro-gpx-drop__text { margin: 12px 0 4px; font-weight: 800; color: var(--ro-primary-700); font-size: 15px; letter-spacing: -0.01em; }
.ro-gpx-drop__hint { font-size: 12px; color: var(--ro-text-sub); }

/* GPX 분석 결과 카드 */
.ro-gpx-result {
    display: none;
    margin-top: 14px;
    padding: 16px;
    background: var(--ro-success-50);
    border: 1px solid var(--ro-success-200);
    border-radius: var(--ro-radius-md);
}
.ro-gpx-result.show { display: block; }
.ro-gpx-result__row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 12px;
    margin-top: 8px;
}
.ro-gpx-result__stat { background: white; padding: 10px 12px; border-radius: 8px; text-align: center; }
.ro-gpx-result__stat strong { display: block; font-size: 18px; color: var(--ro-success-700); }
.ro-gpx-result__stat span { font-size: 11px; color: var(--ro-text-sub); }

/* 사진+시작점 모드 안내 박스 */
.ro-photo-guide {
    margin-bottom: 14px;
    padding: 16px 18px;
    background: var(--ro-primary-50, rgba(34,197,94,0.07));
    border: 1px solid var(--ro-primary-200, rgba(34,197,94,0.22));
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.65;
    color: var(--ro-text);
}
.ro-photo-guide > strong { display: block; font-size: 14.5px; margin-bottom: 6px; color: var(--ro-primary-700); letter-spacing: -0.01em; }
.ro-photo-guide p { margin: 0 0 8px; color: var(--ro-text-sub); }
.ro-photo-guide ol { margin: 8px 0; padding-left: 20px; display: flex; flex-direction: column; gap: 5px; }
.ro-photo-guide li { color: var(--ro-text); }
.ro-photo-guide b { color: var(--ro-text); font-weight: 700; }
.ro-photo-guide__tip {
    margin: 10px 0 0 !important;
    padding: 9px 12px;
    background: var(--ro-surface);
    border-radius: 10px;
    font-size: 12.5px;
    color: var(--ro-text-sub) !important;
}

/* 지도 컨테이너 */
.ro-map {
    width: 100%;
    height: 460px;
    border-radius: var(--ro-radius-md);
    border: 1px solid var(--ro-border);
    overflow: hidden;
    /* 타일 로딩 중 회색 배경 */
    background: linear-gradient(135deg, #f3f4f6, #e5e7eb);
}
[data-theme="dark"] .ro-map { background: linear-gradient(135deg, #1f2937, #111827); }
@media (max-width: 540px) { .ro-map { height: 340px; } }
.ro-map-helper {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-top: 8px;
    padding: 10px 12px;
    background: var(--ro-bg);
    border: 1px solid var(--ro-border);
    border-radius: 8px;
    font-size: 12px;
    color: var(--ro-text-sub);
}
.ro-map-helper button {
    padding: 4px 10px;
    background: var(--ro-surface);
    border: 1px solid var(--ro-border);
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
}

/* ── 지도 그리기 — 단계 안내 ── */
.ro-draw-steps {
    margin: 0 0 12px;
    padding: 12px 14px 12px 16px;
    list-style: none;
    background: var(--ro-primary-50, rgba(34,197,94,0.08));
    border: 1px solid var(--ro-primary-200, rgba(34,197,94,0.25));
    border-radius: 10px;
    font-size: 13px;
    line-height: 1.7;
    color: var(--ro-text);
}
.ro-draw-steps li { margin: 0; }
[data-theme="dark"] .ro-draw-steps { background: rgba(144,195,32,0.10); border-color: rgba(144,195,32,0.28); }

/* ── 그리기 컨트롤 바 (버튼 크게 · 모바일 줄바꿈 · 터치 타깃 확대) ── */
.ro-map-helper--draw { flex-wrap: wrap; gap: 8px; }
.ro-draw-btn {
    padding: 10px 14px;
    min-height: 42px;
    background: var(--ro-surface);
    border: 1px solid var(--ro-border);
    border-radius: 9px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
    color: var(--ro-text);
    transition: background 140ms, border-color 140ms, transform 140ms;
}
.ro-draw-btn:hover { border-color: var(--ro-primary-400, #90C320); }
.ro-draw-btn--primary {
    background: linear-gradient(120deg, #5b7d12, #90C320);
    color: #fff;
    border-color: transparent;
}
.ro-draw-btn--primary.is-drawing {
    background: linear-gradient(120deg, #b45309, #f97316);
    animation: ro-draw-pulse 1.4s ease-in-out infinite;
}
@keyframes ro-draw-pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(249,115,22,0.45); } 50% { box-shadow: 0 0 0 6px rgba(249,115,22,0); } }
.ro-draw-dist { margin-left: auto; font-size: 13px; color: var(--ro-text-sub); white-space: nowrap; }
.ro-draw-dist strong { color: var(--ro-text); font-variant-numeric: tabular-nums; }

/* ── Leaflet-Geoman 툴바 아이콘 — 모바일에서 작아 안 보이던 문제: 키우고 강조 ── */
.leaflet-pm-toolbar .leaflet-buttons-control-button {
    width: 40px !important;
    height: 40px !important;
    background-size: 22px 22px !important;
}
.leaflet-pm-toolbar .leaflet-pm-icon-polyline {
    box-shadow: 0 0 0 2px rgba(144,195,32,0.55) inset;
    border-radius: 6px;
}
@media (max-width: 540px) {
    .ro-draw-btn { flex: 1 1 auto; }
    .ro-draw-dist { margin-left: 0; flex-basis: 100%; }
    .leaflet-pm-toolbar .leaflet-buttons-control-button { width: 44px !important; height: 44px !important; }
}
@media (prefers-reduced-motion: reduce) {
    .ro-draw-btn--primary.is-drawing { animation: none; }
}

/* 이미지 업로드 (썸네일 미리보기) */
.ro-image-upload {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 130px), 1fr));
    gap: 10px;
}
.ro-image-upload__slot {
    position: relative;
    aspect-ratio: 1;
    border: 2px dashed var(--ro-border);
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    background: var(--ro-bg);
    color: var(--ro-text-sub);
    cursor: pointer;
    overflow: hidden;
}
.ro-image-upload__slot.has-image { border: 1px solid var(--ro-border); }
.ro-image-upload__slot img { width: 100%; height: 100%; object-fit: cover; }
.ro-image-upload__slot input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.ro-image-upload__remove {
    position: absolute; top: 4px; right: 4px;
    width: 22px; height: 22px;
    border-radius: 50%;
    background: rgba(0,0,0,0.65);
    color: white;
    border: none;
    cursor: pointer;
    font-size: 12px;
    display: flex; align-items: center; justify-content: center;
}

/* 코스 상세 — 지도 + 정보 */
.ro-route-detail-map {
    width: 100%;
    height: 480px;
    border-radius: var(--ro-radius-md);
    margin: 18px 0;
    border: 1px solid var(--ro-border);
    overflow: hidden;
    background: linear-gradient(135deg, #f3f4f6, #e5e7eb);
}
[data-theme="dark"] .ro-route-detail-map { background: linear-gradient(135deg, #1f2937, #111827); }
@media (max-width: 540px) { .ro-route-detail-map { height: 340px; } }
.ro-route-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 130px), 1fr));
    gap: 10px;
    margin-bottom: 18px;
}
.ro-route-stats__item {
    background: var(--ro-surface);
    border: 1px solid var(--ro-border);
    border-radius: var(--ro-radius-sm);
    padding: 12px 14px;
    text-align: center;
}
.ro-route-stats__item strong {
    display: block;
    font-size: var(--ro-text-lg);
    color: var(--ro-primary-700);
    font-weight: 800;
}
.ro-route-stats__item span {
    font-size: 11px;
    color: var(--ro-text-sub);
}

.ro-route-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr));
    gap: 10px;
    margin-bottom: 20px;
}
.ro-route-gallery img {
    width: 100%;
    aspect-ratio: 4/3;
    object-fit: cover;
    border-radius: var(--ro-radius-md);
    cursor: pointer;
}

@media (prefers-reduced-motion: reduce) {
    .ro-route-card, .ro-region-chip, .ro-mode-tab { transition: none !important; }
    .ro-route-card:hover { transform: none; }
}
