/**
 * TNL Widget System v1.0 - Stylesheet
 *
 * Components:
 *   1. Shop Comparison Widget (.tnl-shop-widget)
 *   2. Near-Me CTR Button (.tnl-widget-ctr, .ctr-btn)
 *   3. Featured-In-Guides Section (.tnl-featured-in-guides)
 *   4. Shop Page Modal Trigger (.shop-directions-btn)
 *   5. 5-Step Directions Modal (.tnl-directions-modal)
 *
 * Used on: post-detail.php, shop-detail.php
 * Color palette mirrors existing site (#ff6b00 orange, #000/#1a1a1a/#2a2a2a dark)
 *
 * @version 1.0
 * @date    2026-05-15
 */

/* ============================================================
 * Widget-scoped CSS variables (mirroring site palette)
 * ============================================================ */

.tnl-shop-widget,
.tnl-widget-ctr,
.tnl-featured-in-guides,
.shop-directions-wrap,
.tnl-directions-modal {
    --w-orange: #ff6b00;
    --w-orange-light: #ff8533;
    --w-orange-bg-soft: rgba(255, 107, 0, 0.1);
    --w-orange-bg-dark: #3d2814;
    --w-bg: #000;
    --w-card: #1a1a1a;
    --w-card-hover: #222;
    --w-card-deep: #0a0a0a;
    --w-border: #2a2a2a;
    --w-border-light: #333;
    --w-text: #fff;
    --w-text-soft: #ddd;
    --w-text-muted: #b8b8b8;
    --w-text-faint: #b8b8b8;
}

/* ============================================================
 * 1. Shop Comparison Widget (HTML5 details/summary - native toggle)
 * ============================================================ */

.tnl-shop-widget {
    margin: 24px 0;
    background: var(--w-card);
    border: 1px solid var(--w-border);
    border-radius: 12px;
    overflow: hidden;
}

/* Remove details/summary native marker */
.tnl-shop-widget summary {
    list-style: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.tnl-shop-widget summary::-webkit-details-marker {
    display: none;
}
.tnl-shop-widget summary::marker {
    display: none;
}

.tnl-widget-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 16px 14px;
    transition: background-color 0.15s ease;
}

.tnl-shop-widget summary.tnl-widget-header:hover,
.tnl-shop-widget summary.tnl-widget-header:focus {
    background: var(--w-card-hover);
    outline: none;
}

.tnl-shop-widget[open] .tnl-widget-header {
    border-bottom: 1px solid var(--w-border);
}

.tnl-widget-header-text {
    flex: 1;
    min-width: 0;
}

.tnl-widget-main {
    font-size: 16px;
    font-weight: 700;
    color: var(--w-orange);
    margin: 0 0 4px 0;
    line-height: 1.4;
}

.tnl-widget-sub {
    font-size: 12px;
    color: var(--w-text-muted);
    margin: 0;
    line-height: 1.4;
}

.tnl-widget-chevron {
    color: var(--w-orange);
    font-size: 12px;
    line-height: 1;
    flex-shrink: 0;
    transition: transform 0.2s ease;
    user-select: none;
}

.tnl-shop-widget[open] .tnl-widget-chevron {
    transform: rotate(180deg);
}

.tnl-widget-rows {
    display: block;
}

.tnl-widget-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    transition: background-color 0.15s ease;
    /* Prevent conflicts with other CSS - row uses border-bottom only (no 4-side box) */
    border: 0;
    border-bottom: 1px solid var(--w-border);
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    margin: 0;
    outline: none;
    -webkit-tap-highlight-color: transparent;
    box-sizing: border-box;
}

.tnl-widget-row:last-child {
    border-bottom: 0;
}

.tnl-widget-row:hover,
.tnl-widget-row:focus {
    background: var(--w-card-hover);
}

/* Uniform photo size. Scoped to the widget so it outranks bare
   .tnl-widget-thumb rules from other stylesheets without !important. */
.tnl-shop-widget .tnl-widget-thumb {
    width: 48px;
    height: 48px;
    min-width: 48px;
    min-height: 48px;
    max-width: 48px;
    max-height: 48px;
    aspect-ratio: 1 / 1;
    border-radius: 8px;
    object-fit: cover;
    object-position: center;
    flex-shrink: 0;
    background: var(--w-card-deep);
    display: block;
}

.tnl-widget-info {
    flex: 1;
    min-width: 0;
}

