/* =============================================
   RESPONSIVE FIXES — Production-Ready
   Consolidated mobile/cross-device overrides.
   Load AFTER site.css & custom_theme.css.
   ============================================= */

/* ─── BASE RESETS & SAFETY ─── */
html {
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    min-width: 320px;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

img,
video,
svg,
canvas {
    max-width: 100%;
    height: auto;
    display: block;
}

/* ─── SAFE AREA (Notch devices) ─── */
body {
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
}

.main-header {
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
}

.seo-footer {
    padding-bottom: calc(40px + env(safe-area-inset-bottom, 0px));
}

/* ─── HEADER — Stable across all widths ─── */
.header-container {
    flex-wrap: nowrap;
    min-height: 0;
    gap: var(--space-2, 8px);
}

.header-actions {
    flex-shrink: 0;
    flex-wrap: nowrap;
}

/* ─── QUANTITY INPUT — Fluid width ─── */
#quantity-input {
    max-width: 100%;
    width: min(240px, 80vw);
}

/* ─── FREE RIBBON — Clip overflow ─── */
.free-ribbon {
    pointer-events: none;
    z-index: 10;
}

.platform-card {
    overflow: hidden;
}

.card-inner {
    overflow: hidden;
}

/* ─── PACKAGES GRID — Smooth breakpoints ─── */
.packages-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
}

/* ─── TOOL WRAPPER — Single source of truth ─── */
.tool-wrapper {
    width: 100%;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
    overflow: hidden;
}

/* ─── FEATURED TOOLS GRID — Fluid ─── */
.featured-tools-grid {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
}

/* ─── RELATED TOOLS GRID — Unified (resolve flex vs grid conflict) ─── */
.related-tools-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
    align-items: stretch;
}

.related-tools-grid > a,
.related-tools-grid > .related-tool-card {
    flex: 0 1 220px;
    min-width: 0;
}

.related-tool-card {
    height: 100%;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* ─── HERO CTA — Unified sizing ─── */
.hero-cta-btn {
    width: auto;
    max-width: 100%;
    white-space: nowrap;
}

/* ─── DYNAMIC ADD TO CART — Unified ─── */
#dynamic-add-to-cart-btn {
    max-width: 100%;
    white-space: normal;
    word-wrap: break-word;
}

