/* Reel News - Story Detail Page */

/* global.css disables scrolling for the feed; the detail page needs it */
body.detail-page {
  height: auto;
  min-height: 100vh;
  overflow-y: auto;
  background-color: #0f1528;
}

.story-detail {
  position: relative;
  isolation: isolate;
  max-width: 800px;
  margin: 0 auto;
  padding: 32px 20px 64px;
  color: #f3f4f6;
}

.story-detail::before {
  content: "";
  position: absolute;
  z-index: -1;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 100vw;
  transform: translateX(-50%);
  background: #132f4d;
}

.detail-lower-background {
  display: flow-root;
  position: relative;
  isolation: isolate;
}

.detail-lower-background::before {
  content: "";
  position: absolute;
  z-index: -1;
  top: 16px;
  bottom: calc(-200px - env(safe-area-inset-bottom, 0px));
  left: 50%;
  width: 100vw;
  transform: translateX(-50%);
  background: #0f1528;
}

.story-detail h1 {
  color: #fff;
  font-size: 36px;
  line-height: 1.15;
  margin: 24px 0 8px;
}

.story-detail h2 {
  color: #fff;
  font-size: 22px;
  margin: 32px 0 8px;
}

.story-detail p {
  line-height: 1.6;
}

.back-link,
.story-detail a {
  color: #4496fb;
}

.story-image {
  display: block;
  width: 100%;
  max-height: 360px;
  object-fit: cover;
  border: 3px solid rgba(255, 255, 255, 0.6);
  border-radius: 8px;
}

.story-meta,
.source-publisher {
  color: #c9ccd3;
  font-size: 14px;
}

.placeholder {
  color: #c9ccd3;
  font-style: italic;
}

.story-sources {
  padding-block-start: 20px;
}

.story-sources-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.story-sources-heading h2 {
  margin: 0;
  font-size: 20px;
}

.story-sources-heading > span,
.story-sources-intro {
  color: #c9ccd3;
  font-size: 14px;
}

.story-sources-intro {
  margin-block: 10px;
}

.source-group {
  margin-block-start: 16px;
  --framing-color: #c8d4e1;
}

.source-group[data-rating="left"],
.source-group[data-rating="lean left"] {
  --framing-color: #60a5fa;
}

.source-group[data-rating="lean right"],
.source-group[data-rating="right"] {
  --framing-color: #ff7779;
}

.source-group[data-rating="left"]       { --needle-angle: -52deg; }
.source-group[data-rating="lean left"]  { --needle-angle: -28deg; }
.source-group[data-rating="lean right"] { --needle-angle: 28deg; }
.source-group[data-rating="right"]      { --needle-angle: 52deg; }

.source-group-heading,
.source-group-heading h3 {
  display: flex;
  align-items: center;
  gap: 8px;
}

.source-group-heading {
  flex-wrap: wrap;
  margin-block-end: 6px;
  color: #c9ccd3;
  font-size: 14px;
}

.source-group-heading h3 {
  margin: 0;
  color: var(--framing-color);
  font-size: 16px;
}

.source-framing-icon {
  position: relative;
  flex-shrink: 0;
  width: 24px;
  height: 14px;
  border: 2px solid currentColor;
  border-bottom: 0;
  border-radius: 16px 16px 0 0;
}

/* Pivot the needle from the bottom center of the meter. */
.source-framing-icon::before {
  position: absolute;
  bottom: 0;
  left: calc(50% - 1px);
  width: 2px;
  height: 9px;
  border-radius: 2px;
  background: currentColor;
  transform: rotate(var(--needle-angle, 0deg));
  transform-origin: center bottom;
  content: "";
}

.source-view-all {
  margin-inline-start: auto;
  padding: 4px;
  border: 0;
  background: transparent;
  color: #75b6ff;
  font: inherit;
  cursor: pointer;
}

.source-view-all:hover {
  text-decoration: underline;
}

.source-list {
  --source-card-width: min(240px, 82%);
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: var(--source-card-width);
  gap: 8px;
  padding: 4px;
  margin: 0 -4px;
  overflow-x: auto;
  scroll-padding-inline: 4px;
  scroll-snap-type: x mandatory;
  list-style: none;
}

.source-list.is-expanded {
  grid-auto-flow: row;
  grid-template-columns: repeat(auto-fill, var(--source-card-width));
  overflow: visible;
  scroll-snap-type: none;
}

