* { margin:0; padding:0; box-sizing:border-box; border:none; outline:none; }
html { margin:0; padding:0; }

body{
    font-family: monospace, serif;
    background: linear-gradient(135deg, #83eadc 0%, #fdb0ce 100%);
    display:flex;
    flex-direction:column;
    align-items:center;
    color:black;
    transition: background-color .5s ease, color .5s ease;
    min-height:100vh;
    position:relative;
    overflow-x:hidden;
}

video.bg-video{
    position:fixed;
    top:0;
    left:0;
    width:100vw;
    height:100vh;
    object-fit:cover;
    z-index:-2;
    filter:brightness(.78) saturate(1);
    transition:opacity .6s ease, filter .6s ease;
    opacity:1;
    pointer-events:none;
}

video.bg-video.changing{
    opacity:0.6;
    filter:brightness(.5) saturate(.8);
}

.bg-overlay{
    position:fixed;
    inset:0;
    background:linear-gradient(rgba(0,0,0,0.22), rgba(0,0,0,0.18));
    z-index:-1;
    pointer-events:none;
    transition:background .4s ease;
}

/* Title - Animated Underline Reveal */
h1.title {
    text-align: center;
    font-family: monospace, serif;
    margin: 30px 0 20px 0;
    font-size: 3.5rem;
    font-weight: 900;
    color: black;
    z-index: 1;
    position: relative;
    cursor: pointer;
    text-decoration: none;
    transition: color 0.3s ease;
}

h1.title::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 4px;
    background: linear-gradient(135deg, #3498db, #8e44ad);
    transition: width 0.3s ease;
}

h1.title:hover::after {
    width: 100%;
}

.weatherform {
    margin:20px 0;
    padding:0;
    display:flex;
    align-items:center;
    background:none;
    z-index:1;
    position:relative;
}

.cityinput {
    padding:10px 15px;
    border:1px solid black;
    font-size:20px;
    font-weight:bold;
    border-radius:10px;
    margin:10px;
    width:300px;
    background:white;
    box-shadow:0 2px 10px rgba(0,0,0,.1);
    transition:all .3s ease;
    position:relative;
}
.cityinput:focus {
    border:2px solid #3498db;
    box-shadow:0 0 0 3px rgba(52,152,219,.2);
    transform:translateY(-2px);
}
.cityinput:hover {
    box-shadow:0 4px 15px rgba(0,0,0,.15);
    transform:translateY(-1px);
}

button[type="submit"]{
    padding:10px 20px;
    font-size:20px;
    font-weight:bold;
    background-color:forestgreen;
    color:white;
    cursor:pointer;
    border-radius:10px;
    margin-left:10px;
    box-shadow:0 4px 15px rgba(34,139,34,.3);
    transition:all .3s ease;
}
button[type="submit"]:hover{
    background-color:rgba(102,255,0,.8);
    color:black;
    transform:translateY(-3px) scale(1.05);
}

#darkModeToggle{
    padding:10px 16px;
    font-size:1rem;
    font-weight:bold;
    border-radius:10px;
    background:#333;
    color:#eee;
    box-shadow:0 4px 15px rgba(51,51,51,.3);
    position:fixed;
    top:15px;
    right:15px;
    z-index:20;
    cursor:pointer;
    transition:all .3s ease;
}
#darkModeToggle:hover{
    background:#555;
    transform:translateY(-2px);
}

.card{
    background: linear-gradient(180deg, rgba(0,0,255,.67) 0%, rgba(255,165,0,.58) 100%);
    padding:35px;
    border-radius:20px;
    box-shadow:0 15px 35px rgba(0,0,0,.1);
    min-width:480px;
    max-width:680px;
    width: 90%;
    display:flex;
    flex-direction:column;
    align-items:center;
    margin-top:20px;
    color:black;
    transition:all .4s cubic-bezier(.4,0,.2,1);
    transform:translateY(0) scale(1);
    opacity:0;
    position:relative;
    overflow:hidden;
    z-index:1;
    cursor: pointer;
}

