/*
 * Additions for the static archive, on top of the agatha theme's compiled custom.css.
 * Theme source is theme/scss (compiled to custom.css); this file is only for archive-specific bits.
 */

/*
 * No focus outline on mouse click (e.g. heading links), but keep it for keyboard users.
 * Vanilla did this with its focus-visible polyfill script (.js-focus-visible), which the archive doesn't load.
 */
:focus:not(:focus-visible) {
  outline: none;
}

/*
 * YouTube previews in posts: a thumbnail with a play button; site.js swaps in the player on click.
 * The play button replaces Vanilla's overlay image, which was loaded from Vanilla's CDN.
 */
.userContent .VideoPreview img {
  display: block;
  max-width: 100%;
  height: auto;
}

.Video.YouTube .VideoPreview::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 68px;
  height: 48px;
  margin: -24px 0 0 -34px;
  border-radius: 12px;
  background: rgba(33, 33, 33, 0.8) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 68 48'%3E%3Cpath d='M27 15v18l16-9z' fill='%23fff'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
  transition: background-color 0.15s ease;
  pointer-events: none;
}

.Video.YouTube .VideoPreview:hover::after,
.Video.YouTube .VideoPreview:focus-within::after {
  background-color: #d71f3b;
  background-position: center; /* Vanilla's hover rule moves the old sprite */
}

/* Playlists: no thumbnail, so a dark 16:9 panel with the play button and a label. */
.Video.YouTube.Playlist .VideoPreview,
.Video.YouTube.Playlist .VideoPreview a {
  display: block;
  width: 640px;
  max-width: 100%;
  aspect-ratio: 16 / 9;
}

.Video.YouTube.Playlist .VideoPreview a {
  position: relative;
  background: #1a1a1a;
  color: #fff;
  text-decoration: none;
}

.Video.YouTube .VideoPlaylistLabel {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(50% + 36px);
  text-align: center;
  font-size: 15px;
}

/* Shown under a video when it's clicked without marketing-cookie consent (site.js). */
.Video.YouTube .VideoConsent {
  display: block;
  max-width: 640px;
  box-sizing: border-box;
  margin-top: 8px;
  padding: 14px 16px;
  border: 1px solid #d3d4d5;
  border-radius: 6px;
  background: #f7f7f7;
  color: #5f6065;
  line-height: 1.5;
}

.Video.YouTube .VideoConsent-button {
  margin: 6px 12px 0 0;
  padding: 6px 14px;
  border: 0;
  border-radius: 6px;
  background: #d71f3b;
  color: #fff;
  font: inherit;
  cursor: pointer;
}

.Video.YouTube .VideoConsent-button:hover,
.Video.YouTube .VideoConsent-button:focus-visible {
  background: #b31a31;
}

/* Images in posts hosted on other sites: shown only after marketing-cookie consent (site.js). */
.userContent .ExternalImage,
.userContent .ImageUnavailable {
  display: inline-block;
  max-width: 100%;
  box-sizing: border-box;
  margin: 2px 0;
  padding: 6px 10px;
  border: 1px dashed #d3d4d5;
  border-radius: 6px;
  background: #f7f7f7;
  color: #5f6065;
  font-size: 0.9em;
  line-height: 1.5;
}

.userContent .ExternalImage-settings {
  margin: 0 8px 0 0;
  padding: 0;
  border: 0;
  background: none;
  color: #d71f3b;
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

/* Spam comments replaced on export (tools/export/spam.mjs). */
.userContent .CommentRemoved {
  margin: 0;
  color: #5f6065;
  font-style: italic;
}

/* Videos that have been removed from YouTube. */
.Video.YouTube .VideoUnavailable {
  display: block;
  max-width: 640px;
  padding: 18px 20px;
  border: 1px solid #d3d4d5;
  border-radius: 6px;
  background: #f7f7f7;
  color: #5f6065;
}

.Video.YouTube .VideoPlayer {
  display: block;
  width: 640px;
  max-width: 100%;
  aspect-ratio: 16 / 9;
  height: auto;
  border: 0;
}

/* @mentions: profiles aren't part of the archive, so mentions are styled text in the brand colour. */
.userContent .UserLink {
  color: #d71f3b;
}

.userContent img {
  max-width: 100%;
  height: auto;
}

/* Keep text before and after an image in a post from crowding it. This has to outrank
   style-compat.css's `.userContent > :not(.emoji):first-child:not(br)` (-0.25em !important) and
   `:not(:last-child)` (14px) rules, which assume an element starts or ends the post even when text
   runs on either side of it. */
.MessageList .Message.userContent img {
  margin: 15px 0 !important;
}

/* Emoji sit in the line of text; YouTube thumbnails get the spacing on their wrapper (below). */
.MessageList .Message.userContent img[src^="/assets/emoji/"],
.MessageList .Message.userContent .VideoPreview img {
  margin: 0 !important;
}

.userContent .Video {
  display: block;
  margin: 15px 0;
}

/* Pagefind search UI, coloured to match the theme. */
.ArchiveSearch {
  --pagefind-ui-scale: 0.9;
  --pagefind-ui-primary: #000;
  --pagefind-ui-text: #000;
  --pagefind-ui-border: #d8d8d8;
  --pagefind-ui-tag: #f2f2f2;
  --pagefind-ui-border-radius: 0;
  --pagefind-ui-font: inherit;
  margin-top: 1.5em;
}

#ArchiveSearch .pagefind-ui__result-link {
  color: inherit;
}

