/* memento_mori/static/css/style.css */
:root {
  --instagram-bg: #fafafa;
  --instagram-border: #dbdbdb;
  --instagram-text: #262626;
  --instagram-link: #0095f6;
  --header-height: 60px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--instagram-bg);
  color: var(--instagram-text);
  line-height: 1.5;
}

header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background-color: white;
  border-bottom: 1px solid var(--instagram-border);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 20px;
  z-index: 100;
}

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

.logo {
  font-size: 24px;
  font-weight: bold;
  color: var(--instagram-text);
  text-decoration: none;
}

.date-range-header {
  color: #8e8e8e;
  font-size: 14px;
  margin-left: 15px;
}

main {
  max-width: 975px;
  margin: calc(var(--header-height) + 30px) auto 30px;
  padding: 0 20px;
}

.profile-info {
  display: flex;
  align-items: center;
  margin-bottom: 30px;
}

.profile-picture {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  object-fit: cover;
  margin-right: 30px;
  background-color: #eee;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  color: #aaa;
}

.profile-details h1 {
  font-size: 28px;
  font-weight: 300;
  margin-bottom: 15px;
}

.profile-details .bio {
  margin: 0 0 10px 0;
  max-width: 600px;
  line-height: 1.4;
}

.profile-details .website {
  margin: 0 0 15px 0;
  font-size: 14px;
}

.profile-details .website a {
  color: var(--instagram-link);
  text-decoration: none;
}

.profile-details .website a:hover {
  text-decoration: underline;
}

.stats {
  display: flex;
  margin-bottom: 15px;
  font-size: 16px;
}

.stat {
  margin-right: 40px;
}

.stat-count {
  font-weight: 600;
}

.posts-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 28px;
}

.grid-item {
  position: relative;
  aspect-ratio: 1/1;
  cursor: pointer;
  overflow: hidden;
}

.grid-item img,
.grid-item video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
  aspect-ratio: 1/1;
}

.grid-item:hover img,
.grid-item:hover video {
  transform: scale(1.05);
}

.multi-indicator {
  position: absolute;
  top: 10px;
  right: 10px;
  color: white;
  background-color: rgba(0, 0, 0, 0.6);
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 12px;
  z-index: 2;
}

.video-indicator {
  position: absolute;
  top: 10px;
  right: 10px;
  color: white;
  background-color: rgba(0, 0, 0, 0.7);
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: bold;
  z-index: 2;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.post-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.9);
  z-index: 1000;
  overflow-y: auto;
}

