/* =========================================================
   Sicolagya — Day / Night Mode Toggle (complete, video-faithful)
   + Ink theme color system
   ========================================================= */

:root {
  --nx-paper: #F6F5F2;
  --nx-ink: #2A2A2A;
  --nx-muted: #5C5C5C;
  --nx-card: #FFFFFF;
  --nx-line: #E4E2DC;
  --nx-accent: #0a8a9a;
  --nx-header: #1F2A30;
  --paper: var(--nx-paper);
  --ink: var(--nx-ink);
  --mist: #EFEDE8;
  --card: var(--nx-card);
  --line: var(--nx-line);
  --slate: var(--nx-muted);
}

html.dark {
  --nx-paper: #1A1A1A;
  --nx-ink: #F0EEEA;
  --nx-muted: #A8A6A1;
  --nx-card: #242424;
  --nx-line: #333330;
  --nx-accent: #2ec4d6;
  --nx-header: #0F0F0F;
  --paper: var(--nx-paper);
  --ink: var(--nx-ink);
  --mist: #222220;
  --card: var(--nx-card);
  --line: var(--nx-line);
  --slate: var(--nx-muted);
}

html.ink-ready body {
  transition: background-color 0.45s ease, color 0.45s ease;
}

/* ========== DAY / NIGHT SWITCH ========== */
.theme-switch {
  --ts-w: 78px;
  --ts-h: 36px;
  --ts-knob: 30px;
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: var(--ts-w);
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  z-index: 2;
  gap: 3px;
  font-family: inherit;
}

.theme-switch .dn-caption {
  font-size: 7px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.82);
  line-height: 1;
  user-select: none;
  pointer-events: none;
  transition: opacity 0.4s ease, color 0.4s ease;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

