/* ─── Reset & Base ─────────────────────────────────────────────────────────── */

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

:root {
  --bg: #F7F6F2;
  --text: #1A1A1A;
  --text-muted: #6B6B6B;
  --border: #E2E0D8;
  --tile-bg: #FFFFFF;

  /* Button gradients */
  --btn-grad-a: linear-gradient(135deg, #7C83D4, #5AAFE0);
  --btn-grad-b: linear-gradient(135deg, #E8A84C, #5CBD9A);

  --font-display: 'Fredoka One', system-ui, sans-serif;
  --font: 'Nunito', system-ui, sans-serif;
  --transition-base: 0.3s ease;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font);
  min-height: 100vh;
}

a {
  text-decoration: none;
  color: inherit;
}

/* ─── Cursor Glow ───────────────────────────────────────────────────────────── */

.cursor-glow {
  position: fixed;
  width: 500px;
  height: 500px;
  border-radius: 50%;
  pointer-events: none;
  transform: translate(-50%, -50%);
  z-index: 0;
  opacity: 0;
  transition: opacity 0.4s ease;
  animation: glowShift 8s ease-in-out infinite;
}

.cursor-glow.active {
  opacity: 1;
}

@keyframes glowShift {
  0%,  100% { background: radial-gradient(circle, rgba(124, 131, 212, 0.18) 0%, transparent 65%); }
  17%        { background: radial-gradient(circle, rgba(224, 122, 143, 0.18) 0%, transparent 65%); }
  34%        { background: radial-gradient(circle, rgba(232, 168, 76,  0.18) 0%, transparent 65%); }
  51%        { background: radial-gradient(circle, rgba(92,  189, 154, 0.18) 0%, transparent 65%); }
  68%        { background: radial-gradient(circle, rgba(90,  175, 224, 0.18) 0%, transparent 65%); }
  85%        { background: radial-gradient(circle, rgba(168, 126, 212, 0.18) 0%, transparent 65%); }
}

/* ─── Wordmark ──────────────────────────────────────────────────────────────── */

.wordmark {
  font-family: var(--font-display);
  font-size: clamp(140px, 26vw, 300px);
  font-weight: 400; /* Fredoka One is a single-weight display font */
  letter-spacing: 0.01em;
  line-height: 1;
  display: flex;
  gap: 0;
  user-select: none;
}

.wordmark .word {
  display: flex;
}

.wordmark .space {
  width: 0.3em;
}

/* Individual letters — color is set by JS on load */
.wordmark span[class^="l-"] {
  display: inline-block;
  cursor: default;
}

/* Spring bounce on hover — overrides the float */
.wordmark span[class^="l-"]:hover {
  animation: letterBounce 0.5s cubic-bezier(0.34, 1.8, 0.64, 1) forwards;
}

@keyframes letterBounce {
  0%   { transform: translateY(0)    scale(1)    rotate(0deg);  }
  35%  { transform: translateY(-20px) scale(1.3)  rotate(-6deg); }
  65%  { transform: translateY(-8px)  scale(1.15) rotate(3deg);  }
  100% { transform: translateY(0)    scale(1)    rotate(0deg);  }
}

/* ─── Homepage ──────────────────────────────────────────────────────────────── */

.home {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
  text-align: center;
  position: relative;
  z-index: 1;
}

/* Mouse parallax target */
.home-parallax {
  display: flex;
  flex-direction: column;
  align-items: center;
  will-change: transform;
  /* JS sets inline transform */
}

/* Shrink/slide animation on load */
.home-wordmark-wrap {
  transform: translateY(0px) scale(1);
  transition: transform 0.8s cubic-bezier(0.34, 1.15, 0.64, 1);
}

.home-wordmark-wrap.shrunk {
  transform: translateY(-20px) scale(0.8);
}

/* Action buttons fade in after wordmark shrinks */
.home-actions {
  display: flex;
  gap: 1rem;
  margin-top: 2.5rem;
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.5s ease 0.35s, transform 0.5s ease 0.35s;
  pointer-events: none;
}

.home-actions.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* ─── Buttons ───────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  padding: 0.8rem 2rem;
  border-radius: 100px;
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: #fff;
  border: none;
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.34, 1.5, 0.64, 1),
              box-shadow 0.2s ease,
              opacity 0.2s ease;
}