.post-modal-content {
  display: flex;
  max-width: 1200px;
  margin: 30px auto;
  background-color: white;
  height: calc(100vh - 60px);
  max-height: 800px;
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

.post-media {
  flex: 1;
  background-color: black;
  position: relative;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.post-media img,
.post-media video {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.post-info {
  width: 340px;
  border-left: 1px solid var(--instagram-border);
  display: flex;
  flex-direction: column;
}

.post-header {
  padding: 16px;
  border-bottom: 1px solid var(--instagram-border);
  display: flex;
  align-items: center;
}

.post-user {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  margin-right: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #eee;
  font-size: 14px;
  color: #aaa;
}

.post-username {
  font-weight: 600;
  flex-grow: 1;
}

.share-button {
  cursor: pointer;
  padding: 5px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s;
}

.share-button:hover {
  background-color: rgba(0, 0, 0, 0.1);
}

.share-button svg {
  width: 18px;
  height: 18px;
  color: #8e8e8e;
}

.post-caption {
  padding: 16px;
  flex-grow: 1;
  overflow-y: auto;
}

.post-date {
  padding: 16px;
  color: #8e8e8e;
  font-size: 12px;
  border-top: 1px solid var(--instagram-border);
}

.post-stats {
  padding: 12px 16px;
  color: var(--instagram-text);
  font-size: 14px;
  border-top: 1px solid var(--instagram-border);
  display: flex;
  gap: 16px;
}

.post-stat {
  display: flex;
  align-items: center;
  gap: 6px;
}

.post-stat-icon {
  font-size: 16px;
}

.likes-indicator {
  position: absolute;
  bottom: 10px;
  left: 10px;
  color: white;
  background-color: rgba(0, 0, 0, 0.7);
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: bold;
  z-index: 2;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.close-modal {
  position: absolute;
  top: 20px;
  right: 20px;
  color: white;
  font-size: 30px;
  cursor: pointer;
  z-index: 1001;
}

.modal-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  color: white;
  font-size: 30px;
  cursor: pointer;
  z-index: 1001;
  background-color: rgba(0, 0, 0, 0.5);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-prev {
  left: 20px;
}

.modal-next {
  right: 20px;
}

.slideshow-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  color: white;
  font-size: 30px;
  cursor: pointer;
  z-index: 5;
  background-color: rgba(0, 0, 0, 0.7);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s;
}

.slideshow-nav:hover {
  background-color: rgba(0, 0, 0, 0.9);
}

.slideshow-prev {
  left: 10px;
}

.slideshow-next {
  right: 10px;
}

.slideshow-indicator {
  position: absolute;
  bottom: 20px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  z-index: 5;
  background-color: rgba(0, 0, 0, 0.3);
  padding: 8px 0;
  border-radius: 20px;
  width: auto;
  max-width: 80%;
  margin: 0 auto;
}

.slideshow-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.5);
  margin: 0 4px;
  cursor: pointer;
  transition: background-color 0.2s;
}

.slideshow-dot:hover {
  background-color: rgba(255, 255, 255, 0.8);
}

.slideshow-dot.active {
  background-color: white;
}

.media-container {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.media-slide {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.5s ease;
  pointer-events: none;
  will-change: transform, opacity;
  transform: translateX(0);
}

.media-slide img,
.media-slide video {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.media-slide.active {
  opacity: 1;
  z-index: 2;
  pointer-events: auto;
}

.media-slide.active {
  opacity: 1;
  z-index: 2;
}

.file-input-container {
  margin-bottom: 20px;
  padding: 20px;
  background-color: white;
  border: 1px solid var(--instagram-border);
  border-radius: 4px;
}

.loading {
  text-align: center;
  padding: 40px;
  font-size: 18px;
}

.sort-options {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  margin-bottom: 20px;
}

.sort-row {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  margin: 5px 0;
  width: 100%;
  max-width: 600px;
}

.sort-link {
  margin: 0 10px;
  color: var(--instagram-text);
  text-decoration: none;
  padding: 5px 0;
  position: relative;
  transition: color 0.2s;
}

.sort-link:hover {
  color: var(--instagram-link);
}

.sort-link.active {
  color: var(--instagram-link);
  font-weight: 600;
}

.sort-link.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background-color: var(--instagram-link);
}

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

  .post-modal-content {
    flex-direction: column;
    height: auto;
    max-height: none;
    margin: 30px auto 0;
    border-radius: 0;
    width: 100%;
  }

  .post-media {
    height: 50vh;
    width: 100%;
    min-height: 300px;
    position: relative;
  }

  .post-info {
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--instagram-border);
  }

  .profile-picture {
    width: 80px;
    height: 80px;
    margin-right: 15px;
  }

  .stat {
    margin-right: 20px;
  }

  .post-modal {
    overflow-y: auto;
    padding-top: 0;
  }

  .media-container {
    position: relative;
    width: 100%;
    height: 100%;
  }

  .media-slide {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .media-slide img,
  .media-slide video {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
  }
}

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

  .profile-info {
    flex-direction: column;
    text-align: center;
  }

  .profile-picture {
    margin-right: 0;
    margin-bottom: 15px;
  }

  .stats {
    justify-content: center;
  }

  .header-content {
    flex-direction: column;
    align-items: center;
    padding: 5px 0;
  }

  .date-range-header {
    margin-left: 0;
    margin-top: 2px;
    font-size: 12px;
  }

  .sort-options {
    padding: 5px;
  }

  .sort-row {
    width: 100%;
    flex-wrap: wrap;
    justify-content: center;
  }

  .sort-link {
    margin: 5px;
    font-size: 13px;
    padding: 5px 0;
    flex: 0 0 auto;
  }
}

/* Stories grid styles */
.stories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
  margin-top: 20px;
}

.story-item {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  background-color: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  transition: transform 0.2s ease;
}

.story-item:hover {
  transform: translateY(-5px);
}

.story-info {
  padding: 12px;
}

.story-date {
  font-size: 12px;
  color: #8e8e8e;
  margin-bottom: 4px;
}

/* Story caption styles removed as they're now used for alt text */

