@font-face {
  font-family: 'MajorMono';
  src: url('https://files.crystalsky.dev/generalAssets/fonts/Major_Mono_Display/MajorMonoDisplay-Regular.ttf') format('truetype');
  font-display: swap;
}

:root {
  --bg-color: #0a0a0a;
  --accent: #e8e0d0;
  --dim: rgba(232,224,208,0.35);
  --glow: rgba(232,224,208,0.08);
  --glass: rgba(10,10,10,0.55);
}

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

html, body {
  width: 100%; height: 100%;
  font-family: 'MajorMono', monospace;
  overflow: hidden;
  background: var(--bg-color);
  color: var(--accent);
}

/*  PAGE LOAD SPLASH  */
#splash {
  position: fixed; inset: 0; z-index: 9999;
  background: #000;
  display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 18px;
  transition: opacity 0.7s ease, visibility 0.7s ease;
}
#splash.hidden { opacity: 0; visibility: hidden; pointer-events: none; }

.splash-ring {
  width: 64px; height: 64px;
  border: 2px solid rgba(232,224,208,0.15);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
.splash-text {
  font-family: 'MajorMono', monospace;
  font-size: 0.7rem;
  letter-spacing: 0.35em;
  color: rgba(232,224,208,0.45);
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%,100%{opacity:.3} 50%{opacity:1} }

/*  BACKGROUND  */
#bg-layer {
  position: fixed; inset: 0; z-index: 0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  transition: background-image 0.6s ease, background-color 0.6s ease;
}
#bg-layer::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(to bottom,
    rgba(0,0,0,0.42) 0%,
    rgba(0,0,0,0.18) 40%,
    rgba(0,0,0,0.18) 60%,
    rgba(0,0,0,0.52) 100%);
}

/*  GRAIN OVERLAY  */
#grain {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 200px 200px;
}

/*  MAIN LAYOUT  */
#app {
  position: relative; z-index: 2;
  width: 100vw; height: 100vh;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 0;
  opacity: 0;
  transition: opacity 0.8s ease 0.2s;
}
#app.visible { opacity: 1; }

/*  CLOCK  */
#clock-wrap {
  display: flex; flex-direction: column; align-items: center;
  gap: 6px;
  transform: translateY(20px);
  opacity: 0;
  transition: opacity 0.9s ease 0.4s, transform 0.9s cubic-bezier(0.16,1,0.3,1) 0.4s;
}
#clock-wrap.in { opacity: 1; transform: translateY(0); }

#clock {
  font-family: 'MajorMono', monospace;
  font-size: clamp(4.5rem, 14vw, 11rem);
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--accent);
  text-shadow:
    0 0 60px rgba(232,224,208,0.18),
    0 0 120px rgba(232,224,208,0.07);
  user-select: none;
  position: relative;
  perspective: 800px;
}

.clock-digit {
  display: inline-block;
  position: relative;
  min-width: 1ch;
  height: 1em;
  transform-style: preserve-3d;
  will-change: transform, opacity, filter;
}

#hh2, #mm2, #ss2 {
  margin-right: 0.15em;
}

#mm1, #ss1 {
  margin-left: 0.05em;
}

.clock-digit .digit-current,
.clock-digit .digit-next {
  display: inline-block;
  width: 100%;
  backface-visibility: hidden;
}

.clock-digit .digit-next {
  position: absolute;
  left: 0;
  top: 0;
  opacity: 0;
  transform: translateZ(-24px) scale(0.98);
}

.clock-digit.swap .digit-current {
  animation: digit-out 220ms ease forwards;
}

.clock-digit.swap .digit-next {
  animation: digit-in 180ms ease forwards;
  animation-delay: 120ms;
}

#clock .colon {
  display: inline-block;
  opacity: 1;
}

body.no-colon-blink #clock .colon {
  opacity: 1;
}

@keyframes digit-out {
  0% { opacity: 1; transform: translateZ(0) scale(1); filter: blur(0); }
  100% { opacity: 0; transform: translateZ(-28px) scale(0.96); filter: blur(1.6px); }
}

@keyframes digit-in {
  0% { opacity: 0; transform: translateZ(-28px) scale(0.96); filter: blur(1.6px); }
  100% { opacity: 1; transform: translateZ(0) scale(1); filter: blur(0); }
}

#date-line {
  font-family: 'MajorMono', monospace;
  font-size: clamp(0.55rem, 1.4vw, 0.85rem);
  letter-spacing: 0.28em;
  color: var(--dim);
  text-transform: lowercase;
  margin-top: 4px;
}

