Warung kopi di malam hujan: neon BUKA berkedip, uap kopi tubruk melingkar, dan si Oyen tidur sambil bernapas. Semuanya CSS murni: hujan dari radial-gradient…
Oleh @belajarweb · CSS
<!doctype html>
<html lang="id">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Warung Kopi Tengah Malam</title>
<style>
/* Warung Kopi Tengah Malam: satu warung, satu malam hujan, tanpa JavaScript.
1rem = 10px pada 1024x640; seluruh adegan ikut membesar/mengecil bersama layar. */
:root {
--malam-1: #0c0b20;
--malam-2: #17143a;
--malam-3: #2a2350;
--bohlam: #ffcf7a;
--bohlam-kuat: #ffb04a;
--neon: #ff4f9a;
--terpal-merah: #c9453b;
--terpal-krem: #efe2c4;
--kayu: #6b4127;
--kayu-tua: #3a2317;
--oyen: #e78b3f;
--oyen-tua: #b9622a;
--oyen-muda: #f8c896;
}
* { box-sizing: border-box; margin: 0; }
html {
font-size: min(calc(100vw / 102.4), calc(100vh / 64));
height: 100%;
}
@media (max-aspect-ratio: 4/5) {
html { font-size: min(calc(100vw / 64), calc(100vh / 90)); }
.wk .wk-stage { bottom: 12vh; }
.wk .wk-ground { height: calc(12rem + 12vh); }
.wk .wk-city { bottom: calc(12rem + 12vh); }
}
body {
height: 100%;
overflow: hidden;
font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
background:
radial-gradient(9rem 9rem at 21% 13%, #ebe4ff4c, transparent 70%),
radial-gradient(30rem 22rem at 21% 13%, #9687d238, transparent 70%),
radial-gradient(60rem 9rem at 30% 20%, #463c7859, transparent 70%),
radial-gradient(120rem 40rem at 50% 100%, #3d2c58 0%, transparent 70%),
linear-gradient(180deg, var(--malam-1) 0%, var(--malam-2) 50%, var(--malam-3) 100%);
color: #fff;
}
.wk { position: relative; height: 100%; overflow: hidden; }
.wk i, .wk b { display: block; position: absolute; font-style: normal; }
/* ---------- kota di kejauhan ---------- */
.wk-city {
position: absolute; left: 50%; bottom: 12rem; width: 150rem; height: 30rem; margin-left: -75rem;
z-index: 1; opacity: .9;
}
.wk-city::after { /* kabut hujan */
content: ""; position: absolute; inset: 0;
background: linear-gradient(180deg, transparent 20%, #7869aa47 100%);
}
.wk-bld {
bottom: 0; background-color: #1b1838;
background-image:
conic-gradient(from 90deg at 6.4rem 9rem, #ffc46ecc 0 25%, transparent 0),
conic-gradient(from 90deg at 3.8rem 12.6rem, #ffe2aa99 0 25%, transparent 0),
conic-gradient(from 90deg at 1.2rem 1.8rem, #262150 0 25%, transparent 0);
background-size: 7.8rem 10.8rem, 5.2rem 14.4rem, 2.6rem 3.6rem;
background-position: -.2rem -.6rem, 1.1rem -2.4rem, -.2rem -.6rem;
}
.wk-bld--1 { left: 8rem; width: 16rem; height: 19rem; }
.wk-bld--2 { left: 22rem; width: 10rem; height: 26rem; background-color: #18153a; }
.wk-bld--3 { left: 33rem; width: 20rem; height: 15rem; }
.wk-bld--4 { left: 84rem; width: 14rem; height: 22rem; }
.wk-bld--5 { left: 98rem; width: 22rem; height: 17rem; background-color: #18153a; }
.wk-bld--6 { left: 121rem; width: 14rem; height: 25rem; }
.wk-mesjid { left: 60rem; bottom: 0; width: 18rem; height: 12rem; background: #1d1a3d; border-radius: 1rem 1rem 0 0; }
.wk-mesjid::before { /* kubah */
content: ""; position: absolute; left: 3.5rem; top: -7rem; width: 11rem; height: 9rem;
border-radius: 50% 50% 10% 10% / 70% 70% 10% 10%; background: #1d1a3d;
}
.wk-mesjid b { /* menara */
left: -4rem; bottom: 0; width: 2.6rem; height: 26rem; background: #1d1a3d; border-radius: 1.3rem 1.3rem 0 0;
}
.wk-mesjid b::before {
content: ""; position: absolute; left: -.6rem; top: 5rem; width: 3.8rem; height: 1rem; background: #1d1a3d; border-radius: .3rem;
}
.wk-mesjid b::after { /* lampu bulan sabit hijau */
content: ""; position: absolute; left: .55rem; top: -2.4rem; width: 1.5rem; height: 1.5rem; border-radius: 50%;
box-shadow: .35rem -.15rem 0 0 #8fe6b8; filter: drop-shadow(0 0 .4rem #8fe6b8);
}
/* ---------- jalan basah ---------- */
.wk-ground {
position: absolute; left: 0; right: 0; bottom: 0; height: 12rem; z-index: 1;
background:
linear-gradient(180deg, #4a3a5c 0 .5rem, #2a2238 .5rem 1.1rem, transparent 1.1rem),
linear-gradient(180deg, #221b33 0%, #120e1d 100%);
}
.wk-refl { bottom: 0; top: 1.1rem; }
.wk-refl--neon {
left: calc(50% - 22rem); width: 12rem;
background: radial-gradient(50% 100% at 50% 0, #ff4f9a61, transparent 85%);
animation: wk-flicker-soft 6.5s infinite;
}
.wk-refl--bulb {
left: calc(50% - 16rem); width: 34rem;
background: radial-gradient(50% 100% at 50% 0, #ffbe6452, transparent 90%);
}
.wk-refl--lamp {
left: calc(50% + 31rem); width: 14rem;
background: radial-gradient(50% 100% at 50% 0, #ffa0464c, transparent 85%);
}
.wk-ripple {
left: var(--x); bottom: 3rem; width: 5.6rem; height: 1.3rem; margin-left: -2.8rem;
border: .16rem solid #c8d2ff80; border-radius: 50%;
animation: wk-ripple 1.7s var(--d) ease-out infinite;
}
.wk-ripple:nth-child(2n) { bottom: 6.5rem; width: 4.2rem; }
.wk-ripple:nth-child(3n) { bottom: 1.4rem; width: 6.6rem; }
@keyframes wk-ripple {
0% { transform: scale(.1); opacity: 0; }
12% { opacity: 1; }
100% { transform: scale(1); opacity: 0; }
}
/* ---------- hujan (dua lapis, digeser dengan transform supaya murah) ---------- */
.wk-rain { position: absolute; inset: 0; z-index: 2; overflow: hidden; pointer-events: none; }
.wk-rain i { left: -30%; right: -30%; top: -60%; bottom: -30%; will-change: transform; }
.wk-rain-far {
background:
radial-gradient(.1rem 1.3rem at 50% 30%, #becdff80, transparent),
radial-gradient(.1rem 1.1rem at 50% 70%, #becdff66, transparent);
background-size: 2.9rem 8rem, 4.3rem 8rem;
background-position: 0 0, 1.7rem 0;
animation: wk-rain-far .75s linear infinite;
}
.wk-rain-near {
background:
radial-gradient(.14rem 2.6rem at 50% 20%, #d2deff8c, transparent),
radial-gradient(.14rem 2.2rem at 50% 65%, #d2deff73, transparent);
background-size: 7.3rem 16rem, 11.3rem 16rem;
background-position: 0 0, 4.1rem 0;
animation: wk-rain-near .5s linear infinite;
}
@keyframes wk-rain-far { from { transform: rotate(9deg) translateY(0); } to { transform: rotate(9deg) translateY(8rem); } }
@keyframes
…