/* Reset and Base Styles */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --color-bg: #0a0a0a;
  --color-surface: #1a1a1a;
  --color-text: #f5f5f5;
  --color-text-muted: #a0a0a0;
  --color-accent: #3b82f6;
  --color-overlay: rgba(0, 0, 0, 0.85);
  --spacing-xs: 0.5rem;
  --spacing-sm: 1rem;
  --spacing-md: 1.5rem;
  --spacing-lg: 2rem;
  --spacing-xl: 3rem;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
}

html {
  scroll-behavior: smooth;
  /* Allow content to extend into safe areas */
  background-color: var(--color-bg);
}

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

/* Site Header */
.site-header {
  padding: var(--spacing-md) var(--spacing-lg);
  text-align: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.site-header h1 {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

/* Posts Grid */
.posts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 2px;
  padding: 2px;
}

@media (min-width: 768px) {
  .posts-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 1200px) {
  .posts-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* Post Card */
.post-card {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  background-color: var(--color-surface);
  text-decoration: none;
  color: var(--color-text);
  display: block;
  cursor: pointer;
}

.post-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.post-card:hover img,
.post-card:focus img {
  transform: scale(1.05);
}

.post-card__overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: var(--spacing-sm);
  background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.post-card:hover .post-card__overlay,
.post-card:focus .post-card__overlay {
  opacity: 1;
}

.post-card__overlay p {
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.4;
}

/* Video Post Card */
.post-card--video .post-card__play-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 48px;
  height: 48px;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.3s ease, transform 0.3s ease;
}

.post-card--video .post-card__play-icon svg {
  width: 20px;
  height: 20px;
  margin-left: 3px;
}

.post-card--video:hover .post-card__play-icon {
  background: var(--color-accent);
  transform: translate(-50%, -50%) scale(1.1);
}

/* YouTube Post Card */
.post-card--youtube .post-card__play-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 68px;
  height: 48px;
  background: #ff0000;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.3s ease, transform 0.3s ease;
}

.post-card--youtube .post-card__play-icon svg {
  width: 24px;
  height: 24px;
  margin-left: 2px;
}

.post-card--youtube:hover .post-card__play-icon {
  background: #cc0000;
  transform: translate(-50%, -50%) scale(1.1);
}

/* Text Only Post Card */
.post-card--text {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-md);
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

.post-card__text-content {
  text-align: center;
}

.post-card__text-content p {
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.5;
}

.post-card--text:hover {
  background: linear-gradient(135deg, #1f1f3a 0%, #1a2744 100%);
}

/* Fullscreen Container */
.fullscreen-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: var(--color-bg);
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

/* Show fullscreen when any post is targeted - modern browsers */
.fullscreen-container:has(.fullscreen-post:target) {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* Targeted post scrolls into view */
.fullscreen-post:target {
  scroll-margin-top: 0;
}

/* Close Button */
.fullscreen-close {
  position: fixed;
  top: var(--spacing-sm);
  right: var(--spacing-sm);
  width: 44px;
  height: 44px;
  background: rgba(0, 0, 0, 0.6);
  border: none;
  border-radius: 50%;
  color: var(--color-text);
  font-size: 1.75rem;
  line-height: 1;
  cursor: pointer;
  z-index: 1001;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  transition: background-color 0.3s ease;
}

.fullscreen-close:hover {
  background: rgba(0, 0, 0, 0.8);
}

/* Fullscreen Scroll Container */
.fullscreen-scroll {
  height: 100vh;
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  scroll-behavior: smooth;
}

/* Fullscreen Post */
.fullscreen-post {
  min-height: 100vh;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  display: flex;
  flex-direction: column;
}

@media (min-width: 768px) {
  .fullscreen-post {
    flex-direction: row;
  }
}

/* Fullscreen Post Media */
.fullscreen-post__media {
  flex: 1;
  min-height: 40vh;
  background-color: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}

@media (min-width: 768px) {
  .fullscreen-post__media {
    min-height: 100vh;
    flex: 1.5;
  }
}

.fullscreen-post__media img,
.fullscreen-post__media video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  max-height: 60vh;
}

@media (min-width: 768px) {
  .fullscreen-post__media img,
  .fullscreen-post__media video {
    max-height: 100vh;
  }
}

/* YouTube Embed in Fullscreen */
.fullscreen-post__media .youtube-embed {
  position: relative;
  width: 100%;
  max-width: 100%;
  aspect-ratio: 16 / 9;
}

.fullscreen-post__media .youtube-embed iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
}