/*  SEARCH BAR  */
#search-wrap {
  margin-top: clamp(28px, 5vw, 52px);
  width: min(640px, 90vw);
  transform: translateY(18px);
  opacity: 0;
  transition: opacity 0.9s ease 0.6s, transform 0.9s cubic-bezier(0.16,1,0.3,1) 0.6s;
}
#search-wrap.in { opacity: 1; transform: translateY(0); }
#search-wrap.hidden-ui { display: none; }

#search-form {
  position: relative;
  display: flex; align-items: center;
}

#search-input {
  width: 100%;
  background: var(--glass);
  backdrop-filter: blur(18px) saturate(1.3);
  -webkit-backdrop-filter: blur(18px) saturate(1.3);
  border: 1px solid rgba(232,224,208,0.18);
  border-radius: 3px;
  padding: 14px 52px 14px 20px;
  font-family: 'MajorMono', monospace;
  font-size: clamp(0.7rem, 1.5vw, 0.9rem);
  letter-spacing: 0.06em;
  color: var(--accent);
  outline: none;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
  caret-color: var(--accent);
}
#search-input::placeholder { color: rgba(232,224,208,0.28); }
#search-input:focus {
  border-color: rgba(232,224,208,0.55);
  box-shadow: 0 0 0 1px rgba(232,224,208,0.08), 0 4px 32px rgba(0,0,0,0.35);
}

#search-btn {
  position: absolute; right: 0; top: 0; bottom: 0;
  width: 52px;
  display: flex; align-items: center; justify-content: center;
  color: var(--dim);
  cursor: pointer;
  background: none; border: none;
  transition: color 0.2s ease;
}
#search-btn:hover { color: var(--accent); }

/*  SETTINGS BUTTON  */
#settings-btn {
  position: fixed; top: 22px; right: 26px; z-index: 50;
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  color: rgba(232,224,208,0.38);
  cursor: pointer;
  transition: color 0.2s ease, transform 0.5s ease;
  background: none; border: none;
}
#settings-btn:hover { color: var(--accent); transform: rotate(60deg); }

/*  PHOTO CREDIT  */
#photo-credit {
  position: fixed; bottom: 18px; left: 22px; z-index: 10;
  font-family: 'MajorMono', monospace;
  font-size: 0.6rem;
  letter-spacing: 0.18em;
  color: rgba(232,224,208,0.32);
  transition: color 0.2s ease;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.9s ease 1s;
}
#photo-credit.in { opacity: 1; }
#photo-credit span { text-transform: lowercase; }

/*  SETTINGS PANEL  */
#settings-panel {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: flex-start; justify-content: flex-end;
  pointer-events: none;
}
#settings-overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0);
  transition: background 0.4s ease;
  pointer-events: none;
}
#settings-panel.open #settings-overlay {
  background: rgba(0,0,0,0.45);
  pointer-events: all;
}

#settings-drawer {
  position: relative; z-index: 1;
  width: min(420px, 100vw);
  height: 100vh;
  background: rgba(12,12,12,0.96);
  backdrop-filter: blur(24px) saturate(1.4);
  -webkit-backdrop-filter: blur(24px) saturate(1.4);
  border-left: 1px solid rgba(232,224,208,0.1);
  transform: translateX(100%);
  transition: transform 0.45s cubic-bezier(0.16,1,0.3,1);
  overflow-y: auto;
  padding: 32px 28px 60px;
  pointer-events: all;
}
#settings-panel.open #settings-drawer {
  transform: translateX(0);
}

.s-title {
  font-family: 'MajorMono', monospace;
  font-size: 0.78rem;
  letter-spacing: 0.28em;
  color: var(--dim);
  text-transform: lowercase;
  margin-bottom: 20px;
  margin-top: 32px;
}
.s-title:first-of-type { margin-top: 12px; }

.s-heading {
  font-family: 'MajorMono', monospace;
  font-size: 1.05rem;
  letter-spacing: 0.12em;
  color: var(--accent);
  margin-bottom: 28px;
}

.s-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid rgba(232,224,208,0.06);
}
.s-row label {
  font-family: 'MajorMono', monospace;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  color: rgba(232,224,208,0.7);
}

