:root {
  /* Fallback for mobile viewport units; JS updates this on resize */
  --vh: 1vh;
  /* Fixed element heights measured by JS */
  --player-h: 60px;
  --footer-h: 60px;
  /* Proportional edge gap: scales with viewport height, clamped for usability */
  --edge-gap: clamp(0.75rem, 2.5vh, 2.5rem);
  /* Unified width system: content multiplier (decimal) and horizontal inset */
  --content-w: 1;
  --h-inset: 2rem;
  /* Color scheme - Cosmic theme */
  --color-bg-primary: #0a0a0f;
  --color-bg-secondary: rgb(10 10 15 / 70%);
  --color-text-primary: #e0e0e0;
  --color-text-secondary: rgb(224 224 224 / 85%);
  --color-text-muted: rgb(224 224 224 / 60%);
  --color-border: rgb(0 212 255 / 10%);
  --color-interactive-bg: rgb(0 212 255 / 15%);
  --color-interactive-bg-hover: rgb(0 212 255 / 25%);
  --color-accent: #00d4ff;
}

/* =============================================
   Responsive Styles for simonlowes.com
   Breakpoints: 480px, 768px, 1024px
   ============================================= */

/* ----- Base / Mobile-first ----- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  overflow-x: hidden; /* prevent horizontal scroll */
  overflow-y: auto;
  background: transparent; /* Allow canvas starfield to show through */
}

/* ----- Canvas background ----- */
canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  height: calc(var(--vh, 1vh) * 100);
  z-index: 0;
  pointer-events: none;
}

/* ----- Skip to main content link (accessibility) ----- */
/* Uses clip-path visually-hidden pattern - works regardless of parent positioning */
.skip-link {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link:focus {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  width: auto;
  height: auto;
  padding: 0.75rem 1.5rem;
  margin: 0;
  overflow: visible;
  clip-path: none;
  white-space: normal;
  z-index: 10000;
  background: rgb(0 212 255 / 95%);
  color: #0a0a0f;
  border-radius: 999px;
  font-weight: 600;
  text-decoration: none;
  box-shadow: 0 6px 20px rgb(0 0 0 / 40%);
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* ----- Main content wrapper ----- */
.content-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: stretch;
  align-items: center;
  position: relative;
  z-index: 1; /* above canvas */

  /* Match audio player + footer width system */
  width: calc((100% - var(--h-inset)) * var(--content-w));
  max-width: calc((1200px - var(--h-inset)) * var(--content-w));
  margin: 0 auto;

  /* Keep vertical spacing only (avoid skewing widths) */
  padding-left: 0;
  padding-right: 0;

  /* Dynamic padding: edge gap + element height + inner gap + safe areas */
  padding-top: calc(var(--edge-gap) + var(--player-h) + var(--edge-gap) + env(safe-area-inset-top));
  padding-bottom: calc(
    var(--edge-gap) + var(--footer-h) + var(--edge-gap) + env(safe-area-inset-bottom)
  );
  min-height: 0;
}

/* ----- Blog panel (replaces Posthaven iframe) ----- */
/* Fill the wrapper exactly (wrapper already matches audio/footer widths) */
#blog-slot {
  width: 100%;
}

/* ----- Footer ----- */
footer {
  position: fixed;
  bottom: calc(var(--edge-gap) + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  /* Unified width: percentage of available space after inset */
  width: calc((100% - var(--h-inset)) * var(--content-w));
  max-width: calc((1200px - var(--h-inset)) * var(--content-w));
  text-align: center;
  /* No background box - icons float freely */
  background: transparent;
  border: none;
  border-radius: 0;
  /* Responsive padding for very small screens */
  padding: calc(clamp(0.5rem, 2vw, 0.75rem) + env(safe-area-inset-bottom))
    clamp(0.25rem, 1vw, 0.5rem) clamp(0.5rem, 2vw, 0.75rem);
  color: #fff;
  z-index: 100;
}

footer nav ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: nowrap; /* Force single row */
  justify-content: center;
  align-items: center;
  gap: clamp(0.25rem, 1.5vw, 0.5rem);
}

footer nav ul li {
  display: flex;
}

footer nav ul li a {
  display: flex;
  justify-content: center;
  align-items: center;
  color: #fff;
  text-decoration: none;
  padding: clamp(0.125rem, 1vw, 0.25rem);
  /* Allow flex items to shrink below content size (MDN: min-width auto prevents shrinking) */
  min-width: 0;
  min-height: 44px; /* Maintain vertical tap target for accessibility */
  border-radius: 8px;
  transition:
    background 0.2s ease,
    transform 0.15s ease;
}

footer nav ul li a:hover,
footer nav ul li a:focus {
  /* No background box - just scale */
  transform: scale(1.1);
}

