/*
 * Neomania Episode List Styles - Master Grid Implementation
 * Based on Figma Dev Mode Spec
 * File: css/episode-list.css
*/

/* ==========================================================================
   Variable Font Utilities
   ========================================================================== */

/* Roboto Flex slant utility - use instead of font-style: italic */
.roboto-slant {
  font-variation-settings: "slnt" -10;
}

/* Apply base styles to pages using this layout */
body:has(.episode-list-container) {
  background-color: var(--bg-color);
  color: var(--text-color);
}

/* ==========================================================================
   Master Grid Container System
   ========================================================================== */

/* Container handles max-width and padding at each breakpoint */
.episode-list-container {
  width: 100%;
  max-width: 393px;
  margin: 2rem auto;
  padding: 10rem 22px 0 22px; /* Add top padding to prevent scrolling too close to header */
  box-sizing: border-box;
  font-family: "Roboto Flex", sans-serif;
}

/* Navigation styles */
.main-nav {
  display: flex;
  gap: 1.5rem;
  padding-bottom: 1rem;
  margin-bottom: 2rem;
  border-bottom: 1px solid var(--text-level3);
}

.nav-item {
  font-family: "Space Mono", monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  text-decoration: none;
  color: var(--text-level3);
  transition: color 0.2s ease;
}

.nav-item.active,
.nav-item:hover {
  color: var(--text-color);
}

.spacer {
  flex-grow: 1;
}

/* Master Grid: XS Default (8 columns) */
.episode-list {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  column-gap: 14px;
}

/* Episode Row: Direct grid item using subgrid */
.episode-row {
  grid-column: 1 / -1; /* Span all columns */
  display: grid;
  grid-template-columns: subgrid;
  
  /* XS Layout: Multi-row stacked */
  grid-template-rows: auto 1px auto 17px auto;
  
  padding: 12px 0 16px;
  border-bottom: 0.5px solid var(--text-level3);
}

/* Remove border from last episode */
.episode-row:last-child {
  border-bottom: none;
  text-decoration: none;
  color: inherit;
  align-items: start;
}

/* Add top border to first episode row */
.episode-row:first-child {
  border-top: 0.5px solid var(--text-level3);
}

/* Episode Row Hover State - Based on Figma Design */
a.episode-row {
  transition: background-color 0.2s ease-out;
  position: relative;
  text-decoration: none;
  /* Debug: Add a subtle background to confirm CSS is loading */
  background-color: transparent;
  /* Force pointer events to work */
  pointer-events: auto !important;
  cursor: pointer !important;
}

a.episode-row:hover {
  background-color: rgba(255, 255, 255, 0.08) !important; /* Subtle Figma hover background */
}

/* Add border separator on hover */
a.episode-row:hover::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 0.5px;
  background-color: var(--text-level3);
  opacity: 1;
  z-index: 1;
}

a.episode-row:hover .episode-title {
  opacity: 0.9;
}

/* ==========================================================================
   XS Layout (Mobile First, 0-767px)
   ========================================================================== */

/* Row 1: Number + Main Content (Title/Desc) */
.episode-number {
  grid-column: 1;
  grid-row: 1;
  font-family: "Space Mono", monospace;
  font-size: 10px; /* Base size */
  letter-spacing: 0.7px;
  text-transform: uppercase;
  color: var(--text-level2);
  align-self: start;
}

/* This is the key change for mobile layouts.
   The .episode-main container is dissolved, and its children
   (.episode-title, .episode-desc) are placed directly on the grid. */
.episode-main {
  display: contents; /* Dissolve the container */
}

.episode-title {
  grid-column: 2 / 9; /* Place title in columns 2-8 */
  grid-row: 1;      /* Place title in the first row */
  font-size: 13px; /* Base size */
  font-weight: 600;
  letter-spacing: 0.39px;
  line-height: 19px;
  color: var(--text-level-1); /* Figma-aligned token */
  margin: 0;
  transition: opacity 0.2s ease;
}

.episode-desc {
  grid-column: 2 / 9; /* Place description in columns 2-8 */
  grid-row: 3; /* Place description in the third row */
  font-size: 13px; /* XS Title size */
  font-weight: 300;
  line-height: 19px;
  color: var(--text-color);
  margin: 0;
}

