/**
 * Quantity Tier Selector + Subscribe & Save
 * ryytas.lt — production styles
 * @version 4.0.0
 */

:root {
    --rt-font: "Boston Regular", Arial, Helvetica, sans-serif;
    --rt-dark: #1f1f1f;
    --rt-border: #d9d8d3;
    --rt-text: #222;
    --rt-text-light: #888;
    --rt-text-muted: #aaa;
    --rt-bg: #fff;
    --rt-bg-sel: #fafaf8;
    --rt-radius: 14px;
}

/* Hide WooCommerce qty input */
.ryytas-has-tiers .quantity,
.ryytas-has-tiers form.cart .quantity {
    display: none !important;
}

/* Hide NUOLAIDA badge when tier selector is present */
.ryytas-tier-selector ~ .ryytas-sp__discount,
.ryytas-sp__price-row:has(~ #ryytas-sp-form .ryytas-tier-selector) .ryytas-sp__discount,
.ryytas-sp__discount {
    display: none !important;
}

/* ========================
   GRID — 2 columns
   ======================== */
.ryytas-tier-selector {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    width: 100%;
    margin: 1rem 0;
    font-family: var(--rt-font);
}

/* If 3 cards: first card spans full width */
.ryytas-tier-selector .tier-card:first-child:nth-last-child(3) {
    grid-column: 1 / -1;
}

/* ========================
   CARD
   ======================== */
.tier-card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.875rem 0.75rem 0.75rem;
    background: var(--rt-bg);
    border: 1.5px solid var(--rt-border);
    border-radius: var(--rt-radius);
    cursor: pointer;
    text-align: center;
    overflow: visible;
    font-family: var(--rt-font);
    transition: border-color 0.15s ease, background-color 0.15s ease;
    box-sizing: border-box;
}

/* Hover — only on non-selected cards */
.tier-card:not(.selected):hover {
    border-color: #999;
}

.tier-card input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

/* ========================
   SELECTED STATE
   ======================== */
.tier-card.selected {
    border-color: var(--rt-dark);
    background: var(--rt-bg-sel);
}

/* Top accent line */
.tier-card.selected::before {
    content: '';
    position: absolute;
    top: -1.5px;
    left: -1.5px;
    right: -1.5px;
    height: 3px;
    background: var(--rt-dark);
    border-radius: var(--rt-radius) var(--rt-radius) 0 0;
    pointer-events: none;
}

/* Checkmark — top-left to avoid badge overlap */
.tier-card.selected::after {
    content: '\2713';
    position: absolute;
    top: 0.375rem;
    left: 0.375rem;
    width: 1rem;
    height: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--rt-dark);
    color: #fff;
    border-radius: 50%;
    font-size: 0.5625rem;
    font-weight: 600;
    line-height: 1;
}

/* ========================
   BADGE — top-right pill
   ======================== */
.tier-badge {
    position: absolute;
    top: 0.375rem;
    right: 0.375rem;
    padding: 0.1875rem 0.4375rem;
    font-size: 0.5rem;
    font-weight: 500;
    font-family: var(--rt-font);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-radius: 9999px;
    white-space: nowrap;
    z-index: 1;
    background: rgba(31, 31, 31, 0.08);
    color: var(--rt-dark);
    line-height: 1.4;
}

/* ========================
   LABEL
   ======================== */
.tier-label {
    margin-top: 0.25rem;
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--rt-text);
    letter-spacing: 0.01em;
}

/* ========================
   IMAGE
   ======================== */
