/* ===== Perchance — Editorial, cool palette, interactive ===== */
:root {
  --bg: #0a0a0c;
  --bg-elevated: #111113;
  --text: #f0f0f2;
  --text-muted: #88889a;
  --accent: #7b9fd4;
  --accent-soft: rgba(123, 159, 212, 0.2);
  --border: rgba(255, 255, 255, 0.07);
  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Source Sans 3', system-ui, sans-serif;
  --ease: cubic-bezier(0.25, 0.1, 0.25, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --space-xs: 0.5rem;
  --space-sm: 1rem;
  --space-md: 1.5rem;
  --space-lg: 2rem;
  --space-xl: 3rem;
  --space-2xl: 4rem;
  --space-3xl: 6rem;
  --space-4xl: 8rem;
  --measure: 42rem;
}

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

html {
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  margin: 0;
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 1.0625rem;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ===== Navigation ===== */
.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-xl);
  background: transparent;
  transition: background 0.25s var(--ease);
}

.nav.scrolled {
  background: rgba(10, 10, 12, 0.92);
}

/* Scroll progress bar */
.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 0%;
  height: 2px;
  background: var(--accent);
  z-index: 101;
  transition: width 0.08s linear;
}

.nav__logo {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
  letter-spacing: 0.02em;
}

.nav__logo:hover {
  color: var(--accent);
}

.nav__links {
  display: flex;
  gap: var(--space-xl);
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav__links a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9375rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  position: relative;
  transition: color 0.2s var(--ease);
}

.nav__links a::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: -3px;
  width: 0;
  height: 1px;
  background: var(--accent);
  transition: width 0.25s var(--ease);
}

.nav__links a:hover,
.nav__links a.active {
  color: var(--text);
}

.nav__links a:hover::after,
.nav__links a.active::after {
  width: 100%;
}

.nav__menu-btn {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: var(--space-xs);
}

.nav__menu-btn span {
  width: 20px;
  height: 1.5px;
  background: var(--text);
  transition: opacity 0.2s var(--ease);
}

/* ===== Hero ===== */
.hero {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-3xl) var(--space-lg);
}

.hero__word {
  font-family: var(--font-display);
  font-size: clamp(4.5rem, 18vw, 11rem);
  font-weight: 300;
  margin: 0;
  letter-spacing: -0.03em;
  line-height: 0.95;
  color: var(--text);
  text-align: center;
  transition: transform 0.2s var(--ease-out);
}

.hero__word:hover {
  transform: scale(1.02);
}

.hero__tagline {
  margin: var(--space-lg) 0 0;
  font-family: var(--font-body);
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

/* ===== Sections ===== */
/* Only hide sections when JS has run (scroll reveal); otherwise show everything */
html.js .section {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s var(--ease), transform 0.6s var(--ease);
}

html.js .section.visible {
  opacity: 1;
  transform: translateY(0);
}

html.js .section__inner > * {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.5s var(--ease), transform 0.5s var(--ease);
}

html.js .section.visible .section__inner > * {
  opacity: 1;
  transform: translateY(0);
}

html.js .section.visible .section__inner > .section__title { transition-delay: 0.05s; }
html.js .section.visible .section__inner > *:not(.section__title) { transition-delay: 0.12s; }

.section {
  padding: var(--space-4xl) var(--space-lg);
  max-width: var(--measure);
  margin: 0 auto;
}

@media (prefers-reduced-motion: reduce) {
  html.js .section,
  html.js .section__inner > * {
    opacity: 1;
    transform: none;
  }
  .hero__word:hover {
    transform: none;
  }
}

.section__inner {
  margin: 0 auto;
}

.section + .section {
  border-top: 1px solid var(--border);
}

.section__title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 500;
  color: var(--text-muted);
  margin: 0 0 var(--space-lg);
  letter-spacing: 0.02em;
}

/* Definition */
.definition__content {
  font-size: 1.0625rem;
  line-height: 1.75;
}

.definition__headline {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 500;
  margin: 0 0 var(--space-xs);
  color: var(--text);
}

