

/* =========================================================
   RUST INVESTOR — RESPONSIVE LAYER
   Desktop + tablet + mobile
   ========================================================= */

html {
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
}

body {
    min-width: 0;
    overflow-x: hidden;
}

img, svg, video, canvas {
    max-width: 100%;
}

button, input, select, textarea {
    max-width: 100%;
    font: inherit;
}

/* Main containers */
.container, .page, main, .content, .site-main {
    width: min(100% - 32px, 1500px);
    margin-left: auto;
    margin-right: auto;
}

/* Wide desktop */
@media (min-width: 1600px) {
    .container, .page, main, .content, .site-main {
        width: min(100% - 64px, 1680px);
    }
}

/* Medium desktop / laptops */
@media (max-width: 1199px) {
    .container, .page, main, .content, .site-main {
        width: min(100% - 28px, 1180px);
    }
}

/* Tablet */
@media (max-width: 900px) {
    .container, .page, main, .content, .site-main {
        width: calc(100% - 24px);
    }

    .grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }

    .hero,
    .hero-content,
    .detail-layout,
    .analysis-layout,
    .market-layout {
        grid-template-columns: 1fr !important;
    }

    .filters,
    .filter-row,
    .toolbar {
        flex-wrap: wrap !important;
    }

    table {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* Mobile */
@media (max-width: 640px) {
    .container, .page, main, .content, .site-main {
        width: calc(100% - 20px);
    }

    header,
    .header,
    nav,
    .navbar {
        min-height: 0;
    }

    .header-inner,
    .nav-inner,
    .navbar-inner {
        flex-wrap: wrap;
        gap: 10px;
    }

    /* Navigation */
    nav ul,
    .nav-links {
        width: 100%;
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
    }

    nav a,
    .nav-links a {
        padding: 8px 10px;
    }

    /* Hero */
    .hero,
    .hero-content {
        padding: 22px 0 !important;
    }

    .hero h1 {
        font-size: clamp(28px, 8vw, 42px) !important;
        line-height: 1.05;
    }

    .hero p {
        font-size: 14px;
        line-height: 1.5;
    }

    /* Skin grid */
    .grid {
        grid-template-columns: 1fr !important;
        gap: 14px !important;
    }

    .skin-card {
        width: 100%;
        min-width: 0;
    }

    .skin-image {
        height: 190px !important;
        min-height: 190px !important;
        flex-basis: 190px !important;
    }

    .skin-image img {
        max-width: 72% !important;
        max-height: 72% !important;
    }

    .skin-body {
        min-width: 0;
    }

    .skin-title,
    .skin-name,
    .card-title {
        overflow-wrap: anywhere;
        word-break: break-word;
    }

    /* Search / filters */
    .filters,
    .filter-row,
    .toolbar {
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
        width: 100%;
        gap: 9px !important;
    }

    .filters > *,
    .filter-row > *,
    .toolbar > * {
        width: 100% !important;
        min-width: 0 !important;
    }

    input,
    select,
    button {
        min-height: 42px;
    }

    /* Date/week navigation */
    .week-tabs,
    .date-tabs,
    .store-tabs {
        display: flex !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        justify-content: flex-start !important;
        gap: 8px;
        padding-bottom: 5px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
    }

    .week-tabs > *,
    .date-tabs > *,
    .store-tabs > * {
        flex: 0 0 auto;
    }

    /* Detail pages */
    .detail,
    .detail-page,
    .detail-layout,
    .skin-detail {
        width: 100%;
        min-width: 0;
    }

    .detail-image,
    .detail-hero-image {
        min-height: 220px;
        max-height: 360px;
    }

    .detail-image img,
    .detail-hero-image img {
        max-height: 300px;
        object-fit: contain;
    }

    .metrics,
    .metric-grid,
    .stats-grid,
    .analysis-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 8px !important;
    }

    .metric,
    .stat,
    .analysis-card {
        min-width: 0;
    }

    /* Market cards / tables */
    .market-card,
    .panel,
    .card,
    .analysis-card {
        min-width: 0;
        max-width: 100%;
    }

    .market-table,
    .data-table {
        overflow-x: auto;
        display: block;
        width: 100%;
    }

    /* Prevent long URLs / IDs from expanding viewport */
    code,
    pre,
    .mono,
    .url,
    .external-id {
        max-width: 100%;
        overflow-wrap: anywhere;
        word-break: break-word;
    }

    /* Footer */
    footer {
        padding-left: 10px;
        padding-right: 10px;
    }
}

/* Small phones */
@media (max-width: 420px) {
    .container, .page, main, .content, .site-main {
        width: calc(100% - 16px);
    }

    .metrics,
    .metric-grid,
    .stats-grid,
    .analysis-grid {
        grid-template-columns: 1fr !important;
    }

    .skin-image {
        height: 175px !important;
        min-height: 175px !important;
        flex-basis: 175px !important;
    }

    .hero h1 {
        font-size: 30px !important;
    }

    .tooltip,
    [role="tooltip"] {
        max-width: min(280px, calc(100vw - 24px));
    }
}

/* Touch devices: don't depend exclusively on hover */
@media (hover: none) and (pointer: coarse) {
    .tooltip-trigger,
    [data-tooltip],
    .help,
    .info {
        cursor: pointer;
    }

    a,
    button,
    select,
    input {
        touch-action: manipulation;
    }
}


