/* 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;
}

.source-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.source-list li {
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

.source-publisher {
  display: block;
}

.source-details {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem 0.6rem;
  margin-top: 0.25rem;
}

.source-framing-badge {
  --badge-gold: #dfa528;
  --badge-paper: #fff8e9;
  --badge-ink: #253447;
  --badge-icon: #253447;
  --badge-shape: polygon(
    0.6rem 0, calc(100% - 0.6rem) 0, 100% 0.6rem,
    100% calc(100% - 0.6rem), calc(100% - 0.6rem) 100%,
    0.6rem 100%, 0 calc(100% - 0.6rem), 0 0.6rem
  );

  display: inline-grid;
  box-sizing: border-box;
  inline-size: 9.5rem;
  block-size: 2.2rem;
  padding: 2px;
  background: var(--badge-gold);
  color: var(--badge-ink);
  clip-path: var(--badge-shape);
}

.source-framing-inner {
  position: relative;
  display: grid;
  grid-template-columns: 1.25rem minmax(0, 1fr);
  align-items: center;
  gap: 0.4rem;
  padding-inline: 0.55rem 1.2rem;
  background: var(--badge-paper);
  clip-path: var(--badge-shape);
}

/* Folded corner and compact newspaper icon. */
.source-framing-inner::after {
  position: absolute;
  inset-block-start: 0;
  inset-inline-end: 0;
  inline-size: 0.65rem;
  block-size: 0.65rem;
  background: var(--badge-gold);
  clip-path: polygon(0 0, 100% 100%, 0 100%);
  content: "";
}

.source-framing-icon {
  position: relative;
  box-sizing: border-box;
  width: 1.25rem;
  height: 0.75rem;
  border: 2px solid var(--badge-icon);
  border-bottom: 0;
  border-radius: 1rem 1rem 0 0;
}

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

.source-framing-copy {
  display: grid;
  gap: 0.1rem;
  padding-inline-start: 0.4rem;
  border-inline-start: 1px solid var(--badge-gold);
  line-height: 1;
  white-space: nowrap;
}

.source-framing-caption {
  font-size: 0.58rem;
  font-weight: 700;
  text-transform: uppercase;
}

.source-framing-copy strong {
  font-size: 0.85rem;
  font-style: italic;
}

.source-framing-badge[data-rating="Left"],
.source-framing-badge[data-rating="Lean left"], .source-framing-badge[data-rating="Lean Left"] {
  --badge-paper: #eaf3ff;
  --badge-ink: #123f85;
  --badge-icon: #0866d9;
}

.source-framing-badge[data-rating="Right"],
.source-framing-badge[data-rating="Lean right"], .source-framing-badge[data-rating="Lean Right"] {
  --badge-paper: #fff0ed;
  --badge-ink: #a4131b;
  --badge-icon: #e32636;
}

.source-framing-unclear {
  color: #c9ccd3;
  font-size: 0.8rem;
  font-style: italic;
}

.source-framing-badge[data-rating="Left"]       { --needle-angle: -52deg; }
.source-framing-badge[data-rating="Lean left"],
.source-framing-badge[data-rating="Lean Left"] { --needle-angle: -28deg; }
.source-framing-badge[data-rating="Lean right"],
.source-framing-badge[data-rating="Lean Right"] { --needle-angle: 28deg; }
.source-framing-badge[data-rating="Right"]      { --needle-angle: 52deg; }


/* ---------------------------------------------------------
   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: #0f1528;
    border: 1px solid rgba(252, 211, 77, 0.3);
    border-left: 4px solid #fcd34d;
    border-radius: 6px;
    padding: 16px;
    margin-bottom: 24px;
}

.historical-notice strong {
    color: #fcd34d;
    font-size: 16px;
}

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

.historical-notice a {
    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 Bookmark Layout
   --------------------------------------------------------- */

/* Arrange the headline and bookmark button horizontally. */
.story-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin: 24px 0 8px;
}

/* Allow the headline to occupy the available space. */
.story-heading h1 {
    flex: 1;
    min-width: 0;
    margin: 0;
}

/* Prevent the bookmark button from shrinking beside long headlines. */
.story-heading .bookmark-button {
    flex-shrink: 0;
}
