/* ============================================================
   BroCast — Premium Theme v2
   Inspired by: Linear, Raycast, Stripe
   Rule: Premium internet joke, not a weather dashboard.
   ============================================================ */

:root {
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.55);
    --text-tertiary: rgba(255, 255, 255, 0.35);
    --bg-color-1: #111111;
    --bg-color-2: #0a0a0a;
    --accent: rgba(255, 255, 255, 0.08);
    --border: rgba(255, 255, 255, 0.06);
    --spacing-xs: 0.4rem;
    --spacing-sm: 0.8rem;
    --spacing-md: 1.5rem;
    --spacing-lg: 2.5rem;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    user-select: none;
    -webkit-user-select: none;
    -webkit-user-drag: none;
}

input, textarea {
    user-select: auto;
    -webkit-user-select: auto;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #050505;
    color: var(--text-primary);
}

#app-container {
    position: relative;
    width: 100vw;
    height: 100dvh;
    overflow: hidden;
    display: flex;
    justify-content: center;
}

/* === DYNAMIC BACKGROUND === */
#background-layer {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 0;
    transition: background 2.5s ease-in-out;
    background: linear-gradient(165deg, var(--bg-color-1) 0%, var(--bg-color-2) 70%, #000000 100%);
}

/* Subtle noise texture overlay */
#background-layer::after {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    opacity: 0.025;
    background-image: url('data:image/svg+xml;utf8,%3Csvg viewBox="0 0 256 256" xmlns="http://www.w3.org/2000/svg"%3E%3Cfilter id="n"%3E%3CfeTurbulence type="fractalNoise" baseFrequency="0.9" numOctaves="4" stitchTiles="stitch"/%3E%3C/filter%3E%3Crect width="100%25" height="100%25" filter="url(%23n)" opacity="1"/%3E%3C/svg%3E');
}

/* Heat Distortion — highway shimmer, NOT flames */
#heat-distortion-layer {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 2;
    pointer-events: none;
    opacity: 0;
    transition: opacity 2s ease;
    background-image: url('data:image/svg+xml;utf8,%3Csvg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg"%3E%3Cfilter id="noiseFilter"%3E%3CfeTurbulence type="fractalNoise" baseFrequency="0.015" numOctaves="3" stitchTiles="stitch"/%3E%3C/filter%3E%3Crect width="100%25" height="100%25" filter="url(%23noiseFilter)" opacity="0.06"/%3E%3C/svg%3E');
    mix-blend-mode: overlay;
}

@keyframes shimmer {
    0% { transform: scale(1) translate(0, 0); }
    50% { transform: scale(1.015) translate(0.5%, 0.5%); }
    100% { transform: scale(1) translate(0, 0); }
}

.heatwave-active #heat-distortion-layer {
    opacity: 1;
    animation: shimmer 7s infinite alternate ease-in-out;
}

/* === MAIN LAYOUT === */
#capture-area {
    position: relative;
    z-index: 10;
    width: 100%;
    max-width: 520px;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: none;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: var(--spacing-lg) var(--spacing-md);
    padding-bottom: env(safe-area-inset-bottom, var(--spacing-md));
}

#capture-area::-webkit-scrollbar {
    display: none;
}

/* === HEADER === */
header {
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.brand-logo {
    height: 58px;
    opacity: 1;
    user-select: none;
    cursor: zoom-in;
    position: relative;
    z-index: 30;
    transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
    transform-origin: center center;
    will-change: transform;
}

.brand-logo.lightbox-active {
    cursor: zoom-out;
    z-index: 9999;
}

#logo-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 9998;
    opacity: 0;
    display: none;
    transition: opacity 0.4s ease;
    cursor: zoom-out;
}

