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

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: "Inter", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

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

button {
  border: none;
  background: none;
  cursor: pointer;
  font: inherit;
  color: inherit;
}

/* ── Design Tokens ────────────────────────────────────── */

:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #141420;
  --bg-card: #1a1a2e;
  --text-primary: #f5f0eb;
  --text-secondary: #b8a99a;
  --text-muted: #6b6178;
  --accent: #e8927c;
  --accent-hover: #f0a58e;
  --heart: #e74c5e;
  --heart-glow: rgba(231, 76, 94, 0.4);
  --overlay: linear-gradient(
    to bottom,
    rgba(10, 10, 15, 0.05) 0%,
    rgba(10, 10, 15, 0.15) 30%,
    rgba(10, 10, 15, 0.55) 65%,
    rgba(10, 10, 15, 0.88) 100%
  );
  --font-heading: "Cormorant Garamond", "Georgia", serif;
  --font-body: "Inter", "Helvetica Neue", sans-serif;
  --radius: 12px;
  --radius-sm: 8px;
}

/* ── Main Page: Hero ──────────────────────────────────── */

.hero {
  position: fixed;
  inset: 0;
  background-color: var(--bg-primary);
  background-size: cover;
  background-position: center;
  transition: opacity 1.2s ease;
}

.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--overlay);
  pointer-events: none;
}

.hero.loading {
  opacity: 0.6;
}

.hero.loaded {
  opacity: 1;
}

/* ── Loading Shimmer ──────────────────────────────────── */

.loader {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  background: var(--bg-primary);
  transition: opacity 0.8s ease;
  pointer-events: none;
}

.loader.hidden {
  opacity: 0;
}

.loader-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  margin: 0 5px;
  animation: pulse 1.4s ease-in-out infinite;
}

.loader-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.loader-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes pulse {
  0%,
  80%,
  100% {
    opacity: 0.3;
    transform: scale(0.8);
  }
  40% {
    opacity: 1;
    transform: scale(1);
  }
}

/* ── Overlay Content ──────────────────────────────────── */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 0 6vw 10vh;
  pointer-events: none;
}

.overlay > * {
  pointer-events: auto;
}

.overlay__date {
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.25em;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
}

.overlay__landmark {
  font-family: var(--font-heading);
  font-size: clamp(2.2rem, 9vw, 5rem);
  font-weight: 300;
  line-height: 1.05;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

.overlay__location {
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 400;
  color: var(--text-secondary);
  margin-bottom: 1.25rem;
}

.overlay__time {
  font-family: var(--font-heading);
  font-size: 1.35rem;
  font-weight: 400;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.overlay__time-icon {
  font-size: 1.1rem;
}

.overlay__weather {
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin-top: 0.3rem;
}

.overlay__message {
  font-family: var(--font-heading);
  font-style: italic;
  font-size: 1.05rem;
  font-weight: 300;
  color: var(--text-secondary);
  margin-top: 1.5rem;
  max-width: 34ch;
  line-height: 1.5;
}

.overlay__day-counter {
  font-family: var(--font-body);
  font-size: 0.7rem;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--text-muted);
  margin-top: 2rem;
}

/* ── Top Bar ──────────────────────────────────────────── */

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 5vw;
}

.topbar__logo {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 400;
  color: var(--text-secondary);
  letter-spacing: 0.05em;
}

.topbar__nav {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.topbar__link {
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--text-secondary);
  transition: color 0.3s ease;
  padding: 0.5rem;
}

.topbar__link:hover {
  color: var(--text-primary);
}

/* ── Star Rating ──────────────────────────────────────── */

.star-rating {
  position: fixed;
  bottom: 10vh;
  right: 6vw;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 0.2rem;
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 2rem;
  padding: 0.5rem 0.75rem;
}

.star-rating__star {
  position: relative;
  display: inline-block;
  width: 1.5rem;
  height: 1.5rem;
  font-size: 1.5rem;
  line-height: 1;
  transition: transform 0.2s ease;
}

.star-rating__star:hover {
  transform: scale(1.2);
}

/* Star shape via ::before */
.star-rating__star::before {
  content: "\2606";
  position: absolute;
  top: 0;
  left: 0;
  color: var(--text-muted);
}

.star--full::before {
  content: "\2605";
  color: var(--accent);
}

.star--half::before {
  content: "\2605";
  color: var(--accent);
  clip-path: inset(0 50% 0 0);
}

.star--half::after {
  content: "\2606";
  position: absolute;
  top: 0;
  left: 0;
  color: var(--text-muted);
  clip-path: inset(0 0 0 50%);
}

.star--empty::before {
  content: "\2606";
  color: var(--text-muted);
}

/* Invisible half buttons overlay the star */
.star-half {
  position: absolute;
  top: 0;
  width: 50%;
  height: 100%;
  z-index: 1;
  cursor: pointer;
  opacity: 0;
}

.star-half--left {
  left: 0;
}

.star-half--right {
  right: 0;
}

.star-rating.pulse {
  animation: starPulse 0.5s ease;
}

@keyframes starPulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
}

/* ── Attribution Footer ───────────────────────────────── */

