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

/* grid-paper background shared by both pages (from the Canva design) */
body {
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    color: #1f2d1f;
    min-height: 100vh;
    overflow-x: clip;
    background-color: #faf6e4;
    background-image:
        linear-gradient(#b9d0a6 1px, transparent 1px),
        linear-gradient(90deg, #b9d0a6 1px, transparent 1px);
    background-size: 2.35vw 2.35vw;
}

/* Home / landing page */

.hero {
    display: flex;
    align-items: center;
    min-height: 100vh;
    padding: 6vh 3vw 6vh 11vw;
    gap: 2vw;
}

.hero-text {
    flex: 1;
    text-align: left;
}

.hero-text h1 {
    font-family: "Archivo", system-ui, sans-serif;
    font-weight: 600;
    font-size: clamp(3.2rem, 11.5vw, 15rem);
    line-height: 1;
    letter-spacing: -0.02em;
    color: #3e7c3e;
    margin-bottom: 3vh;
}

.tagline {
    font-family: "Poppins", system-ui, sans-serif;
    font-style: italic;
    font-weight: 500;
    font-size: clamp(1.05rem, 2.3vw, 2.6rem);
    line-height: 1.4;
    color: #16301b;
    margin-bottom: 7vh;
    margin-left: 6px;
}

.tagline strong {
    font-weight: 700;
    color: #1f4d24;
}

.hero-btn {
    display: inline-block;
    font-family: "Archivo", system-ui, sans-serif;
    font-weight: 600;
    font-size: clamp(1rem, 1.9vw, 2.2rem);
    color: #fff;
    background: #3e7c3e;
    text-decoration: none;
    padding: 0.6em 2.4em;
    border-radius: 0.5em;
    margin-left: 6px;
    transition: background 0.2s;
}

.hero-btn:hover {
    background: #2f612f;
}

.earth-scene {
    --scene: min(45vw, 85vh);
    position: relative;
    width: var(--scene);
    height: var(--scene);
    flex-shrink: 0;
    pointer-events: none;
}

.earth-scene img {
    position: absolute;
    top: 50%;
    left: 50%;
}

.earth {
    width: 70%;
    transform: translate(-50%, -50%);
}

/* Each item orbits the earth's center at radius */
.orbit-item {
    --T: 80s;
    width: var(--s);
    animation: orbit var(--T) linear infinite;
    animation-delay: calc(var(--a) / 360 * -1 * var(--T));
}

@keyframes orbit {
    from {
        transform: translate(-50%, -50%) rotate(0turn)
            translateX(calc(var(--r) * var(--scene))) rotate(var(--tilt, 0deg));
    }
    to {
        transform: translate(-50%, -50%) rotate(1turn)
            translateX(calc(var(--r) * var(--scene))) rotate(calc(var(--tilt, 0deg) - 1turn));
    }
}

@media (prefers-reduced-motion: reduce) {
    .orbit-item {
        animation-play-state: paused;
    }
}

/* Title Case for all button/label text */
.hero-btn,
.pill-btn,
.cancel-sort-btn,
.camera-controls button,
.panel-hint,
.drop-zone {
    text-transform: capitalize;
}

/* Sort page */

.sort-page {
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding: 4vh 6vw 6vh;
}

.sort-page [hidden] {
    display: none !important;
}

.logo {
    font-family: "Archivo", system-ui, sans-serif;
    font-weight: 600;
    font-size: clamp(2rem, 5.2vw, 6.5rem);
    line-height: 1;
    letter-spacing: -0.02em;
    color: #3e7c3e;
    text-decoration: none;
    align-self: flex-start;
    margin-bottom: 3.5vh;
}

.sort-columns {
    display: flex;
    gap: 4vw;
    flex: 1;
    min-height: 0;
}

.sort-left {
    width: 44%;
    display: flex;
    flex-direction: column;
    gap: 2.4vh;
    min-height: 0;
}

.pill-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6em;
    font-family: "Poppins", system-ui, sans-serif;
    font-weight: 500;
    font-size: clamp(1rem, 2.1vw, 2.5rem);
    color: #3e7c3e;
    background: #cbe3c3;
    border: 3px solid #3e7c3e;
    border-radius: 18px;
    padding: 0.55em 1em;
    cursor: pointer;
    transition: background 0.2s;
}

.pill-btn:hover {
    background: #badcae;
}

.pill-btn svg {
    width: 1.25em;
    height: 1.25em;
    flex-shrink: 0;
}

.drop-zone {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    overflow: hidden;
    text-align: center;
    font-family: "Poppins", system-ui, sans-serif;
    font-size: clamp(1rem, 2.1vw, 2.5rem);
    color: #3e7c3e;
    background: #cbe3c3;
    border: 3px dashed #3e7c3e;
    border-radius: 18px;
    padding: 1rem;
    cursor: pointer;
    transition: background 0.2s;
}

.drop-zone:hover,
.drop-zone.dragover {
    background: #badcae;
}

.drop-zone img {
    max-width: 100%;
    max-height: 90%;
    min-height: 0;
    object-fit: contain;
    border-radius: 12px;
}

.camera-view {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.camera-view video {
    flex: 1;
    min-height: 0;
    width: 100%;
    object-fit: cover;
    border-radius: 18px;
    border: 3px solid #3e7c3e;
    background: #000;
}

.camera-controls {
    display: flex;
    gap: 0.75rem;
}

.camera-controls button {
    flex: 1;
    font-family: "Poppins", system-ui, sans-serif;
    font-weight: 500;
    font-size: clamp(0.95rem, 1.3vw, 1.5rem);
    color: #3e7c3e;
    background: #cbe3c3;
    border: 3px solid #3e7c3e;
    border-radius: 14px;
    padding: 0.5em;
    cursor: pointer;
    transition: background 0.2s;
}

.camera-controls button:hover {
    background: #badcae;
}

#capture-btn {
    color: #fff;
    background: #3e7c3e;
}

#capture-btn:hover {
    background: #2f612f;
}