.video-indicator {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 30px;
  height: 30px;
  background-color: rgba(0, 0, 0, 0.5);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.video-placeholder {
  width: 100%;
  height: 300px;
  background-color: #f0f0f0;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Navigation links */
.nav-link {
  margin-right: 20px;
  font-weight: 600;
  color: #8e8e8e;
  text-decoration: none;
}

.nav-link.active {
  color: #262626;
  border-bottom: 2px solid #262626;
}

/* Mobile-specific fixes */
@media (max-width: 768px) {

  /* Ensure the modal takes up the full screen */
  .post-modal {
    padding: 0;
    overflow-y: auto;
  }

  /* Make modal content take full width */
  .post-modal-content {
    flex-direction: column;
    height: auto;
    margin: 0;
    width: 100%;
    max-width: 100%;
  }

  /* Explicitly set post-media height */
  .post-media {
    height: 50vh !important;
    /* Important to override any inline styles */
    min-height: 300px !important;
    width: 100%;
    flex: 0 0 auto;
    /* Don't grow or shrink */
  }

  /* Ensure media container fills the available space */
  .media-container {
    position: relative;
    width: 100%;
    height: 100% !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
  }

  /* Fix media slides */
  .media-slide {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex !important;
    align-items: center;
    justify-content: center;
  }

  /* Ensure images don't exceed container */
  .media-slide img,
  .media-slide video {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
  }

  /* Make post info section scroll independently if needed */
  .post-info {
    flex: 1 1 auto;
    overflow-y: auto;
    max-height: 50vh;
  }
}

/* Stories section */
.section-title {
    text-align: center;
    margin: 30px 0 15px;
}

.section-title h2 {
    font-size: 24px;
    font-weight: 600;
    color: #262626;
    margin: 0;
    padding-bottom: 10px;
    border-bottom: 1px solid #dbdbdb;
}

.story-item {
    position: relative;
}

.story-info {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    padding: 8px;
    font-size: 12px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.story-item:hover .story-info {
    opacity: 1;
}

.story-date {
    font-weight: bold;
    margin-bottom: 4px;
    color: white;
    opacity: 1;
}

.story-caption {
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* Stories page specific styles */
.stories-container {
  margin-top: 30px;
}

.stories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
  margin-top: 20px;
}

.story-item {
  border-radius: 8px;
  overflow: hidden;
  background-color: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  transition: transform 0.2s ease;
  cursor: pointer;
}

.story-item:hover {
  transform: translateY(-5px);
}

.story-media {
  position: relative;
  aspect-ratio: 9/16;
  overflow: hidden;
  background-color: #000;
}

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

.story-viewer {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh; /* Explicitly use viewport height */
  background-color: rgba(0, 0, 0, 0.95);
  z-index: 2000;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.story-close {
  position: absolute;
  top: 20px;
  right: 20px;
  color: white;
  font-size: 30px;
  cursor: pointer;
  z-index: 2001;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(0, 0, 0, 0.5);
  border-radius: 50%;
}

.story-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  color: white;
  font-size: 30px;
  cursor: pointer;
  z-index: 2001;
  background-color: rgba(0, 0, 0, 0.5);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.story-prev {
  left: 20px;
}

.story-next {
  right: 20px;
}

.story-progress-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background-color: rgba(255, 255, 255, 0.3);
  z-index: 2001;
}

.story-progress {
  height: 100%;
  width: 0%;
  background-color: white;
  transition: width 10s linear;
}

.story-content {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

.story-media-container {
  max-width: 100%;
  max-height: 100%;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  overflow: hidden; /* Important to hide slides that move outside the container */
}

.story-media-container img,
.story-media-container video {
  width: 100%;
  height: 100%; 
  max-height: 90vh;
  object-fit: contain;
}

.story-info-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  padding: 20px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
  color: white;
}

/* Caption styles removed as they're now used for alt text */
.story-info-overlay .story-date {
  font-size: 14px;
  opacity: 1;
  color: white;
  max-width: 800px;
  margin: 0 auto;
  text-align: center;
}

@media (max-width: 768px) {
  .story-media-container img,
  .story-media-container video {
    max-height: 80vh;
  }
  
  .story-nav {
    width: 30px;
    height: 30px;
    font-size: 20px;
  }
  
  .story-close {
    width: 30px;
    height: 30px;
    font-size: 20px;
  }
  
  .story-info-overlay {
    padding: 15px;
  }
  
  .story-info-overlay .story-caption {
    font-size: 14px;
  }
  
  .story-info-overlay .story-date {
    font-size: 12px;
  }
}

/* Navigation links */
.nav-link {
  color: #0095f6;
  text-decoration: none;
  padding-bottom: 2px;
  transition: color 0.2s ease;
  position: relative;
}

.nav-link:hover {
  color: #00376b;
  text-decoration: underline;
}

.nav-link.active {
  font-weight: 600;
  color: #262626;
  border-bottom: 2px solid #262626;
}