.search-backdrop {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 40;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.search-backdrop.hidden {
    display: none;
}

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

.location-bar {
    position: relative;
    z-index: 60;
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px 0;
    font-family: inherit;
    transition: color 0.2s ease;
}

.location-bar:hover {
    color: var(--text-primary);
}

.location-bar span {
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.location-search-icon {
    opacity: 0.4;
    margin-left: 2px;
    margin-top: 1px;
    transition: opacity 0.2s ease;
}

.location-bar:hover .location-search-icon {
    opacity: 0.9;
}

/* === SEARCH OVERLAY === */
.search-overlay {
    position: absolute;
    top: 0; left: 0; width: calc(100% - 65px);
    z-index: 60;
}

.search-overlay.hidden {
    display: none;
}

.search-input-row {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    background: var(--bg-color-2);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 14px;
    transition: border-color 0.2s ease;
}

.search-input-row:focus-within {
    border-color: rgba(255, 255, 255, 0.15);
}

.live-location-btn {
    flex-shrink: 0;
    color: var(--text-tertiary);
    background: none;
    border: none;
    cursor: pointer;
    transition: color 0.2s ease, transform 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.live-location-btn:hover {
    color: var(--text-primary);
    transform: scale(1.1);
}

#search-input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 0.95rem;
    font-weight: 500;
    font-family: inherit;
    letter-spacing: 0.01em;
}

#search-input::placeholder {
    color: var(--text-tertiary);
}

.search-close-btn {
    background: none;
    border: none;
    color: var(--text-tertiary);
    font-size: 1.3rem;
    cursor: pointer;
    padding: 0 2px;
    line-height: 1;
    transition: color 0.2s ease;
}

.search-close-btn:hover {
    color: var(--text-primary);
}

.search-dropdown {
    margin-top: 6px;
    background: var(--bg-color-2);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    max-height: 280px;
    overflow-y: auto;
}

.search-dropdown.hidden {
    display: none;
}

.search-dropdown::-webkit-scrollbar {
    width: 4px;
}

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

.search-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-right: 14px;
}

.search-section-title {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-tertiary);
    padding: 10px 14px 4px;
}

.clear-history-btn {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: none;
    border: none;
    cursor: pointer;
    text-transform: uppercase;
    transition: color 0.2s ease;
    margin-top: 6px;
}

.clear-history-btn:hover {
    color: #ff4a4a;
}

.search-item-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.delete-recent-btn {
    position: absolute;
    right: 14px;
    background: none;
    border: none;
    color: var(--text-tertiary);
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s ease, color 0.2s ease;
    padding: 0 4px;
}

.search-item-wrapper:hover .delete-recent-btn {
    opacity: 1;
}

.delete-recent-btn:hover {
    color: #ff4a4a;
}

.search-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    cursor: pointer;
    transition: background 0.15s ease;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-family: inherit;
    color: var(--text-primary);
}

.search-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.search-item .item-icon {
    font-size: 0.85rem;
    flex-shrink: 0;
    opacity: 0.5;
}

.search-item .item-name {
    font-size: 0.9rem;
    font-weight: 500;
}

.search-item .item-region {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    margin-left: auto;
    white-space: nowrap;
}

.search-divider {
    height: 1px;
    background: var(--border);
    margin: 2px 0;
}

/* === HERO SECTION === */
.hero {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: var(--spacing-md);
}

/* 1. Temperature */
.temp-wrapper {
    display: flex;
    flex-direction: column;
}

.feels-like-label {
    font-size: 0.85rem;
    font-weight: 800;
    letter-spacing: 0.15em;
    color: var(--text-secondary);
    display: block;
    margin-bottom: 0.3rem;
    margin-left: 0.3rem;
}

