/* Standalone Scan / QR / server-rendered public pages: use space deliberately. */

.scan-main {
    padding-top: clamp(30px, 3.5vw, 46px) !important;
    padding-bottom: clamp(42px, 5vw, 64px) !important;
}

/* Desktop scanner composition.
   The primary interaction (camera/upload stage) belongs in the large visual area
   beside the headline. Guidance stays with the copy instead of becoming a tall,
   mostly-empty card. */
@media (min-width: 931px) {
    .scan-main {
        display: grid !important;
        grid-template-columns: minmax(0, .9fr) minmax(440px, 1.1fr) !important;
        grid-template-rows: auto 1fr auto !important;
        column-gap: clamp(22px, 3vw, 42px) !important;
        row-gap: 18px !important;
        align-items: stretch !important;
    }

    .scan-intro {
        grid-column: 1 !important;
        grid-row: 1 !important;
        max-width: none !important;
        display: block !important;
        margin: 0 !important;
        padding: clamp(18px, 2.5vw, 34px) 2px 6px !important;
        align-self: end !important;
    }
    .scan-intro h1 {
        margin-bottom: 17px !important;
        max-width: 760px !important;
    }
    .scan-intro > p {
        max-width: 720px !important;
        margin: 0 !important;
    }

    .scanner {
        display: contents !important;
    }

    /* Put the actual scanner in the hero's visual column. */
    .scanner > .stage {
        grid-column: 2 !important;
        grid-row: 1 / span 2 !important;
        min-width: 0 !important;
        min-height: clamp(600px, 66vh, 720px) !important;
        display: grid !important;
        grid-template-rows: minmax(0, 1fr) auto !important;
        align-self: stretch !important;
        padding: 14px !important;
        border-radius: 22px !important;
    }
    .scanner > .stage .viewport {
        width: 100% !important;
        height: 100% !important;
        min-height: 0 !important;
        border-radius: 16px !important;
    }
    .scanner > .stage video,
    .scanner > .stage .preview {
        width: 100% !important;
        height: 100% !important;
        min-height: 0 !important;
    }
    .scanner > .stage .stage-actions {
        margin-top: 12px !important;
    }

    /* Guidance is a compact supporting card directly under the intro. */
    .scanner > .side {
        grid-column: 1 !important;
        grid-row: 2 !important;
        position: relative !important;
        top: auto !important;
        min-width: 0 !important;
        min-height: 0 !important;
        align-self: start !important;
        display: grid !important;
        align-content: start !important;
        padding: clamp(22px, 2.4vw, 30px) !important;
        overflow: hidden !important;
        border-radius: 18px !important;
    }
    .scanner > .side::after {
        content: '';
        position: absolute;
        right: -38px;
        bottom: -44px;
        width: 150px;
        height: 150px;
        pointer-events: none;
        opacity: .045;
        background: url('/brand-icon.svg') center/contain no-repeat;
        transform: rotate(9deg);
    }
    .scanner > .side > * {
        position: relative;
        z-index: 1;
    }
    .scanner > .side h2 {
        margin-bottom: 8px !important;
    }
    .scanner > .side > p {
        margin-bottom: 16px !important;
    }
    .scanner > .side .tips {
        margin-bottom: 0 !important;
    }

    .results {
        grid-column: 1 / -1 !important;
        grid-row: 3 !important;
        margin-top: 14px !important;
    }
}

.scan-intro { max-width: none !important; }
.scanner { gap: 18px !important; }
.stage { padding: 14px !important; }
.side { padding: 21px !important; }
.results { margin-top: 28px !important; }

.qr-shell {
    padding-top: clamp(28px, 3vw, 42px) !important;
}
.qr-shell .hero {
    gap: clamp(28px, 4vw, 46px) !important;
    padding: clamp(26px, 3vw, 38px) !important;
}
.qr-shell .cover { min-height: 250px !important; }
.qr-shell .section { padding-top: 38px !important; }
.qr-shell .qr-panel { margin-top: 34px !important; margin-bottom: 50px; }

/* Strong readable secondary text in both modes. */
html[data-theme='light'] .scan-intro > p,
html[data-theme='light'] .side > p,
html[data-theme='light'] .tips li,
html[data-theme='light'] .result-head small,
html[data-theme='light'] .qr-shell .hero p,
html[data-theme='light'] .qr-copy p {
    color: #52625d !important;
}
html[data-theme='dark'] .scan-intro > p,
html[data-theme='dark'] .side > p,
html[data-theme='dark'] .tips li,
html[data-theme='dark'] .result-head small,
html[data-theme='dark'] .qr-shell .hero p,
html[data-theme='dark'] .qr-copy p {
    color: #9dadaa !important;
}

html[data-theme='light'] .stage,
html[data-theme='light'] .side,
html[data-theme='light'] .qr-shell .hero,
html[data-theme='light'] .qr-panel,
html[data-theme='light'] .match,
html[data-theme='light'] .qr-shell .card {
    border-color: rgba(45,61,55,.12) !important;
    background-color: rgba(255,253,247,.88) !important;
}

/* Remove artwork gutters on standalone result/chase cards. */
.match-img,
.qr-shell .art {
    padding: 0 !important;
    overflow: hidden !important;
}
.match-img img,
.qr-shell .art img {
    display: block !important;
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 0 !important;
    object-fit: cover !important;
}

@media (max-width: 930px) {
    .scan-main { display: block !important; }
    .scan-intro {
        display: block !important;
        margin-bottom: 18px !important;
    }
    .scan-intro > p { margin-top: 14px !important; }
    .scanner { display: grid !important; grid-template-columns: 1fr !important; }
    .stage {
        min-height: 0 !important;
        display: block !important;
    }
    .side { position: static !important; min-height: 0 !important; }
}

@media (max-width: 620px) {
    .scan-main { padding-top: 26px !important; }
    .scan-intro { margin-bottom: 18px !important; }
    .scan-intro h1 { font-size: clamp(40px, 13vw, 56px) !important; }
    .scan-intro > p { margin-top: 12px !important; line-height: 1.6 !important; }
    .stage { padding: 9px !important; }
    .side { padding: 16px !important; }
    .qr-shell .hero { padding: 19px !important; gap: 20px !important; }
    .qr-shell .section { padding-top: 30px !important; }
}