footer nav ul li a:focus {
  outline: 2px solid #fff;
  outline-offset: 3px;
}

footer nav ul li a:focus:not(:focus-visible) {
  outline: none;
}

footer nav ul li a:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
}

/* Brand colors on hover - official hex colors */
/* Bandcamp: #629aa9 (teal) */
footer nav ul li a[data-social="bandcamp"]:hover img {
  filter: brightness(0) saturate(100%) invert(58%) sepia(18%) saturate(683%) hue-rotate(148deg)
    brightness(94%) contrast(89%) drop-shadow(0 0 8px #629aa9);
}
/* Spotify: #1DB954 (green) */
footer nav ul li a[data-social="spotify"]:hover img {
  filter: brightness(0) saturate(100%) invert(53%) sepia(94%) saturate(421%) hue-rotate(101deg)
    brightness(91%) contrast(87%) drop-shadow(0 0 8px #1db954);
}
/* Apple Music: #FA57C1 (pink) */
footer nav ul li a[data-social="apple-music"]:hover img {
  filter: brightness(0) saturate(100%) invert(48%) sepia(96%) saturate(1547%) hue-rotate(300deg)
    brightness(98%) contrast(97%) drop-shadow(0 0 8px #fa57c1);
}
/* YouTube Music: #FF0000 (red) */
footer nav ul li a[data-social="youtube-music"]:hover img {
  filter: brightness(0) saturate(100%) invert(12%) sepia(97%) saturate(7471%) hue-rotate(4deg)
    brightness(104%) contrast(117%) drop-shadow(0 0 8px #f00);
}
/* YouTube: #FF0000 (red) */
footer nav ul li a[data-social="youtube"]:hover img {
  filter: brightness(0) saturate(100%) invert(12%) sepia(97%) saturate(7471%) hue-rotate(4deg)
    brightness(104%) contrast(117%) drop-shadow(0 0 8px #f00);
}
/* Instagram: #E4405F (gradient pink - using primary) */
footer nav ul li a[data-social="instagram"]:hover img {
  filter: brightness(0) saturate(100%) invert(36%) sepia(69%) saturate(2234%) hue-rotate(326deg)
    brightness(95%) contrast(93%) drop-shadow(0 0 8px #e4405f);
}

/* Icon sizing */
footer nav ul li a img {
  /* Responsive icon size: min 24px, preferred 5vw, max 32px */
  width: clamp(24px, 5vw, 32px);
  height: clamp(24px, 5vw, 32px);
  object-fit: contain;
  transition: filter 0.3s ease;
}

/* ----- Tablet (480px+) ----- */
@media (width >= 480px) {
  :root {
    --content-w: 0.9;
    --h-inset: 3rem;
  }

  .content-wrapper {
    padding-top: calc(
      var(--edge-gap) + var(--player-h) + var(--edge-gap) + env(safe-area-inset-top)
    );
    padding-bottom: calc(
      var(--edge-gap) + var(--footer-h) + var(--edge-gap) + env(safe-area-inset-bottom)
    );
  }

  footer ul {
    gap: clamp(0.375rem, 2vw, 0.75rem);
  }

  footer nav ul li a img {
    width: clamp(28px, 5.5vw, 36px);
    height: clamp(28px, 5.5vw, 36px);
  }
}

/* ----- Tablet landscape / small desktop (768px+) ----- */
@media (width >= 768px) {
  :root {
    --content-w: 0.75;
    --h-inset: 4rem;
  }

  .content-wrapper {
    padding-top: calc(
      var(--edge-gap) + var(--player-h) + var(--edge-gap) + env(safe-area-inset-top)
    );
    padding-bottom: calc(
      var(--edge-gap) + var(--footer-h) + var(--edge-gap) + env(safe-area-inset-bottom)
    );
  }

  footer ul {
    gap: clamp(0.5rem, 2vw, 1rem);
  }

  footer nav ul li a img {
    width: clamp(32px, 5vw, 40px);
    height: clamp(32px, 5vw, 40px);
  }
}

/* ----- Desktop (1024px+) ----- */
@media (width >= 1024px) {
  :root {
    --content-w: 0.7;
  }

  .content-wrapper {
    padding-top: calc(
      var(--edge-gap) + var(--player-h) + var(--edge-gap) + env(safe-area-inset-top)
    );
    padding-bottom: calc(
      var(--edge-gap) + var(--footer-h) + var(--edge-gap) + env(safe-area-inset-bottom)
    );
  }

  footer ul {
    gap: clamp(0.75rem, 2vw, 1.25rem);
  }

  footer nav ul li a img {
    width: clamp(36px, 4vw, 44px);
    height: clamp(36px, 4vw, 44px);
  }
}

/* =============================================
   Audio Player Component
   ============================================= */

.audio-player {
  position: fixed;
  top: calc(var(--edge-gap) + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  /* Unified width: percentage of available space after inset */
  width: calc((100% - var(--h-inset)) * var(--content-w));
  max-width: calc((1200px - var(--h-inset)) * var(--content-w));
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: rgb(15 15 15 / 18%);
  border: 1px solid rgb(255 255 255 / 8%);
  border-radius: 12px;
  z-index: 99;
  font-family: "freight-sans-pro", "Helvetica Neue", Helvetica, Arial, sans-serif;
}

/* Hide player gracefully if audio fails */
.audio-player--error {
  opacity: 0.5;
  pointer-events: none;
}

.audio-player--error::after {
  content: "Audio unavailable";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: rgb(255 255 255 / 70%);
  font-size: 0.875rem;
}

/* Play/Pause Button */
.audio-player__play {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgb(255 255 255 / 15%);
  color: #fff;
  cursor: pointer;
  transition:
    background 0.2s ease,
    transform 0.15s ease;
  flex-shrink: 0;
}

.audio-player__play:hover {
  background: rgb(255 255 255 / 25%);
  transform: scale(1.05);
}

.audio-player__play:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
}

.audio-player__play svg {
  width: 24px;
  height: 24px;
}

/* Show/hide play vs pause icons */
.audio-player__play .icon-pause {
  display: none;
}

.audio-player__play[aria-pressed="true"] .icon-play {
  display: none;
}

.audio-player__play[aria-pressed="true"] .icon-pause {
  display: block;
}

/* Time Display */
.audio-player__time {
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
  color: rgb(255 255 255 / 85%);
  min-width: 3rem;
  text-align: center;
  flex-shrink: 0;
}

.audio-player__time--remaining {
  color: rgb(255 255 255 / 60%);
}

/* Seek Slider */
.audio-player__seek {
  flex: 1;
  min-width: 80px;
  max-width: 300px;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: rgb(255 255 255 / 20%);
  border-radius: 3px;
  cursor: pointer;
}

.audio-player__seek::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
  transition: transform 0.15s ease;
}

.audio-player__seek::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border: none;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
}

.audio-player__seek:hover::-webkit-slider-thumb {
  transform: scale(1.2);
}

.audio-player__seek:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
}

/* Volume Controls Container */
.audio-player__volume {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  flex-shrink: 0;
}

/* Mute Button */
.audio-player__mute {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: rgb(255 255 255 / 85%);
  cursor: pointer;
  transition:
    background 0.2s ease,
    color 0.2s ease;
}

.audio-player__mute:hover {
  background: rgb(255 255 255 / 10%);
  color: #fff;
}

.audio-player__mute:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
}

.audio-player__mute svg {
  width: 20px;
  height: 20px;
}

/* Show/hide volume vs muted icons */
.audio-player__mute .icon-muted {
  display: none;
}

.audio-player__mute[aria-pressed="true"] .icon-volume {
  display: none;
}

.audio-player__mute[aria-pressed="true"] .icon-muted {
  display: block;
}

/* Volume Slider */
.audio-player__volume-slider {
  width: 60px;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: rgb(255 255 255 / 20%);
  border-radius: 2px;
  cursor: pointer;
}

.audio-player__volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
}

.audio-player__volume-slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border: none;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
}

