/*
 * Main stylesheet for the Last.fm statistics visualizer.
 * This file defines the layout, typography and responsive
 * behaviour of the app. The site uses a dark theme by default
 * to let the colourful album and artist art really pop.
 */

/* Reset some base styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  color: #ffffff;
  background-color: #0c0c0c;
  line-height: 1.4;
}

/* Navigation bar */
.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  background-color: #161616;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 1000;
  /* Remove bottom border for a cleaner header */
  border-bottom: none;
}

.navbar .logo {
  font-size: 1.25rem;
  font-weight: 600;
  /* Use green for the header text */
  color: #32cd32;
  text-decoration: none;
}

/* Hide nav links by default and display them in a vertical
   dropdown when the hamburger is toggled. The menu will slide
   down beneath the navbar. */
.navbar ul {
  list-style: none;
  display: none;
  flex-direction: column;
  gap: 0;
  position: absolute;
  top: 60px;
  right: 0;
  background-color: #161616;
  border: 1px solid #1f1f1f;
  width: 200px;
  z-index: 999;
}
.navbar ul.active {
  display: flex;
}

.navbar li a {
  color: #ffffff;
  text-decoration: none;
  padding: 0.5rem;
  border-radius: 0.25rem;
  transition: background-color 0.2s;
  /* Make nav links fill the available width in the dropdown */
  display: block;
}

.navbar li a:hover, .navbar li a.active {
  background-color: #242424;
}

/* Show the hamburger button on all screen sizes */
.hamburger {
  display: block;
  background: none;
  border: none;
  color: #ffffff;
  font-size: 1.5rem;
  cursor: pointer;
}

/* Layout containers */
.container {
  display: flex;
  margin-top: 60px; /* height of navbar */
  height: calc(100vh - 60px);
  width: 100%;
  overflow: hidden;
  /* Center the sidebar and mosaic horizontally and vertically within the page */
  justify-content: center;
  align-items: center;
}

.sidebar {
  /* Reduce the width slightly so the list hugs closer to the mosaic */
  width: 240px;
  /* Match the page background for a seamless look */
  background-color: #0c0c0c;
  /* Remove any border to avoid a visual divider between the list and mosaic */
  border-right: none;
  padding: 1rem;
  overflow-y: auto;
}

.sidebar h2 {
  font-size: 1.2rem;
  margin-bottom: 0.75rem;
}

.sidebar ul {
  list-style: none;
  padding-left: 0;
  max-height: 100%;
}

/* Sidebar paragraphs (used for messages when no data is available) */
.sidebar p {
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
  color: #c0c0c0;
  line-height: 1.4;
  white-space: normal;
}

.sidebar li {
  margin-bottom: 0.4rem;
  /* Allow text to wrap onto multiple lines for longer names */
  white-space: normal;
  overflow-wrap: anywhere;
  font-size: 0.8rem;
  color: #e5e5e5;
}

/* Style for play counts within the sidebar lists */
.sidebar li .playcount {
  color: #32cd32;
}

.content {
  /* Let the content shrink to the mosaic size rather than filling the remaining width */
  flex: 0 0 auto;
  /* Arrange list and mosaic side by side and align the mosaic to the left
     so that the list sits directly next to it with minimal gap */
  display: flex;
  justify-content: flex-start;
  align-items: center;
  /* Remove horizontal padding so the list sits closer to the mosaic */
  padding: 0;
  overflow: hidden;
}

/* Mosaic wrapper to preserve square aspect ratio */
.mosaic-wrapper {
  /* Take up all available space next to the list */
  /* Allow the mosaic to scale down if it would otherwise overflow */
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  width: auto;
}

.mosaic-wrapper img {
  /* Scale the mosaic down to fit within the viewport while preserving aspect ratio */
  max-width: calc(100vw - 320px);
  max-height: calc(100vh - 120px);
  width: auto;
  height: auto;
  object-fit: contain;
  border: none;
}

/* Home page styling */
.home {
  padding: 5rem 2rem;
  max-width: 900px;
  margin: 0 auto;
  text-align: center;
}

.home h1 {
  font-size: 2rem;
  margin-bottom: 1rem;
}

.home p {
  font-size: 1rem;
  line-height: 1.6;
  color: #cccccc;
}

/* Now Playing page styles */
.nowplaying-main {
  margin-top: 60px; /* height of navbar */
  padding: 1rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: calc(100vh - 60px);
}

/* Home summary page styles */
.home-summary {
  padding: 5rem 2rem;
  max-width: 1000px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 2rem;
  text-align: left;
}
.home-summary .summary {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}
.home-summary .summary img {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #1f1f1f;
}
.home-summary .summary-mosaics {
  display: flex;
  flex-wrap: wrap;
  gap: 2rem;
}
.home-summary .mosaic-section {
  flex: 1;
  min-width: 250px;
}
.home-summary .mosaic-section h3 {
  margin-bottom: 0.5rem;
}
.home-summary .mosaic-section .mosaic-wrapper {
  aspect-ratio: 1 / 1;
  max-width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}
.home-summary .mosaic-section .mosaic-wrapper img {
  max-width: 100%;
  max-height: 300px;
  width: auto;
  height: auto;
  object-fit: contain;
  border: none;
}

.now-playing {
  text-align: center;
  max-width: 600px;
  width: 100%;
  margin: 0 auto;
}

.now-playing img {
  /* Display album art prominently; center horizontally and limit size */
  display: block;
  margin: 0 auto 1rem auto;
  width: 100%;
  max-width: 500px;
  max-height: 80vh;
  border-radius: 8px;
  border: 2px solid #1f1f1f;
}

.now-playing .info {
  font-size: 1.1rem;
  margin-top: 0.5rem;
}

.now-playing .info .plays {
  font-size: 0.9rem;
  color: #aaaaaa;
}

.now-playing .status {
  font-size: 1.1rem;
  color: #c0c0c0;
  margin-top: 1rem;
}

/* Responsive adjustments */
@media (max-width: 900px) {
  .sidebar {
    width: 200px;
  }
}

@media (max-width: 768px) {
  /* Navigation styling is now defined globally, so no overrides are necessary here */
  .container {
    flex-direction: column;
    height: auto;
  }
  .sidebar {
    width: 100%;
    /* allow the list to grow naturally and scroll if needed */
    max-height: 40vh;
    overflow-y: auto;
    border-right: none;
    border-bottom: 1px solid #1f1f1f;
  }
  .content {
    width: 100%;
    height: auto;
    flex: none;
  }
  .mosaic-wrapper {
    max-width: 100%;
    aspect-ratio: 1 / 1;
  }

  /* On small screens, allow the mosaic to fill more of the viewport. The
     image will scale down responsively while maintaining its aspect ratio. */
  .mosaic-wrapper img {
    max-width: 100%;
    max-height: 60vh;
    width: auto;
    height: auto;
    object-fit: contain;
  }
}