.attribution {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 15;
  padding: 1rem 5vw;
  font-family: var(--font-body);
  font-size: 0.6rem;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.attribution a {
  color: var(--text-muted);
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color 0.3s ease;
}

.attribution a:hover {
  color: var(--text-secondary);
}

/* ══════════════════════════════════════════════════════════
   FAVORITES PAGE
   ══════════════════════════════════════════════════════════ */

.fav-page {
  min-height: 100dvh;
  background: var(--bg-primary);
  padding-bottom: 4rem;
}

/* ── Favorites Header ─────────────────────────────────── */

.fav-header {
  padding: 2rem 5vw 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.fav-header__title {
  font-family: var(--font-heading);
  font-size: clamp(1.8rem, 5vw, 2.5rem);
  font-weight: 300;
  color: var(--text-primary);
}

.fav-header__back {
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--text-secondary);
  transition: color 0.3s ease;
  padding: 0.5rem 0;
}

.fav-header__back:hover {
  color: var(--text-primary);
}

.fav-header__count {
  font-family: var(--font-body);
  font-size: 0.8rem;
  color: var(--text-muted);
  padding: 0.5rem 5vw;
}

/* ── Leaderboard ─────────────────────────────────────── */

.leaderboard {
  padding: 1rem 5vw;
  max-width: 720px;
  margin: 0 auto;
}

.lb-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  transition: background 0.2s ease;
}

.lb-row:last-child {
  border-bottom: none;
}

.lb-row:hover {
  background: rgba(255, 255, 255, 0.03);
}

.lb-row--top {
  background: rgba(255, 255, 255, 0.02);
  border-radius: var(--radius-sm);
  border-bottom-color: transparent;
  margin-bottom: 0.25rem;
}

.lb-row__pos {
  width: 2rem;
  text-align: center;
  font-family: var(--font-body);
  font-size: 1.1rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.lb-row--top .lb-row__pos {
  font-size: 1.3rem;
}

.lb-row__thumb {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  background-size: cover;
  background-position: center;
  background-color: var(--bg-secondary);
  flex-shrink: 0;
}

.lb-row__info {
  flex: 1;
  min-width: 0;
}

.lb-row__name {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 400;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lb-row__location {
  font-family: var(--font-body);
  font-size: 0.7rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lb-row__meta {
  text-align: right;
  flex-shrink: 0;
}

.lb-row__stars {
  font-size: 0.85rem;
  letter-spacing: 1px;
  display: flex;
  gap: 1px;
}

.lb-star {
  display: inline-block;
  position: relative;
}

.lb-star--full {
  color: var(--accent);
}

.lb-star--half {
  position: relative;
  display: inline-block;
  width: 0.85rem;
}

.lb-star--half .lb-star__fill {
  position: absolute;
  left: 0;
  top: 0;
  color: var(--accent);
  clip-path: inset(0 50% 0 0);
}

.lb-star--half .lb-star__empty {
  color: var(--text-muted);
}

.lb-star--empty {
  color: var(--text-muted);
}

.lb-row__date {
  font-family: var(--font-body);
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.lb-row__remove {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  color: var(--text-muted);
  border-radius: 50%;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.2s ease, color 0.2s ease, background 0.2s ease;
}

.lb-row:hover .lb-row__remove {
  opacity: 1;
}

.lb-row__remove:hover {
  color: var(--heart);
  background: rgba(231, 76, 94, 0.1);
}

/* ── Empty State ──────────────────────────────────────── */

.empty-state {
  text-align: center;
  padding: 6rem 2rem;
}

.empty-state__icon {
  font-size: 3rem;
  margin-bottom: 1.5rem;
  opacity: 0.4;
}

.empty-state__title {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 300;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
}

.empty-state__text {
  font-family: var(--font-body);
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 2rem;
  max-width: 30ch;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.6;
}

.empty-state__link {
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--accent);
  border-bottom: 1px solid var(--accent);
  padding-bottom: 2px;
  transition: opacity 0.3s ease;
}

.empty-state__link:hover {
  opacity: 0.8;
}

/* ── Mobile Optimisation ─────────────────────────────── */

@media (max-width: 480px) {
  .overlay {
    padding: 0 5vw 18vh;
  }

  .overlay__landmark {
    font-size: clamp(1.8rem, 8vw, 3rem);
  }

  .overlay__location {
    font-size: 0.8rem;
    margin-bottom: 1rem;
  }

  .overlay__time {
    font-size: 1.1rem;
    flex-wrap: wrap;
  }

  .overlay__weather {
    font-size: 0.85rem;
  }

  .overlay__message {
    font-size: 0.95rem;
    max-width: 28ch;
    margin-top: 1rem;
  }

  .overlay__day-counter {
    margin-top: 1.25rem;
  }

  /* Bigger touch targets for stars */
  .star-rating {
    bottom: 5vh;
    right: 4vw;
    gap: 0.1rem;
    padding: 0.6rem 0.8rem;
  }

  .star-rating__star {
    width: 2rem;
    height: 2rem;
    font-size: 2rem;
  }

  /* Attribution stack on mobile */
  .attribution {
    flex-direction: column;
    gap: 0.25rem;
    text-align: center;
    padding: 0.75rem 5vw;
  }

  /* Leaderboard mobile tweaks */
  .lb-row {
    gap: 0.5rem;
    padding: 0.6rem 0.5rem;
  }

  .lb-row__thumb {
    width: 40px;
    height: 40px;
  }

  .lb-row__name {
    font-size: 0.95rem;
  }

  .lb-row__stars {
    font-size: 0.75rem;
  }

  /* Always show remove button on mobile (no hover) */
  .lb-row__remove {
    opacity: 1;
  }

  .fav-header {
    padding: 1.5rem 5vw 1rem;
  }

  .fav-header__title {
    font-size: 1.6rem;
  }
}

/* Ensure touch targets are big enough */
@media (pointer: coarse) {
  .star-half {
    min-height: 44px;
    min-width: 22px;
  }

  .lb-row__remove {
    opacity: 1;
    width: 36px;
    height: 36px;
  }

  .topbar__link {
    padding: 0.75rem;
  }
}

/* ── Utility ──────────────────────────────────────────── */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}