.card:hover {
    transform: translateY(-5px) scale(1.02);
    box-shadow: 0 25px 50px rgba(0,0,0,.2);
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    transition: left 0.6s;
    z-index: 1;
    pointer-events: none;
}

.card:hover::before {
    left: 100%;
}

.card > * {
    position: relative;
    z-index: 2;
}

@keyframes cardAppear {
    from { opacity:0; transform:translateY(30px) scale(.95); }
    to   { opacity:1; transform:translateY(0) scale(1); }
}
.card.show {
    opacity:1;
    transform:translateY(0) scale(1);
    animation:cardAppear .6s ease-out forwards;
}

.card > * {
    animation:contentFadeIn .8s ease-out forwards;
    opacity:0;
    transform:translateY(20px);
}
@keyframes contentFadeIn {
    to { opacity:1; transform:translateY(0); }
}

.weather-content {
    display:flex;
    flex-direction:row;
    align-items:center;
    gap:35px;
    width:100%;
    justify-content:center;
}

.weather-icon-container {
    font-size:90px;
    display:flex;
    align-items:center;
    justify-content:center;
    min-width:150px;
}

.weather-text {
    display:flex;
    flex-direction:column;
    align-items:flex-start;
    gap:12px;
}

.citydisplay {
    font-size:2rem;
    font-weight:700;
    color:black;
    animation: slideInFromLeft 0.6s ease-out 0.2s both;
}

