/* Home.css — v6.x.5e
   LINE LIFF 新首頁:hero greeting + 互動搜尋列 + 地圖卡片(取代原本 3 個 card / tile) + 公告
   v6.x.5e 重大重組:掃碼充電 / 地圖 tile / 紀錄 tile → 1 個大塊 map card + 篩選 sheet
   tokens 從 v6x5.css 來 */

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--type-display);
    background: var(--bg);
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    font-size: 14px;
    line-height: 1.5;
}

.container {
    max-width: 480px;
    margin: 0 auto;
    min-height: 100vh;
    padding-bottom: calc(var(--tab-height) + 24px + env(safe-area-inset-bottom));
}

/* ==========================================================
   Hero image (LINE GO 參考)
   右半裁切(貓頭鷹+充電樁+車),底部 mask 漸層 fade 進 --bg
   標題絕對定位疊在圖底
   ========================================================== */
.hero_img_wrap {
    margin: 0 0 2px;
    position: relative;
    overflow: hidden;
}

.hero_img {
    display: block;
    width: 100%;
    height: clamp(140px, 36vw, 220px);
    object-fit: cover;
    object-position: center center;
    -webkit-mask-image: linear-gradient(to bottom, #000 55%, transparent 100%);
            mask-image: linear-gradient(to bottom, #000 55%, transparent 100%);
}

.hero_title {
    position: absolute;
    left: 20px;
    right: 20px;
    bottom: 18px;
    margin: 0;
    font-size: 26px;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.25;
    color: var(--ink);
    z-index: 2;
}

/* ==========================================================
   v6.x.5e — 互動搜尋列 (top-left, tap 開 sheet)
   視覺像 iOS search input 但不接文字輸入
   ========================================================== */
.search_bar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 12px 16px 0;
    padding: 12px 14px;
    background: var(--card);
    border: 1px solid var(--line-soft);
    border-radius: var(--radius-pill);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    width: calc(100% - 32px);
    text-align: left;
    font: inherit;
    color: var(--ink-soft);
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.12s var(--ease-out), box-shadow 0.12s var(--ease-out);
}

.search_bar:active {
    transform: scale(0.99);
    box-shadow: var(--shadow-md);
}

.search_bar:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
}

.search_bar_icon {
    flex: 0 0 auto;
    width: 20px;
    height: 20px;
    color: var(--ink-soft);
    display: flex;
    align-items: center;
    justify-content: center;
}

.search_bar_icon svg {
    width: 100%;
    height: 100%;
}

.search_bar_text {
    flex: 1;
    min-width: 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--ink-soft);
    letter-spacing: 0.01em;
}

.search_bar_arrow {
    flex: 0 0 auto;
    color: var(--ink-soft);
    font-size: 14px;
    line-height: 1;
    font-family: var(--type-mono);
    transition: transform 0.18s var(--ease-out);
}

.search_bar:hover .search_bar_arrow {
    transform: translateY(2px);
}

/* ==========================================================
   v6.x.5e — 地圖卡片 (取代 scan_cta + tile_grid)
   ========================================================== */
.map_card {
    margin: 12px 16px 0;
    background: var(--card);
    border: 1px solid var(--line-soft);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.map_card_preview {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    background: #e8e9eb;
    overflow: hidden;
}

/* v6.x.5e.3 — MapKit JS 6 互動式地圖
   host 是 <div id="homeMapCanvas">,MapKit JS 載入後會自動加 .mapkit-map class + 自己的 .mk- 子元素
   skeleton + badge + locate pill 都 absolute 浮在上面 */
.map_canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    background: #e8e9eb;   /* MapKit 載入前顯示淺灰 */
    transition: background 0.4s var(--ease-out);
}

/* MapKit JS 會在 div 加 .mapkit-map class,並 inject 自己的 canvas/svg 子層 */
.map_canvas.mapkit-map {
    background: transparent;
}

/* v6.x.5h.87 + v6.x.5h.98 — 地圖灰色 + 圖釘綠色(對齊 user 「地圖要維持灰色,地圖圖釘綠色」)
   之前:.map_canvas 整個 grayscale → 連 SVG marker 都變灰 → 失去 AC chip 顏色
   修法:
   - .map_canvas { filter: grayscale(0.85) saturate(0.4) } — 整個灰色 + 降彩度
   - .mk-annotation-svg 排除 grayscale filter(保留原本顏色) → SVG marker chip 維持綠色
   - 對齊 v6.x.5h.87 Tesla 風格 + v6.x.5h.95 SVG chip 顏色辨識 */
.map_canvas {
    filter: grayscale(0.85) saturate(0.4);
    transition: filter 0.3s ease-out;
}

/* v6.x.5h.98:排除 marker(annotation)SVG 的 grayscale filter — 讓充電樁 chip 維持綠色可辨識
   Apple MapKit JS 5.x/6.x marker 真實 DOM class 不確定,試多個可能的 selector */
