/* ── Reset & Base ───────────────────────────── */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --white: #ffffff;
    --black: #111111;
    --gray-100: #f5f5f5;
    --gray-300: #d4d4d4;
    --gray-500: #737373;
    --green: #22c55e;
    --red: #ef4444;
    --amber: #f59e0b;
    --radius: 20px;
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--white);
    color: var(--black);
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

/* ── Screens ───────────────────────────────── */
.screen {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition);
}

.screen.active {
    opacity: 1;
    pointer-events: auto;
}

/* ── Start Screen ──────────────────────────── */
#screen-start {
    justify-content: center;
    align-items: center;
    padding: 2rem;
    background: var(--white);
}

.start-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    font-size: 3.5rem;
    line-height: 1;
    margin-bottom: 0.5rem;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

h1 {
    font-size: 1.75rem;
    font-weight: 600;
    letter-spacing: -0.03em;
}

.subtitle {
    font-size: 0.95rem;
    font-weight: 300;
    color: var(--gray-500);
    text-align: center;
    line-height: 1.5;
    margin-bottom: 1.5rem;
}

.btn-primary {
    appearance: none;
    border: none;
    background: var(--black);
    color: var(--white);
    font-family: inherit;
    font-size: 1rem;
    font-weight: 500;
    padding: 0.9rem 2.5rem;
    border-radius: 100px;
    cursor: pointer;
    transition: transform var(--transition), opacity var(--transition);
    -webkit-tap-highlight-color: transparent;
}

.btn-primary:active {
    transform: scale(0.96);
    opacity: 0.85;
}

.footer-note {
    position: absolute;
    bottom: max(2rem, env(safe-area-inset-bottom, 1rem));
    font-size: 0.75rem;
    font-weight: 300;
    color: var(--gray-300);
    letter-spacing: 0.08em;
}

/* ── Camera Screen ─────────────────────────── */
#screen-camera {
    background: var(--black);
}

.camera-wrapper {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

#webcam-container {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

#webcam-container canvas {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover;
}

/* Scan frame */
.scan-frame {
    position: absolute;
    width: 220px;
    height: 220px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 28px;
    pointer-events: none;
    animation: pulse-frame 2.5s ease-in-out infinite;
}

@keyframes pulse-frame {
    0%, 100% { transform: scale(1); border-color: rgba(255,255,255,0.3); }
    50% { transform: scale(1.03); border-color: rgba(255,255,255,0.5); }
}

/* ── Glassmorphism Card ────────────────────── */
.glass-card {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 1.5rem 1.5rem max(1.5rem, env(safe-area-inset-bottom, 1.5rem));
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(24px) saturate(1.4);
    -webkit-backdrop-filter: blur(24px) saturate(1.4);
    border-radius: var(--radius) var(--radius) 0 0;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    transform: translateY(100%);
    transition: transform 0.45s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--white);
}

.glass-card.visible {
    transform: translateY(0);
}

/* Scanning state */
.glass-scanning {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.scanning-icon {
    font-size: 1.5rem;
    animation: pulse-emoji 1.5s ease-in-out infinite;
}

@keyframes pulse-emoji {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

.scanning-label {
    font-size: 1rem;
    font-weight: 400;
    opacity: 0.8;
    letter-spacing: -0.01em;
}

/* Result state */
.glass-result {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.glass-result.hidden {
    display: none;
}

.glass-header {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.glass-emoji {
    font-size: 2.75rem;
    line-height: 1;
    filter: drop-shadow(0 2px 8px rgba(0,0,0,0.2));
}

.glass-title {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.glass-name {
    font-size: 1.35rem;
    font-weight: 600;
    letter-spacing: -0.03em;
}

.glass-verdict {
    font-size: 0.8rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    opacity: 0.75;
}

.glass-verdict.fresh  { color: var(--green); opacity: 1; }
.glass-verdict.mid    { color: var(--amber); opacity: 1; }
.glass-verdict.bad    { color: var(--red);   opacity: 1; }

/* ── Stat Bars ─────────────────────────────── */
.glass-bars {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.stat-row {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.stat-label-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.stat-label {
    font-size: 0.78rem;
    font-weight: 400;
    opacity: 0.7;
    letter-spacing: 0.01em;
}

.stat-value {
    font-size: 0.78rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.stat-track {
    width: 100%;
    height: 6px;
    border-radius: 100px;
    background: rgba(255, 255, 255, 0.12);
    overflow: hidden;
}

.stat-fill {
    height: 100%;
    border-radius: 100px;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 0;
}

.stat-fill.green  { background: var(--green); }
.stat-fill.red    { background: var(--red); }
.stat-fill.amber  { background: var(--amber); }
.stat-fill.white  { background: rgba(255,255,255,0.5); }

/* ── Back Button ───────────────────────────── */
.btn-back {
    position: absolute;
    top: max(1rem, env(safe-area-inset-top, 1rem));
    left: 1rem;
    appearance: none;
    border: none;
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    color: var(--white);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform var(--transition), background var(--transition);
    -webkit-tap-highlight-color: transparent;
    border: 1px solid rgba(255,255,255,0.15);
}

.btn-back:active {
    transform: scale(0.9);
    background: rgba(255, 255, 255, 0.25);
}

/* ── Utility ───────────────────────────────── */
.hidden { display: none !important; }

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

@media (min-width: 500px) {
    #screen-start, #screen-camera {
        max-width: 430px;
        margin: 0 auto;
    }
}