.temp {
    font-size:2.2rem;
    font-weight:700;
    color:black;
    animation: slideInFromRight 0.6s ease-out 0.4s both;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.temp:hover {
    transform: scale(1.1);
    text-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

.humidity {
    font-weight:700;
    font-size:1rem;
    padding:8px 16px;
    border-radius:25px;
    background:rgba(255,255,255,.2);
    animation: slideInFromLeft 0.6s ease-out 0.6s both;
    transition: all 0.3s ease;
    cursor: pointer;
}

.humidity:hover {
    background:rgba(255,255,255,.4);
    transform: scale(1.05);
}

.desc {
    font-style:italic;
    font-weight:700;
    font-size:1.3rem;
    animation: slideInFromRight 0.6s ease-out 0.8s both;
}

@keyframes slideInFromLeft {
    0% {
        opacity: 0;
        transform: translateX(-30px);
    }
    100% {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInFromRight {
    0% {
        opacity: 0;
        transform: translateX(30px);
    }
    100% {
        opacity: 1;
        transform: translateX(0);
    }
}

.loader-container {
    margin-top:20px;
    display:flex;
    justify-content:center;
    width:100%;
    animation:pulse 1.5s ease-in-out infinite;
    z-index:1;
}
.loader{
    border:6px solid #f3f3f3;
    border-top:6px solid #3498db;
    border-radius:50%;
    width:40px;
    height:40px;
    animation:spin 1s linear infinite;
    position:relative;
}
@keyframes spin { 0%{transform:rotate(0)} 100%{transform:rotate(360deg)} }
@keyframes pulse { 0%,100%{opacity:1; transform:scale(1);} 50%{opacity:.7; transform:scale(1.05);} }

.sun-icon {
    width:80px;
    height:80px;
    background:radial-gradient(circle,#FFD700 0%, #FFA500 70%);
    border-radius:50%;
    animation:sunPulse 3s ease-in-out infinite;
}
@keyframes sunPulse { 0%,100%{transform:scale(1)} 50%{transform:scale(1.1)} }

.weather-icon {
    font-size: 90px;
    cursor: pointer;
    transition: transform 0.3s ease;
    animation: subtleFloat 4s ease-in-out infinite;
}

.weather-icon:hover {
    transform: scale(1.2) !important;
    filter: drop-shadow(0 10px 20px rgba(0,0,0,0.3));
}

@keyframes subtleFloat {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-8px); }
}

.thunderstorm-icon {
    animation: thunderstormShake 3s ease-in-out infinite, subtleFloat 4s ease-in-out infinite;
}
@keyframes thunderstormShake {
    0%, 100% { transform: translateX(0px) rotate(0deg); }
    25% { transform: translateX(-2px) rotate(-1deg); }
    75% { transform: translateX(2px) rotate(1deg); }
}

.rain-icon {
    animation: rainDrop 2.5s ease-in-out infinite, subtleFloat 4s ease-in-out infinite;
}
@keyframes rainDrop {
    0%, 100% { transform: translateY(0px) scaleY(1); }
    50% { transform: translateY(5px) scaleY(1.1); }
}

.snow-icon {
    animation: snowFall 4s ease-in-out infinite, subtleFloat 4s ease-in-out infinite;
}
@keyframes snowFall {
    0%, 100% { transform: translateY(0px) rotate(0deg); }
    25% { transform: translateY(-3px) rotate(-5deg); }
    50% { transform: translateY(-1px) rotate(0deg); }
    75% { transform: translateY(-2px) rotate(5deg); }
}

.mist-icon {
    animation: mistSway 5s ease-in-out infinite, subtleFloat 4s ease-in-out infinite;
    opacity: 0.9;
}
@keyframes mistSway {
    0%, 100% { transform: translateX(0px); opacity: 0.9; }
    50% { transform: translateX(5px); opacity: 0.7; }
}

.cloud-icon {
    animation: cloudDrift 6s ease-in-out infinite, subtleFloat 4s ease-in-out infinite;
}
@keyframes cloudDrift {
    0%, 100% { transform: translateX(0px) scale(1); }
    50% { transform: translateX(8px) scale(1.05); }
}

.sun-icon {
    width:100px;
    height:100px;
    background:radial-gradient(circle,#FFD700 0%, #FFA500 70%);
    border-radius:50%;
    animation: sunRotate 8s linear infinite, sunPulse 3s ease-in-out infinite, subtleFloat 4s ease-in-out infinite;
    position: relative;
}
@keyframes sunRotate {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.emoji { font-size:3.5em; display:none; }

body.dark-mode {
    background: linear-gradient(135deg,#0f2027 0%,#203a43 50%,#2c5364 100%);
    color:#eee;
}

body.dark-mode h1.title {
    color: white;
}

body.dark-mode h1.title::after {
    background: linear-gradient(135deg, #f1c40f, #e67e22);
}

body.dark-mode .card {
    background: linear-gradient(180deg, rgba(30,30,60,.85) 0%, rgba(70,70,100,.85) 100%);
    color:#eee;
}
body.dark-mode .citydisplay,
body.dark-mode .temp,
body.dark-mode .humidity,
body.dark-mode .desc {
    color:#eee;
}
body.dark-mode .cityinput {
    background:#444;
    color:#eee;
    border:1px solid #666 !important;
}

body > *:not(.bg-video):not(.bg-overlay) { position:relative; z-index:1; }

.ErrorDisplay {
    color: #cc0000;
    background: rgba(255, 255, 255, 0.9);
    padding: 15px;
    border-radius: 10px;
    text-align: center;
    font-weight: bold;
}

@media (max-width:768px) {
    .card {
        min-width: 90%;
        max-width: 95%;
        padding: 25px;
    }

    .weather-content {
        flex-direction:column;
        gap:15px;
    }

    .weather-icon-container {
        font-size:70px;
        min-width: auto;
    }

    .weather-icon {
        font-size: 70px;
    }

    .sun-icon {
        width: 80px;
        height: 80px;
    }

    .citydisplay, .temp {
        font-size:1.8rem;
        text-align: center;
    }

    .desc {
        font-size: 1.1rem;
        text-align: center;
    }

    .weather-text {
        align-items: center;
    }
}

@media (max-width:480px) {
    .weather-content {
        flex-direction: column;
        gap: 10px;
    }

    .weather-icon-container {
        font-size: 60px;
    }

    .weather-icon {
        font-size: 60px;
    }

    .sun-icon {
        width: 70px;
        height: 70px;
    }

    .citydisplay, .temp {
        font-size: 1.5rem;
    }

    .desc {
        font-size: 1rem;
    }
}