/* Row 5: Guest info and metadata */
.episode-guest-w {
  grid-column: 1;
  grid-row: 5;
  font-family: "Space Mono", monospace;
  font-size: 10px; /* Base size */
  letter-spacing: 0.7px;
  text-transform: uppercase;
  color: var(--text-level2);
}

.episode-guest-name {
  grid-column: 2;
  grid-row: 5;
  font-family: "Space Mono", monospace;
  font-size: 10px; /* Base size */
  letter-spacing: 0.7px;
  text-transform: uppercase;
  color: var(--text-level2);
}
.episode-date {
  grid-column: 4;
  grid-row: 5;
  font-family: "Space Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  color: var(--text-level2);
}

.episode-duration {
  grid-column: 5 / 9; /* Span from col 5 to the end of the grid */
  grid-row: 5;
  font-family: "Space Mono", monospace;
  font-size: 10px; /* Base size */
  letter-spacing: 0.7px;
  text-transform: uppercase;
  color: var(--text-level2);
  text-align: right; /* Align the text content to the right */
}

/* Hide guest info when there's no guest */
.episode-row.no-guest .episode-guest-w,
.episode-row.no-guest .episode-guest-name {
  display: none;
}

/* On mobile, date is only shown if there is no guest, to avoid crowding */
.episode-row.no-guest .episode-date {
  grid-column: 2;
}

/* Global: Make episode-main use contents for stacked layouts */
.episode-main {
  display: contents;
}

/* XS: Show display title, hide original title */
.episode-title-display {
  display: inline;
}

.episode-title-original {
  display: none;
}

/* ==========================================================================
   S Layout (768px - 1023px)
   ========================================================================== */

@media (min-width: 768px) {
  /* Update container for S breakpoint */
  .episode-list-container {
    max-width: 768px;
    padding: 10rem 50px 0 50px; /* Maintain top padding for mobile header spacing */
  }
  
  /* Update grid to 16 columns */
  .episode-list {
    grid-template-columns: repeat(16, 1fr);
  }
  
  /* S Layout: Still stacked, but with 16 columns */
  .episode-row {
    grid-template-rows: auto 1px auto 13px auto;
    padding-top: 10px;
  }
  
  /* Adjust column spans for 16-column grid */
  .episode-title {
    grid-column: 3 / 17;
  }
  
  .episode-desc {
    grid-column: 3 / 17;
  }
  
  .episode-guest-w {
    grid-column: 1;
  }
  
  .episode-guest-name {
    grid-column: 3 / 8;
  }
  
  .episode-date {
    grid-column: 13 / 15;
  }

  /* On S, date moves to fill guest slot */
  .episode-row.no-guest .episode-date {
    grid-column: 3;
  }
  
  /* S Breakpoint Typography */
  .episode-title {
    font-size: 13.9px;
    font-style: normal;
    font-weight: 600;
    line-height: 19.6px; /* 141.007% */
    letter-spacing: 0.42px;
    color: var(--text-level-1);
  }

  .episode-desc {
    font-size: 13.9px;
    font-style: normal;
    font-weight: 300;
    line-height: 19.6px; /* 141.007% */
    letter-spacing: 0.42px;
    color: var(--text-level-1);
  }

  .episode-number,
  .episode-guest-w,
  .episode-guest-name,
  .episode-date,
  .episode-duration {
    font-family: "Space Mono", monospace;
    font-size: 11px;
    font-style: normal;
    font-weight: 400;
    line-height: normal;
    letter-spacing: 0.77px;
    text-transform: uppercase;
    color: var(--text-level2);
  }

  .episode-duration {
    grid-column: 14 / 17; /* Span last 3 columns */
    /* text-align: right is inherited from mobile-first styles */
  }
}

/* ==========================================================================
   M/L/XL Unified Layout (1024px+)
   ========================================================================== */

