/* 
  ResourceIndex — Homepage
  Theme: Minimal Black & White / Space
  Title font: JUST Sans Minimal (geometric sans) -> Space Grotesk + Inter fallback
  Small text: Verdana
*/

/* Try to load JUST Sans if available, fallback to Space Grotesk */
@font-face {
  font-family: "JUST Sans";
  src: local("JUST Sans"), local("Just Sans"), local("JUSTSans");
  font-display: swap;
}

:root {
  --bg: #000000;
  --fg: #ffffff;
  --muted: #9a9a9a;
  --border: #222222;
  --search-bg: #0a0a0a;
  --search-border: #2a2a2a;
  --search-focus: #ffffff;
}

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

html {
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: #333 #000;
}

body {
  position: relative;
  background: var(--bg);
  color: var(--fg);
  font-family: Verdana, Geneva, Tahoma, sans-serif;
  overflow-x: hidden;
  min-height: 100vh;
}

/* ---------- Starfield (space theme, subtle, black & white) ---------- */
.stars, .stars2, .stars3 {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.stars {
  background-image: 
    radial-gradient(1px 1px at 20% 30%, #fff, transparent),
    radial-gradient(1px 1px at 40% 70%, #fff, transparent),
    radial-gradient(1.2px 1.2px at 90% 40%, #fff, transparent),
    radial-gradient(1px 1px at 65% 15%, #fff, transparent),
    radial-gradient(1px 1px at 10% 85%, #fff, transparent),
    radial-gradient(1px 1px at 75% 80%, #fff, transparent),
    radial-gradient(1px 1px at 50% 50%, #fff, transparent),
    radial-gradient(1px 1px at 30% 10%, #fff, transparent);
  background-repeat: repeat;
  background-size: 550px 550px;
  opacity: 0.45;
}

.stars2 {
  background-image:
    radial-gradient(1px 1px at 15% 15%, #fff, transparent),
    radial-gradient(1px 1px at 55% 25%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 85% 65%, #fff, transparent),
    radial-gradient(1px 1px at 35% 85%, #fff, transparent);
  background-size: 800px 800px;
  opacity: 0.25;
  animation: drift 120s linear infinite;
}

.stars3 {
  background-image:
    radial-gradient(1.8px 1.8px at 70% 20%, #fff, transparent),
    radial-gradient(1px 1px at 25% 55%, #fff, transparent);
  background-size: 1000px 1000px;
  opacity: 0.15;
  animation: drift2 180s linear infinite;
}

@keyframes drift {
  from { transform: translateY(0); }
  to { transform: translateY(-800px); }
}
@keyframes drift2 {
  from { transform: translateY(0); }
  to { transform: translateY(-1000px); }
}

/* ---------- Hero — fits in viewport without scrolling required ---------- */
.hero {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px 90px;
}

.hero-inner {
  width: 100%;
  max-width: 760px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0;
}

/* Title — single line, never wraps */
.title {
  font-family: "JUST Sans", "Space Grotesk", Inter, system-ui, -apple-system, sans-serif;
  font-weight: 300;
  font-size: clamp(1.9rem, 6.2vw, 5.2rem);
  letter-spacing: -0.04em;
  line-height: 1;
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  align-items: baseline;
  gap: 0.22em;
  margin-bottom: 10px;
  text-transform: uppercase;
  white-space: nowrap;
  max-width: 100%;
}

.title-search {
  font-weight: 300;
  color: var(--fg);
  letter-spacing: -0.05em;
}

.title-dynamic {
  font-weight: 600;
  min-width: 5.2ch; /* prevents layout shift */
  text-align: left;
  display: inline-block;
  letter-spacing: -0.03em;
  white-space: nowrap;
  flex-shrink: 0;
}

.cursor {
  font-weight: 300;
  margin-left: 1px;
  animation: blink 1s step-end infinite;
  opacity: 0.9;
}

@keyframes blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

.subtitle {
  font-family: Verdana, Geneva, sans-serif;
  font-size: 0.82rem;
  color: var(--muted);
  letter-spacing: 0.04em;
  margin-bottom: 34px;
  opacity: 0.9;
}

/* Searchbar — long, round, magnifying glass on left inside */
.search-wrap {
  width: 100%;
  max-width: 620px;
  margin-bottom: 14px;
}

.searchbar {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  background: var(--search-bg);
  border: 1px solid var(--search-border);
  border-radius: 999px;
  padding: 14px 22px;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.searchbar:focus-within {
  border-color: var(--search-focus);
  box-shadow: 0 0 0 1px var(--fg), 0 8px 30px rgba(255,255,255,0.08);
  background: #111;
}

.search-icon {
  width: 20px;
  height: 20px;
  color: var(--muted);
  flex-shrink: 0;
}

.searchbar:focus-within .search-icon {
  color: var(--fg);
}

.searchbar input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--fg);
  font-family: Verdana, Geneva, sans-serif;
  font-size: 0.95rem;
  letter-spacing: 0.01em;
  width: 100%;
}

.searchbar input::placeholder {
  color: #5a5a5a;
}

.search-feedback {
  min-height: 20px;
  font-family: Verdana, sans-serif;
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 26px;
}

/* Most Viewed Resources */
.most-viewed {
  width: 100%;
  max-width: 620px;
  text-align: center;
  margin-top: 6px;
}

.most-viewed-title {
  font-family: Verdana, Geneva, sans-serif;
  font-size: 0.95rem;
  font-weight: 600; /* medium bold */
  letter-spacing: 0.02em;
  text-decoration: underline;
  text-underline-offset: 5px;
  text-decoration-thickness: 1.5px;
  margin-bottom: 16px;
  color: var(--fg);
  text-align: center;
}

.most-viewed-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0;
  counter-reset: mv;
}

.most-viewed-list li {
  counter-increment: mv;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border: 1px solid transparent;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.18s, border-color 0.18s, transform 0.18s;
}

.most-viewed-list li:hover {
  background: #0f0f0f;
  border-color: #222;
  transform: translateX(4px);
}

.most-viewed-list li::before {
  content: "0" counter(mv);
  font-family: "JUST Sans", "Space Grotesk", sans-serif;
  font-weight: 600;
  font-size: 0.85rem;
  color: #555;
  min-width: 24px;
}

.most-viewed-list .mv-name {
  font-family: Verdana, sans-serif;
  font-size: 0.92rem;
  color: var(--fg);
  flex: 1;
  text-transform: capitalize;
}

.most-viewed-list .mv-meta {
  font-family: Verdana, sans-serif;
  font-size: 0.72rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.mv-badge {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #fff;
  opacity: 0.8;
  display: inline-block;
}

.most-viewed-hint {
  font-family: Verdana, sans-serif;
  font-size: 0.68rem;
  color: #555;
  margin-top: 10px;
  letter-spacing: 0.02em;
  text-align: center;
}

/* Social footer — 3 SVGs at bottom */
.social-footer {
  position: absolute;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 22px;
  z-index: 2;
}

.social-link {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid #222;
  border-radius: 50%;
  background: transparent;
  transition: background 0.2s, border-color 0.2s, transform 0.2s;
}

.social-link svg {
  width: 18px;
  height: 18px;
}

.social-link:hover {
  background: #fff;
  border-color: #fff;
  transform: translateY(-2px);
}

.social-link:hover svg {
  stroke: #000;
  fill: #000;
}

.social-link:hover svg path {
  fill: #000;
}

/* Scroll hint */
.scroll-hint {
  position: absolute;
  bottom: 78px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: #444;
  font-family: Verdana, sans-serif;
  font-size: 0.65rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0;
  transition: opacity 0.6s;
  pointer-events: none;
}

.scroll-hint.visible {
  opacity: 1;
}

.scroll-hint svg {
  width: 14px;
  height: 14px;
  animation: bounce 1.6s infinite;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(4px); }
}

/* Scroll spacer — allows scrolling even though hero fits */
.scroll-spacer {
  height: 140vh; /* enough scroll to trigger easter egg */
  pointer-events: none;
}

/* ---------- Easter Egg: Planet Earth ---------- */
/* Anchored at the bottom of the scrollable page — does NOT follow viewport when scrolling back up */
.earth-container {
  position: absolute;
  left: 50%;
  bottom: 60px;
  transform: translateX(-50%) translateY(60px) scale(0.8);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.9s ease, transform 1s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 5;
}

.earth-container.revealed {
  opacity: 1;
  transform: translateX(-50%) translateY(0) scale(1);
  pointer-events: auto;
}

.earth-glow {
  display: none;
}

.earth {
  position: relative;
  width: 340px;
  height: 340px;
  border-radius: 50%;
  overflow: hidden;
  background: #0a1931;
  box-shadow:
    inset -22px -14px 40px rgba(0,0,0,0.85),
    inset 10px 10px 24px rgba(255,255,255,0.08),
    0 0 50px rgba(80,120,255,0.30),
    0 0 100px rgba(80,120,255,0.14);
}

/* Image placeholder — just drop your file at assets/earth.png */
.earth-image {
  display: block;
  width: 340px;
  height: 340px;
  object-fit: cover;
  border-radius: 50%;
  background: transparent;
  box-shadow: none;
  animation: spinEarth 80s linear infinite;
}

.earth-fallback {
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 30% 30%, #1a3a5a 0%, #0a1931 65%, #000 100%);
}

.earth-orbit {
  display: none;
}

.orbit-dot {
  position: absolute;
  top: -4px;
  left: 50%;
  width: 7px;
  height: 7px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 0 8px #fff;
  transform: translateX(-50%);
  animation: orbit 8s linear infinite;
}

@keyframes orbit {
  from { transform: translateX(-50%) rotate(0deg) translateY(170px) rotate(0deg); }
  to   { transform: translateX(-50%) rotate(360deg) translateY(170px) rotate(-360deg); }
}

@keyframes spinEarth {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* legacy kept for fallback if needed */
@keyframes rotateEarth {
  from { filter: hue-rotate(0deg) brightness(1); }
  to { filter: hue-rotate(360deg) brightness(1); }
}

@keyframes driftClouds {
  0% { transform: translateX(0); }
  100% { transform: translateX(-18px); }
}

.earth-caption {
  font-family: "JUST Sans", "Space Grotesk", sans-serif;
  font-size: 1.05rem;
  font-weight: 500;
  color: #fff;
  text-align: center;
  line-height: 1.3;
  letter-spacing: -0.02em;
}

.earth-caption span {
  font-family: Verdana, sans-serif;
  font-size: 0.78rem;
  font-weight: 400;
  color: #aaa;
  letter-spacing: 0.01em;
}

.earth-subcaption {
  font-family: Verdana, sans-serif;
  font-size: 0.68rem;
  color: #555;
  letter-spacing: 0.04em;
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(80px);
  background: #fff;
  color: #000;
  font-family: Verdana, sans-serif;
  font-size: 0.82rem;
  padding: 12px 20px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: transform 0.4s cubic-bezier(0.16,1,0.3,1), opacity 0.4s;
  z-index: 20;
  white-space: nowrap;
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* Responsive */
@media (max-height: 700px) {
  .hero { padding-top: 24px; }
  .title { font-size: clamp(2rem, 7vw, 3.8rem); }
  .subtitle { margin-bottom: 22px; }
}

@media (max-width: 480px) {
  .title { flex-wrap: nowrap; flex-direction: row; gap: 0.18em; font-size: clamp(1.55rem, 7.2vw, 2.8rem); }
  .title-dynamic { min-width: 5ch; text-align: left; }
  .scroll-spacer { height: 110vh; }
  .earth, .earth-image { width: 260px; height: 260px; }
  .earth-orbit { width: 280px; height: 280px; }
}