.temp-wrapper h1 {
    font-size: clamp(7rem, 22vw, 11rem);
    font-weight: 900;
    line-height: 0.82;
    letter-spacing: -0.06em;
    margin-left: -0.4rem;
    background: linear-gradient(180deg, var(--text-primary) 40%, rgba(255,255,255,0.6) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* 2. Roast Comment — DOMINATES after temp */
.joke-container h2 {
    font-size: clamp(1.6rem, 5.5vw, 2.3rem);
    font-weight: 600;
    line-height: 1.1;
    letter-spacing: -0.03em;
    max-width: 95%;
    color: var(--text-primary);
}

/* 3. Difficulty */
.difficulty-block {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.difficulty-label-text {
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    color: var(--text-tertiary);
}

.difficulty-row {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
}

.difficulty-score {
    font-size: 1.8rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.difficulty-dot {
    font-size: 1.2rem;
    color: var(--text-tertiary);
}

.difficulty-word {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text-secondary);
}

/* 4. Verdict */
.verdict-container {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.verdict-label {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

#daily-verdict {
    font-size: 1rem;
    font-weight: 400;
    color: var(--text-secondary);
    line-height: 1.3;
}

/* 5. Daily Record */
.daily-record {
    font-size: 0.8rem;
    font-weight: 400;
    color: var(--text-tertiary);
    line-height: 1.3;
    margin-top: -0.5rem;
}

/* === FOOTER === */
footer {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

/* Weather Alert */
.weather-alert {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 8px;
    background: rgba(255, 180, 50, 0.08);
    border-left: 3px solid rgba(255, 180, 50, 0.5);
    font-size: 0.8rem;
    font-weight: 500;
    color: rgba(255, 220, 150, 0.9);
}

.weather-alert.hidden {
    display: none;
}

.alert-icon {
    font-size: 0.9rem;
}

/* Achievement (small, supporting) */
.achievement-banner {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    border-left: 2px solid rgba(255, 215, 0, 0.3);
    padding-left: 10px;
}

.ach-icon {
    width: 14px;
    height: 14px;
    color: rgba(255, 215, 0, 0.6);
    flex-shrink: 0;
}

.ach-text {
    display: flex;
    flex-direction: column;
}

.ach-title {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 700;
    color: var(--text-tertiary);
}

.ach-value {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
}

/* Primary Stats (4 visible) */
.primary-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--spacing-xs);
    padding-top: var(--spacing-xs);
}

.stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.stat-label {
    font-size: 0.6rem;
    font-weight: 700;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.stat-val {
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--text-secondary);
}

/* More Details Toggle */
#more-details-wrapper {
    display: flex;
    flex-direction: column;
}

.more-details-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    color: var(--text-tertiary);
    font-family: inherit;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    cursor: pointer;
    padding: 4px 0;
    transition: color 0.2s ease;
}

.more-details-btn:hover {
    color: var(--text-secondary);
}

.more-details-btn .chevron-icon {
    transition: transform 0.25s ease;
}

.more-details-btn.expanded .chevron-icon {
    transform: rotate(180deg);
}

.more-details {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: var(--spacing-xs);
    padding-top: var(--spacing-xs);
    overflow: hidden;
    max-height: 200px;
    animation: slideDown 0.25s ease;
}

.more-details.hidden {
    display: none;
}

@keyframes slideDown {
    from {
        opacity: 0;
        max-height: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        max-height: 200px;
        transform: translateY(0);
    }
}

/* Bottom Row */
.footer-bottom-row {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding-top: var(--spacing-xs);
}

.action-buttons {
    display: flex;
    gap: var(--spacing-xs);
}

.action-buttons button {
    background: var(--accent);
    border: 1px solid var(--border);
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.action-buttons button:hover {
    background: rgba(255, 255, 255, 0.12);
    color: var(--text-primary);
    transform: scale(1.04);
}

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

/* Footer Tagline */
.footer-tagline {
    font-size: 0.65rem;
    font-weight: 500;
    color: var(--text-tertiary);
    text-align: center;
    letter-spacing: 0.02em;
    padding-top: var(--spacing-xs);
    padding-bottom: var(--spacing-sm);
    opacity: 0.7;
}

.footer-tagline a {
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 700;
    transition: opacity 0.2s ease;
}

.footer-tagline a:hover {
    opacity: 0.8;
}

/* === LOADING OVERLAY === */
#loading-overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: #080808;
    z-index: 100;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    transition: opacity 0.6s ease;
}

#loading-overlay p {
    font-size: 0.85rem;
    color: var(--text-tertiary);
    font-weight: 500;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 2px solid rgba(255, 255, 255, 0.06);
    border-top-color: rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* === TOAST NOTIFICATION === */
.toast {
    position: fixed; /* Prevents any layout shifting */
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: rgba(20, 20, 20, 0.95);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: var(--text-primary);
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    border: 1px solid var(--border);
    box-shadow: 0 8px 20px rgba(0,0,0,0.4);
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

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

/* === SHARE VIEW OVERRIDES === */
#capture-area.sharing {
    background: inherit;
}

#share-title {
    margin-bottom: var(--spacing-sm);
}