.mk-annotation-svg,
.mk-marker-svg,
.mapkit-marker-overlay svg,
.mk-callout,
.map_canvas svg.mk-annotation-svg,
.map_canvas [class*="marker"] svg,
.map_canvas [class*="annotation"] svg,
.map_canvas [class*="mk-"] svg {
    filter: none !important;
}

/* v6.x.5e.3.8 — POI filter API 全失敗時的 CSS 灰階 fallback */
.map_canvas.grayscale-fallback,
.map_canvas.grayscale-fallback .mk-canvas-container,
.map_canvas.grayscale-fallback .mk-canvas,
.map_canvas.grayscale-fallback svg {
    filter: grayscale(0.85) saturate(0.4) brightness(1.05);
    transition: filter 0.5s ease-out;
}

/* loading skeleton — Apple Maps tiles 還沒進來前顯示淺灰漸層,避免白屏 */
.map_card_skeleton {
    position: absolute;
    inset: 0;
    background: linear-gradient(120deg,
        #e8e9eb 25%,
        #f4f5f7 50%,
        #e8e9eb 75%
    );
    background-size: 200% 100%;
    animation: skeletonShimmer 1.4s ease-in-out infinite;
    transition: opacity 0.4s var(--ease-out);
}

.map_card_skeleton.is_loaded {
    opacity: 0;
    pointer-events: none;
}

@keyframes skeletonShimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.map_card_locate {
    position: absolute;
    top: 10px;
    left: 10px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px 5px 8px;
    background: rgba(255, 255, 255, 0.92);
    border-radius: var(--radius-pill);
    font-size: 11px;
    font-weight: 700;
    color: var(--ink-mid);
    letter-spacing: 0.01em;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: 0 2px 8px rgba(20, 30, 22, 0.08);
}

.map_card_locate_dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--info);
    box-shadow: 0 0 0 3px rgba(59, 125, 221, 0.18);
    animation: locatePulse 1.6s ease-in-out infinite;
}

@keyframes locatePulse {
    0%, 100% { box-shadow: 0 0 0 3px rgba(59, 125, 221, 0.18); }
    50%      { box-shadow: 0 0 0 5px rgba(59, 125, 221, 0.06); }
}

.map_card_type_badge {
    position: absolute;
    top: 10px;
    right: 10px;
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    background: var(--brand);
    color: #fff;
    border-radius: var(--radius-pill);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.05em;
    box-shadow: 0 2px 8px rgba(31, 157, 62, 0.32);
}

.map_card_overlay {
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 10px 10px 14px;
    background: rgba(255, 255, 255, 0.94);
    border-radius: 16px;
    backdrop-filter: blur(14px) saturate(1.2);
    -webkit-backdrop-filter: blur(14px) saturate(1.2);
    box-shadow: 0 4px 18px rgba(20, 30, 22, 0.14);
    text-decoration: none;
    color: inherit;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.12s var(--ease-out);
}

.map_card_overlay:active {
    transform: scale(0.985);
}

.map_card_overlay_info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.map_card_overlay_eyebrow {
    font-size: 10px;
    font-weight: 700;
    color: var(--ink-soft);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    line-height: 1.1;
}

.map_card_overlay_name {
    font-size: 14px;
    font-weight: 800;
    color: var(--ink);
    letter-spacing: -0.005em;
    line-height: 1.25;
    margin-top: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.map_card_overlay_address {
    font-size: 11px;
    color: var(--ink-soft);
    line-height: 1.3;
    letter-spacing: 0.01em;
    margin-top: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.map_card_icon_btn {
    flex: 0 0 auto;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--ink);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.12s var(--ease-out);
}

.map_card_icon_btn svg {
    width: 16px;
    height: 16px;
}

.map_card_overlay[hidden],
.map_card_type_badge[hidden] {
    display: none;
}

/* ==========================================================
   News / announcements (保留 v6.x.5)
   ========================================================== */
.news_section {
    margin: 18px 16px 0;
}

.section_head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 12px;
    padding: 0 4px;
}

.section_head .label {
    font-size: 16px;
    font-weight: 800;
    color: var(--ink);
    letter-spacing: -0.01em;
}

.section_head .more {
    font-size: 12px;
    color: var(--ink-soft);
    text-decoration: none;
    font-weight: 600;
    -webkit-tap-highlight-color: transparent;
}

.section_head .more:hover { color: var(--brand); }

.news_list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.news_card {
    background: var(--card);
    border-radius: var(--radius-md);
    border: 1px solid var(--line-soft);
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    text-decoration: none;
    color: var(--ink);
    box-shadow: var(--shadow-sm);
    transition: border-color 0.12s var(--ease-out), transform 0.1s var(--ease-out);
    -webkit-tap-highlight-color: transparent;
}

.news_card:active { transform: scale(0.99); }

.news_card:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
}

.news_top {
    display: flex;
    align-items: center;
    gap: 8px;
}

.news_tag {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.04em;
    background: var(--brand-tint);
    color: var(--brand-deep);
    text-transform: uppercase;
}

.news_tag.tag_info {
    background: #e8f1ff;
    color: #1d4ea8;
}

.news_tag.tag_warn {
    background: #fff4dc;
    color: #8a5a00;
}

