﻿/* 拍賣站「車輛比較」樣式。
   front/css/sale.css 是已編譯的 Tailwind、專案內沒有 Tailwind 設定檔可重新 build，
   因此新樣式一律寫在這裡，只沿用 sale.css 已定義的 CSS 變數。 */

/* ---------- 卡片上的加入比較鈕 ---------- */
.compare-add {
    position: relative;
    cursor: pointer;
    line-height: 0;
}

.compare-add:hover svg,
.compare-add:focus-visible svg {
    color: var(--color-red);
}

/* 說明泡泡：文字取自 JS 寫入的 data-tip（加入比較／移出比較清單），
   native title 要等一秒才跳，這裡改用 CSS 即時顯示 */
.compare-add::after {
    content: attr(data-tip);
    position: absolute;
    left: 50%;
    bottom: calc(100% + .375rem);
    z-index: 30;
    transform: translateX(-50%);
    padding: .25rem .5rem;
    border-radius: .25rem;
    background: rgba(15, 15, 15, .88);
    color: var(--color-white);
    font-size: .8125rem;
    line-height: 1.4;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .15s ease;
}

.compare-add:hover::after,
.compare-add:focus-visible::after {
    opacity: 1;
    visibility: visible;
}

/* 不沿用 sale.css 的 .icon：它會強制 fill:currentColor，把只有描邊的圖示填成一塊 */
.compare-add svg {
    width: 1.6em;
    height: 1.6em;
    fill: none;
}

.compare-add .compare-add-on {
    display: none;
}

.compare-add.is-added .compare-add-off {
    display: none;
}

.compare-add.is-added .compare-add-on {
    display: block;
}

.compare-add.is-added svg {
    color: var(--color-red);
}

/* 卡片照片右下角的版本：白底、黑色 icon（詳情頁仍用上方的預設樣式） */
.compare-add--photo {
    position: absolute;
    right: 0;
    bottom: 0;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    /*    border-radius: .25rem;
*/ background: var(--color-white);
    color: var(--color-black);
/*    box-shadow: 0 1px 4px rgba(0, 0, 0, .25);
*/    border: 0.25px solid #d1d1d1;
}

.compare-add--photo svg {
    width: 1.5rem;
    height: 1.5rem;
}

.compare-add--photo.is-added svg {
    color: var(--color-black);
}

.compare-add--photo:hover svg,
.compare-add--photo:focus-visible svg {
    color: var(--color-red);
}

/* 按鈕貼著照片右緣，泡泡改靠右對齊，避免超出卡片 */
.compare-add--photo::after {
    left: auto;
    right: 0;
    transform: none;
}

/* ---------- 右側浮動鈕 ---------- */
.compare-rail {
    position: fixed;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    z-index: 60;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 3.5rem;
    height: 3.5rem;
    background: var(--color-white);
    color: var(--color-black);
    border: 1px solid var(--color-stoke);
    border-right: 0;
    border-radius: .5rem 0 0 .5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .12);
    cursor: pointer;
}

.compare-rail:hover {
    color: var(--color-red);
}

/* 「車輛／比較」兩行文字，按鈕維持正方形 */
.compare-rail-text {
    font-size: .9375rem;
    line-height: 1.25;
    text-align: center;
    white-space: nowrap;
}

.compare-rail-badge {
    position: absolute;
    top: -.375rem;
    left: -.375rem;
    min-width: 1.25rem;
    height: 1.25rem;
    padding: 0 .25rem;
    border-radius: 999px;
    background: var(--color-red);
    color: var(--color-white);
    font-size: .75rem;
    line-height: 1.25rem;
    text-align: center;
}

.compare-rail-badge.is-empty {
    display: none;
}

@media (max-width: 767px) {
    .compare-rail {
        top: auto;
        bottom: 6rem;
        width: 3.25rem;
        height: 3.25rem;
        transform: none;
    }

    .compare-rail-text {
        font-size: .875rem;
    }
}

/* ---------- 側欄 ---------- */
.compare-mask {
    position: fixed;
    inset: 0;
    z-index: 70;
    background: rgba(15, 15, 15, .5);
    display: none;
}

.compare-mask.is-open {
    display: block;
}

.compare-drawer {
    position: fixed;
    top: 0;
    right: 0;
    z-index: 80;
    display: flex;
    flex-direction: column;
    width: min(26rem, 100vw);
    height: 100%;
    background: var(--color-white);
    transform: translateX(100%);
    transition: transform .25s ease;
}

.compare-drawer.is-open {
    transform: translateX(0);
}

.compare-drawer-head {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    font-size: 1.375rem;
    border-bottom: 1px solid var(--color-stoke);
}

.compare-drawer-close {
    line-height: 0;
    cursor: pointer;
}

.compare-drawer-close svg {
    width: 1.5rem;
    height: 1.5rem;
}

.compare-drawer-hint {
    padding: 1rem 1.25rem .5rem;
    color: var(--color-sub);
    font-size: 1rem;
}

.compare-drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 0 1.25rem 1rem;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
    align-content: start;
}

.compare-drawer-empty {
    grid-column: 1 / -1;
    padding: 2rem 0;
    text-align: center;
    font-size: 1rem;
    line-height: 1.7;
    color: var(--color-hint);
}

