:root {
  --accent: #0b4db3;
  --background: #ffffff;
  --text: #0f172a;

  --muted: color-mix(
    in srgb,
    var(--text) 62%,
    transparent
  );

  --soft-muted: color-mix(
    in srgb,
    var(--text) 48%,
    transparent
  );

  --border: color-mix(
    in srgb,
    var(--text) 12%,
    transparent
  );

  --card-background: color-mix(
    in srgb,
    var(--accent) 9%,
    var(--background)
  );

  --shadow:
    0 8px 24px
    color-mix(
      in srgb,
      var(--text) 10%,
      transparent
    );
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: transparent;
  color: var(--text);
  font-family:
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

body.modal-open {
  overflow: hidden;
}

button,
input {
  font: inherit;
}

.hidden {
  display: none !important;
}

#libraryRoot {
  width: 100%;
  padding: 14px 0 40px;
}

/* =========================================================
   LOADING AND ERROR STATES
   ========================================================= */

.library-state {
  width: min(1180px, calc(100% - 36px));
  min-height: 220px;
  margin: 20px auto;
  padding: 30px;

  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;

  border: 1px solid var(--border);
  border-radius: 20px;

  background: var(--card-background);
  color: var(--muted);
  text-align: center;
}

.library-state h1,
.library-state p {
  margin: 0;
}

.loader {
  width: 36px;
  height: 36px;

  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 999px;

  animation: library-spin 800ms linear infinite;
}

@keyframes library-spin {
  to {
    transform: rotate(360deg);
  }
}

/* =========================================================
   SEARCH
   ========================================================= */

.sermon-search {
  width: min(1180px, 100%);
  margin: 0 auto 24px;
  padding: 0 18px;
}

.search-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.search-icon {
  width: 54px;
  height: 54px;
  flex: 0 0 auto;

  display: grid;
  place-items: center;

  border-radius: 999px;

  background: var(--accent);
  color: #ffffff;

  box-shadow:
    0 8px 18px
    color-mix(
      in srgb,
      var(--accent) 24%,
      transparent
    );
}

.search-icon svg {
  width: 26px;
  height: 26px;
}

.search-field {
  min-width: 0;
  flex: 1 1 auto;
}

.search-field input {
  width: 100%;
  padding: 6px 0 14px;

  border: 0;
  outline: 0;

  background: transparent;
  color: var(--text);

  font-size: clamp(28px, 5vw, 42px);
  font-weight: 650;
}

.search-field input::placeholder {
  color: color-mix(
    in srgb,
    var(--text) 16%,
    transparent
  );
}

.search-underline {
  width: 100%;
  height: 2px;

  border-radius: 999px;

  background: color-mix(
    in srgb,
    var(--text) 10%,
    transparent
  );
}

/* =========================================================
   SECTIONS
   ========================================================= */

.library-section {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 12px 18px 20px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;

  margin: 4px 0 16px;
}

.section-header h1,
.section-header h2 {
  margin: 0;

  color: var(--text);

  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.025em;
}

.section-header h1 {
  font-size: clamp(40px, 6vw, 56px);
}

.section-header h2 {
  font-size: clamp(32px, 5vw, 44px);
}

/* =========================================================
   HORIZONTAL RAILS
   ========================================================= */

.rail-wrap {
  position: relative;
}

