/* ============================================
   ROAST MY ROOM — Styles
   Dark theme, flame/orange accents, mobile-first
   ============================================ */

:root {
    --bg: #0a0a0a;
    --bg-card: #141414;
    --bg-card-hover: #1a1a1a;
    --text: #f0f0f0;
    --text-dim: #888;
    --text-muted: #555;
    --flame: #ff6b2b;
    --flame-light: #ff9a5c;
    --flame-dark: #cc4400;
    --flame-glow: rgba(255, 107, 43, 0.3);
    --gold: #ffd700;
    --radius: 16px;
    --radius-sm: 10px;
    --font-display: 'Space Grotesk', system-ui, sans-serif;
    --font-body: 'Inter', system-ui, sans-serif;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-top: env(safe-area-inset-top, 0px);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

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

/* ============================================
   SCREENS
   ============================================ */

.screen {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s ease;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

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

/* ============================================
   LANDING PAGE
   ============================================ */

#landing {
    justify-content: flex-start;
    padding: calc(60px + var(--safe-top)) 24px calc(32px + var(--safe-bottom));
    background: var(--bg);
    position: relative;
}

.landing-bg-glow {
    position: absolute;
    top: -120px;
    left: 50%;
    transform: translateX(-50%);
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(255, 107, 43, 0.15) 0%, transparent 70%);
    pointer-events: none;
    animation: pulse-glow 4s ease-in-out infinite;
}

@keyframes pulse-glow {
    0%, 100% { opacity: 0.6; transform: translateX(-50%) scale(1); }
    50% { opacity: 1; transform: translateX(-50%) scale(1.1); }
}

.landing-header {
    text-align: center;
    margin-bottom: 32px;
    position: relative;
    z-index: 1;
}

.logo-text {
    font-family: var(--font-display);
    font-size: clamp(2.2rem, 8vw, 3.5rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--flame-light), var(--flame), var(--flame-dark));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    line-height: 1.1;
    margin-bottom: 8px;
}

.tagline {
    font-size: 1.1rem;
    color: var(--text-dim);
    font-weight: 400;
}

/* CTA Button */
.cta-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px 40px;
    font-family: var(--font-display);
    font-size: 1.15rem;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(135deg, var(--flame), var(--flame-dark));
    border: none;
    border-radius: 60px;
    cursor: pointer;
    position: relative;
    z-index: 1;
    transition: transform 0.15s ease, box-shadow 0.2s ease;
    box-shadow: 0 4px 24px rgba(255, 107, 43, 0.35);
}

.cta-button:hover {
    transform: scale(1.03);
    box-shadow: 0 6px 32px rgba(255, 107, 43, 0.5);
}

.cta-button:active {
    transform: scale(0.97);
}

.cta-icon {
    font-size: 1.3rem;
}

.cta-secondary {
    background: var(--bg-card);
    border: 2px solid var(--flame);
    box-shadow: none;
    color: var(--flame-light);
    margin-top: 16px;
}

.cta-secondary:hover {
    background: rgba(255, 107, 43, 0.1);
    box-shadow: none;
}

.cta-small {
    padding: 12px 28px;
    font-size: 1rem;
}

/* Credits display */
.credits-display {
    text-align: center;
    margin-top: 16px;
    font-size: 0.9rem;
    color: var(--text-dim);
    min-height: 24px;
}

.credits-display .credit-count {
    color: var(--flame-light);
    font-weight: 600;
}

/* Examples section */
.examples-section {
    width: 100%;
    max-width: 600px;
    margin-top: 40px;
    position: relative;
    z-index: 1;
}

.examples-title {
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 16px;
    text-align: center;
}

.examples-grid {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.example-card {
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius);
    padding: 20px;
    transition: border-color 0.2s ease, transform 0.15s ease;
}

.example-card:hover {
    border-color: rgba(255, 107, 43, 0.2);
    transform: translateY(-1px);
}

.example-icon {
    font-size: 1.6rem;
    margin-bottom: 6px;
}

.example-label {
    font-family: var(--font-display);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--flame-light);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 8px;
}

.example-text {
    font-size: 0.95rem;
    line-height: 1.55;
    color: var(--text);
    margin-bottom: 10px;
}