/* ─── TRUST BOX — Prevent text overflow ─── */
.trust-box-item .tb-content p {
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.trust-box-item .tb-content h4 {
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* ─── SC-EMOTION-SUBTITLE — Fix white-space conflict ─── */
#sc-emotion-subtitle {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    word-wrap: break-word;
}

/* ─── SCRATCH CARD — Prevent overflow ─── */
.scratch-card-container {
    max-width: 100%;
    overflow: hidden;
}

/* ─── DETAIL ROW — Word break for long values ─── */
.detail-row span,
.detail-row strong {
    word-wrap: break-word;
    overflow-wrap: break-word;
    min-width: 0;
}

/* ─── SHARE BUTTONS — Proper wrap ─── */
.share-buttons {
    gap: 10px;
}

.share-btn {
    flex-shrink: 0;
}

/* ─── PAYMENT CONTAINER — Fluid ─── */
.payment-container {
    max-width: 100%;
}

/* ─── FORM INPUTS — iOS zoom prevention (≥ 16px) ─── */
input[type="text"],
input[type="number"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="url"],
input[type="tel"],
select,
textarea {
    font-size: max(1rem, 16px);
}

/* ─── MODAL — Viewport safe ─── */
.site-modal-popup-overlay {
    padding: 15px;
    padding-top: calc(15px + env(safe-area-inset-top, 0px));
    padding-bottom: calc(15px + env(safe-area-inset-bottom, 0px));
}

.site-modal-popup {
    max-height: calc(100vh - 30px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    overflow-y: auto;
}

/* ─── REWARD STEP SCALE — Prevent horizontal overflow ─── */
.reward-step-sc.current-tier,
.reward-step-sc.unlocked {
    transform: none;
}

/* ─── CQS ADVANTAGE RATE — Prevent overflow ─── */
.cqs-advantage-rate {
    max-width: 100%;
    word-wrap: break-word;
}

/* ─── INPUT GROUP — Fluid ─── */
.input-group-with-button {
    max-width: 100%;
}

.input-group-with-button .form-input {
    min-width: 0;
}

/* ─── COUPON CODE DISPLAY — Word break ─── */
.coupon-code-display {
    word-break: break-all;
    max-width: 100%;
}

/* ─── HOVER PROTECTION FOR TOUCH DEVICES ─── */


/* =============================================
   TABLET (max-width: 992px)
   ============================================= */
@media (max-width: 992px) {
    .packages-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }

    .related-tools-grid > a,
    .related-tools-grid > .related-tool-card {
        flex: 0 1 200px;
    }

    .hero-details {
        gap: 10px;
    }
    
    .hero-value-badge {
        min-width: 120px;
    }
}

/* =============================================
   MOBILE (max-width: 768px)
   ============================================= */
@media (max-width: 768px) {
    /* Container padding */
    .container {
        padding-left: 12px;
        padding-right: 12px;
    }

    /* Platform grid */
    .platform-grid {
        grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr));
        gap: 15px;
    }

    /* Packages — 2 col at tablet, handled above */

    /* Trust box stack */
    .trust-box-container {
        flex-direction: column;
    }

    .trust-box-item {
        border-right: none;
        border-bottom: 1px solid #f0f0f0;
        padding: 15px 12px;
        flex-direction: row;
        gap: 12px;
    }

    .trust-box-item:last-child {
        border-bottom: none;
    }

    .trust-box-item .tb-icon {
        margin-bottom: 0;
        width: 40px;
        height: 40px;
        font-size: var(--font-lg, 18px);
    }

    .trust-box-item .tb-content {
        text-align: left;
    }

    /* Tool steps */
    #tool-container {
        padding: 20px 12px;
        border-radius: 20px;
    }

    .tool-step.active {
        padding: 20px;
        border-radius: 16px;
    }

    /* Input group stacking */
    .input-group-with-button {
        flex-direction: column;
        align-items: stretch;
    }

    .input-group-with-button .form-input,
    .input-group-with-button .btn-validate {
        width: 100%;
        min-width: 100%;
        min-height: 44px;
    }

    /* Task items stack */
    .task-item {
        flex-direction: column;
        text-align: center;
        gap: 10px;
        padding: 15px;
    }

    .task-content {
        width: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 5px;
    }

    .task-action-btn {
        width: 100%;
        justify-content: center;
        margin-left: 0;
    }

    /* Desktop-only elements */
    .desktop-only {
        display: none;
    }

    /* Related tools — 2 col */
    .related-tools-grid > a,
    .related-tools-grid > .related-tool-card {
        flex: 0 1 calc(50% - 0.5rem);
        min-width: 0;
    }

    /* Slider bigger touch target */
    input[type="range"] {
        height: 14px;
        border-radius: 7px;
    }

    input[type=range]::-webkit-slider-thumb {
        width: 48px;
        height: 30px;
        background-size: 24px;
    }

    input[type=range]::-moz-range-thumb {
        width: 48px;
        height: 30px;
        background-size: 24px;
    }

    /* Dynamic platform selector */
    .dynamic-platform-selector {
        gap: 8px;
    }

    /* Selector options flex */
    .dynamic-selector-option {
        flex: 1 1 45%;
    }

    /* Reward progress — vertical on mobile */
    .reward-progress-steps-sc {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    .reward-step-sc {
        flex-direction: row;
        align-items: center;
        text-align: left;
        gap: 12px;
        padding: 12px;
    }

    .reward-step-sc .step-icon {
        font-size: 1.8rem;
        margin: 0;
        flex-shrink: 0;
    }

    .reward-step-sc .step-content {
        flex: 1;
        min-width: 0;
    }

    /* Payment container */
    .payment-container {
        margin: 20px auto;
        padding: 0 12px;
    }

    .success-container {
        padding: 25px 15px;
    }

    /* Scratch card */
    .scratch-card-container {
        width: 100%;
        max-width: 100%;
        padding: 20px 15px;
    }

    /* Page intro */
    .page-intro h1 {
        font-size: clamp(1.5rem, 5vw, 2rem);
    }

    /* Trust badges wrap */
    .trust-badges-container {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
    }

    .trust-badge {
        flex: 0 1 auto;
    }

    /* Share buttons stack */
    .share-buttons {
        flex-direction: column;
        align-items: center;
    }

    .share-btn {
        width: 100%;
        max-width: 300px;
        justify-content: center;
    }

    /* Hero details stack */
    .hero-details {
        flex-direction: column;
        align-items: center;
        gap: 10px;
    }

    .hero-value-badge,
    .hero-code-badge {
        width: 100%;
        max-width: 300px;
        padding: 12px 15px;
    }

    /* Section titles */
    .section-title h1,
    .section-title h2 {
        font-size: clamp(1.6rem, 5vw, 2.2rem);
    }

    .section-title-alt h2 {
        font-size: clamp(1.4rem, 4vw, 1.8rem);
    }

    /* Prevent iOS zoom on inputs */
    .form-input,
    .coupon-input,
    .tracking-input,
    .popup-input,
    .item-link-input {
        font-size: 16px;
    }

    /* Navigation tabs scroll */
    .nav-tabs {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .nav-tabs::-webkit-scrollbar {
        display: none;
    }

    .nav-tabs .nav-link {
        white-space: nowrap;
    }

    /* Modal adjustments */
    .modal-dialog {
        margin: 0.5rem;
    }

    /* Tracking widget stack */
    .tracking-widget-card {
        flex-direction: column;
        gap: var(--space-3, 12px);
    }

    .tracking-widget-header {
        width: 100%;
        justify-content: space-between;
    }

    .tracking-widget-form {
        width: 100%;
    }

    .tracking-input-group {
        flex-direction: column;
        gap: var(--space-2, 8px);
        background: transparent;
        border: none;
    }

    .tracking-input {
        width: 100%;
        border: 1px solid var(--border-color);
        border-radius: var(--border-radius-md, 8px);
    }

    .tracking-submit-btn {
        width: 100%;
        justify-content: center;
        margin: 0;
    }
}

/* =============================================
   SMALL MOBILE (max-width: 576px)
   ============================================= */
@media (max-width: 576px) {
    /* Platform grid single col */
    .platform-grid {
        grid-template-columns: 1fr;
    }

    /* Packages single col */
    .packages-grid {
        grid-template-columns: 1fr;
    }

    /* Platform selector 3-col grid */
    .dynamic-platform-selector {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
        justify-items: center;
    }

    .dynamic-platform-selector .platform-card {
        height: 75px;
        width: 100%;
        padding: 8px 4px;
        flex: none;
    }

    .dynamic-platform-selector .platform-card .platform-icon {
        font-size: 1.4rem;
    }

    .dynamic-platform-selector .platform-card .platform-name {
        font-size: 0.65rem;
    }

    /* CQS padding */
    .custom-quantity-selector-dynamic {
        padding: 15px;
    }

    /* Quantity input smaller */
    #quantity-input {
        width: min(180px, 70vw);
        font-size: 2.5rem;
    }

    /* Selector options full width */
    .dynamic-selector-option {
        flex: 1 1 100%;
    }

    /* Add to cart full width */
    #dynamic-add-to-cart-btn {
        padding: 15px 20px;
        font-size: 0.9rem;
        min-height: 60px;
        width: 100%;
        min-width: 0;
    }

    /* Trust badges smaller */
    .trust-badges-container {
        gap: 8px;
    }

    .trust-badge {
        padding: 5px 12px;
        font-size: 0.8rem;
        min-width: auto;
    }

    /* Header */
    .main-header {
        min-height: var(--header-height-mobile, 60px);
    }

    .main-header .logo img {
        max-height: 36px;
    }

    .header-cart-text {
        display: none;
    }

    /* Footer legal links vertical */
    .footer-legal-links a {
        display: block;
        margin: 5px 0;
    }

    .footer-legal-links a:not(:last-child)::after {
        content: '';
        margin-left: 0;
    }

    /* Share buttons full width */
    .share-btn {
        padding: 10px 20px;
        font-size: 0.9rem;
        max-width: 100%;
    }

    /* Iframe height fix */
    #paytriframe {
        top: var(--header-height-mobile, 60px);
        height: calc(100vh - var(--header-height-mobile, 60px));
    }

    /* Redeem upsell grid */
    .redeem-upsell-grid {
        grid-template-columns: 1fr;
    }

    /* Scratch card */
    .scratch-card-container {
        padding: 15px 10px;
    }

    #sc-emotion-title {
        font-size: 1.2rem;
    }

    .prize-content {
        font-size: 1.5rem;
    }

    /* Reward steps */
    .reward-step {
        min-width: 100%;
        flex-direction: row;
        align-items: center;
        text-align: left;
        gap: 15px;
    }

    .step-icon {
        margin-bottom: 0;
        font-size: 2rem;
    }

    /* Notification panel */
    #notification-panel {
        width: 90vw;
        max-width: none;
        position: fixed;
        top: calc(var(--header-height-mobile, 60px) + 5px);
        right: auto;
        left: 50%;
        transform: translateX(-50%);
        border-radius: 12px;
        z-index: 2000;
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    }

    /* Related tools — keep 2 col */
    .related-tools-grid > a,
    .related-tools-grid > .related-tool-card {
        flex: 0 1 calc(50% - 0.5rem);
    }
}

