/* =============================================================================
   DESIGN TOKENS
   ============================================================================= */

:root {
  /* Colors */
  --color-bg:           #faf9f7;          /* warm off-white — not pure white */
  --color-surface:      #f0eeeb;          /* card placeholder, subtle fills  */
  --color-border:       #e2e0dc;          /* dividers                        */
  --color-text-primary: #0f0f0f;          /* headings, body                  */
  --color-text-muted:   #7a7672;          /* secondary: year, duration, nums */
  --color-accent:       #0a0a0a;          /* links, interactive — near-black  */
  --color-accent-hover: #333333;          /* link hover                      */

  /* Typography */
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                 Helvetica, Arial, sans-serif;
  --font-size-base: 16px;
  --font-size-xs:   0.8125rem;   /* 13px */
  --font-size-sm:   0.875rem;    /* 14px */
  --font-size-md:   0.9375rem;   /* 15px */
  --font-size-lg:   1.125rem;    /* 18px */
  --font-size-xl:   1.5rem;      /* 24px */
  --font-size-2xl:  2rem;        /* 32px */
  --font-size-3xl:  2.5rem;      /* 40px */

  /* Spacing — 4-point base scale */
  --space-1:  4px;
  --space-2:  8px;
  --space-3:  12px;
  --space-4:  16px;
  --space-5:  24px;
  --space-6:  32px;
  --space-7:  48px;
  --space-8:  64px;

  /* Layout */
  --max-width:       960px;
  --content-padding: var(--space-5);   /* 24px page gutter */
}


/* =============================================================================
   RESET / BASE
   ============================================================================= */

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

html {
  font-size: var(--font-size-base);
  -webkit-text-size-adjust: 100%;
}

body {
  background-color: var(--color-bg);
  color: var(--color-text-primary);
  font-family: var(--font-family);
  line-height: 1.6;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

a {
  color: var(--color-accent);
  text-decoration: none;
}

a:hover {
  color: var(--color-accent-hover);
  text-decoration: none;
}

/* Keyboard focus ring */
a:focus-visible,
button:focus-visible,
audio:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 3px;
  border-radius: 2px;
}


/* =============================================================================
   LAYOUT SHELL
   ============================================================================= */

.site-wrapper {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--content-padding);
}


/* =============================================================================
   SITE HEADER  (landing page)
   ============================================================================= */

.site-header {
  padding: var(--space-6) 0 var(--space-5);
  border-bottom: 1px solid var(--color-border);
  margin-bottom: var(--space-5);
}

.site-title {
  font-size: var(--font-size-xl);
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--color-text-primary);
}


/* =============================================================================
   ALBUM GRID  (landing page)
   ============================================================================= */

.album-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-4);              /* 16px on mobile — tighter than before  */
  padding-bottom: var(--space-8);
}

@media (min-width: 480px) {
  .album-grid {
    gap: var(--space-5);            /* 24px once there's a bit more room     */
  }
}

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

@media (min-width: 780px) {
  .album-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-6);            /* 32px on desktop                       */
  }
}


/* Album card */

.album-card__link {
  display: block;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  /* Lift effect lives here so it applies to the whole card, not just the image */
  transition: transform 150ms ease;
}

.album-card__link:hover {
  transform: translateY(-2px);
}

.album-card__link:hover .album-card__cover {
  opacity: 0.85;
}

.album-card__link:hover .album-card__title {
  color: var(--color-accent-hover);
}

.album-card__cover-wrap {
  width: 100%;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
}

.album-card__cover {
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* Smooth opacity transition matches the card lift */
  transition: opacity 150ms ease;
}

.album-card__title {
  margin-top: var(--space-2);
  font-size: var(--font-size-md);    /* 15px — slightly larger than before  */
  font-weight: 500;
  color: var(--color-text-primary);
  line-height: 1.35;
  /* Clamp to two lines so the grid stays tidy */
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}


/* =============================================================================
   SITE FOOTER
   ============================================================================= */

.site-footer {
  padding: var(--space-5) 0;
  border-top: 1px solid var(--color-border);
  margin-top: auto;
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
}


/* =============================================================================
   ALBUM PAGE — NAV
   ============================================================================= */

.album-nav {
  padding: var(--space-5) 0 var(--space-3);
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--color-text-muted);
  text-decoration: none;
  letter-spacing: 0.01em;
  transition: color 150ms ease;
}

.back-link:hover {
  color: var(--color-accent);
}


/* =============================================================================
   ALBUM PAGE — HEADER (cover art + metadata)

   Mobile:   cover is full-width and edge-to-edge (bleeds out of .site-wrapper
             padding), metadata sits below it with normal gutter padding.
   Desktop:  standard side-by-side layout, cover constrained to ~280px.
   ============================================================================= */

.album-page {
  padding-bottom: var(--space-8);
}

/* --- Mobile layout (default, < 600px) ------------------------------------- */

.album-header {
  display: flex;
  flex-direction: column;
  gap: 0;                            /* cover and meta are flush; gap added below */
  margin-bottom: var(--space-6);
}