.audio-player__volume-slider:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
}

/* ----- Audio Player Responsive ----- */

/* Mobile: stack and simplify */
@media (width <= 479px) {
  .audio-player {
    gap: 0.375rem;
    padding: 0.5rem;
  }

  .audio-player__play {
    width: 40px;
    height: 40px;
  }

  .audio-player__play svg {
    width: 20px;
    height: 20px;
  }

  .audio-player__time {
    font-size: 0.75rem;
    min-width: 2.5rem;
  }

  .audio-player__seek {
    min-width: 60px;
    max-width: 120px;
  }

  .audio-player__volume-slider {
    width: 40px;
  }

  .audio-player__mute {
    width: 32px;
    height: 32px;
  }

  .audio-player__mute svg {
    width: 18px;
    height: 18px;
  }
}

/* Tablet and up: more space for seek bar */
@media (width >= 480px) {
  .audio-player {
    gap: 0.75rem;
    padding: 0.625rem 1rem;
  }

  .audio-player__seek {
    max-width: 400px;
  }

  .audio-player__volume-slider {
    width: 80px;
  }
}

/* Desktop: full-width seek bar */
@media (width >= 768px) {
  .audio-player {
    gap: 1rem;
  }

  .audio-player__seek {
    max-width: 500px;
  }

  .audio-player__volume-slider {
    width: 100px;
  }
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  .audio-player__play,
  .audio-player__mute,
  .audio-player__seek::-webkit-slider-thumb {
    transition: none;
  }

  .audio-player__play:hover,
  .audio-player__seek:hover::-webkit-slider-thumb {
    transform: none;
  }
}