/* =============================================
   EXTRA SMALL (max-width: 480px)
   ============================================= */
@media (max-width: 480px) {
    /* Slider bigger */
    input[type=range]::-webkit-slider-thumb {
        width: 52px;
        height: 32px;
    }

    input[type=range]::-moz-range-thumb {
        width: 52px;
        height: 32px;
    }

    /* Detail rows stack */
    .detail-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
        padding: 8px 0;
    }

    .detail-row span:last-child,
    .detail-row strong {
        text-align: left;
    }

    /* Order items stack */
    .order-items-list li {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .item-price {
        align-self: flex-end;
    }

    /* Order detail boxes overflow */
    .order-details-box,
    .customer-details-box {
        overflow-x: auto;
        word-wrap: break-word;
    }

    /* Payment container tighter */
    .payment-container {
        margin: 10px auto;
        gap: var(--space-4, 16px);
    }

    .success-container {
        padding: 20px 12px;
    }

    .success-container h1 {
        font-size: 1.4rem;
    }

    /* Scratch zone deeper on small */
    .scratch-zone {
        padding-bottom: 55%;
    }

    /* CTA button full */
    #claim-prize-btn {
        padding: 12px 20px;
        font-size: 0.95rem;
        min-width: 0;
        width: 100%;
        max-width: 280px;
    }

    /* Footer text */
    .footer-text-sc {
        font-size: 0.65rem;
    }

    /* Input popup */
    .site-modal-popup.input-popup {
        padding: 16px 14px;
        width: 92%;
        max-width: none;
    }

    /* Selector options chips */
    .dynamic-selector-option {
        min-height: 32px;
        padding: 4px 12px;
    }

    .dynamic-selector-option span {
        font-size: 0.78rem;
    }

    /* Featured tools grid */
    .featured-tools-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    /* Package header title wrap protection */
    .package-header h3 {
        font-size: 0.95rem;
        padding-right: 0;
        max-width: 100%;
    }

    /* Gold gradient text */
    .gold-gradient-text {
        font-size: 1.6rem;
    }

    /* SEO content quote */
    .seo-content-quote {
        margin: 1rem 0;
        padding: 1.2rem 1rem;
        font-size: 0.9rem;
    }
}