.tnl-widget-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--w-text);
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tnl-widget-price {
    font-size: 12px;
    color: var(--w-orange-light);
    margin-top: 2px;
}

.tnl-widget-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 4px;
    font-size: 12px;
    color: var(--w-orange-light);
    font-weight: 600;
}

.tnl-widget-meta > span {
    display: inline-flex;
    align-items: center;
}

.tnl-widget-meta > span + span::before {
    content: '·';
    margin-right: 6px;
    color: var(--w-orange-light);
    opacity: 0.6;
}

.tnl-widget-arrow {
    color: var(--w-text-muted);
    font-size: 20px;
    line-height: 1;
    flex-shrink: 0;
    transition: color 0.15s ease;
}

.tnl-widget-row:hover .tnl-widget-arrow,
.tnl-widget-row:focus .tnl-widget-arrow {
    color: var(--w-orange);
}

/* ============================================================
 * 2. Near-Me CTR Button (Full-width centered button)
 * ============================================================ */

.ctr-row.tnl-widget-ctr {
    margin: 16px 0;
}

.ctr-row .ctr-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    background: var(--w-orange-bg-soft);
    color: var(--w-orange);
    padding: 16px 18px;
    border-radius: 10px;
    border: 1px solid var(--w-orange);
    font-size: 15px;
    font-weight: 700;
    text-decoration: none;
    transition: background-color 0.15s ease, color 0.15s ease;
    box-sizing: border-box;
}

.ctr-row .ctr-btn:hover,
.ctr-row .ctr-btn:focus {
    background: var(--w-orange);
    color: #fff;
    outline: none;
}

.ctr-row .ctr-btn:hover svg,
.ctr-row .ctr-btn:focus svg {
    fill: #fff;
}

/* ============================================================
 * 3. Featured-In-Guides Section
 * ============================================================ */

.tnl-featured-in-guides {
    margin: 30px 0;
    padding: 16px;
    background: var(--w-card);
    border: 1px solid var(--w-border);
    border-radius: 12px;
}

.tnl-featured-header {
    font-size: 16px;
    font-weight: 700;
    color: var(--w-orange);
    margin: 0 0 12px 0;
    line-height: 1.4;
}

.tnl-featured-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.tnl-featured-list li {
    padding: 10px 0;
    border-bottom: 1px solid var(--w-border);
}

.tnl-featured-list li:last-child {
    border-bottom: none;
}

.tnl-featured-list li.featured {
    padding-left: 10px;
    margin-left: -10px;
    border-left: 3px solid var(--w-orange);
}

.tnl-featured-list li a {
    color: var(--w-text-soft);
    text-decoration: none;
    font-size: 14px;
    line-height: 1.4;
    transition: color 0.15s ease;
    display: block;
}

.tnl-featured-list li a:hover,
.tnl-featured-list li a:focus {
    color: var(--w-orange);
}

/* ============================================================
 * 4. Shop Page Modal Trigger Button
 * ============================================================ */

.shop-info-item.shop-directions-wrap {
    margin: 12px 0;
    border: none;
    padding: 0;
    background: none;
}

.shop-directions-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--w-orange-bg-soft);
    color: var(--w-orange);
    border: 1px solid var(--w-orange);
    padding: 11px 18px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
    font-family: inherit;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

.shop-directions-btn:hover,
.shop-directions-btn:focus {
    background: var(--w-orange);
    color: #fff;
}

.shop-directions-btn:hover svg,
.shop-directions-btn:focus svg {
    fill: #fff;
}

/* ============================================================
 * 5. 5-Step Directions Modal (JS-activated)
 * ============================================================ */

.tnl-directions-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 9999;
    display: none;
    align-items: flex-end;
    justify-content: center;
    padding: 0;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
}

.tnl-directions-modal.active {
    display: flex;
    animation: tnlModalFadeIn 0.2s ease;
}

@keyframes tnlModalFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.tnl-modal-box {
    background: var(--w-card);
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
    width: 100%;
    max-width: 480px;
    max-height: 85vh;
    overflow-y: auto;
    padding: 0;
    border: 1px solid var(--w-border);
    border-bottom: none;
    animation: tnlModalSlideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes tnlModalSlideUp {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
}

.tnl-modal-header {
    position: relative;
    padding: 18px 50px 14px 18px;
    border-bottom: 1px solid var(--w-border);
}

.tnl-modal-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--w-text);
    margin: 0 0 4px 0;
    line-height: 1.4;
}