/* =============================================
   Blog Prose Typography (AstroPaper-inspired)
   ============================================= */

.prose {
  color: #fff;
  font-family: "freight-sans-pro", "Helvetica Neue", Helvetica, Arial, sans-serif;
  line-height: 1.7;
}

.prose h1 {
  font-size: 2rem;
  font-weight: 700;
  margin: 0 0 1.5rem;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.prose h2 {
  font-size: 1.5rem;
  font-weight: 650;
  margin: 2rem 0 0.75rem;
  line-height: 1.3;
}

.prose h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 1.75rem 0 0.5rem;
  line-height: 1.4;
}

.prose h4 {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 1.5rem 0 0.5rem;
}

.prose p {
  margin: 1rem 0;
}

.prose a {
  color: #fff;
  text-decoration: underline;
  text-underline-offset: 0.2em;
  transition: opacity 0.15s ease;
}

.prose a:hover {
  opacity: 0.8;
}

.prose strong {
  font-weight: 650;
}

.prose em {
  font-style: italic;
}

.prose ul,
.prose ol {
  margin: 1rem 0;
  padding-left: 1.5rem;
}

.prose li {
  margin: 0.5rem 0;
}

.prose ul li {
  list-style-type: disc;
}

.prose ol li {
  list-style-type: decimal;
}

.prose blockquote {
  margin: 1.5rem 0;
  padding: 0.75rem 1rem 0.75rem 1.25rem;
  border-left: 3px solid rgb(255 255 255 / 40%);
  background: rgb(255 255 255 / 5%);
  border-radius: 0 8px 8px 0;
  font-style: italic;
}

.prose blockquote p {
  margin: 0;
}

.prose code {
  font-family: "SF Mono", Monaco, "Cascadia Code", "Roboto Mono", Menlo, monospace;
  font-size: 0.9em;
  background: rgb(255 255 255 / 10%);
  padding: 0.15em 0.4em;
  border-radius: 4px;
}

.prose pre {
  margin: 1.5rem 0;
  padding: 1rem 1.25rem;
  background: rgb(0 0 0 / 40%);
  border: 1px solid rgb(255 255 255 / 10%);
  border-radius: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.prose pre code {
  background: none;
  padding: 0;
  font-size: 0.875rem;
  line-height: 1.6;
}

.prose hr {
  margin: 2rem 0;
  border: none;
  border-top: 1px solid rgb(255 255 255 / 15%);
}

.prose img {
  max-width: 100%;
  height: auto;
  margin: 1.5rem 0;
  border-radius: 8px;
}

.prose figure {
  margin: 1.5rem 0;
}

.prose figcaption {
  margin-top: 0.5rem;
  font-size: 0.9rem;
  opacity: 0.75;
  text-align: center;
}

.prose table {
  width: 100%;
  margin: 1.5rem 0;
  border-collapse: collapse;
}

.prose th,
.prose td {
  padding: 0.75rem;
  border: 1px solid rgb(255 255 255 / 15%);
  text-align: left;
}

.prose th {
  background: rgb(255 255 255 / 5%);
  font-weight: 600;
}

/* Blog navigation */
.blog-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid rgb(255 255 255 / 10%);
}

.blog-nav a {
  color: #fff;
  text-decoration: none;
  opacity: 0.75;
  transition: opacity 0.15s ease;
}

.blog-nav a:hover {
  opacity: 1;
}

.blog-nav--footer {
  margin-top: 2rem;
  margin-bottom: 0;
  padding-top: 1rem;
  padding-bottom: 0;
  border-top: 1px solid rgb(255 255 255 / 8%);
  border-bottom: none;
}

/* Blog post header */
.blog-header {
  margin-bottom: 2rem;
}

.blog-header__title {
  font-size: 2rem;
  font-weight: 700;
  margin: 0 0 0.75rem;
  line-height: 1.2;
}

.blog-header__meta {
  font-size: 0.9rem;
  opacity: 0.7;
}

/* Blog post list */
.blog-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.blog-list__item {
  padding: 1rem 0;
  border-bottom: 1px solid rgb(255 255 255 / 8%);
}

.blog-list__item:last-child {
  border-bottom: none;
}

.blog-list__link {
  display: block;
  color: #fff;
  text-decoration: none;
  transition: opacity 0.15s ease;
}

.blog-list__link:hover {
  opacity: 0.8;
}

.blog-list__title {
  font-size: 1.2rem;
  font-weight: 600;
  margin: 0 0 0.25rem;
}

.blog-list__date {
  font-size: 0.85rem;
  opacity: 0.6;
}

.blog-list__description {
  margin: 0.5rem 0 0;
  font-size: 0.95rem;
  opacity: 0.85;
  line-height: 1.5;
}