/* Toggle */
.toggle {
  position: relative; width: 40px; height: 22px;
  cursor: pointer; flex-shrink: 0;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-track {
  position: absolute; inset: 0;
  background: rgba(232,224,208,0.12);
  border: 1px solid rgba(232,224,208,0.2);
  border-radius: 11px;
  transition: background 0.3s ease;
}
.toggle-track::after {
  content: '';
  position: absolute; left: 3px; top: 3px;
  width: 14px; height: 14px;
  background: rgba(232,224,208,0.45);
  border-radius: 50%;
  transition: transform 0.3s ease, background 0.3s ease;
}
.toggle input:checked + .toggle-track {
  background: rgba(232,224,208,0.25);
}
.toggle input:checked + .toggle-track::after {
  transform: translateX(18px);
  background: var(--accent);
}

/* Select / Input */
.s-select, .s-input {
  background: rgba(232,224,208,0.06);
  border: 1px solid rgba(232,224,208,0.16);
  border-radius: 3px;
  color: var(--accent);
  font-family: 'MajorMono', monospace;
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  padding: 6px 10px;
  outline: none;
  transition: border-color 0.2s ease;
}
.s-select:focus, .s-input:focus {
  border-color: rgba(232,224,208,0.45);
}
.s-select option { background: #111; }

.s-input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 132px;
  height: 22px;
  background: transparent;
  border: none;
  padding: 0;
}

.s-input[type="range"]::-webkit-slider-runnable-track {
  height: 5px;
  background: rgba(232,224,208,0.2);
  border: 1px solid rgba(232,224,208,0.16);
  border-radius: 999px;
}

.s-input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--accent);
  border: 1px solid rgba(0,0,0,0.45);
  margin-top: -5px;
  box-shadow: 0 0 0 1px rgba(232,224,208,0.15);
}

.s-input[type="range"]::-moz-range-track {
  height: 5px;
  background: rgba(232,224,208,0.2);
  border: 1px solid rgba(232,224,208,0.16);
  border-radius: 999px;
}

.s-input[type="range"]::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--accent);
  border: 1px solid rgba(0,0,0,0.45);
  box-shadow: 0 0 0 1px rgba(232,224,208,0.15);
}

.s-input[type="range"]:focus {
  outline: none;
}

.s-input[type="range"]:focus::-webkit-slider-runnable-track {
  border-color: rgba(232,224,208,0.35);
}

.s-input[type="range"]:focus::-moz-range-track {
  border-color: rgba(232,224,208,0.35);
}

.s-input-full {
  width: 100%;
  margin-top: 8px;
}

.s-link {
  color: rgba(232,224,208,0.7);
  text-decoration: none;
  border-bottom: 1px solid rgba(232,224,208,0.2);
  transition: color 0.2s ease, border-color 0.2s ease;
}
.s-link:hover {
  color: var(--accent);
  border-color: rgba(232,224,208,0.5);
}

/* Color picker row */
.color-row {
  display: flex; align-items: center; gap: 10px; margin-top: 10px;
}
.color-row input[type=color] {
  width: 36px; height: 36px;
  border: 1px solid rgba(232,224,208,0.2);
  border-radius: 3px;
  background: none; cursor: pointer; padding: 2px;
}

/* BG grid */
#bg-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 12px;
}
.bg-thumb {
  aspect-ratio: 16/9;
  border-radius: 3px;
  border: 2px solid transparent;
  cursor: pointer;
  background-size: cover;
  background-position: center;
  transition: border-color 0.2s ease, transform 0.2s ease;
  overflow: hidden;
  position: relative;
}
.bg-thumb:hover { transform: scale(1.03); }
.bg-thumb.active { border-color: var(--accent); }
.bg-thumb.solid-thumb {
  display: flex; align-items: center; justify-content: center;
  font-size: 0.55rem; letter-spacing: 0.1em; color: rgba(232,224,208,0.45);
}

/* Upload button */
.s-btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: rgba(232,224,208,0.08);
  border: 1px solid rgba(232,224,208,0.2);
  border-radius: 3px;
  color: rgba(232,224,208,0.7);
  font-family: 'MajorMono', monospace;
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  padding: 8px 14px;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
  margin-top: 10px;
}
.s-btn:hover { background: rgba(232,224,208,0.15); color: var(--accent); }

/*  MISC ANIM  */
@keyframes fadeSlideUp {
  from { opacity:0; transform:translateY(14px); }
  to   { opacity:1; transform:translateY(0); }
}

/* scrollbar */
#settings-drawer::-webkit-scrollbar { width: 4px; }
#settings-drawer::-webkit-scrollbar-track { background: transparent; }
#settings-drawer::-webkit-scrollbar-thumb { background: rgba(232,224,208,0.15); border-radius: 2px; }