.tnl-modal-meta {
    font-size: 13px;
    color: var(--w-orange-light);
    font-weight: 600;
    line-height: 1.4;
}

.tnl-modal-meta strong {
    color: var(--w-orange);
    font-weight: 700;
}

.tnl-modal-close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 30px;
    height: 30px;
    background: transparent;
    border: none;
    color: var(--w-text-muted);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    border-radius: 50%;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.tnl-modal-close:hover,
.tnl-modal-close:focus {
    background: var(--w-card-hover);
    color: var(--w-text);
    outline: none;
}

.tnl-modal-body {
    padding: 8px 0 16px;
}

.tnl-modal-option {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    padding: 16px 20px;
    background: transparent;
    border: none;
    color: var(--w-text);
    cursor: pointer;
    text-align: left;
    text-decoration: none;
    transition: background-color 0.15s ease;
    font-family: inherit;
    font-size: 14px;
    outline: none;
    border-bottom: 1px solid var(--w-border);
}

.tnl-modal-option:last-child {
    border-bottom: none;
}

.tnl-modal-option:hover,
.tnl-modal-option:focus {
    background: var(--w-card-hover);
}

.tnl-modal-option-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--w-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 18px;
}

.tnl-modal-option-info {
    flex: 1;
    min-width: 0;
}

.tnl-modal-option-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--w-text);
    margin-bottom: 2px;
}

.tnl-modal-option-meta {
    font-size: 12px;
    color: var(--w-text-muted);
}

.tnl-modal-option-arrow {
    color: var(--w-text-faint);
    font-size: 18px;
    flex-shrink: 0;
}

/* ============================================================
 * Desktop layout (modal centers instead of bottom-sheet)
 * ============================================================ */

@media (min-width: 768px) {
    .tnl-directions-modal {
        align-items: center;
        padding: 20px;
    }

    .tnl-modal-box {
        border-radius: 16px;
        border: 1px solid var(--w-border);
        max-width: 440px;
    }

    .tnl-modal-box {
        animation-name: tnlModalSlideDesktop;
    }

    @keyframes tnlModalSlideDesktop {
        from {
            opacity: 0;
            transform: translateY(20px) scale(0.96);
        }
        to {
            opacity: 1;
            transform: translateY(0) scale(1);
        }
    }
}

/* ============================================================
 * Mobile fine-tuning (≤480px)
 * ============================================================ */

@media (max-width: 480px) {
    .tnl-widget-main {
        font-size: 15px;
    }

    .tnl-widget-name {
        font-size: 13px;
    }

    .tnl-widget-row {
        padding: 10px 12px;
        gap: 10px;
    }

    .tnl-widget-header {
        padding: 14px 12px 12px;
    }

    .ctr-row .ctr-btn {
        padding: 11px 16px;
        font-size: 13px;
    }

    .tnl-featured-in-guides {
        padding: 14px;
    }

    .tnl-featured-header {
        font-size: 15px;
    }

    .tnl-modal-header {
        padding: 16px 46px 12px 16px;
    }

    .tnl-modal-option {
        padding: 12px 16px;
    }
}

/* ============================================================
 * Body lock when modal is open (set by JS)
 * ============================================================ */

body.tnl-modal-open {
    overflow: hidden;
    padding-right: var(--scrollbar-width, 0);
}

/* ============================================================
 * Toast Notification (clipboard-copy alerts, etc.)
 * ============================================================ */

.tnl-toast {
    --w-orange: #ff6b00;
    --w-card: #1a1a1a;
    --w-text: #fff;
    --w-border: #2a2a2a;

    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--w-card);
    color: var(--w-text);
    padding: 12px 22px;
    border-radius: 24px;
    border: 1px solid var(--w-orange);
    font-size: 14px;
    font-weight: 600;
    z-index: 10000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    max-width: 90vw;
    text-align: center;
}

.tnl-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
/* ============================================================
 * 6. Shop Widget redesign (2026-07)
 *    - black surface (was #1a1a1a)
 *    - circular thumb
 *    - distance/fare as a right-aligned column
 *    - relative distance bar (--pct set by JS)
 *    Placed last so it overrides the blocks above.
 * ============================================================ */

.tnl-shop-widget {
    --tnl-css-version: 6;
    background: var(--w-bg);
}