.btn:hover {
  transform: translateY(-3px) scale(1.04);
}

.btn:active {
  transform: translateY(0) scale(0.98);
}

.btn-primary {
  background: var(--btn-grad-a);
  box-shadow: 0 4px 20px rgba(90, 175, 224, 0.3);
}

.btn-primary:hover {
  box-shadow: 0 8px 30px rgba(90, 175, 224, 0.45);
}

.btn-secondary {
  background: var(--btn-grad-b);
  box-shadow: 0 4px 20px rgba(92, 189, 154, 0.3);
}

.btn-secondary:hover {
  box-shadow: 0 8px 30px rgba(92, 189, 154, 0.45);
}

/* ─── Page Shell (shared nav) ───────────────────────────────────────────────── */

.page {
  min-height: 100vh;
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem 2.5rem;
  border-bottom: 1px solid var(--border);
}

.nav-logo {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 400;
  letter-spacing: 0.01em;
  display: flex;
  gap: 0;
  cursor: pointer;
}

/* Nav logo letter colors are randomized by JS on inner pages */
.nav-logo span[class^="l-"] {
  display: inline-block;
  transition: transform 0.2s cubic-bezier(0.34, 1.6, 0.64, 1);
}

.nav-logo:hover .l-d  { transform: translateY(-3px); transition-delay: 0.00s; }
.nav-logo:hover .l-i  { transform: translateY(-3px); transition-delay: 0.04s; }
.nav-logo:hover .l-s  { transform: translateY(-3px); transition-delay: 0.08s; }
.nav-logo:hover .l-t  { transform: translateY(-3px); transition-delay: 0.12s; }
.nav-logo:hover .l-i2 { transform: translateY(-3px); transition-delay: 0.16s; }
.nav-logo:hover .l-l  { transform: translateY(-3px); transition-delay: 0.20s; }
.nav-logo:hover .l-l2 { transform: translateY(-3px); transition-delay: 0.24s; }
.nav-logo:hover .l-r  { transform: translateY(-3px); transition-delay: 0.28s; }


.nav-links {
  display: flex;
  gap: 2rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
}

.nav-links a:hover { color: var(--text); }
.nav-links a.active { color: var(--text); }

/* ─── Today Page ────────────────────────────────────────────────────────────── */

.today-page .content {
  max-width: 720px;
  margin: 0 auto;
  padding: 4rem 2rem;
}

.today-page .date-label {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.today-page h1 {
  font-family: var(--font-display);
  font-size: 2.4rem;
  font-weight: 400;
  letter-spacing: 0.01em;
  margin-bottom: 3rem;
}

.story {
  padding: 2rem 0;
  border-bottom: 1px solid var(--border);
}

.story:first-of-type {
  border-top: 1px solid var(--border);
}

.story-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.6rem;
}

.story-rank {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.story-source {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--border);
  padding: 0.2rem 0.65rem;
  border-radius: 100px;
}

.story h2 {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin-bottom: 0.5rem;
  line-height: 1.4;
}

.story p {
  font-size: 0.92rem;
  color: var(--text-muted);
  line-height: 1.75;
}

/* ─── Archive Page ──────────────────────────────────────────────────────────── */

.archive-page .content {
  max-width: 1100px;
  margin: 0 auto;
  padding: 4rem 2rem;
}

.archive-page h1 {
  font-family: var(--font-display);
  font-size: 2.4rem;
  font-weight: 400;
  letter-spacing: 0.01em;
  margin-bottom: 3rem;
}

.tile-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
}