.album-header__cover-wrap {
  /*
   * Break out of the .site-wrapper padding so the image bleeds to both
   * viewport edges.  The negative margin pulls the element out; the width
   * compensates to cover the full viewport.
   */
  margin-left:  calc(-1 * var(--content-padding));
  margin-right: calc(-1 * var(--content-padding));
  width: calc(100% + 2 * var(--content-padding));

  aspect-ratio: 1 / 1;
  overflow: hidden;
  background-color: var(--color-surface);

  /* No border on mobile — edge-to-edge image needs none */
  border: none;
}

.album-header__cover {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.album-header__meta {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding-top: var(--space-5);
  padding-bottom: var(--space-1);
}

/* --- Desktop layout (>= 600px) ------------------------------------------- */

@media (min-width: 600px) {
  .album-header {
    flex-direction: row;
    align-items: flex-start;
    gap: var(--space-6);
    margin-bottom: var(--space-7);
  }

  .album-header__cover-wrap {
    /* Reset the mobile bleed — back to a contained, fixed-width block */
    flex-shrink: 0;
    width: 280px;
    margin-left: 0;
    margin-right: 0;
    border: 1px solid var(--color-border);
    /* aspect-ratio and overflow are still set from the base rule */
  }

  .album-header__meta {
    padding-top: 0;
    justify-content: flex-end;     /* align text to the bottom of the cover */
    padding-bottom: var(--space-1);
  }
}

/* Typography */

.album-header__title {
  font-size: var(--font-size-2xl);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.15;
  color: var(--color-text-primary);
}

@media (min-width: 600px) {
  .album-header__title {
    font-size: var(--font-size-3xl);
  }
}

.album-header__artist {
  font-size: var(--font-size-lg);
  font-weight: 500;
  color: var(--color-text-primary);
  line-height: 1.3;
}

.album-header__year {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  letter-spacing: 0.02em;
}


/* =============================================================================
   ALBUM PAGE — TRACKLIST
   ============================================================================= */

/*
 * .tracklist__heading is hidden via display:none — the element still exists
 * in the DOM (from album.html) but the heading is visually redundant on this
 * page. If you have already removed the <h2> from album.html you can delete
 * this rule entirely; it does no harm either way.
 */
.tracklist__heading {
  display: none;
}

.tracklist__list {
  list-style: none;
  border-top: 1px solid var(--color-border);
}


/* Individual track row */

.track {
  border-bottom: 1px solid var(--color-border);
  padding: var(--space-4) 0 var(--space-3);
}

.track__info {
  display: grid;
  /* number | name | duration */
  grid-template-columns: 22px 1fr auto;
  align-items: baseline;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.track__number {
  font-size: var(--font-size-xs);     /* 13px — quieter than before */
  color: var(--color-text-muted);
  text-align: right;
  font-variant-numeric: tabular-nums;
  opacity: 0.7;
}

.track__name {
  font-size: 1rem;
  font-weight: 500;
  color: var(--color-text-primary);
  line-height: 1.4;
}

.track__duration {
  font-size: var(--font-size-xs);     /* 13px — keeps it out of the way */
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  opacity: 0.8;
}


/* =============================================================================
   CUSTOM AUDIO PLAYER
   Native <audio> is hidden. Controls are a play/pause button + range scrubber.
   ============================================================================= */

/* Play / pause button */
.track__controls {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-2);
}

.track__play-btn {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width:  44px;
  height: 44px;
  padding: 0;
  background: none;
  border: none;
  color: var(--color-text-primary);
  cursor: pointer;
  border-radius: 50%;
  transition: background 150ms ease, color 150ms ease;
}

.track__play-btn:hover {
  background: var(--color-surface);
}

.track__play-btn svg {
  width:  18px;
  height: 18px;
  display: block;
}

/* Scrubber — styled range input */
.track__scrubber {
  --fill: 0%;
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 3px;
  border-radius: 2px;
  cursor: pointer;
  outline: none;
  /* Two-tone background: filled portion dark, unfilled portion border colour */
  background: linear-gradient(
    to right,
    var(--color-accent) var(--fill),
    var(--color-border) var(--fill)
  );
}

/* Thumb — Webkit (Chrome, Safari, iOS) */
.track__scrubber::-webkit-slider-thumb {
  -webkit-appearance: none;
  width:  13px;
  height: 13px;
  border-radius: 50%;
  background: var(--color-accent);
  cursor: pointer;
  transition: transform 120ms ease;
}

.track__scrubber::-webkit-slider-thumb:active {
  transform: scale(1.3);
}

/* Thumb — Firefox */
.track__scrubber::-moz-range-thumb {
  width:  13px;
  height: 13px;
  border-radius: 50%;
  background: var(--color-accent);
  border: none;
  cursor: pointer;
}


/* Error state shown when audio fetch fails */
.load-error {
  grid-column: 1 / -1;
  color: #b00000;
  padding: var(--space-3) 0;
  font-size: var(--font-size-sm);
}


/* Very narrow screens (< 360px) — prevent track info overflow */
@media (max-width: 359px) {
  .track__info {
    grid-template-columns: 18px 1fr auto;
    gap: var(--space-2);
  }
}