.theme-switch-track {
  position: relative;
  display: block;
  width: var(--ts-w);
  height: var(--ts-h);
  border-radius: 999px;
  overflow: hidden;
  isolation: isolate;
  background: linear-gradient(180deg, #6eb0e8 0%, #a8d4f5 40%, #cfe8fb 100%);
  box-shadow:
    inset 0 1px 2px rgba(255, 255, 255, 0.45),
    inset 0 -2px 4px rgba(80, 120, 160, 0.15),
    0 3px 10px rgba(0, 0, 0, 0.22);
  transition:
    background 0.6s cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 0.5s ease;
}

.theme-switch.is-on .theme-switch-track {
  background: linear-gradient(180deg, #0d0d28 0%, #1a1640 45%, #12102a 100%);
  box-shadow:
    inset 0 1px 3px rgba(0, 0, 0, 0.5),
    inset 0 -1px 2px rgba(100, 120, 200, 0.08),
    0 3px 14px rgba(0, 0, 0, 0.4);
}

.dn-sun {
  position: absolute;
  top: 50%;
  right: 9%;
  width: 15px;
  height: 15px;
  margin-top: -7.5px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fffce8 0%, #ffe98a 45%, #f5c842 100%);
  box-shadow:
    0 0 8px 2px rgba(255, 210, 80, 0.65),
    0 0 18px 4px rgba(255, 190, 60, 0.35);
  z-index: 2;
  opacity: 1;
  transform: scale(1);
  transition: opacity 0.5s ease, transform 0.55s cubic-bezier(0.34, 1.2, 0.64, 1);
  pointer-events: none;
}

.theme-switch.is-on .dn-sun {
  opacity: 0;
  transform: scale(0.25) translateY(4px);
}

.dn-moon {
  position: absolute;
  top: 50%;
  left: 11%;
  width: 13px;
  height: 13px;
  margin-top: -6.5px;
  border-radius: 50%;
  background: transparent;
  box-shadow: inset -3.5px -1px 0 1.5px #f0e6b8;
  z-index: 2;
  opacity: 0;
  transform: rotate(-40deg) scale(0.4);
  transition: opacity 0.5s ease 0.05s, transform 0.55s cubic-bezier(0.34, 1.3, 0.64, 1);
  pointer-events: none;
}

.theme-switch.is-on .dn-moon {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

.dn-clouds {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.55s ease;
}

.dn-clouds::before,
.dn-clouds::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  background: #fff;
  opacity: 0.92;
  filter: drop-shadow(0 1px 1px rgba(180, 200, 220, 0.3));
}

.dn-clouds::before {
  width: 18px;
  height: 10px;
  bottom: 5px;
  left: 6%;
  box-shadow:
    7px 1px 0 -1px #fff,
    14px 0 0 -2px #fff,
    4px -4px 0 -2px #fff;
  animation: dn-drift 16s linear infinite;
}

.dn-clouds::after {
  width: 22px;
  height: 11px;
  bottom: 7px;
  left: 38%;
  opacity: 0.8;
  box-shadow:
    9px 1px 0 -1px #fff,
    16px 0 0 -3px #fff,
    6px -5px 0 -2px #fff;
  animation: dn-drift 20s linear infinite reverse;
}

.theme-switch.is-on .dn-clouds {
  opacity: 0.25;
}

.theme-switch.is-on .dn-clouds::before,
.theme-switch.is-on .dn-clouds::after {
  background: #a8b4e0;
  box-shadow:
    7px 1px 0 -1px #a8b4e0,
    14px 0 0 -2px #9aabd8;
  opacity: 0.45;
}

@keyframes dn-drift {
  0% { transform: translateX(0); }
  50% { transform: translateX(6px); }
  100% { transform: translateX(0); }
}

.dn-stars {
  position: absolute;
  inset: 0;
  z-index: 1;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.6s ease;
  background:
    radial-gradient(1.2px 1.2px at 18% 22%, #fff 50%, transparent 50%),
    radial-gradient(1.5px 1.5px at 42% 16%, #fff 50%, transparent 50%),
    radial-gradient(1px 1px at 65% 28%, #fff 50%, transparent 50%),
    radial-gradient(1.3px 1.3px at 78% 18%, #fff 50%, transparent 50%),
    radial-gradient(1px 1px at 30% 48%, rgba(255,255,255,0.85) 50%, transparent 50%),
    radial-gradient(1.2px 1.2px at 55% 52%, #fff 50%, transparent 50%),
    radial-gradient(1px 1px at 72% 45%, rgba(255,255,255,0.7) 50%, transparent 50%);
}

.theme-switch.is-on .dn-stars {
  opacity: 1;
  animation: dn-twinkle 3.5s ease-in-out infinite;
}

@keyframes dn-twinkle {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.dn-shoot {
  position: absolute;
  top: 22%;
  left: 25%;
  width: 18px;
  height: 1.5px;
  border-radius: 2px;
  background: linear-gradient(90deg, transparent, #fff 40%, rgba(255,255,255,0.2));
  opacity: 0;
  z-index: 2;
  pointer-events: none;
  transform: rotate(-25deg);
}

.theme-switch.is-on .dn-shoot {
  animation: dn-shoot 4.5s ease-in-out infinite;
  animation-delay: 1.2s;
}

@keyframes dn-shoot {
  0%, 70% { opacity: 0; transform: rotate(-25deg) translateX(0); }
  75% { opacity: 1; }
  90% { opacity: 0; transform: rotate(-25deg) translateX(28px); }
  100% { opacity: 0; }
}

.theme-switch-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: var(--ts-knob);
  height: var(--ts-knob);
  border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, #ffffff 0%, #f7f7f7 50%, #eaeaea 100%);
  box-shadow:
    0 2px 6px rgba(0, 0, 0, 0.2),
    0 0 14px rgba(255, 255, 255, 0.5),
    inset 0 1px 1px rgba(255, 255, 255, 0.9);
  z-index: 6;
  transition:
    left 0.55s cubic-bezier(0.34, 1.4, 0.64, 1),
    box-shadow 0.45s ease;
  will-change: left;
  pointer-events: none;
}

.theme-switch.is-on .theme-switch-knob {
  left: calc(100% - var(--ts-knob) - 3px);
  box-shadow:
    0 2px 10px rgba(0, 0, 0, 0.45),
    0 0 18px rgba(180, 200, 255, 0.55),
    inset 0 1px 1px rgba(255, 255, 255, 0.85);
}

.theme-switch::after {
  content: "";
  display: block;
  width: var(--ts-w);
  height: calc(var(--ts-h) * 0.55);
  margin-top: 2px;
  border-radius: 999px;
  opacity: 0.22;
  filter: blur(3px);
  transform: scaleY(-1);
  pointer-events: none;
  background: linear-gradient(180deg, rgba(110, 176, 232, 0.5), transparent);
  transition: background 0.55s ease, opacity 0.4s ease;
  -webkit-mask-image: linear-gradient(to bottom, rgba(0,0,0,0.5), transparent);
  mask-image: linear-gradient(to bottom, rgba(0,0,0,0.5), transparent);
}

.theme-switch.is-on::after {
  background: linear-gradient(180deg, rgba(26, 22, 64, 0.55), transparent);
  opacity: 0.28;
}

.theme-switch:focus-visible {
  outline: 2px solid var(--header-accent, #f0b429);
  outline-offset: 4px;
  border-radius: 12px;
}

.theme-switch:active .theme-switch-knob {
  transform: scale(0.93);
}

.theme-switch-label {
  display: none !important;
}

@media (max-width: 380px) {
  .theme-switch::after {
    display: none;
  }
}

.ink-video-layer {
  position: fixed;
  inset: 0;
  z-index: 99990;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  background: transparent;
}
.ink-video-layer.is-active {
  opacity: 1;
  visibility: visible;
}
.ink-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}

html.ink-animating,
html.ink-animating body {
  overflow: hidden;
}

@media (prefers-reduced-motion: reduce) {
  .theme-switch-knob,
  .theme-switch-track,
  .dn-sun,
  .dn-moon,
  .dn-clouds,
  .dn-stars,
  .dn-shoot,
  .theme-switch::after {
    transition: none !important;
    animation: none !important;
  }
  .ink-video-layer {
    display: none !important;
  }
}

@media (max-width: 480px) {
  .theme-switch {
    --ts-w: 68px;
    --ts-h: 32px;
    --ts-knob: 26px;
  }
  .theme-switch .dn-caption {
    font-size: 6px;
    letter-spacing: 0.1em;
  }
}
