/* ========================================================================
   Trixel Scanner — Dark Glassmorphic UI
   ======================================================================== */

:root {
    --bg: #0a0a0f;
    --surface: rgba(255, 255, 255, 0.04);
    --surface-hover: rgba(255, 255, 255, 0.08);
    --glass: rgba(255, 255, 255, 0.06);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text: #e8e8ed;
    --text-muted: rgba(255, 255, 255, 0.5);
    --accent: #75B3B8;
    --accent-glow: rgba(117, 179, 184, 0.3);
    --success: #4ade80;
    --success-glow: rgba(74, 222, 128, 0.3);
    --radius: 16px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

html, body {
    height: 100%;
    overflow: hidden;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ---- App Layout ---- */
#app {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-width: 480px;
    margin: 0 auto;
    padding: 0 16px;
}

/* ---- Header ---- */
#header {
    text-align: center;
    padding: 20px 0 12px;
    flex-shrink: 0;
}

#header h1 {
    font-size: 1.4rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--accent), #a8d8dc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 4px;
    font-weight: 300;
}

/* ---- Viewfinder ---- */
#viewfinder {
    position: relative;
    flex: 1;
    min-height: 0;
    border-radius: var(--radius);
    overflow: hidden;
    background: #111118;
    border: 1px solid var(--glass-border);
}

#camera {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

#overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
}

/* Scan frame corners */
#scan-frame {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 65%;
    aspect-ratio: 1;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.corner {
    position: absolute;
    width: 24px;
    height: 24px;
    border-color: var(--accent);
    border-style: solid;
    border-width: 0;
}
.corner.tl { top: 0; left: 0; border-top-width: 3px; border-left-width: 3px; border-radius: 4px 0 0 0; }
.corner.tr { top: 0; right: 0; border-top-width: 3px; border-right-width: 3px; border-radius: 0 4px 0 0; }
.corner.bl { bottom: 0; left: 0; border-bottom-width: 3px; border-left-width: 3px; border-radius: 0 0 0 4px; }
.corner.br { bottom: 0; right: 0; border-bottom-width: 3px; border-right-width: 3px; border-radius: 0 0 4px 0; }

/* Animated scan line */
#scan-line {
    position: absolute;
    left: 17.5%;
    width: 65%;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    box-shadow: 0 0 12px var(--accent-glow);
    animation: scan 2.5s ease-in-out infinite;
    opacity: 0.7;
}

@keyframes scan {
    0%   { top: 17.5%; opacity: 0; }
    10%  { opacity: 0.7; }
    90%  { opacity: 0.7; }
    100% { top: 82.5%; opacity: 0; }
}

/* ---- Status ---- */
#status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    flex-shrink: 0;
}

#status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    animation: pulse 2s ease-in-out infinite;
}

#status-dot.error { background: #ef4444; animation: none; }
#status-dot.success { background: var(--success); animation: none; }

@keyframes pulse {
    0%, 100% { opacity: 0.4; transform: scale(0.8); }
    50% { opacity: 1; transform: scale(1); }
}

#status-text {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 400;
}

/* ---- Result Panel ---- */
#result {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(10, 10, 15, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: 10;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

#result-card {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    padding: 32px 28px;
    text-align: center;
    width: 90%;
    max-width: 360px;
    animation: slideUp 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(24px); }
    to { opacity: 1; transform: translateY(0); }
}

#result-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--success-glow);
    color: var(--success);
    font-size: 1.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    font-weight: 700;
}

#result-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 8px;
}

#result-value {
    font-size: 1rem;
    font-weight: 500;
    word-break: break-all;
    line-height: 1.5;
    margin-bottom: 24px;
    color: var(--text);
}

#result-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 44px;
    padding: 0 20px;
    border-radius: 10px;
    font-family: var(--font);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: all 0.2s ease;
}

.btn-primary {
    background: var(--accent);
    color: #0a0a0f;
}
.btn-primary:hover { background: #8cc9ce; }

.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--glass-border);
}
.btn-secondary:hover { background: var(--surface-hover); }

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
}
.btn-ghost:hover { color: var(--text); }

/* ---- Upload ---- */
#upload-section {
    padding: 12px 0 24px;
    text-align: center;
    flex-shrink: 0;
}

#upload-label {
    font-size: 0.8rem;
}

/* ---- Responsive ---- */
@media (min-height: 700px) {
    #header { padding: 28px 0 16px; }
}