.tier-image {
    width: 44px;
    height: 44px;
    margin: 0.25rem 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tier-image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* ========================
   PRICE
   ======================== */
.tier-price-wrapper {
    display: flex;
    align-items: baseline;
    gap: 0.25rem;
    justify-content: center;
}

.tier-original-price {
    font-size: 0.625rem;
    color: var(--rt-text-muted);
    text-decoration: line-through;
    text-decoration-color: var(--rt-text-muted);
    font-weight: 400;
}

.tier-price {
    font-size: 1rem;
    font-weight: 500;
    color: var(--rt-text);
    line-height: 1.2;
}

/* ========================
   PER UNIT
   ======================== */
.tier-per-unit {
    font-size: 0.5625rem;
    color: var(--rt-text-light);
    font-weight: 400;
    margin-top: 0.0625rem;
}

/* ========================
   SAVINGS PILL
   ======================== */
.tier-savings {
    margin-top: 0.1875rem;
    padding: 0.0625rem 0.3125rem;
    font-size: 0.5rem;
    font-weight: 400;
    color: var(--rt-dark);
    background: rgba(31, 31, 31, 0.06);
    border-radius: 9999px;
    letter-spacing: 0.01em;
}

.tier-savings:empty {
    display: none;
}

/* ========================
   FOCUS
   ======================== */
.tier-card:focus-within {
    outline: 2px solid var(--rt-dark);
    outline-offset: 2px;
}

/* ========================
   RESPONSIVE
   ======================== */
@media (max-width: 480px) {
    .ryytas-tier-selector {
        gap: 0.375rem;
    }
    .tier-card {
        padding: 0.625rem 0.5rem;
    }
    .tier-image {
        width: 36px;
        height: 36px;
    }
    .tier-price {
        font-size: 0.875rem;
    }
    .tier-badge {
        font-size: 0.4375rem;
        padding: 0.0625rem 0.3125rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .tier-card {
        transition: none;
    }
}

.ryytas-tier-selector:empty {
    display: none;
}

/* Hide main product price when tier selector is present */
.ryytas-sp__panel-inner:has(.ryytas-tier-selector) .ryytas-sp__price-row {
    display: none !important;
}

/* ========================
   WooCommerce .amount override
   Kill font-weight: 600 everywhere
   ======================== */

/* Main product price (fallback if tiers not present) */
.ryytas-sp__price-row .price del {
    color: #aaa;
    font-size: 15px;
    text-decoration: line-through;
    text-decoration-color: #aaa;
}

.ryytas-sp__price-row .price del .woocommerce-Price-amount.amount {
    font-weight: 400 !important;
    font-size: 15px !important;
    color: #aaa;
}

.ryytas-sp__price-row .price ins {
    text-decoration: none;
}

.ryytas-sp__price-row .price ins .woocommerce-Price-amount.amount {
    font-weight: 500 !important;
    font-size: 22px !important;
    color: #1f1f1f;
}

/* Tier card prices */
.tier-original-price .woocommerce-Price-amount.amount {
    font-weight: 400 !important;
    font-size: 0.625rem !important;
    color: var(--rt-text-muted) !important;
}

.tier-price .woocommerce-Price-amount.amount {
    font-weight: 500 !important;
    font-size: 1rem !important;
    color: var(--rt-text) !important;
}

.tier-per-unit .woocommerce-Price-amount.amount {
    font-weight: 400 !important;
    font-size: 0.5625rem !important;
    color: var(--rt-text-light) !important;
}

/* Subscription toggle prices */
.ryytas-toggle-strike .woocommerce-Price-amount.amount {
    font-weight: 400 !important;
    font-size: 0.625rem !important;
    color: var(--rt-text-muted) !important;
}

.ryytas-toggle-price .woocommerce-Price-amount.amount {
    font-weight: 500 !important;
    font-size: 0.8125rem !important;
    color: var(--rt-text) !important;
}

.ryytas-per-serving .woocommerce-Price-amount.amount {
    font-weight: 400 !important;
    font-size: 0.625rem !important;
    color: var(--rt-text-light) !important;
}

/* ============================
   Subscribe & Save Toggle
   ============================ */

.ryytas-purchase-toggle {
    width: 100%;
    margin: 0.75rem 0 1rem;
    border-radius: var(--rt-radius);
    overflow: hidden;
    border: 1px solid var(--rt-border);
    font-family: var(--rt-font);
}

.ryytas-toggle-header {
    background: #f0efe9;
    color: var(--rt-text);
    text-align: center;
    padding: 0.3125rem 0.75rem;
    font-size: 0.625rem;
    font-weight: 400;
    letter-spacing: 0.02em;
}

.ryytas-toggle-option {
    display: flex;
    align-items: flex-start;
    padding: 0.625rem 0.75rem;
    cursor: pointer;
    transition: background 0.12s ease;
    border-bottom: 1px solid #f0efe9;
    background: #fff;
}

.ryytas-toggle-option:last-child {
    border-bottom: none;
}

.ryytas-toggle-option:hover {
    background: #fafaf8;
}

.ryytas-toggle-option.selected {
    background: #fafaf8;
    border-left: 2px solid var(--rt-dark);
}

.ryytas-radio-container {
    flex-shrink: 0;
    margin-right: 0.5rem;
    padding-top: 0.125rem;
}

.ryytas-radio-container input[type="radio"] {
    width: 14px;
    height: 14px;
    accent-color: var(--rt-dark);
    cursor: pointer;
}

.ryytas-toggle-content {
    flex: 1;
    min-width: 0;
}

.ryytas-toggle-title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.375rem;
}

.ryytas-toggle-title {
    font-weight: 400;
    font-size: 0.75rem;
    color: var(--rt-text);
}

.ryytas-toggle-pricing {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-shrink: 0;
}

.ryytas-toggle-strike {
    font-size: 0.625rem;
    color: var(--rt-text-muted);
    text-decoration: line-through;
    text-decoration-color: var(--rt-text-muted);
    font-weight: 400;
}

.ryytas-toggle-price {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--rt-text);
}