#share-title h4 {
    font-size: 0.85rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-tertiary);
    font-weight: 700;
}

#share-branding {
    margin-top: var(--spacing-sm);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-tertiary);
}

/* === SVG GRAPHICS ENGINE === */
#dynamic-graphics-layer {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    z-index: 1; /* Above background, below heat distortion */
    pointer-events: none;
    overflow: hidden;
}

.dynamic-sun {
    position: absolute;
    top: -10%; right: -10%;
    width: 650px; height: 650px;
    animation: pulse 4s ease-in-out infinite alternate;
    opacity: 0.3;
    mix-blend-mode: screen;
}

.dynamic-sun.hell {
    width: 800px; height: 800px;
    animation: pulse-aggressive 2s ease-in-out infinite alternate;
    opacity: 0.4;
}

.dynamic-sun.pleasant {
    opacity: 0.25;
}

.dynamic-moon {
    position: absolute;
    top: -10%; right: -10%;
    width: 450px; height: 450px;
    animation: float 6s ease-in-out infinite alternate;
    opacity: 0.3;
    mix-blend-mode: screen;
}

.cloud-wrapper {
    position: absolute;
    width: 200px;
    animation: drift linear infinite;
}

.cloud-wrapper svg {
    width: 100%;
    height: auto;
}

.cloud-1 { top: 15%; left: -300px; animation-duration: 35s; }
.cloud-2 { top: 35%; left: -400px; animation-duration: 50s; transform: scale(1.4); opacity: 0.6; }
.cloud-3 { top: 60%; left: -250px; animation-duration: 25s; transform: scale(0.9); opacity: 0.4; }

@keyframes pulse {
    0% { transform: scale(1); opacity: 0.6; }
    100% { transform: scale(1.04); opacity: 0.8; }
}

@keyframes pulse-aggressive {
    0% { transform: scale(1); opacity: 0.7; }
    100% { transform: scale(1.08); opacity: 0.9; }
}

@keyframes drift {
    from { transform: translateX(-20vw); }
    to { transform: translateX(120vw); }
}

@keyframes float {
    from { transform: translateY(0); }
    to { transform: translateY(15px); }
}

/* === EDGE BLUR === */
#edge-blur {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    pointer-events: none;
    z-index: 3;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    mask-image: linear-gradient(to right, black 0%, transparent 15%, transparent 85%, black 100%);
    -webkit-mask-image: linear-gradient(to right, black 0%, transparent 15%, transparent 85%, black 100%);
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
    #edge-blur {
        display: none;
    }
}

@media (max-width: 400px) {
    #capture-area {
        padding: var(--spacing-md) var(--spacing-sm);
    }

    .temp-wrapper h1 {
        font-size: clamp(5.5rem, 20vw, 8rem);
    }

    .joke-container h2 {
        font-size: clamp(1.3rem, 5vw, 1.8rem);
    }

    .difficulty-score {
        font-size: 1.4rem;
    }

    .primary-stats {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--spacing-sm);
    }
}

@media (min-height: 800px) {
    .hero {
        gap: var(--spacing-lg);
    }
}