.example-score {
    font-size: 0.85rem;
    color: var(--text-dim);
    letter-spacing: 0.04em;
}

.landing-footer {
    margin-top: 40px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    position: relative;
    z-index: 1;
}

/* ============================================
   CAMERA SCREEN
   ============================================ */

#camera {
    background: #000;
}

#camera-feed {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.camera-controls {
    position: absolute;
    top: calc(16px + var(--safe-top));
    left: 16px;
    right: 16px;
    display: flex;
    justify-content: space-between;
    z-index: 10;
}

.camera-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: none;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s ease;
}

.camera-btn:hover {
    background: rgba(0, 0, 0, 0.7);
}

.capture-area {
    position: absolute;
    bottom: calc(32px + var(--safe-bottom));
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    z-index: 10;
}

.capture-button {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 18px 36px;
    background: linear-gradient(135deg, var(--flame), var(--flame-dark));
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 60px;
    color: #fff;
    cursor: pointer;
    font-family: var(--font-display);
    font-weight: 700;
    transition: transform 0.1s ease, box-shadow 0.2s ease;
    box-shadow: 0 4px 32px rgba(255, 107, 43, 0.5);
}

.capture-button:active {
    transform: scale(0.92);
}

.capture-icon {
    font-size: 1.8rem;
    line-height: 1;
}

.capture-label {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

/* ============================================
   LOADING SCREEN
   ============================================ */

#loading {
    justify-content: center;
    background: var(--bg);
}

.loading-content {
    text-align: center;
}

.flame-container {
    position: relative;
    width: 80px;
    height: 120px;
    margin: 0 auto 32px;
}

.flame {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 70px;
    background: radial-gradient(ellipse at bottom, var(--flame) 0%, var(--flame-dark) 50%, transparent 70%);
    border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
    animation: flicker 0.8s ease-in-out infinite alternate;
}

.flame-2 {
    width: 28px;
    height: 50px;
    left: 35%;
    animation-delay: 0.15s;
    opacity: 0.7;
}

.flame-3 {
    width: 24px;
    height: 45px;
    left: 65%;
    animation-delay: 0.3s;
    opacity: 0.6;
}

@keyframes flicker {
    0% { transform: translateX(-50%) scaleY(1) scaleX(1); opacity: 1; }
    25% { transform: translateX(-50%) scaleY(1.08) scaleX(0.92); }
    50% { transform: translateX(-50%) scaleY(0.95) scaleX(1.05); opacity: 0.9; }
    75% { transform: translateX(-50%) scaleY(1.1) scaleX(0.95); }
    100% { transform: translateX(-50%) scaleY(1.05) scaleX(1.02); opacity: 1; }
}

.loading-text {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text);
    animation: fade-pulse 2s ease-in-out infinite;
}

.loading-subtext {
    margin-top: 8px;
    font-size: 0.9rem;
    color: var(--text-muted);
}

@keyframes fade-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ============================================
   RESULT SCREEN
   ============================================ */

#result {
    justify-content: flex-end;
    padding: 8px 16px calc(12px + var(--safe-bottom));
    background: var(--bg);
}

.result-content {
    width: 100%;
    max-width: 500px;
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
}

.roast-photo-wrapper {
    width: 100%;
    flex: 1;
    min-height: 0;
    border-radius: var(--radius);
    overflow: hidden;
    position: relative;
}

.roast-photo-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.roast-photo-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: linear-gradient(transparent, rgba(0,0,0,0.7));
    pointer-events: none;
}

.roast-watermark {
    position: absolute;
    top: 12px;
    left: 16px;
    font-family: var(--font-display);
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--flame);
    text-shadow: 0 1px 4px rgba(0,0,0,0.6);
}

.roast-text-scroll {
    width: 100%;
    max-height: 25vh;
    overflow-y: auto;
    padding: 10px 4px;
    font-size: 1.25rem;
    line-height: 1.6;
    color: var(--text);
    font-weight: 500;
    text-align: center;
    -webkit-overflow-scrolling: touch;
}

.roast-card-wrapper {
    width: 100%;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: 0 8px 48px rgba(0, 0, 0, 0.5);
    margin-bottom: 20px;
}

.roast-card-wrapper canvas {
    width: 100%;
    height: auto;
    display: block;
}