.ryytas-toggle-details {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.0625rem;
    font-size: 0.625rem;
    color: var(--rt-text-light);
    font-weight: 400;
}

.ryytas-per-serving {
    font-weight: 400;
    color: var(--rt-text-light);
}

.ryytas-toggle-benefits {
    margin-top: 0.375rem;
    padding-top: 0.375rem;
    border-top: 1px solid #f0efe9;
}

.ryytas-benefit {
    display: flex;
    align-items: center;
    gap: 0.3125rem;
    font-size: 0.625rem;
    font-weight: 400;
    color: var(--rt-text);
    padding: 0.0625rem 0;
}

.ryytas-benefit svg {
    flex-shrink: 0;
}

.ryytas-frequency-selector {
    margin-top: 0.375rem;
    display: flex;
    align-items: center;
    gap: 0.3125rem;
}

.ryytas-frequency-label {
    font-size: 0.625rem;
    font-weight: 400;
    color: var(--rt-text-light);
    white-space: nowrap;
}

.ryytas-frequency-selector select {
    padding: 0.1875rem 0.4375rem;
    border: 1px solid var(--rt-border);
    border-radius: 8px;
    font-size: 0.625rem;
    color: var(--rt-text);
    background: #fff;
    cursor: pointer;
    font-family: var(--rt-font);
}

.ryytas-frequency-selector select:focus {
    outline: none;
    border-color: var(--rt-dark);
    box-shadow: 0 0 0 2px rgba(31, 31, 31, 0.08);
}

@media (max-width: 480px) {
    .ryytas-toggle-title-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.0625rem;
    }
    .ryytas-toggle-pricing {
        align-self: flex-start;
    }
    .ryytas-toggle-details {
        flex-direction: column;
        align-items: flex-start;
    }
    .ryytas-frequency-selector {
        flex-direction: column;
        align-items: flex-start;
    }
    .ryytas-frequency-selector select {
        width: 100%;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ryytas-toggle-benefits,
    .ryytas-frequency-selector {
        transition: none;
    }
}

/* Archive/shop page subscription price */
.ryytas-archive-sub-price del {
    color: var(--rt-text-muted, #aaa);
    font-size: 0.85em;
    margin-right: 4px;
}
.ryytas-archive-sub-price ins {
    text-decoration: none;
    font-weight: 600;
}
.ryytas-sub-suffix {
    font-weight: 400;
    font-size: 0.8em;
    color: var(--rt-text-light, #888);
    margin-left: 1px;
}