/* =========================================================
   MOBILE HARD FIX — 1 CARD PER ROW / NO OVERFLOW
   ========================================================= */

@media screen and (max-width: 767px) {
    html,
    body {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        overflow-x: hidden !important;
    }

    *,
    *::before,
    *::after {
        box-sizing: border-box !important;
        min-width: 0;
        max-width: 100%;
    }

    .container,
    .page,
    main,
    .content,
    .site-main,
    .main,
    .wrapper {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        padding-left: 10px !important;
        padding-right: 10px !important;
    }

    /* ABSOLUTE RULE: one skin per row on phones */
    .grid,
    .skins-grid,
    .skin-grid,
    .items-grid {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        gap: 12px !important;
    }

    .grid > *,
    .skins-grid > *,
    .skin-grid > *,
    .items-grid > * {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        grid-column: 1 / -1 !important;
    }

    .skin-card,
    .card {
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        margin: 0 !important;
        overflow: hidden !important;
    }

    .skin-image {
        width: 100% !important;
        max-width: 100% !important;
        height: 170px !important;
        min-height: 170px !important;
        flex: 0 0 170px !important;
        overflow: hidden !important;
    }

    .skin-image img {
        display: block !important;
        width: auto !important;
        max-width: 70% !important;
        height: auto !important;
        max-height: 78% !important;
        object-fit: contain !important;
        margin: auto !important;
    }

    .skin-body,
    .skin-card-body,
    .card-body {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        overflow: hidden !important;
    }

    .skin-title,
    .skin-name,
    .card-title,
    .skin-body h2,
    .skin-body h3 {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        overflow-wrap: anywhere !important;
        word-break: break-word !important;
        white-space: normal !important;
    }

    /* Metrics inside cards: never preserve desktop width */
    .skin-meta,
    .skin-stats,
    .card-stats,
    .metrics,
    .metric-grid,
    .stats-grid,
    .analysis-grid {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }

    .skin-meta > *,
    .skin-stats > *,
    .card-stats > *,
    .metrics > *,
    .metric-grid > *,
    .stats-grid > *,
    .analysis-grid > * {
        min-width: 0 !important;
        max-width: 100% !important;
    }

    /* Header / navigation */
    header,
    .header,
    .header-inner,
    .nav,
    .navbar,
    .navbar-inner {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
    }

    .header-inner,
    .navbar-inner {
        flex-wrap: wrap !important;
    }

    nav,
    nav ul,
    .nav-links {
        max-width: 100% !important;
        min-width: 0 !important;
    }

    nav ul,
    .nav-links {
        overflow-x: auto !important;
        flex-wrap: nowrap !important;
        justify-content: flex-start !important;
        -webkit-overflow-scrolling: touch;
    }

    /* Search and filters */
    .filters,
    .filter-row,
    .toolbar,
    form {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        flex-direction: column !important;
        align-items: stretch !important;
    }

    .filters > *,
    .filter-row > *,
    .toolbar > *,
    form > * {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
    }

    input,
    select,
    textarea,
    button {
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }

    /* Week tabs can scroll, page itself cannot */
    .week-tabs,
    .date-tabs,
    .store-tabs {
        width: 100% !important;
        max-width: 100% !important;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        flex-wrap: nowrap !important;
        justify-content: flex-start !important;
        -webkit-overflow-scrolling: touch;
    }

    .week-tabs > *,
    .date-tabs > *,
    .store-tabs > * {
        flex: 0 0 auto !important;
        width: auto !important;
        max-width: none !important;
    }

    /* Detail page */
    .detail-layout,
    .detail-page,
    .skin-detail,
    .hero,
    .hero-content,
    .market-layout,
    .analysis-layout {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
    }

    .detail-image,
    .detail-hero-image {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        min-height: 190px !important;
        max-height: 330px !important;
        overflow: hidden !important;
    }

    /* Any row of inline metric blocks may wrap instead of overflow */
    .metrics,
    .stats,
    .badges,
    .chips,
    .tags {
        display: flex !important;
        flex-wrap: wrap !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
    }

    .metrics > *,
    .stats > *,
    .badges > *,
    .chips > *,
    .tags > * {
        max-width: 100% !important;
        min-width: 0 !important;
    }

    /* Long data cannot widen the viewport */
    p,
    span,
    div,
    a,
    td,
    th,
    code,
    pre {
        overflow-wrap: anywhere;
        word-break: normal;
    }

    pre {
        white-space: pre-wrap !important;
    }

    table {
        width: 100% !important;
        max-width: 100% !important;
    }
}

@media screen and (max-width: 420px) {
    .container,
    .page,
    main,
    .content,
    .site-main,
    .main,
    .wrapper {
        padding-left: 8px !important;
        padding-right: 8px !important;
    }

    .grid,
    .skins-grid,
    .skin-grid,
    .items-grid {
        gap: 10px !important;
    }

    .skin-image {
        height: 155px !important;
        min-height: 155px !important;
        flex-basis: 155px !important;
    }

    .metrics,
    .metric-grid,
    .stats-grid,
    .analysis-grid,
    .skin-meta,
    .skin-stats,
    .card-stats {
        grid-template-columns: 1fr 1fr !important;
        gap: 6px !important;
    }
}
