/* 3B giriş sayfası: küreye çift tıklayınca giriş penceresi açılır */
:root {
  --bg: #05060a;
  --fg: #eef1ff;
  --muted: #8b90a8;
  --accent: #7c5cff;
  --accent-2: #2de2e6;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: "Space Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: manipulation;
}

/* Yükleme ekranı */
#loader {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: var(--bg);
  transition: opacity 0.8s ease, visibility 0.8s;
}
#loader span {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.1);
  border-top-color: var(--accent-2);
  animation: spin 0.9s linear infinite;
}
body.ready #loader { opacity: 0; visibility: hidden; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Atom girişi: çekirdeğin etrafında yörüngeler ve elektron kapsülleri */
@property --spin {
  syntax: "<angle>";
  initial-value: 0deg;
  inherits: false;
}

.login {
  position: fixed;
  inset: 0;
  z-index: 30;
  visibility: hidden;
  pointer-events: none;
  transition: visibility 0s linear 0.6s;
}
body.login-open .login { visibility: visible; transition-delay: 0s; }
.login form { display: contents; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.orbits {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}
.orbit {
  fill: none;
  stroke: rgba(124, 92, 255, 0.45);
  stroke-width: 1;
  stroke-dasharray: 2400;
  stroke-dashoffset: 2400;
  filter: drop-shadow(0 0 4px rgba(45, 226, 230, 0.5));
  transition: stroke-dashoffset 1.2s cubic-bezier(.6,.1,.2,1), stroke 0.6s;
}
.orbits g:nth-child(1) .orbit { stroke: rgba(45, 226, 230, 0.55); }
body.login-open .orbit { stroke-dashoffset: 0; transition-delay: 0.25s; }
.e-dot {
  fill: #e9fbff;
  filter: drop-shadow(0 0 6px var(--accent-2)) drop-shadow(0 0 12px var(--accent));
  opacity: 0;
  transition: opacity 0.6s;
}
body.login-open .e-dot { opacity: 1; transition-delay: 1s; }

/* Elektron kapsülü: kenarında dönen ışık */
.electron {
  position: absolute;
  left: 50%;
  top: 50%;
  width: clamp(200px, 22vw, 250px);
  height: 52px;
  border-radius: 999px;
  pointer-events: auto;
  opacity: 0;
  transform: translate(-50%, -50%) translate(var(--fx, 0), var(--fy, 0)) scale(0.1);
  transition: opacity 0.35s ease, transform 0.5s cubic-bezier(.5,0,.75,0);
  animation: none;
}
body.login-open .electron {
  opacity: 1;
  transform: translate(-50%, -50%);
  transition: opacity 0.4s ease calc(0.45s + var(--d)), transform 0.9s cubic-bezier(.16,1.3,.3,1) calc(0.4s + var(--d));
}
.electron::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1.5px;
  background: conic-gradient(from var(--spin), transparent 0 55%, var(--accent) 75%, var(--accent-2) 88%, #fff 90%, transparent 92%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  animation: orbit-spin 3.2s linear infinite;
  animation-delay: var(--d);
}
.electron::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(120% 140% at 50% 50%, rgba(124, 92, 255, 0.16), rgba(5, 6, 10, 0.6) 70%);
  box-shadow: inset 0 0 0 1px rgba(124, 92, 255, 0.4), 0 0 30px rgba(124, 92, 255, 0.25);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: -1;
  transition: box-shadow 0.3s;
}
@keyframes orbit-spin { to { --spin: 360deg; } }

.electron:focus-within::before { animation-duration: 1.4s; }
.electron:focus-within::after {
  box-shadow: inset 0 0 0 1px rgba(45, 226, 230, 0.35), 0 0 42px rgba(45, 226, 230, 0.3);
}

.electron input {
  position: relative;
  width: 100%;
  height: 100%;
  padding: 0 26px;
  border: 0;
  border-radius: inherit;
  background: transparent;
  color: var(--fg);
  font: inherit;
  font-size: 1.02rem;
  letter-spacing: 0.06em;
  text-align: center;
  caret-color: var(--accent-2);
  outline: none;
}
.electron input::placeholder {
  color: rgba(205, 210, 235, 0.72);
  letter-spacing: 0.32em;
  font-size: 0.82rem;
  text-transform: lowercase;
}
.electron input[type="password"] {
  color: var(--accent-2);
  letter-spacing: 0.45em;
  text-shadow: 0 0 8px var(--accent-2), 0 0 16px var(--accent);
}
.electron input:-webkit-autofill {
  -webkit-text-fill-color: var(--fg);
  transition: background-color 9999s;
}

/* İki alan dolunca kapsüller de nabız gibi atar */
.login.is-ready .electron::after { animation: ready-beat 1.25s ease-in-out infinite; }
@keyframes ready-beat {
  50% { box-shadow: inset 0 0 0 1px rgba(45, 226, 230, 0.45), 0 0 48px rgba(45, 226, 230, 0.4); }
}

/* Giriş yapılırken alanlar çekirdeğe çöker */
body.entering .electron {
  opacity: 0;
  transform: translate(-50%, -50%) translate(var(--fx, 0), var(--fy, 0)) scale(0.05);
  transition: opacity 0.5s ease, transform 0.55s cubic-bezier(.6,0,.9,.4);
}
body.entering .orbit { stroke-dashoffset: 2400; transition-delay: 0s; transition-duration: 0.6s; }
body.entering .e-dot { opacity: 0; transition-delay: 0s; }

/* Hata: alanlar sarsılır, çekirdeğin altında kırmızı yazı */
.login.has-error .electron { animation: shake 0.6s ease 1.3s; }
.login.has-error .orbit { stroke: rgba(255, 59, 107, 0.5); }
@keyframes shake {
  20%, 60% { margin-left: -10px; }
  40%, 80% { margin-left: 10px; }
}
.error {
  position: absolute;
  transform: translate(-50%, 0);
  margin-top: clamp(100px, 17vh, 150px);
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  color: #ff8fa8;
  text-shadow: 0 0 10px rgba(255, 59, 107, 0.7);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.6s ease 1.2s;
}
body.login-open .error { opacity: 1; }

/* Uygulama ikonlarının ad etiketi */
.app-label {
  position: fixed;
  top: 0; left: 0;
  z-index: 20;
  padding: 6px 12px;
  border-radius: 8px;
  background: rgba(13, 15, 23, 0.85);
  border: 1px solid rgba(255,255,255,0.12);
  font-size: 0.8rem;
  color: var(--fg);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  white-space: nowrap;
}
.app-label.show { opacity: 1; }

@media (max-width: 640px) {
  .electron { width: min(240px, calc(100vw - 48px)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