@media (min-width: 1024px) {
  /* Update container for M breakpoint */
  .episode-list-container {
    max-width: 1024px;
    padding: 10rem 50px 0 50px; /* Maintain top padding for desktop header spacing */
  }
  
  /* Update grid to 24 columns */
  .episode-list {
    grid-template-columns: repeat(24, 1fr);
    column-gap: 14px; /* M breakpoint gutter spec */
  }
  
  /* CRITICAL SWITCH: Change to single row layout */
  .episode-row {
    grid-template-rows: auto;
    align-items: baseline;
    padding: 16px 0;
  }
  
  /* Show original title, hide display title */
  .episode-title-display {
    display: none;
  }
  
  .episode-title-original {
    display: inline;
  }
  
  /* Hide mobile-specific guest elements on desktop */
  .episode-guest-w,
  .episode-guest-name {
    display: none;
  }

  /* 24-column single row layout */
  .episode-number {
    grid-column: 1 / 2;
    grid-row: 1;
  }
  
  .episode-date {
    display: block; /* Show the date on desktop */
    grid-column: 4 / 6;
    grid-row: 1;
    font-family: "Space Mono", monospace;
    font-size: 10px;
    letter-spacing: 0.7px;
    text-transform: uppercase;
    color: var(--text-level2);
    align-self: start;
  }
  
  .episode-main {
    grid-column: 7 / 22; /* Spans up to col 21 */
    grid-row: 1;
    display: block; /* No longer 'contents' */
    align-self: start;
  }
  
  .episode-title {
    /* Unset mobile grid placement */
    grid-column: auto;
    grid-row: auto;    
    font-family: "Roboto Flex", sans-serif;
    font-size: 14px;
    font-style: normal;
    font-weight: 600;
    line-height: 20px; /* 142.857% */
    letter-spacing: 0.42px;
    color: var(--text-level-1);
    margin: 0;
  }
  
  .episode-desc {
    /* Unset mobile grid placement */
    grid-column: auto;
    grid-row: auto;    
    font-family: "Roboto Flex", sans-serif;
    font-size: 14px;
    font-weight: 300;
    line-height: 20px; /* 142.857% */
    letter-spacing: 0.42px;
    color: var(--text-level-1);
  }
  
  .episode-duration {
    grid-column: 22 / -1;
    grid-row: 1;
    text-align: right;
    align-self: start;
  }

  /* M Breakpoint Metadata Styling */
  .episode-number,
  .episode-date,
  .episode-duration {
    font-family: "Space Mono", monospace;
    font-size: 11px;
    font-style: normal;
    font-weight: 400;
    line-height: normal;
    letter-spacing: 0.77px;
    text-transform: uppercase;
    color: var(--text-level2);
  }
}

/* ==========================================================================
   L Layout (1280px+)
   ========================================================================== */

@media (min-width: 1280px) {
  .episode-list-container {
    max-width: 1280px;
  }
  
  .episode-list {
    column-gap: 16px;
  }

  /* L Breakpoint Typography (16px Title) */
  .episode-title,
  .episode-desc {
    font-size: 16px;
  }
  .episode-desc {
    font-weight: 300;
    line-height: 22px; /* 137.5% */
    letter-spacing: 0.48px;
  }
  /* Metadata remains 11px from S breakpoint */

  /* L Breakpoint Metadata Styling */
  .episode-number,
  .episode-guest-w,
  .episode-guest-name,
  .episode-date,
  .episode-duration {
    font-family: "Space Mono", monospace;
    font-size: 11px;
    font-style: normal;
    font-weight: 400;
    line-height: normal;
    letter-spacing: 0.77px;
    text-transform: uppercase;
  }

  /* L Breakpoint Row Spacing */
  .episode-row {
    padding: 15px 0 18px 0;
  }
}

/* ==========================================================================
   XL Layout (1920px+)
   ========================================================================== */

@media (min-width: 1920px) {
  .episode-list-container {
    max-width: 1920px;
    padding: 10rem 60px 0 60px; /* Maintain top padding for XL header spacing */
  }

  /* XL Episode Row Spacing */
  .episode-row {
    padding: 19px 0;
  }

  /* XL Breakpoint Typography (20px Title, 13px Meta) */
  .episode-title,
  .episode-desc,
  .episode-title span {
    font-size: 20px;
    letter-spacing: 0.60px; /* XL letter spacing */
  }

  /* XL Title Weight + Spacing (lighter, but no slant) */
  .episode-title,
  .episode-title span {
    font-variation-settings: "wght" 500; /* Lighter weight, no slant */
  }
  
  .episode-title {
    margin-bottom: 5px; /* Gap between title and subtitle */
  }

  /* XL Subtitle Weight + Slant (light and slanted) */
  .episode-desc {
    font-variation-settings: "wght" 100, "slnt" -10; /* Light weight + slant */
  }

  .episode-number,
  .episode-date,
  .episode-duration {
    font-size: 13px;
    letter-spacing: 0.91px; /* XL metadata letter spacing */
  }
}
