/* Scan flow, mobile first. Uses sg-scan BEM block. */
.sg-scan {
    padding-bottom: 48px;
}

.sg-scan__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 0 8px;
    border-bottom: 1px solid var(--sg-line);
}

.sg-scan__brand {
    font-weight: 800;
    font-size: 1.2rem;
    color: var(--sg-green);
    text-decoration: none;
}

.sg-scan__label {
    font-weight: 700;
    font-size: 1rem;
    color: var(--sg-muted);
}

.sg-scan__panel {
    padding-top: 28px;
}

.sg-scan__title {
    margin: 0 0 12px;
    font-size: clamp(1.6rem, 2vw + 1.1rem, 2.2rem);
    font-weight: 800;
    letter-spacing: -0.02em;
}

.sg-scan__intro {
    margin: 0 0 24px;
    font-size: 1.1rem;
    line-height: 1.6;
    color: var(--sg-muted);
    max-width: 40rem;
}

.sg-scan__camera-wrap {
    display: flex;
    justify-content: center;
    margin-bottom: 24px;
}

.sg-scan__camera {
    position: relative;
    text-align: center;
    cursor: pointer;
    width: 100%;
    max-width: 340px;
}

.sg-scan__input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.sg-scan__camera-text {
    pointer-events: none;
}

.sg-scan__previews {
    list-style: none;
    margin: 0 0 24px;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
}

.sg-scan__preview {
    position: relative;
    width: 104px;
    height: 104px;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--sg-line);
    box-shadow: var(--sg-shadow);
}

.sg-scan__preview-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.sg-scan__actions {
    display: flex;
    justify-content: center;
}

.sg-scan__submit[disabled] {
    opacity: 0.45;
    cursor: not-allowed;
}

/* Author display:flex must not beat the hidden attribute, or overlays leak on top. */
.sg-scan__loading[hidden],
.sg-scan__result[hidden] {
    display: none !important;
    pointer-events: none;
}

.sg-scan__loading {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    background-color: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(4px);
}

.sg-scan__spinner {
    width: 52px;
    height: 52px;
    border-radius: 999px;
    border: 4px solid var(--sg-line);
    border-top-color: var(--sg-green);
    animation: sg-scan-spin 0.85s linear infinite;
}

.sg-scan__loading-text {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--sg-text);
}

.sg-scan__error {
    margin: 16px auto;
    padding: 16px 18px;
    border-radius: 12px;
    border: 1px solid #e0b4b4;
    background-color: #fff5f5;
    color: #6b1d1d;
    font-weight: 600;
    text-align: center;
    max-width: 36rem;
}

.sg-scan__result {
    position: fixed;
    inset: 0;
    z-index: 90;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    text-align: center;
}

.sg-scan__result-inner {
    max-width: 28rem;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: center;
}

.sg-scan__verdict {
    margin: 0;
    font-size: clamp(2.2rem, 6vw + 1rem, 3.2rem);
    line-height: 1.1;
    font-weight: 800;
    color: #ffffff;
}

.sg-scan__reason {
    margin: 0;
    font-size: 1.15rem;
    line-height: 1.55;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.95);
}

.sg-scan__label-reading-wrap {
    width: 100%;
    max-width: 100%;
    text-align: left;
    border-radius: 12px;
    background-color: rgba(0, 0, 0, 0.22);
    padding: 14px 14px 12px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.sg-scan__label-reading-wrap[hidden] {
    display: none !important;
    pointer-events: none;
}

.sg-scan__label-reading-title {
    margin: 0 0 4px;
    text-align: center;
    font-size: 0.95rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #ffffff;
}


.sg-scan__label-reading-text {
    margin: 0;
    padding: 0;
    max-height: 38vh;
    overflow-y: auto;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
    font-size: 0.85rem;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
    color: rgba(255, 255, 255, 0.96);
    scroll-margin-top: 12px;
}

.sg-scan__result-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    align-items: center;
}

@media (min-width: 28rem) {
    .sg-scan__result-actions {
        flex-direction: row;
        justify-content: center;
    }
}

.sg-scan__result .sg-scan__save-btn {
    background-color: transparent;
    color: #ffffff;
    border: 2px solid #ffffff;
}

.sg-scan__result .sg-scan__save-btn:hover,
.sg-scan__result .sg-scan__save-btn:focus {
    background-color: rgba(255, 255, 255, 0.15);
}

.sg-scan__result-actions .sg-scan__save-btn[hidden],
.sg-scan__result-actions .sg-scan__again[hidden] {
    display: none !important;
}

.sg-scan__result .sg-scan__again {
    background-color: #ffffff;
    color: var(--sg-text);
    border-color: #ffffff;
}

.sg-scan__result--green {
    background-color: var(--sg-green);
}

.sg-scan__result--red {
    background-color: var(--sg-red);
}

.sg-scan__result--amber {
    background-color: #E8A000;
}

@keyframes sg-scan-spin {
    to {
        transform: rotate(360deg);
    }
}

@media (min-width: 48rem) {
    .sg-scan__preview {
        width: 120px;
        height: 120px;
    }
}