.message-rail {
  display: flex;
  gap: 14px;

  overflow-x: auto;
  overscroll-behavior-inline: contain;

  padding: 6px 4px 18px;

  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

.message-rail::-webkit-scrollbar {
  height: 10px;
}

.message-rail::-webkit-scrollbar-thumb {
  border-radius: 999px;

  background: color-mix(
    in srgb,
    var(--text) 12%,
    transparent
  );
}

.rail-arrow {
  position: absolute;
  top: 42%;
  z-index: 5;

  width: 44px;
  height: 44px;

  display: grid;
  place-items: center;

  border: 0;
  border-radius: 999px;

  background: color-mix(
    in srgb,
    var(--accent) 93%,
    transparent
  );

  color: #ffffff;

  font-size: 25px;
  font-weight: 900;
  line-height: 1;

  cursor: pointer;

  box-shadow:
    0 10px 24px
    color-mix(
      in srgb,
      var(--accent) 22%,
      transparent
    );

  transform: translateY(-50%);
}

.rail-arrow.left {
  left: -12px;
}

.rail-arrow.right {
  right: -12px;
}

.rail-arrow:hover {
  filter: brightness(1.05);
}

.rail-arrow:active {
  transform:
    translateY(-50%)
    scale(0.97);
}

/* =========================================================
   MESSAGE CARDS
   ========================================================= */

.message-card {
  flex: 0 0 420px;
  min-width: 0;

  padding: 14px;

  overflow: hidden;

  border: 1px solid var(--border);
  border-radius: 20px;

  background: var(--card-background);

  box-shadow: var(--shadow);

  scroll-snap-align: start;
  cursor: pointer;

  transition:
    transform 150ms ease,
    border-color 150ms ease;
}

.message-card:hover,
.message-card:focus {
  border-color: var(--accent);
  outline: none;

  transform: translateY(-3px);
}

.message-thumbnail {
  position: relative;

  overflow: hidden;

  aspect-ratio: 16 / 9;

  border: 1px solid var(--border);
  border-radius: 14px;

  background: color-mix(
    in srgb,
    var(--accent) 12%,
    #000000
  );
}

.message-thumbnail img {
  width: 100%;
  height: 100%;

  display: block;
  object-fit: cover;

  transition: transform 220ms ease;
}

.message-card:hover .message-thumbnail img,
.series-card:hover .message-thumbnail img {
  transform: scale(1.025);
}

.message-play {
  position: absolute;
  inset: 50% auto auto 50%;

  width: 52px;
  height: 52px;

  display: grid;
  place-items: center;

  padding-left: 3px;

  border-radius: 999px;

  background: var(--accent);
  color: #ffffff;

  box-shadow:
    0 12px 28px rgba(0, 0, 0, 0.28);

  transform: translate(-50%, -50%);
}

.message-card h3 {
  margin: 11px 0 0;

  color: var(--text);

  font-size: 22px;
  font-weight: 900;
  line-height: 1.15;
}

.message-series,
.message-speaker {
  display: block;

  margin-top: 4px;

  font-size: 15px;
  font-weight: 650;
}

.message-series {
  color: var(--muted);
}

.message-speaker {
  color: var(--soft-muted);
}

.message-date {
  margin-top: 7px;

  color: var(--soft-muted);

  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}

/* =========================================================
   SERIES CARDS
   ========================================================= */

.series-card {
  flex: 0 0 320px;
  min-width: 0;

  padding: 14px;

  overflow: hidden;

  border: 1px solid var(--border);
  border-radius: 20px;

  background: var(--card-background);

  box-shadow: var(--shadow);

  scroll-snap-align: start;
  cursor: pointer;

  transition:
    transform 150ms ease,
    border-color 150ms ease;
}

.series-card:hover,
.series-card:focus {
  border-color: var(--accent);
  outline: none;

  transform: translateY(-3px);
}

.series-card h3 {
  margin: 11px 0 2px;

  color: var(--text);

  font-size: 19px;
  font-weight: 900;
  line-height: 1.2;
}

/* =========================================================
   SEARCH AND SERIES RESULTS
   ========================================================= */

.search-results-grid {
  display: grid;

  grid-template-columns:
    repeat(3, minmax(0, 1fr));

  gap: 18px;
}

.search-results-grid .message-card {
  width: 100%;
  min-width: 0;
  flex: initial;
}

/* =========================================================
   VIDEO MODAL
   ========================================================= */

.video-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;

  display: grid;
  place-items: center;

  padding: 24px;

  background: rgba(0, 0, 0, 0.9);
}

.video-frame {
  width: min(1100px, 100%);
  aspect-ratio: 16 / 9;

  overflow: hidden;

  border-radius: 16px;

  background: #000000;

  box-shadow:
    0 24px 80px rgba(0, 0, 0, 0.5);
}

.video-frame iframe {
  width: 100%;
  height: 100%;

  display: block;

  border: 0;
}

.modal-close {
  position: fixed;
  top: 18px;
  right: 22px;
  z-index: 1001;

  width: 48px;
  height: 48px;

  display: grid;
  place-items: center;

  padding: 0;

  border: 0;
  border-radius: 999px;

  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;

  font-size: 38px;
  font-weight: 300;
  line-height: 1;

  cursor: pointer;
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* =========================================================
   TABLET
   ========================================================= */

@media (max-width: 900px) {
  .message-card {
    flex-basis: 360px;
  }

  .series-card {
    flex-basis: 290px;
  }

  .search-results-grid {
    grid-template-columns:
      repeat(2, minmax(0, 1fr));
  }
}

/* =========================================================
   MOBILE
   ========================================================= */

@media (max-width: 700px) {
  #libraryRoot {
    padding-top: 10px;
  }

  .sermon-search,
  .library-section {
    padding-left: 14px;
    padding-right: 14px;
  }

  .search-row {
    gap: 11px;
  }

  .search-icon {
    width: 46px;
    height: 46px;
  }

  .search-icon svg {
    width: 23px;
    height: 23px;
  }

  .section-header h1 {
    font-size: 40px;
  }

  .section-header h2 {
    font-size: 34px;
  }

  .message-card {
    flex-basis: 82vw;
  }

  .series-card {
    flex-basis: 74vw;
  }

  .rail-arrow {
    width: 42px;
    height: 42px;
  }

  .rail-arrow.left {
    left: -5px;
  }

  .rail-arrow.right {
    right: -5px;
  }

  .search-results-grid {
    grid-template-columns: 1fr;
  }

  .video-modal {
    padding: 14px;
  }

  .modal-close {
    top: 10px;
    right: 10px;
  }
}

@media (max-width: 420px) {
  .message-card {
    flex-basis: 86vw;
  }

  .series-card {
    flex-basis: 78vw;
  }

  .message-card h3 {
    font-size: 20px;
  }
}