/* Share buttons */
.share-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
    width: 100%;
    margin-bottom: 4px;
}

.share-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex: 1 1 0;
    padding: 12px 8px;
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 40px;
    color: var(--text);
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.share-btn:hover {
    background: var(--bg-card-hover);
    border-color: rgba(255, 255, 255, 0.15);
}

.share-btn-primary {
    background: linear-gradient(135deg, var(--flame), var(--flame-dark));
    border-color: transparent;
    color: #fff;
    font-weight: 600;
}

.home-link {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.85rem;
    cursor: pointer;
    padding: 8px;
    margin-top: 6px;
    transition: color 0.15s;
}

.home-link:hover {
    color: var(--text);
}

.share-app-btn {
    background: none;
    border: 1px solid rgba(255, 107, 43, 0.3);
    border-radius: 40px;
    color: var(--flame-light);
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 500;
    padding: 10px 24px;
    cursor: pointer;
    margin-top: 8px;
    transition: background 0.15s, border-color 0.15s;
}

.share-app-btn:hover {
    background: rgba(255, 107, 43, 0.1);
    border-color: var(--flame);
}

.result-actions {
    display: flex;
    gap: 8px;
    width: 100%;
    max-width: 500px;
    margin-top: 10px;
}

.result-actions .cta-button {
    flex: 1 1 0;
    min-width: 0;
    padding: 10px 0;
    font-size: 0.85rem;
    margin-top: 0;
    border: 1px solid;
    box-sizing: border-box;
}

.cta-danger {
    background: rgba(255, 60, 60, 0.15) !important;
    border: 1px solid rgba(255, 60, 60, 0.3) !important;
    color: #ff6b6b !important;
}

.cta-danger:hover {
    background: rgba(255, 60, 60, 0.25) !important;
}

.share-btn-primary:hover {
    background: linear-gradient(135deg, var(--flame-light), var(--flame));
}

/* ============================================
   PAYWALL SCREEN
   ============================================ */

#paywall {
    justify-content: center;
    background: var(--bg);
}

.paywall-content {
    text-align: center;
    padding: 24px;
    max-width: 380px;
}

.paywall-flames {
    font-size: 3rem;
    margin-bottom: 20px;
    animation: bounce-flames 1.5s ease-in-out infinite;
}

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

.paywall-title {
    font-family: var(--font-display);
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.paywall-subtitle {
    color: var(--text-dim);
    font-size: 1.05rem;
    margin-bottom: 32px;
}

.paywall-offer {
    background: var(--bg-card);
    border: 2px solid var(--flame);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 24px;
}

.paywall-price {
    font-family: var(--font-display);
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--flame-light);
}

.paywall-desc {
    font-size: 1rem;
    color: var(--text-dim);
    margin-top: 4px;
}

.paywall-back {
    display: block;
    margin: 16px auto 0;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.9rem;
    cursor: pointer;
    padding: 8px;
    transition: color 0.15s;
}

.paywall-back:hover {
    color: var(--text-dim);
}

/* ============================================
   ERROR OVERLAY
   ============================================ */

.error-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    transition: opacity 0.3s ease;
}

.error-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.error-content {
    text-align: center;
    padding: 32px;
    max-width: 340px;
}

.error-icon {
    font-size: 3rem;
    margin-bottom: 16px;
}

#error-message {
    font-size: 1.1rem;
    line-height: 1.5;
    margin-bottom: 24px;
    color: var(--text);
}

/* ============================================
   TOAST
   ============================================ */

.toast {
    position: fixed;
    bottom: calc(32px + var(--safe-bottom));
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text);
    padding: 12px 24px;
    border-radius: 40px;
    font-size: 0.9rem;
    font-weight: 500;
    z-index: 200;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast.hidden {
    display: none;
}

/* ============================================
   UTILITIES / SCROLLBAR
   ============================================ */

::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
}

/* Disable selection on buttons */
button {
    user-select: none;
    -webkit-user-select: none;
}

/* ============================================
   RESPONSIVE — Larger screens
   ============================================ */

@media (min-width: 768px) {
    .examples-grid {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 16px;
    }

    #landing {
        padding-top: 80px;
    }

    .roast-card-wrapper {
        max-width: 500px;
    }
}