/* =============================================
   MINIMUM WIDTH (max-width: 360px)
   ============================================= */
@media (max-width: 360px) {
    .container {
        padding-left: 8px;
        padding-right: 8px;
    }

    /* Platform cards 1 col */
    .dynamic-platform-selector {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }

    .dynamic-platform-selector .platform-card {
        height: 68px;
        padding: 6px 2px;
    }

    .dynamic-platform-selector .platform-card .platform-icon {
        font-size: 1.2rem;
    }

    .dynamic-platform-selector .platform-card .platform-name {
        font-size: 0.58rem;
    }

    /* Header actions tighter */
    .header-actions {
        gap: 4px;
    }

    .header-actions a {
        padding: 6px 8px;
    }

    /* Quantity input for tiny screens */
    #quantity-input {
        width: 100%;
        max-width: 160px;
        font-size: 2.2rem;
    }

    /* Package price smaller */
    .final-price {
        font-size: 1.8rem;
    }

    /* Hero CTA narrow */
    .hero-cta-btn {
        padding: 12px 20px;
        font-size: 0.9rem;
        gap: 8px;
    }

    /* Trust badge inline */
    .trust-badge {
        padding: 4px 10px;
        font-size: 0.75rem;
        gap: 6px;
    }

    /* Share buttons tighter */
    .share-btn {
        padding: 8px 15px;
        font-size: 0.85rem;
    }

    .share-btn i {
        margin-right: 6px;
        font-size: 1rem;
    }
}

