/* ==========================================================================
   Grade Variants Component Stylesheet (Storefront Drawer & Product Detail)
   Adheres to Gareth's Global Rules:
     Rule 1: Semantic CSS variables (:root tokens only, zero hardcoded hex)
     Rule 7: Smooth Dropdown/Drawer Animation (cubic-bezier glide)
     Rule 13: External file separation
     Rule 14: Namespaced classes (.trading-grade-*)
   ========================================================================== */

/* ── 1. Drawer Overlay ──────────────────────────────────────────────────── */
.trading-grade-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s cubic-bezier(0.25, 1, 0.5, 1), visibility 0.3s;
    touch-action: manipulation;
}

.trading-grade-overlay.is-open {
    opacity: 1;
    visibility: visible;
}

/* ── 2. Slide-up Drawer Container ────────────────────────────────────────── */
.trading-grade-drawer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    margin: 0 auto;
    max-width: 600px;
    width: 100%;
    background: var(--bg-surface);
    border-top-left-radius: 24px;
    border-top-right-radius: 24px;
    border: 1px solid var(--border-color);
    border-bottom: none;
    box-shadow: 0 -8px 36px rgba(0, 0, 0, 0.55);
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.25, 1, 0.5, 1);
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 10001;
    touch-action: manipulation;
}

.trading-grade-overlay.is-open .trading-grade-drawer {
    transform: translateY(0);
}

.trading-grade-drawer__handle {
    width: 44px;
    height: 4px;
    background: var(--border-color);
    border-radius: 2px;
    margin: 10px auto 4px;
    flex-shrink: 0;
}

.trading-grade-drawer__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 1.25rem 0.65rem;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.trading-grade-drawer__title-wrap {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
}

.trading-grade-drawer__title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.trading-grade-drawer__sub {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.trading-grade-drawer__close {
    background: var(--btn-secondary-bg);
    color: var(--btn-secondary-text);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.95rem;
    transition: background 0.15s, transform 0.1s;
    flex-shrink: 0;
}

.trading-grade-drawer__close:hover {
    background: var(--btn-secondary-hover);
    color: var(--text-primary);
}

.trading-grade-drawer__close:active {
    transform: scale(0.95);
}

/* ── 3. Options List Inside Drawer ───────────────────────────────────────── */
.trading-grade-drawer__list {
    padding: 0.85rem 1.25rem 1.75rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    -webkit-overflow-scrolling: touch;
}

.trading-grade-item {
    background: var(--table-row-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 0.85rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.85rem;
    transition: background 0.15s, border-color 0.15s;
}

.trading-grade-item:hover {
    background: var(--table-row-hover);
    border-color: var(--accent-solid);
}

.trading-grade-item__thumb {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    object-fit: cover;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    flex-shrink: 0;
}

.trading-grade-item__thumb-placeholder {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 1.35rem;
    flex-shrink: 0;
}

.trading-grade-item__info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.trading-grade-item__badge {
    display: inline-block;
    align-self: flex-start;
    background: rgba(66, 133, 244, 0.14);
    color: var(--accent-solid);
    font-weight: 700;
    font-size: 0.72rem;
    border-radius: 6px;
    padding: 0.15rem 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.trading-grade-item__title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.trading-grade-item__meta {
    font-size: 0.8rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.trading-grade-item__price {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
}

.trading-grade-item__link {
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    transition: color 0.15s;
    margin-top: 0.2rem;
}

.trading-grade-item__link:hover {
    color: var(--accent-solid);
}

.trading-grade-item__action {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.35rem;
    flex-shrink: 0;
}

.trading-grade-item__add-btn {
    background: var(--btn-primary-bg);
    color: var(--btn-primary-text);
    border: none;
    border-radius: 10px;
    padding: 0.45rem 1rem;
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    touch-action: manipulation;
    transition: background 0.15s, transform 0.1s;
    white-space: nowrap;
}

.trading-grade-item__add-btn:hover {
    background: var(--btn-primary-hover);
}

.trading-grade-item__add-btn:active {
    transform: scale(0.97);
}

.trading-grade-item__stepper {
    display: inline-flex;
    align-items: center;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 10px;
    overflow: hidden;
}

.trading-grade-item__stepper-btn {
    background: transparent;
    border: none;
    padding: 0.4rem 0.65rem;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.85rem;
    transition: background 0.15s;
    touch-action: manipulation;
}

.trading-grade-item__stepper-btn:hover {
    background: var(--table-row-hover);
}

.trading-grade-item__stepper-input {
    width: 36px;
    text-align: center;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-weight: 700;
    font-size: 0.9rem;
    outline: none;
    -moz-appearance: textfield;
}

.trading-grade-item__stepper-input::-webkit-outer-spin-button,
.trading-grade-item__stepper-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.trading-grade-item__out-of-stock {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-style: italic;
    padding: 0.45rem 0.5rem;
}

/* ── 4. Product Detail Page Grade Selector Chips ────────────────────────── */
.trading-grade-selector {
    margin: 1.25rem 0 1rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1rem 1.15rem;
}

.trading-grade-selector__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.trading-grade-selector__title {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.trading-grade-selector__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
}

.trading-grade-chip {
    display: inline-flex;
    flex-direction: column;
    background: var(--table-row-bg);
    border: 1.5px solid var(--border-color);
    border-radius: 12px;
    padding: 0.65rem 1rem;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.25, 1, 0.5, 1);
    touch-action: manipulation;
    min-width: 110px;
}

.trading-grade-chip:hover {
    border-color: var(--accent-solid);
    background: var(--table-row-hover);
    transform: translateY(-1px);
}

.trading-grade-chip.is-active {
    border-color: var(--accent-solid);
    background: rgba(66, 133, 244, 0.08);
    box-shadow: 0 0 0 1px var(--accent-solid);
}

.trading-grade-chip__label {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.2rem;
}

.trading-grade-chip.is-active .trading-grade-chip__label {
    color: var(--accent-solid);
}

.trading-grade-chip__price {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-primary);
}

.trading-grade-chip__stock {
    font-size: 0.72rem;
    color: var(--text-secondary);
    margin-top: 0.15rem;
}

.trading-grade-chip.is-out-of-stock {
    opacity: 0.45;
    pointer-events: none;
}