.news_date {
    font-size: 11px;
    color: var(--ink-soft);
    font-family: var(--type-mono);
    font-feature-settings: "tnum" 1;
    font-variant-numeric: tabular-nums;
}

.news_title {
    font-size: 14px;
    font-weight: 700;
    color: var(--ink);
    letter-spacing: -0.01em;
    line-height: 1.45;
}

.news_preview {
    font-size: 12px;
    color: var(--ink-soft);
    line-height: 1.55;
}

/* ==========================================================
   Empty news state
   ========================================================== */
.news_empty {
    text-align: center;
    padding: 32px 20px;
    background: var(--card);
    border-radius: var(--radius-md);
    border: 1px dashed var(--line);
    color: var(--ink-soft);
    font-size: 12px;
}

.news_empty svg {
    width: 36px;
    height: 36px;
    color: var(--ink-soft);
    margin-bottom: 10px;
    opacity: 0.5;
}

/* ==========================================================
   v6.x.5e — 底部 sheet 篩選器
   ========================================================== */
.sheet_backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 22, 17, 0.45);
    z-index: 99;
    opacity: 0;
    transition: opacity 0.24s var(--ease-out);
    -webkit-tap-highlight-color: transparent;
}

.sheet_backdrop.is_open {
    opacity: 1;
}

.sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 100;
    background: var(--card);
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -8px 32px rgba(20, 30, 22, 0.18);
    padding: 8px 0 max(16px, env(safe-area-inset-bottom));
    transform: translateY(100%);
    transition: transform 0.28s var(--ease-out);
    max-height: 80vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.sheet.is_open {
    transform: translateY(0);
}

.sheet_grab {
    width: 36px;
    height: 4px;
    background: var(--line);
    border-radius: 999px;
    margin: 0 auto 4px;
}

.sheet_head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px 8px;
    border-bottom: 1px solid var(--line-soft);
}

.sheet_title {
    margin: 0;
    font-size: 16px;
    font-weight: 800;
    color: var(--ink);
    letter-spacing: -0.01em;
}

.sheet_close {
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: var(--bg);
    color: var(--ink-mid);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.12s var(--ease-out);
}

.sheet_close:active { background: var(--line); }

.sheet_close svg {
    width: 18px;
    height: 18px;
}

.sheet_body {
    padding: 8px 20px 4px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

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

.sheet_label {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
}

.sheet_label_main {
    font-size: 13px;
    font-weight: 800;
    color: var(--ink);
    letter-spacing: 0.01em;
}

.sheet_label_sub {
    font-size: 10px;
    font-weight: 600;
    color: var(--ink-faint);
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.chip_row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.chip {
    flex: 1 1 0;
    min-width: 0;
    padding: 10px 8px;
    background: var(--bg);
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    font: inherit;
    font-size: 13px;
    font-weight: 700;
    color: var(--ink-mid);
    cursor: pointer;
    text-align: center;
    letter-spacing: 0.01em;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.15s var(--ease-out), color 0.15s var(--ease-out), border-color 0.15s var(--ease-out);
    white-space: nowrap;
}

.chip:active { background: var(--line); }

.chip.is_active {
    background: var(--brand-tint);
    color: var(--brand-deep);
    border-color: var(--brand);
}

.chip.is_active:active { background: var(--brand-tint); }

.chip:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
}

.sheet_foot {
    display: flex;
    gap: 10px;
    padding: 14px 20px 4px;
    border-top: 1px solid var(--line-soft);
    margin-top: 12px;
}

.sheet_btn_clear,
.sheet_btn_confirm {
    flex: 1;
    padding: 12px 16px;
    border: none;
    border-radius: var(--radius-pill);
    font: inherit;
    font-size: 14px;
    font-weight: 800;
    letter-spacing: 0.02em;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: transform 0.1s var(--ease-out), background 0.12s var(--ease-out);
}

.sheet_btn_clear {
    background: var(--bg);
    color: var(--ink-mid);
}

.sheet_btn_clear:active { background: var(--line); transform: scale(0.98); }

.sheet_btn_confirm {
    background: var(--brand);
    color: #fff;
    box-shadow: 0 4px 12px rgba(31, 157, 62, 0.28);
}

.sheet_btn_confirm svg {
    width: 14px;
    height: 14px;
}

.sheet_btn_confirm:active {
    transform: scale(0.98);
    box-shadow: 0 2px 6px rgba(31, 157, 62, 0.18);
}

/* ==========================================================
   Reduced motion
   ========================================================== */
@media (prefers-reduced-motion: reduce) {
    .search_bar,
    .map_card_overlay,
    .news_card,
    .chip,
    .sheet_btn_clear,
    .sheet_btn_confirm,
    .map_canvas,
    .map_card_skeleton {
        transition: none !important;
    }
    .map_card_locate_dot,
    .map_card_skeleton {
        animation: none !important;
    }
}

@media (max-width: 360px) {
    .hero_title { font-size: 22px; left: 16px; right: 16px; bottom: 14px; }
}