.compare-drawer-item {
    position: relative;
    border: 1px solid var(--color-stoke);
    border-radius: .25rem;
    overflow: hidden;
    cursor: pointer;
}

.compare-drawer-item.is-checked {
    border-color: var(--color-red);
    box-shadow: 0 0 0 1px var(--color-red);
}

/* 已選滿 3 台時，其餘卡片點不動 */
.compare-drawer-item.is-full {
    cursor: not-allowed;
    opacity: .5;
}

.compare-drawer-item img {
    display: block;
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
}

.compare-drawer-item-body {
    padding: .5rem;
}

.compare-drawer-item-title {
    font-size: 1rem;
    line-height: 1.4;
    min-height: 2.8em;
}

.compare-drawer-item-meta {
    margin-top: .25rem;
    font-size: .9375rem;
    color: var(--color-sub);
}

.compare-drawer-item-price {
    color: var(--color-red);
}

/* 勾選標記：白底紅框的方塊，未選時只有空框，選了才填紅底打勾 */
.compare-drawer-item-check {
    position: absolute;
    top: .5rem;
    left: .5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    border: 2px solid var(--color-red);
    border-radius: .25rem;
    background: var(--color-white);
    color: transparent;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .3);
    pointer-events: none;
}

.compare-drawer-item-check svg {
    width: 1rem;
    height: 1rem;
    fill: none;
}

.compare-drawer-item.is-checked .compare-drawer-item-check {
    background: var(--color-red);
    color: var(--color-white);
}

.compare-drawer-item-remove {
    position: absolute;
    top: .5rem;
    right: .5rem;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 999px;
    background: rgba(15, 15, 15, .6);
    color: var(--color-white);
    font-size: .875rem;
    line-height: 1.5rem;
    text-align: center;
    cursor: pointer;
}

.compare-drawer-foot {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--color-stoke);
}

.compare-drawer-foot .btn[disabled] {
    opacity: .4;
    cursor: not-allowed;
}

/* ---------- 比較頁 ---------- */
.compare-page {
    padding: 2rem 1rem 4rem;
    max-width: 72rem;
    margin: 0 auto;
}

.compare-page-head {
    margin-bottom: 2rem;
    text-align: center;
}

.compare-page-title {
    position: relative;
    margin-top: .5rem;
    padding-bottom: 1rem;
    font-size: 2rem;
    line-height: 1.2;
    text-align: center;
}

/* 標題下方紅色短線，做出標題感 */
.compare-page-title::after {
    content: "";
    position: absolute;
    left: 50%;
    bottom: 0;
    transform: translateX(-50%);
    width: 3rem;
    height: 3px;
    background: var(--color-red);
}

.compare-page-lead {
    margin-top: .75rem;
    color: var(--color-sub);
    font-size: .9375rem;
}

.compare-page-notice {
    margin-bottom: 1rem;
    padding: .75rem 1rem;
    background: var(--color-light);
    color: var(--color-sub);
    border-radius: .25rem;
}

.compare-scroll {
    overflow-x: auto;
}

.compare-table {
    border-collapse: collapse;
    width: 100%;
    min-width: 40rem;
}

.compare-table th,
.compare-table td {
    border: 1px solid var(--color-stoke);
    padding: .75rem;
    vertical-align: middle;
    text-align: center;
    font-size: .9375rem;
    line-height: 1.6;
}

.compare-table th {
    position: sticky;
    left: 0;
    z-index: 1;
    width: 7rem;
    min-width: 7rem;
    background: var(--color-black);
    color: var(--color-white);
    font-weight: 400;
    text-align: center;
}

.compare-table td {
    width: 33%;
    min-width: 12rem;
    background: var(--color-white);
}

.compare-table tbody tr:nth-child(2n) td {
    background: var(--color-light);
}

.compare-table .compare-cell-red {
    color: var(--color-red);
}

/* 配備類文字長，統一靠左才讀得下去 */
.compare-table .compare-cell-left {
    text-align: left;
}

.compare-head-cell {
    position: relative;
    padding: 0 !important;
}

.compare-head-cell img {
    display: block;
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
}

.compare-head-remove {
    position: absolute;
    top: .5rem;
    right: .5rem;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 999px;
    background: rgba(15, 15, 15, .6);
    color: var(--color-white);
    line-height: 1.75rem;
    cursor: pointer;
}

.compare-head-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 4 / 3;
    background: var(--color-light);
}

.compare-head-add {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 999px;
    background: var(--color-red);
    color: var(--color-white);
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
}

.compare-tags {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    justify-content: center;
}

/* 比較頁「車輛詳情」：btn--lg 是 width:100% 且只有上下 padding，這裡改成置中、左右留白 */
.compare-detail-btn {
    display: inline-flex;
    width: auto;
    padding-inline: 2.5rem;
}

/* ---------- 比較頁：一台都沒有時的空狀態 ---------- */
.compare-empty-slots {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
}

.compare-empty-text {
    margin-top: 1.5rem;
    text-align: center;
    color: var(--color-sub);
}

@media (max-width: 767px) {
    .compare-page-title {
        font-size: 1.625rem;
    }
}