/* =============================================
   LANDSCAPE PHONE FIX
   ============================================= */
@media (max-height: 500px) and (orientation: landscape) {
    .main-header {
        min-height: 50px;
        padding-top: var(--space-2, 8px);
        padding-bottom: var(--space-2, 8px);
    }

    .main-header .logo img {
        max-height: 32px;
    }

    main {
        padding-top: 15px;
        padding-bottom: 15px;
    }

    .platform-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
        gap: 10px;
    }

    .platform-icon {
        font-size: 2.5rem;
    }

    .tool-step.active {
        padding: 15px;
    }

    /* Scratch zone less tall */
    .scratch-zone {
        padding-bottom: 35%;
    }

    /* Modals shorter */
    .site-modal-popup {
        max-height: 85vh;
    }

    /* Reward hero compact */
    .reward-hero-section {
        padding: 15px;
    }
}

/* =============================================
   PRINT STYLES — Basic cleanup
   ============================================= */
@media print {
    .main-header,
    .mini-cart,
    .mini-cart-overlay,
    .mini-cart-handle,
    .header-actions,
    .share-section,
    .share-buttons,
    .tracking-widget-wrapper,
    .site-modal-popup-overlay,
    .site-modal-popup,
    #notification-panel {
        display: none;
    }

    body {
        background: white;
        color: black;
    }

    main {
        padding: 0;
    }

    .container {
        max-width: 100%;
        padding: 0;
    }
}

/* =============================================
   HIGH DPI (Retina) — Sharper borders
   ============================================= */

@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .platform-card::before {
        border-radius: 22px;
    }
}

/* NOTIFICATION PANEL MOBILE FIX */
@media (max-width: 768px) {
    #notification-panel {
        position: fixed !important;
        top: 80px !important;
        left: 50% !important;
        right: auto !important;
        transform: translateX(-50%) !important;
        width: 94vw !important;
        max-width: 420px !important;
        max-height: 80vh !important;
        overflow-y: auto !important;
        z-index: 99999 !important;
        box-shadow: 0 10px 40px rgba(0,0,0,0.3) !important;
        border: 1px solid var(--border-color) !important;
        border-radius: 16px !important;
        display: none;
        background-color: var(--card-background) !important;
    }

    #notification-panel.active, 
    #notification-panel[style*="display: block"] {
        display: block !important;
        animation: fadeInDown 0.3s ease-out;
    }

    .notification-item {
        padding: 16px !important;
        border-bottom: 1px solid rgba(0,0,0,0.06) !important;
    }

    .notification-text {
        font-size: 1rem !important;
        line-height: 1.5 !important;
    }

    .header-actions {
        position: static !important;
    }
    
    .notification-container {
        position: static !important;
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translate(-50%, -10px);
    }
    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}