.source-list > li {
  min-width: 0;
  scroll-snap-align: start;
}

.source-list .source-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  height: 150px;
  padding: 12px;
  border: 1px solid #3b4657;
  border-radius: 12px;
  background: #182132;
  color: #e7e9ec;
  text-decoration: none;
}

.source-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: #b5c3d5;
}

.source-card-header svg {
  flex-shrink: 0;
}

.source-publisher {
  overflow: hidden;
  color: inherit;
  font-size: 13px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-title {
  display: -webkit-box;
  overflow: hidden;
  font-size: 15px;
  line-height: 1.4;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
}

.source-card:hover .source-title,
.source-card:focus-visible .source-title {
  text-decoration: underline;
}

.source-card:focus-visible,
.source-view-all:focus-visible {
  outline: 2px solid #75b6ff;
  outline-offset: 2px;
}

/* ---------------------------------------------------------
   Story History Navigation
   --------------------------------------------------------- */

/* Position the feed link and history button on opposite sides. */
.detail-navigation {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
}

/* Button linking to the published revision history. */
.history-button {
    display: inline-block;
    padding: 8px 14px;
    border: 1px solid #4496fb;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    transition: background-color 0.2s;
}

.history-button:hover {
    background-color: rgba(255, 179, 185, 0.12);
}

/* Notice displayed when viewing a historical revision. */
.historical-notice {
    background-color: #16293c;
    border: 1px solid #2a4c70;
    border-left: 4px solid #60a5fa;
    border-radius: 6px;
    padding: 16px;
    margin-bottom: 24px;
}

.historical-notice strong {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #93c5fd;
    font-size: 16px;
}

.historical-notice p {
    color: #c9ccd3;
    font-size: 14px;
    margin: 8px 0;
}

.story-detail .historical-notice a {
    color: #60a5fa;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
}

.historical-notice a:hover {
    text-decoration: underline;
}

/* Visible feedback for keyboard navigation. */
.detail-navigation a:focus-visible,
.historical-notice a:focus-visible {
    outline: 2px solid #4496fb;
    outline-offset: 4px;
}

.story-detail-page {
  max-width: 784px;
  padding: 16px 8px 48px;
  font-family: Arial, sans-serif;
  letter-spacing: normal;
}

.story-detail-page .detail-navigation {
  padding-inline: 16px;
  margin-bottom: 16px;
}

.story-detail-page .back-link {
  color: #e4e8ed;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}

.story-detail-page .back-link:hover {
  text-decoration: underline;
}

.story-detail-page .detail-lower-background::before {
  top: 0;
}

.story-overview {
  margin-block-start: 16px;
  padding: 18px 16px 16px;
  border-radius: 12px;
  color: #e7e9ec;
}

.story-overview h1 {
  margin: 0;
  color: inherit;
  font-size: clamp(26px, 4.5vw, 32px);
  line-height: 1.33;
  overflow-wrap: anywhere;
}

.story-overview .story-meta,
.story-overview .story-meta > span,
.story-actions,
.story-actions .history-button {
  display: flex;
  align-items: center;
  gap: 8px;
}

.story-overview .story-meta,
.story-actions {
  flex-wrap: wrap;
}

.story-overview .story-meta {
  margin-block: 12px 14px;
  color: #c8d4e1;
  line-height: 20px;
}

.story-actions .history-button {
  margin-inline-start: auto;
  min-height: 38px;
  padding: 0 8px;
  gap: 4px;
  border-color: rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  color: inherit;
  font-weight: 400;
}

.story-actions .history-button:hover {
  background: #1c3146;
}

.story-actions :is(.bookmark-button, .share-button) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 50%;
  background: #0a1118;
  color: inherit;
}

.story-actions .share-button {
  cursor: pointer;
}

.story-actions :is(.bookmark-button, .share-button):hover {
  background: #1c3146;
}

.story-actions .article-share-status {
  inset-inline-end: auto;
  inset-inline-start: calc(100% + 8px);
  z-index: 1;
}

.story-summary {
  margin-block-start: 20px;
  padding-block-start: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.story-summary h2 {
  margin: 0;
  color: inherit;
  font-size: 19px;
  line-height: 26px;
}

.story-summary p {
  margin-block: 12px 0;
  font-size: 17px;
  line-height: 27px;
}

.story-detail-page .detail-lower-background {
  margin-block-start: 16px;
  padding-inline: 16px;
}
