/* Deal Tracker — see design_handoff_deal_tracker/README.md.
   Tokens come from assets/tokens.css (Peppy Design System). */

* { box-sizing: border-box; }

html, body {
    margin: 0;
    background: #f4f4f5;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: var(--font-sans);
    color: var(--ink);
}

/* Scrollbars are hidden on the three scrolling surfaces. */
.scroll::-webkit-scrollbar { width: 0; height: 0; }
.scroll { scrollbar-width: none; }

.app {
    max-width: 480px;
    margin: 0 auto;
    height: 100dvh;
    background: var(--canvas);
    display: flex;
    flex-direction: column;
}

@media (min-width: 481px) {
    .app { border-inline: 1px solid var(--hairline); }
}

/* ---- Header ---- */

/* Ink band — polarity flip. The colour change is the divider, so no hairline. */
.hdr {
    flex: 0 0 auto;
    padding: 20px;
    background: var(--ink);
    color: var(--on-primary);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.wordmark {
    display: flex;
    align-items: center;
    gap: 12px;
}

.wordmark img { display: block; flex: 0 0 auto; }

.wordmark-text {
    font-size: 26px;
    font-weight: var(--weight-semibold);
    letter-spacing: -0.5px;
    line-height: 30px;
    color: var(--on-primary);
}

.updated {
    font-size: 12px;
    font-weight: var(--weight-caption);
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: var(--mute-soft);
    white-space: nowrap;
}

.summary {
    margin: 4px 0 0;
    font-size: 14px;
    line-height: 20px;
    color: var(--hairline);
}

/* ---- Sort bar ---- */

.sortbar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--hairline);
}

.count {
    font-size: 12px;
    font-weight: var(--weight-caption);
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: var(--mute);
    white-space: nowrap;
}

/* Radio inputs stay in the tab order but are visually replaced by their labels. */
.segmented input, .chips input {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    border: 0;
    overflow: hidden;
    clip-path: inset(50%);
}

.segmented {
    display: inline-flex;
    border: 1px solid var(--hairline);
    border-radius: var(--radius-button);
    overflow: hidden;
}

.segmented label, .chips label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    /* 44px minimum tap target (handoff, accessibility). */
    min-height: 44px;
    padding: 8px 14px;
    font-size: 14px;
    font-weight: var(--weight-medium);
    line-height: 20px;
    white-space: nowrap;
    background: var(--canvas);
    color: var(--ink);
    cursor: pointer;
    user-select: none;
    transition: background-color var(--duration-fast) var(--ease-standard),
                border-color var(--duration-base) var(--ease-standard),
                color var(--duration-base) var(--ease-standard);
}

.segmented > label + label { border-left: 1px solid var(--hairline); }

/* Dash's own option CSS tints labels purple on :hover/:focus-within and outranks
   plain class selectors — these two rules take the colour back. */
.segmented label, .chips label { color: var(--ink) !important; }

.segmented label:has(input:checked),
.chips label:has(input:checked) {
    background: var(--ink);
    color: var(--on-primary) !important;
    border-color: var(--ink);
}

.segmented label:has(input:focus-visible),
.chips label:has(input:focus-visible) {
    outline: 2px solid var(--ink);
    outline-offset: 2px;
}

@media (hover: hover) {
    .segmented label:hover:not(:has(input:checked)),
    .chips label:hover:not(:has(input:checked)) {
        background: var(--action-secondary-bg-hover);
    }
}

/* ---- Store filter ---- */

.chips {
    flex: 0 0 auto;
    display: flex;
    gap: 8px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--hairline);
    overflow-x: auto;
}

.chips > * { flex: 0 0 auto; }

.chips label {
    border: 1px solid var(--hairline);
    border-radius: var(--radius-button);
}

/* ---- Product list ---- */

.list {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #f7f7f8;
}

.card {
    background: var(--canvas);
    border: var(--elevation-1-border);
    border-radius: var(--radius-card);
    padding: 14px 16px;
}

.card-top {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    cursor: pointer;
    list-style: none;
    user-select: none;
}

.card-top::-webkit-details-marker { display: none; }

.card-top:focus-visible {
    outline: 2px solid var(--ink);
    outline-offset: 4px;
    border-radius: var(--radius-xs);
}

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

.name {
    font-size: 14px;
    font-weight: var(--weight-medium);
    line-height: 20px;
    letter-spacing: -0.1px;
    color: var(--ink);
}

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

.store {
    font-size: 12px;
    font-weight: var(--weight-caption);
    color: var(--mute);
}

.card-right {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
}

.price {
    font-size: 18px;
    font-weight: var(--weight-semibold);
    letter-spacing: -0.2px;
    font-variant-numeric: tabular-nums;
}

.spark { display: block; }

/* ---- Badge (Peppy Badge, tones success/info/neutral) ---- */

.badge {
    display: inline-flex;
    align-items: center;
    font-size: var(--text-caption-size);
    line-height: var(--text-caption-line);
    font-weight: var(--text-caption-weight);
    border-radius: var(--radius-badge);
    padding: var(--pad-badge);
    border: 1px solid transparent;
    white-space: nowrap;
}

.badge-success { background: var(--status-success); color: var(--primary); }
.badge-info    { background: var(--status-info);    color: var(--on-primary); }
.badge-neutral { background: var(--primary);        color: var(--on-primary); }

.badge-soft { background: var(--canvas); border-color: currentColor; }
.badge-soft.badge-success { color: var(--status-success); }
.badge-soft.badge-info    { color: var(--status-info); }
.badge-soft.badge-neutral { color: var(--primary); }

/* ---- Expanded detail ---- */

.detail {
    margin-top: 12px;
    border-top: 1px solid var(--hairline);
    padding-top: 14px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.history {
    display: block;
    max-width: 100%;
    height: auto;
}

.legend {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: var(--weight-caption);
    color: var(--body);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.dot {
    width: 7px;
    height: 7px;
    border-radius: var(--radius-full);
    flex: 0 0 auto;
}

.stats {
    display: flex;
    justify-content: space-between;
    gap: 8px;
}

.stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.stat-label {
    font-size: 12px;
    font-weight: var(--weight-caption);
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: var(--mute);
}

.stat-value {
    font-size: 14px;
    font-weight: var(--weight-medium);
    font-variant-numeric: tabular-nums;
}

.cta {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 44px;
    background: var(--action-primary-bg);
    color: var(--action-primary-fg);
    border-radius: var(--radius-button);
    font-size: var(--text-button-size);
    font-weight: var(--text-button-weight);
    letter-spacing: var(--text-button-track);
    text-decoration: none;
    transition: background-color var(--duration-base) var(--ease-standard);
}

.cta:hover { background: var(--action-primary-bg-hover); color: var(--action-primary-fg); text-decoration: none; }
.cta:active { background: var(--action-primary-bg-active); }

/* ---- Empty state ---- */

.empty {
    margin: auto;
    padding: 32px 16px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.empty-title {
    margin: 0;
    font-size: 16px;
    font-weight: var(--weight-medium);
    letter-spacing: -0.16px;
    color: var(--ink);
}

.empty-body {
    margin: 0;
    font-size: 14px;
    line-height: 20px;
    color: var(--body);
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; }
}