/* Search field: rounded like the old forum's search box, magnifying glass on the left, × on the right. */
#ArchiveSearch .pagefind-ui__form {
  position: relative;
}

/* Replace Pagefind's left-hand icon with the theme's vanillicon magnifying glass. */
#ArchiveSearch .pagefind-ui__form::before {
  display: none;
}

#ArchiveSearch .pagefind-ui__form::after {
  content: "\f18e";
  font-family: vanillicon;
  font-style: normal;
  font-weight: 400;
  font-size: 19px;
  -webkit-font-smoothing: antialiased;
  color: #494a50;
  position: absolute;
  top: 0;
  left: 0;
  width: 46px;
  height: 48px;
  line-height: 48px;
  text-align: center;
  pointer-events: none;
}

#ArchiveSearch .pagefind-ui__search-input {
  height: 48px;
  padding: 3px 50px 3px 46px !important; /* Pagefind sets padding inline */
  border: 1px solid #999;
  border-radius: 8px;
  background: #fff;
  color: #000;
  font-size: 18px;
  font-weight: 400;
}

#ArchiveSearch .pagefind-ui__search-input:focus {
  outline: none;
  border-color: #494a50;
}

/* "Clear" becomes an × at the right edge. The text stays as its accessible name. */
#ArchiveSearch .pagefind-ui__search-clear {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #494a50;
  font-size: 0;
  line-height: 36px;
  text-align: center;
  cursor: pointer;
}

#ArchiveSearch .pagefind-ui__search-clear::before {
  content: "\00d7";
  font-size: 28px;
  line-height: 34px; /* the × glyph sits low; this centres it vertically */
}

#ArchiveSearch .pagefind-ui__search-clear:hover,
#ArchiveSearch .pagefind-ui__search-clear:focus-visible {
  background: #f2f2f2;
}


/* Filter heading ("Category"): no focus outline; chevron that flips about its own centre. */
#ArchiveSearch .pagefind-ui__filter-name {
  outline: none;
}

#ArchiveSearch .pagefind-ui__filter-name:focus-visible {
  text-decoration: underline; /* a subtle cue for keyboard users instead of the outline */
}

#ArchiveSearch .pagefind-ui__filter-name::after {
  top: 50%;
  right: 4px;
  width: 12px;
  height: 12px;
  margin-top: -6px;
  border: 0;
  background-color: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' fill='none' stroke='%23000' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' fill='none' stroke='%23000' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
  transform: none;
  transform-origin: 50% 50%;
  transition: transform 0.2s ease;
}

#ArchiveSearch .pagefind-ui__filter-block[open] .pagefind-ui__filter-name::after {
  transform: rotate(180deg);
}

/* Result titles in bold. */
#ArchiveSearch .pagefind-ui__result-title,
#ArchiveSearch .pagefind-ui__result-title a {
  font-weight: 700;
}

/* "Load more results": solid red button. */
#ArchiveSearch .pagefind-ui__button {
  border: 0;
  outline: none;
  margin-bottom: 30px; /* with the 18px above the footer, leaves a 48px gap */
  background: #d71f3b;
  color: #fff;
}

#ArchiveSearch .pagefind-ui__button:hover,
#ArchiveSearch .pagefind-ui__button:focus-visible {
  background: rgb(194, 29, 53);
}

/* Search-term highlight: a paler yellow than the browser default. */
#ArchiveSearch mark {
  background: #fff4a8;
  color: inherit;
}