.definition__headline .word--hover {
  cursor: pointer;
  padding: 0.1em 0;
  border-bottom: 1px solid transparent;
  transition: color 0.2s var(--ease), border-color 0.2s var(--ease);
}

.definition__headline .word--hover:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.definition__pronunciation {
  font-size: 1rem;
  font-weight: 400;
  color: var(--text-muted);
  transition: color 0.2s var(--ease);
}

.definition__pronunciation.highlight {
  color: var(--accent);
}

.definition__meta {
  margin: 0 0 var(--space-sm);
  color: var(--text-muted);
  font-size: 0.9375rem;
}

.definition__meaning {
  margin: 0;
  color: var(--text);
}

/* Etymology */
.etymology__text {
  font-size: 1.0625rem;
  line-height: 1.8;
  color: var(--text);
  margin: 0;
}

/* ===== Quotes ===== */
.quotes__carousel {
  display: flex;
  align-items: flex-start;
  gap: var(--space-lg);
}

.quotes__btn {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s var(--ease), border-color 0.2s var(--ease);
  position: relative;
  z-index: 2;
  pointer-events: auto;
}

.quotes__btn {
  transition: color 0.2s var(--ease), border-color 0.2s var(--ease), transform 0.2s var(--ease);
}

.quotes__btn:hover {
  color: var(--accent);
  border-color: var(--accent);
  transform: scale(1.05);
}

.quotes__btn:active {
  transform: scale(0.98);
}

.quotes__quote {
  flex: 1;
  margin: 0;
  padding: 0;
  border: none;
  min-height: 6rem;
}

.quotes__text {
  font-family: var(--font-display);
  font-size: 1.375rem;
  font-weight: 400;
  font-style: italic;
  line-height: 1.55;
  margin: 0 0 var(--space-sm);
  color: var(--text);
  transition: opacity 0.25s var(--ease);
}

.quotes__quote.animating .quotes__text,
.quotes__quote.animating .quotes__cite {
  opacity: 0;
}

.quotes__dots {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  justify-content: center;
  margin-top: var(--space-md);
}

.quotes__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  border: none;
  background: var(--border);
  cursor: pointer;
  padding: 0;
  transition: background 0.2s var(--ease), transform 0.2s var(--ease);
}

.quotes__dot:hover {
  background: var(--text-muted);
}

.quotes__dot.active {
  background: var(--accent);
  transform: scale(1.3);
}

.quotes__cite {
  transition: opacity 0.25s var(--ease);
}

.quotes__cite {
  font-size: 0.9375rem;
  color: var(--text-muted);
  font-style: normal;
}

/* ===== Footer ===== */
.footer {
  text-align: center;
  padding: var(--space-4xl) var(--space-lg);
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
}

.footer__line {
  font-family: var(--font-display);
  font-size: 1.125rem;
  font-weight: 500;
  color: var(--text-muted);
  margin: 0 0 var(--space-lg);
}

/* ===== Easter egg ===== */
.easter-egg {
  position: fixed;
  bottom: var(--space-lg);
  left: 50%;
  transform: translateX(-50%) translateY(100%);
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-elevated);
  border: 1px solid var(--accent);
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--accent);
  opacity: 0;
  transition: transform 0.35s var(--ease), opacity 0.35s var(--ease);
  z-index: 50;
  pointer-events: none;
}

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

@media (prefers-reduced-motion: reduce) {
  .easter-egg.show {
    transform: translateX(-50%) translateY(0);
  }
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .nav {
    padding: var(--space-sm) var(--space-md);
  }

  .nav__links {
    display: none;
  }

  .nav__links.open {
    display: flex;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    gap: 0;
    padding: var(--space-md);
    background: var(--bg);
    border-bottom: 1px solid var(--border);
  }

  .nav__links.open a {
    padding: var(--space-sm) 0;
    border-bottom: 1px solid var(--border);
  }

  .nav__links.open a:last-child {
    border-bottom: none;
  }

  .nav__menu-btn {
    display: flex;
  }

  .section {
    padding: var(--space-3xl) var(--space-md);
  }

  .quotes__carousel {
    flex-direction: column;
  }

  .quotes__btn {
    width: 40px;
    height: 40px;
  }
}