@media (min-width: 768px) {
  .fullscreen-post__media .youtube-embed {
    max-width: 90%;
    max-height: 80vh;
  }
}

/* Fullscreen Post Content */
.fullscreen-post__content {
  padding: var(--spacing-lg);
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
  background-color: var(--color-bg);
}

@media (min-width: 768px) {
  .fullscreen-post__content {
    flex: 1;
    max-width: 500px;
    padding: var(--spacing-xl);
    justify-content: center;
    overflow-y: auto;
  }
}

.fullscreen-post__content h2 {
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.3;
}

@media (min-width: 768px) {
  .fullscreen-post__content h2 {
    font-size: 1.75rem;
  }
}

.fullscreen-post__date {
  color: var(--color-text-muted);
  font-size: 0.875rem;
}

.fullscreen-post__content p {
  color: var(--color-text);
  font-size: 1rem;
  line-height: 1.7;
}

.fullscreen-post__content ul {
  padding-left: var(--spacing-md);
  color: var(--color-text);
}

.fullscreen-post__content li {
  margin-bottom: var(--spacing-xs);
}

.fullscreen-post__gear {
  margin-top: var(--spacing-sm);
  padding-top: var(--spacing-sm);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 0.875rem;
  color: var(--color-text-muted);
}

/* Text Only Fullscreen Post */
.fullscreen-post--text-only {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  justify-content: center;
  align-items: center;
}

.fullscreen-post__content--centered {
  max-width: 600px;
  text-align: center;
}

@media (min-width: 768px) {
  .fullscreen-post__content--centered {
    padding: var(--spacing-xl);
  }
}

.fullscreen-post--text-only .fullscreen-post__content ul {
  text-align: left;
  display: inline-block;
}

/* Scroll indicator */
.fullscreen-post::after {
  content: '';
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  width: 30px;
  height: 50px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 15px;
  opacity: 0.5;
}

.fullscreen-post::before {
  content: '';
  position: absolute;
  bottom: 35px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 8px;
  background: rgba(255, 255, 255, 0.5);
  border-radius: 2px;
  animation: scroll-hint 2s infinite;
}

@keyframes scroll-hint {
  0%, 100% {
    opacity: 0.5;
    transform: translateX(-50%) translateY(0);
  }
  50% {
    opacity: 1;
    transform: translateX(-50%) translateY(10px);
  }
}

/* Hide scroll indicator on last post and on mobile */
.fullscreen-post:last-child::after,
.fullscreen-post:last-child::before {
  display: none;
}

@media (max-width: 767px) {
  .fullscreen-post::after,
  .fullscreen-post::before {
    display: none;
  }
}

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

  .fullscreen-scroll {
    scroll-behavior: auto;
  }

  .fullscreen-post::before {
    animation: none;
  }

  .post-card img {
    transition: none;
  }
}

/* Focus styles */
.post-card:focus {
  outline: 2px solid var(--color-accent);
  outline-offset: -2px;
}

.fullscreen-close:focus {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* =====================================================
   Landing Page Styles
   ===================================================== */

/* Landing Header */
.landing-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  padding: var(--spacing-sm) var(--spacing-lg);
  padding-top: max(var(--spacing-sm), env(safe-area-inset-top));
  padding-left: max(var(--spacing-lg), env(safe-area-inset-left));
  padding-right: max(var(--spacing-lg), env(safe-area-inset-right));
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.8), transparent);
}

.landing-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1400px;
  margin: 0 auto;
}

.nav-logo {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--color-text);
  text-decoration: none;
  letter-spacing: -0.02em;
}

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