.sort-right {
    flex: 1;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: clamp(0.75rem, 1.2vw, 1.5rem);
    background: #cbe3c3;
    border: 3px solid #3e7c3e;
    border-radius: 18px;
    padding: clamp(0.75rem, 1.2vw, 1.5rem);
}

.panel-hint {
    margin: auto;
    display: flex;
    align-items: center;
    gap: 0.6em;
    font-family: "Poppins", system-ui, sans-serif;
    font-size: clamp(1rem, 2.1vw, 2.5rem);
    color: #3e7c3e;
}

/* while sorting, the hint gives up its bottom auto-margin so the
   cancel button sits right under it, both centered as a pair */
.sort-right.sorting .panel-hint {
    margin-bottom: 0;
}

.cancel-sort-btn {
    margin: 1.2rem auto auto;
    font-family: "Poppins", system-ui, sans-serif;
    font-weight: 500;
    font-size: clamp(0.95rem, 1.3vw, 1.5rem);
    color: #3e7c3e;
    background: transparent;
    border: 3px solid #3e7c3e;
    border-radius: 999px;
    padding: 0.4em 1.8em;
    cursor: pointer;
    transition: background 0.2s;
}

.cancel-sort-btn:hover {
    background: #badcae;
}

.overall-summary {
    flex-shrink: 0;
    text-align: center;
    font-family: "Poppins", system-ui, sans-serif;
    color: #2f612f;
}

#results-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: clamp(0.75rem, 1.2vw, 1.5rem);
}

.item-card {
    --bin-color: #6b7280;
    flex-shrink: 0;
    min-height: 31%;
    background: #fff;
    border-radius: 18px;
    border-left: clamp(14px, 1.6vw, 32px) solid var(--bin-color);
    padding: clamp(0.75rem, 1.3vw, 1.5rem) clamp(1rem, 1.5vw, 1.75rem);
}

.item-card.garbage   { --bin-color: #111111; }
.item-card.recycling { --bin-color: #6b8cf0; }
.item-card.compost   { --bin-color: #10b528; }
.item-card.hazardous { --bin-color: #ea580c; }

.item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
}

.item-header h3 {
    text-transform: capitalize;
    font-family: "Poppins", system-ui, sans-serif;
    font-weight: 600;
    font-size: clamp(1rem, 1.5vw, 1.8rem);
}

.bin-badge {
    padding: 0.25rem 0.9rem;
    border-radius: 999px;
    font-size: clamp(0.8rem, 1vw, 1.2rem);
    font-weight: 600;
    color: #fff;
    background: var(--bin-color);
    white-space: nowrap;
}

.explanation {
    color: #374151;
    line-height: 1.5;
    font-size: clamp(0.9rem, 1.1vw, 1.35rem);
}

.prep-note {
    margin-top: 0.6rem;
    padding: 0.5rem 0.75rem;
    background: #fef3c7;
    border-radius: 10px;
    color: #78350f;
    font-weight: 500;
    font-size: clamp(0.9rem, 1.1vw, 1.35rem);
}

.warning-box {
    margin-top: 0.6rem;
    padding: 0.6rem 0.75rem;
    background: #fee2e2;
    border: 1px solid #dc2626;
    border-radius: 10px;
    color: #991b1b;
    font-weight: 600;
    font-size: clamp(0.9rem, 1.1vw, 1.35rem);
}

.error {
    margin: auto;
    color: #dc2626;
    font-family: "Poppins", system-ui, sans-serif;
    font-weight: 600;
}

.spinner {
    display: inline-block;
    width: 1em;
    height: 1em;
    flex-shrink: 0;
    border: 2px solid rgba(62, 124, 62, 0.25);
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* smaller screens */

@media (max-width: 820px) {
    body {
        background-size: 6vw 6vw;
    }

    .hero {
        flex-direction: column;
        justify-content: center;
        padding: 4rem 4vw;
        gap: 2rem;
    }

    .hero-text {
        width: 100%;
    }

    .hero-text h1 {
        font-size: 26vw;
        margin-bottom: 1rem;
    }

    .tagline {
        font-size: 5.5vw;
        margin-bottom: 1.5rem;
        margin-left: 12px;
    }

    .hero-btn {
        font-size: 5vw;
        margin-left: 12px;
    }

    .earth-scene {
        --scene: min(92vw, 70vh);
    }

    .sort-page {
        height: auto;
        min-height: 100vh;
        padding: 2.5rem 4vw 3rem;
    }

    .logo {
        font-size: 11vw;
        margin-bottom: 1.5rem;
    }

    .sort-columns {
        flex-direction: column;
        gap: 1.25rem;
    }

    .sort-left {
        width: 100%;
    }

    .pill-btn {
        font-size: 5vw;
    }

    .drop-zone {
        flex: none;
        min-height: 30vh;
        font-size: 4.5vw;
    }

    .drop-zone img {
        max-height: 50vh;
    }

    .camera-view {
        flex: none;
        min-height: 40vh;
    }

    .sort-right {
        min-height: 45vh;
        max-height: 75vh;
    }

    .panel-hint {
        font-size: 4.5vw;
    }

    .item-card {
        min-height: 0;
    }

    .item-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.35rem;
    }
}