.tile {
  background: var(--tile-bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.75rem;
  cursor: pointer;
  transition: transform 0.25s cubic-bezier(0.34, 1.4, 0.64, 1),
              box-shadow 0.25s ease,
              border-color 0.25s ease;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.tile:hover {
  transform: translateY(-5px) scale(1.01);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.07);
  border-color: #ccc;
}

.tile-headline {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.5;
  color: var(--text);
}

.tile-date {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: auto;
}

/* ─── Story score pill ──────────────────────────────────────────────────────── */

.story-score {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  padding: 0.2rem 0.65rem;
  border-radius: 100px;
  margin-left: auto;
}

/* ─── Story headline link ────────────────────────────────────────────────────── */

.story h2 a {
  color: inherit;
  text-decoration: none;
  transition: opacity 0.2s ease;
}

.story h2 a:hover {
  opacity: 0.65;
}

/* ─── Theme label ────────────────────────────────────────────────────────────── */

.theme-label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 2rem;
  letter-spacing: 0.01em;
}

/* ─── Tile accent bar ────────────────────────────────────────────────────────── */

.tile-accent {
  display: block;
  width: 28px;
  height: 3px;
  border-radius: 2px;
  margin-bottom: 0.25rem;
}

/* ─── Loading skeletons ──────────────────────────────────────────────────────── */

@keyframes shimmer {
  0%   { opacity: 0.5; }
  50%  { opacity: 1;   }
  100% { opacity: 0.5; }
}

.loading-bar {
  height: 1.1rem;
  background: var(--border);
  border-radius: 6px;
  width: 40%;
  margin-bottom: 1rem;
  animation: shimmer 1.6s ease-in-out infinite;
}

.loading-bar--short {
  width: 60%;
  height: 2.2rem;
}

.loading-stories {
  margin-top: 2rem;
}

.loading-story {
  height: 90px;
  background: var(--border);
  border-radius: 10px;
  margin-bottom: 1rem;
  animation: shimmer 1.6s ease-in-out infinite;
}

.loading-story:nth-child(2) { animation-delay: 0.2s; }
.loading-story:nth-child(3) { animation-delay: 0.4s; }

.loading-tile-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
}

.loading-tile {
  height: 130px;
  background: var(--border);
  border-radius: 16px;
  animation: shimmer 1.6s ease-in-out infinite;
}

.loading-tile:nth-child(2) { animation-delay: 0.15s; }
.loading-tile:nth-child(3) { animation-delay: 0.30s; }
.loading-tile:nth-child(4) { animation-delay: 0.45s; }
.loading-tile:nth-child(5) { animation-delay: 0.60s; }
.loading-tile:nth-child(6) { animation-delay: 0.75s; }

/* ─── Empty / error state ────────────────────────────────────────────────────── */

.empty-state {
  font-size: 0.95rem;
  color: var(--text-muted);
  padding: 3rem 0;
}

/* ─── Sources drawer ────────────────────────────────────────────────────────── */

.sources-drawer {
  margin-top: 3rem;
  border-top: 1px solid var(--border);
  padding-top: 1.5rem;
}

.sources-drawer summary {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.sources-drawer summary::-webkit-details-marker { display: none; }

.sources-drawer summary::after {
  content: '↓';
  font-size: 0.7rem;
  opacity: 0.5;
  transition: transform 0.2s ease;
}

.sources-drawer[open] summary::after {
  transform: rotate(180deg);
}

.sources-drawer ul {
  list-style: none;
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.sources-drawer ul a {
  font-size: 0.82rem;
  color: var(--text-muted);
  word-break: break-all;
}

.sources-drawer ul a:hover { color: var(--text); }

/* ─── Responsive ────────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
  .tile-grid { grid-template-columns: repeat(2, 1fr); }
  .nav { padding: 1.25rem 1.5rem; }
  .home-actions { flex-direction: column; align-items: center; }
}

@media (max-width: 480px) {
  .tile-grid { grid-template-columns: 1fr; }
}
