:root {
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Inter", "Helvetica Neue", system-ui, sans-serif;
  --glass: rgba(255, 255, 255, 0.07);
  --glass-strong: rgba(20, 22, 42, 0.62);
  --stroke: rgba(255, 255, 255, 0.14);
  --text: rgba(255, 255, 255, 0.94);
  --text-dim: rgba(255, 255, 255, 0.58);
  --blur: blur(32px) saturate(160%);
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.16);
  --accent: #6c7cff;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }

body {
  font-family: var(--font);
  color: var(--text);
  background: #0c0e1d;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* WALLPAPER (dark navy / indigo / plum) */
.wallpaper {
  position: fixed; inset: 0; z-index: 0; overflow: hidden;
  background: radial-gradient(120% 90% at 50% 0%, #1a1d3f 0%, #0c0e1d 65%);
}
.blob { position: absolute; border-radius: 50%; filter: blur(90px); }
.b1 { width: 55vmax; height: 55vmax; background: #3d33a8; opacity: 0.5; top: -22vmax; left: -16vmax; animation: drift1 26s ease-in-out infinite alternate; }
.b2 { width: 48vmax; height: 48vmax; background: #7a2766; opacity: 0.4; bottom: -22vmax; right: -12vmax; animation: drift2 30s ease-in-out infinite alternate; }
.b3 { width: 38vmax; height: 38vmax; background: #1a5f7a; opacity: 0.32; top: 30%; left: 45%; animation: drift3 34s ease-in-out infinite alternate; }
@keyframes drift1 { to { transform: translate(18vmax, 12vmax) scale(1.1); } }
@keyframes drift2 { to { transform: translate(-16vmax, -10vmax) scale(1.15); } }
@keyframes drift3 { to { transform: translate(-22vmax, 14vmax) scale(0.9); } }

/* MENU BAR */
#menubar {
  position: fixed; top: 0; left: 0; right: 0; height: 30px; z-index: 10;
  display: flex; justify-content: space-between; align-items: center;
  padding: 0 14px; font-size: 13px;
  background: rgba(12, 14, 30, 0.5);
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.menu-left { display: flex; align-items: center; gap: 12px; }
.menu-logo { width: 12px; height: 12px; border-radius: 50%; background: linear-gradient(135deg, #e8e9ff, #7f89e8); }
.menu-right { font-weight: 500; font-variant-numeric: tabular-nums; }

/* INTRO / LOCK SCREEN */
#intro {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  background: rgba(8, 9, 22, 0.5);
  backdrop-filter: blur(40px) saturate(150%); -webkit-backdrop-filter: blur(40px) saturate(150%);
  transition: opacity 0.8s ease, backdrop-filter 0.8s ease;
}
#intro.hide { opacity: 0; pointer-events: none; backdrop-filter: blur(0); -webkit-backdrop-filter: blur(0); }
.lock-time { font-size: clamp(72px, 18vw, 140px); font-weight: 600; letter-spacing: -0.03em; line-height: 1; font-variant-numeric: tabular-nums; }
.lock-date { margin-top: 8px; font-size: clamp(16px, 3.5vw, 22px); font-weight: 500; color: var(--text-dim); }
.intro-text {
  margin-top: 48px; padding: 11px 28px; border-radius: 999px; font-size: 16px; font-weight: 600;
  background: var(--glass); border: 1px solid var(--stroke);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.16);
  transition: background 0.25s ease, transform 0.25s ease;
}
/* hover cuma kena kalau kursor beneran di atas tombol (bukan di seluruh layar) */
#intro { cursor: default; }
#intro:focus-visible { outline: none; }
#intro:focus-visible .intro-text { outline: 2px solid var(--accent); outline-offset: 3px; }
.intro-text { cursor: pointer; }
@media (hover: hover) {
  .intro-text:hover { background: rgba(255, 255, 255, 0.14); transform: scale(1.04); }
}

/* WINDOW */
.container {
  position: relative; z-index: 2; width: min(720px, calc(100% - 32px));
  opacity: 0; transform: translateY(12px) scale(0.98); pointer-events: none;
  transition: opacity 0.8s ease, transform 0.8s cubic-bezier(.2,.8,.2,1);
}
.container.show { opacity: 1; transform: none; pointer-events: auto; }

.window, .sheet {
  background: var(--glass);
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--stroke);
  border-radius: 20px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.titlebar {
  position: relative; height: 44px; display: flex; align-items: center; justify-content: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
  background: rgba(255, 255, 255, 0.04);
}
.window-title { font-size: 13px; font-weight: 600; color: var(--text-dim); }
.lights { position: absolute; left: 16px; display: flex; gap: 8px; }
.lights i, .light-btn { width: 12px; height: 12px; border-radius: 50%; display: block; }
.lights .red, .light-btn { background: #ff5f57; }
.lights .yellow { background: #febc2e; }
.lights .green { background: #28c840; }
.light-btn { position: absolute; left: 16px; }
.light-btn:hover { box-shadow: 0 0 0 3px rgba(255, 95, 87, 0.3); }

.window-body {
  position: relative; min-height: 300px; padding: 40px 32px;
  display: flex; align-items: center; justify-content: center;
}

/* TYPING TEXT — lebar teks penuh sudah "dipesan" supaya gak geser/nyangkut */
#typing-text {
  position: relative; z-index: 2; width: 100%; min-height: 3.7em;
  display: grid; place-items: center;
  font-size: clamp(26px, 6vw, 46px); font-weight: 700; letter-spacing: -0.02em; line-height: 1.2;
  transition: color 0.4s ease;
}
.tt { max-width: 100%; text-align: center; overflow-wrap: anywhere; }
.rest { color: transparent; }
.caret { display: inline-block; position: relative; width: 0; height: 1em; vertical-align: text-bottom; }
.caret::after {
  content: ""; position: absolute; left: 1px; top: 0.05em; width: 3px; height: 100%;
  background: var(--accent); border-radius: 2px; animation: caret 1s steps(1) infinite;
}
@keyframes caret { 50% { opacity: 0; } }

/* MANCHESTER MODE */
.red-mode { color: #ff5b52; animation: nudge 0.12s infinite; }
.red-mode .caret::after { background: #ff5b52; }
@keyframes nudge {
  0% { transform: translate(0, 0); } 25% { transform: translate(-1px, 1px); }
  50% { transform: translate(1px, -1px); } 75% { transform: translate(-1px, -1px); }
  100% { transform: translate(1px, 1px); }
}

#manutd-logo {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 200px; opacity: 0; transition: opacity 0.8s ease; z-index: 1; pointer-events: none;
}
#manutd-logo.show { opacity: 0.2; }

/* SUPPORT — di atas taskbar */
#support-wrap {
  position: fixed; left: 0; right: 0; bottom: 104px; z-index: 5;
  display: flex; justify-content: center; pointer-events: none;
}
.pill {
  pointer-events: auto; display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 22px; border-radius: 999px; font-size: 15px; font-weight: 600; text-decoration: none; color: #fff;
  background: linear-gradient(180deg, #e05a8a, #b8325f);
  box-shadow: 0 8px 22px rgba(184, 50, 95, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.35);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.pill:hover { transform: translateY(-2px) scale(1.03); box-shadow: 0 12px 28px rgba(184, 50, 95, 0.55), inset 0 1px 0 rgba(255,255,255,0.35); }
.pill:active { transform: scale(0.98); }

/* DOCK */
#btn-group {
  position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 5;
  display: flex; align-items: flex-end; gap: 10px; padding: 10px 12px;
  background: var(--glass);
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--stroke); border-radius: 24px; box-shadow: var(--shadow);
}
#dock-apps { display: flex; gap: 10px; align-items: flex-end; }
.dock-item { position: relative; display: block; transition: transform 0.22s cubic-bezier(.2,.8,.2,1); transform-origin: bottom center; }
.dock-item:hover { transform: translateY(-10px) scale(1.28); }
.dock-item:active { transform: translateY(-6px) scale(1.12); }
.icon {
  width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; color: #fff; font-size: 26px;
  background: linear-gradient(180deg, #4a4f66, #2a2d40);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}
.icon svg { width: 28px; height: 28px; }
.i-power { background: linear-gradient(180deg, #d9585e, #a82a31); }
.dock-sep { width: 1px; align-self: stretch; margin: 6px 2px; background: rgba(255, 255, 255, 0.2); }

.dock-item::after {
  content: attr(data-label); position: absolute; bottom: calc(100% + 14px); left: 50%;
  transform: translateX(-50%) translateY(4px); white-space: nowrap; pointer-events: none;
  padding: 5px 10px; border-radius: 8px; font-size: 12px; font-weight: 500;
  background: rgba(20, 22, 42, 0.85); border: 1px solid var(--stroke);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  opacity: 0; transition: opacity 0.2s ease, transform 0.2s ease;
}
.dock-item:hover::after, .dock-item:focus-visible::after { opacity: 1; transform: translateX(-50%); }

/* POPUPS */
#popup, #spotify-popup {
  position: fixed; inset: 0; display: none; justify-content: center; align-items: center;
  background: rgba(4, 5, 14, 0.55);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
#popup { z-index: 50; }
#spotify-popup { z-index: 60; }
#popup.show, #spotify-popup.show { display: flex; }
#popup.show .sheet, #spotify-popup.show .sheet { animation: pop 0.3s cubic-bezier(.2,.9,.3,1.2); }
@keyframes pop { from { opacity: 0; transform: scale(0.94); } }

.popup-box { width: min(360px, calc(100% - 32px)); padding: 24px; background: var(--glass-strong); }
.popup-box h3 { font-size: 20px; font-weight: 700; margin-bottom: 16px; letter-spacing: -0.01em; }

.popup-box input, .popup-box textarea {
  display: block; width: 100%; margin-bottom: 10px; padding: 11px 14px; font: inherit; font-size: 15px; color: var(--text);
  background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255, 255, 255, 0.12); border-radius: 10px; outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.popup-box textarea { height: 130px; resize: none; }
.popup-box input::placeholder, .popup-box textarea::placeholder { color: var(--text-dim); }
.popup-box input:focus, .popup-box textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(108, 124, 255, 0.35); }

.popup-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }
.btn-primary, .btn-secondary { padding: 9px 20px; border-radius: 10px; font-size: 14px; font-weight: 600; transition: filter 0.2s ease, transform 0.15s ease; }
.btn-primary { background: var(--accent); color: #fff; box-shadow: inset 0 1px 0 rgba(255,255,255,0.25); }
.btn-secondary { background: rgba(255, 255, 255, 0.1); }
.btn-primary:hover, .btn-secondary:hover { filter: brightness(1.15); }
.btn-primary:active, .btn-secondary:active { transform: scale(0.97); }
.btn-primary:disabled { opacity: 0.55; cursor: progress; }

.spotify-box { width: min(380px, calc(100% - 32px)); background: var(--glass-strong); }
.spotify-box iframe { display: block; padding: 10px; width: 100%; }

/* SHUTDOWN SCREEN */
#shutdown {
  position: fixed; inset: 0; z-index: 20000; display: none;
  flex-direction: column; align-items: center; justify-content: center;
  background: rgba(3, 4, 12, 0.72); opacity: 0;
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  transition: opacity 0.7s ease, background 0.9s ease;
}
#shutdown.active { display: flex; }
#shutdown.show { opacity: 1; }
#shutdown.off { background: #000; backdrop-filter: none; -webkit-backdrop-filter: none; }

.sd-load { display: none; flex-direction: column; align-items: center; gap: 18px; }
#shutdown.loading .sd-load { display: flex; }
.sd-spinner {
  width: 38px; height: 38px; border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.18); border-top-color: #fff;
  animation: spin 0.9s linear infinite;
}
.sd-text { font-size: 14px; font-weight: 500; color: var(--text-dim); }
@keyframes spin { to { transform: rotate(360deg); } }

#power-on {
  display: none; width: 84px; height: 84px; border-radius: 50%; place-items: center;
  color: rgba(255, 255, 255, 0.8); border: 2px solid rgba(255, 255, 255, 0.3);
  transition: color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease, transform 0.2s ease;
}
#shutdown.off #power-on { display: grid; }
#power-on:hover { color: #fff; border-color: rgba(255, 255, 255, 0.8); box-shadow: 0 0 28px rgba(255, 255, 255, 0.25); }
#power-on:active { transform: scale(0.94); }

/* RESPONSIVE */
@media (max-width: 520px) {
  .window-body { padding: 32px 20px; min-height: 260px; }
  #btn-group { gap: 6px; padding: 8px 10px; bottom: 10px; }
  #dock-apps { gap: 6px; }
  .icon { width: 42px; height: 42px; border-radius: 12px; font-size: 22px; }
  .icon svg { width: 23px; height: 23px; }
  .dock-item:hover { transform: none; }
  .dock-item::after { display: none; }
  #support-wrap { bottom: 88px; }
}
@media (max-height: 560px) {
  .window-body { min-height: 200px; padding: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  .blob, .red-mode, .caret::after, .sd-spinner { animation: none; }
  .container, .dock-item { transition: none; }
}