.tnl-shop-widget[open] .tnl-widget-header,
.tnl-shop-widget .tnl-widget-row {
    border-color: #1c1c1c;
}

.tnl-shop-widget summary.tnl-widget-header:hover,
.tnl-shop-widget summary.tnl-widget-header:focus,
.tnl-shop-widget .tnl-widget-row:hover,
.tnl-shop-widget .tnl-widget-row:focus {
    background: #111;
}

.tnl-widget-main {
    color: var(--w-text);
}

.tnl-widget-sub {
    color: var(--w-orange);
}

.tnl-shop-widget .tnl-widget-thumb {
    width: 30px;
    height: 30px;
    min-width: 30px;
    min-height: 30px;
    max-width: 30px;
    max-height: 30px;
    border-radius: 50%;
    background: #2a2a2a;
}

/* The widget sits inside .bkk-nuru-complete, which sets line-height:1.7.
   That inherited value, not the padding, is what made the rows tall. */
.tnl-shop-widget,
.tnl-shop-widget .tnl-widget-row,
.tnl-shop-widget .tnl-widget-info,
.tnl-shop-widget .tnl-widget-name,
.tnl-shop-widget .tnl-widget-meta,
.tnl-shop-widget .tnl-widget-meta > span {
    line-height: 1.25;
}

/* Fixed row height. The widget lives inside .post-content / .bkk-nuru-complete,
   so any stray margin or line-height from those sheets would otherwise stretch
   the row. Locking the height makes it immune. */
.tnl-shop-widget .tnl-widget-row {
    height: 46px;
    min-height: 0;
    padding: 0 16px;
    gap: 10px;
    align-items: center;
    overflow: hidden;
}

.tnl-shop-widget .tnl-widget-row > *,
.tnl-shop-widget .tnl-widget-name,
.tnl-shop-widget .tnl-widget-info,
.tnl-shop-widget .tnl-widget-meta,
.tnl-shop-widget .tnl-widget-meta > span {
    margin: 0;
    padding: 0;
}

.tnl-shop-widget .tnl-widget-thumb {
    margin: 0;
    display: block;
    vertical-align: middle;
}

/* distance and fare on one line, right aligned - keeps the row to thumb height */
.tnl-shop-widget .tnl-widget-meta {
    flex-direction: row;
    align-items: baseline;
    gap: 7px;
}

.tnl-shop-widget .tnl-widget-arrow {
    font-size: 16px;
}

.tnl-widget-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.tnl-widget-name {
    flex: 1;
    min-width: 0;
}

.tnl-widget-meta {
    margin-top: 0;
    flex-shrink: 0;
}

.tnl-widget-meta > span + span::before {
    content: none;
    margin: 0;
}

.tnl-widget-distance {
    color: var(--w-text-muted);
    font-weight: 400;
}

.tnl-widget-fare {
    color: var(--w-orange);
    font-weight: 600;
    min-width: 46px;
    justify-content: flex-end;
}

.tnl-widget-row {
    position: relative;
}

.tnl-widget-row::after {
    content: '';
    position: absolute;
    left: 16px;
    bottom: 3px;
    height: 3px;
    width: var(--pct, 0%);
    background: var(--w-orange);
    border-radius: 2px;
    opacity: 0.7;
    transition: width 0.3s ease;
}

.tnl-widget-more {
    display: block;
    width: 100%;
    padding: 12px;
    background: transparent;
    border: 0;
    border-top: 1px solid #1c1c1c;
    color: var(--w-orange);
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.tnl-widget-more:hover,
.tnl-widget-more:focus {
    background: #111;
    outline: none;
}

@media (max-width: 480px) {
    .tnl-shop-widget .tnl-widget-thumb {
        width: 28px;
        height: 28px;
        min-width: 28px;
        min-height: 28px;
        max-width: 28px;
        max-height: 28px;
    }

    .tnl-shop-widget .tnl-widget-meta {
        gap: 6px;
    }

    .tnl-shop-widget .tnl-widget-row {
        height: 42px;
        padding: 0 14px;
        gap: 10px;
    }

    .tnl-shop-widget .tnl-widget-row::after {
        left: 14px;
    }

    .tnl-widget-name {
        font-size: 14px;
    }

    .tnl-widget-meta {
        font-size: 12px;
    }

    .tnl-widget-arrow {
        display: none;
    }

    .tnl-widget-header {
        padding: 12px 14px;
    }

    .tnl-widget-main {
        font-size: 14px;
    }
}