.nav-link {
  color: var(--color-text);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  padding: var(--spacing-xs) var(--spacing-sm);
  border-radius: 4px;
  transition: background-color 0.2s ease;
}

.nav-link:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

/* Site Header with Nav (for feed page) */
.site-header--with-nav {
  display: flex;
  justify-content: center;
}

.site-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: 1400px;
}

.nav-current {
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

/* Hero Section */
.hero {
  position: relative;
  height: 100vh;
  height: 100dvh;
  min-height: 500px;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Extend hero into safe areas using negative margins */
  margin-top: calc(-1 * env(safe-area-inset-top, 0px));
  margin-bottom: calc(-1 * env(safe-area-inset-bottom, 0px));
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.hero__image {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 0;
}

.hero__image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hero__overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
  background: linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.3) 0%,
    rgba(0, 0, 0, 0.1) 40%,
    rgba(0, 0, 0, 0.6) 100%
  );
}

.hero__content {
  position: relative;
  z-index: 2;
  text-align: center;
  padding: var(--spacing-lg);
}

.hero__content h1 {
  font-size: 3rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: var(--spacing-sm);
  text-shadow: 0 2px 20px rgba(0, 0, 0, 0.5);
}

@media (min-width: 768px) {
  .hero__content h1 {
    font-size: 4.5rem;
  }
}

.hero__tagline {
  font-size: 1.25rem;
  color: rgba(255, 255, 255, 0.9);
  font-weight: 400;
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.5);
}

@media (min-width: 768px) {
  .hero__tagline {
    font-size: 1.5rem;
  }
}

/* About Section */
.about-section {
  position: relative;
  padding: var(--spacing-xl) var(--spacing-lg);
  padding-left: max(var(--spacing-lg), env(safe-area-inset-left));
  padding-right: max(var(--spacing-lg), env(safe-area-inset-right));
  background-color: var(--color-bg);
}

.about-content {
  max-width: 700px;
  margin: 0 auto;
  text-align: center;
}

.about-content h2 {
  font-size: 1.75rem;
  font-weight: 600;
  margin-bottom: var(--spacing-md);
}

.about-content > p {
  color: var(--color-text-muted);
  font-size: 1.1rem;
  line-height: 1.8;
  margin-bottom: var(--spacing-lg);
}

/* Social Links */
.social-links {
  display: flex;
  justify-content: center;
  gap: var(--spacing-md);
  flex-wrap: wrap;
}

.social-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background-color: var(--color-surface);
  color: var(--color-text);
  text-decoration: none;
  transition: background-color 0.2s ease, transform 0.2s ease;
}

.social-link:hover {
  background-color: var(--color-accent);
  transform: translateY(-2px);
}

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

/* Latest Posts Section */
.latest-posts {
  position: relative;
  padding: var(--spacing-xl) var(--spacing-lg);
  padding-left: max(var(--spacing-lg), env(safe-area-inset-left));
  padding-right: max(var(--spacing-lg), env(safe-area-inset-right));
  background-color: var(--color-surface);
}

.latest-posts__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1200px;
  margin: 0 auto var(--spacing-lg);
}

.latest-posts__header h2 {
  font-size: 1.5rem;
  font-weight: 600;
}

.view-all-link {
  color: var(--color-accent);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
}

.view-all-link:hover {
  text-decoration: underline;
}

/* Posts Preview Grid */
.posts-preview {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 2px;
  max-width: 1200px;
  margin: 0 auto;
}

@media (min-width: 768px) {
  .posts-preview {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* Landing Footer */
.landing-footer {
  padding: var(--spacing-lg);
  padding-bottom: max(var(--spacing-lg), env(safe-area-inset-bottom));
  padding-left: max(var(--spacing-lg), env(safe-area-inset-left));
  padding-right: max(var(--spacing-lg), env(safe-area-inset-right));
  text-align: center;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  background-color: var(--color-bg);
}

.landing-footer p {
  color: var(--color-text-muted);
  font-size: 0.875rem;
}
