@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

@font-face {
  font-family: "Conpera News Serif";
  src: url("fonts/conpera-news-serif-subset.woff2") format("woff2");
  font-weight: 400 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg-color: #fcfcfc;
  --panel-bg: #ffffff;
  --text-primary: #0a0a0a;
  --text-secondary: #737373;
  --accent: #b42318;
  --border-color: #e5e5e5;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-serif: "Conpera News Serif", "Songti SC", "STSong", "Noto Serif CJK SC", serif;
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.03);
  --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.06);
  --max-width: 480px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  background: var(--bg-color);
  color: var(--text-primary);
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Layout */
.paper-shell {
  width: 100%;
  max-width: var(--max-width);
  min-height: 100vh;
  margin: 0 auto;
  background: var(--panel-bg);
  position: relative;
}

/* Header */
.edition-header {
  padding: 36px 20px 24px;
  background: var(--panel-bg);
}

.edition-header h1 {
  margin: 0 0 18px;
  font-family: var(--font-serif);
  font-size: 2.25rem;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.edition-subline {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text-secondary);
}

/* Category Nav */
.category-rail {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: stretch;
  gap: 12px;
  overflow-x: auto;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-color);
  scrollbar-width: none;
}

.category-rail::-webkit-scrollbar {
  display: none;
}

.category-button {
  appearance: none;
  flex: 0 0 auto;
  min-width: 76px;
  height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 18px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: 0;
  cursor: pointer;
  transition:
    color 260ms cubic-bezier(0.16, 1, 0.3, 1),
    background-color 260ms cubic-bezier(0.16, 1, 0.3, 1),
    box-shadow 260ms cubic-bezier(0.16, 1, 0.3, 1);
  letter-spacing: -0.01em;
}

.category-button:hover {
  color: var(--text-primary);
  background: rgba(0, 0, 0, 0.035);
}

.category-button.active {
  background: var(--text-primary);
  color: var(--panel-bg);
  border-color: var(--text-primary);
  box-shadow: none;
}

.category-home-button {
  min-width: 54px;
  width: 54px;
  padding: 0;
  color: var(--text-primary);
}

.category-home-button svg {
  width: 24px;
  height: 24px;
  stroke: currentColor;
  stroke-width: 2.15;
  fill: none;
}

/* Artistic Back to Top / Return Button */
.back-to-top,
.floating-back-button {
  position: fixed;
  bottom: 32px;
  right: 32px;
  width: 48px;
  height: 48px;
  background: var(--panel-bg);
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  z-index: 100;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px);
}

.floating-back-button {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.18);
}

.back-to-top.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.back-to-top:hover,
.floating-back-button:hover {
  transform: scale(1.1);
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
}

.floating-back-button:hover {
  box-shadow: 0 22px 48px rgba(0, 0, 0, 0.22);
}

.back-to-top svg,
.floating-back-button svg {
  width: 20px;
  height: 20px;
  stroke: var(--text-primary);
  stroke-width: 2.5;
  fill: none;
  transition: transform 0.3s ease;
}

.back-to-top:hover svg {
  transform: translateY(-2px);
}

.floating-back-button:hover svg {
  transform: translateX(-2px);
}


/* Stories */
main {
  padding: 0;
}

.lead-story {
  padding: 0;
  border-bottom: 8px solid var(--bg-color);
}

.lead-card {
  display: block;
}

.clickable-story {
  cursor: pointer;
}

.clickable-story:focus-visible,
.floating-back-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.lead-image-wrap {
  aspect-ratio: 16 / 9;
  overflow: visible;
  background: transparent;
}

.lead-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  border-radius: 0;
  box-shadow: 0 7px 18px rgba(0, 0, 0, 0.09);
}

.lead-content {
  padding: 24px 20px;
}

.meta-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.category-tag {
  color: var(--accent);
}

.lead-title {
  margin: 0 0 12px;
  font-family: var(--font-serif);
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.2;
}

.lead-body,
.story-body {
  margin: 0 0 16px;
  font-family: var(--font-serif);
  color: #333;
  font-size: 0.9375rem;
  line-height: 1.6;
}

.lead-body {
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.source-link {
  display: inline-flex;
  align-items: center;
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--text-primary);
  text-decoration: none;
  border-bottom: 1.5px solid var(--text-primary);
  padding-bottom: 1px;
  transition: opacity 0.2s;
}

.source-link:hover {
  opacity: 0.7;
}

.expandable-story {
  position: relative;
}

.expandable-story .lead-body,
.expandable-story .story-body {
  max-height: 36rem;
  overflow: hidden;
  transition:
    opacity 460ms cubic-bezier(0.16, 1, 0.3, 1),
    max-height 520ms cubic-bezier(0.22, 1, 0.36, 1),
    transform 520ms cubic-bezier(0.22, 1, 0.36, 1),
    margin-bottom 520ms cubic-bezier(0.22, 1, 0.36, 1);
}

.expandable-story.is-expanded .lead-body,
.expandable-story.is-expanded .story-body {
  max-height: 0;
  margin-bottom: 0;
  opacity: 0;
  transform: translateY(-4px);
}

.story-expansion {
  --expanded-height: 0px;
  grid-column: 1 / -1;
  max-height: var(--expanded-height);
  overflow: hidden;
  opacity: 0;
  transform: translateY(-10px);
  transition:
    max-height 760ms cubic-bezier(0.19, 1, 0.22, 1),
    opacity 520ms cubic-bezier(0.19, 1, 0.22, 1),
    transform 680ms cubic-bezier(0.19, 1, 0.22, 1);
}

.expandable-story.is-expanded .story-expansion {
  opacity: 1;
  transform: translateY(0);
}

.story-expansion-image-wrap {
  width: calc(100% + 40px);
  margin: 2px -20px 0;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  opacity: 0;
  transform: translateY(18px) scale(0.985);
  transition:
    opacity 620ms cubic-bezier(0.19, 1, 0.22, 1),
    transform 820ms cubic-bezier(0.19, 1, 0.22, 1);
}

.expandable-story.is-expanded .story-expansion-image-wrap {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.story-expansion-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  border-radius: 0;
  box-shadow: 0 9px 24px rgba(0, 0, 0, 0.1);
}

.story-expansion-image-wrap .image-fallback {
  border-radius: 0;
}

.story-expansion-inner {
  padding-top: 14px;
}

.lead-card .story-expansion-inner {
  padding-top: 18px;
}

.story-full-body {
  margin: 0;
  font-family: var(--font-serif);
  color: #242424;
  font-size: 1rem;
  line-height: 1.78;
}

.story-actions {
  display: flex;
  justify-content: flex-start;
  padding-top: 16px;
}

.detail-arrow-link {
  appearance: none;
  width: 44px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-primary);
  cursor: pointer;
  transition:
    opacity 260ms cubic-bezier(0.16, 1, 0.3, 1),
    transform 320ms cubic-bezier(0.19, 1, 0.22, 1);
}

.detail-arrow-link:hover {
  opacity: 0.72;
  transform: translateX(3px);
}

.detail-arrow-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

.detail-arrow-link svg {
  width: 24px;
  height: 24px;
  stroke: currentColor;
  stroke-width: 2.2;
  fill: none;
}

/* Detail */
.detail-view {
  border-bottom: 8px solid var(--bg-color);
}

.detail-card {
  background: var(--panel-bg);
}

.detail-image-wrap {
  margin-top: 16px;
  aspect-ratio: 16 / 10;
  overflow: visible;
  background: transparent;
}

.detail-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  border-radius: 4px;
  box-shadow: 0 7px 18px rgba(0, 0, 0, 0.09);
}

.detail-content {
  padding: 24px 20px 28px;
}

.detail-title {
  margin: 0 0 14px;
  font-family: var(--font-serif);
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.12;
}

.detail-body {
  margin: 0 0 18px;
  font-family: var(--font-serif);
  color: #242424;
  font-size: 1rem;
  line-height: 1.76;
}

.related-block {
  border-top: 1px solid var(--border-color);
}

.related-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
}

.related-header strong {
  color: var(--accent);
}

.related-card {
  display: grid;
  grid-template-columns: 1fr 100px;
  align-items: center;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border-color);
}

/* News River */
.news-river {
  padding: 0;
}

.story-card {
  display: grid;
  grid-template-columns: 1fr 100px;
  align-items: center;
  gap: 20px;
  padding: 20px;
  border-bottom: 1px solid var(--border-color);
  transition: background-color 0.2s;
}

.story-card:hover {
  background-color: #fafafa;
}

.story-card.is-expanded {
  align-items: start;
}

.story-card.is-expanded .story-thumb {
  margin-top: 2px;
}

.story-title {
  margin: 0 0 8px;
  font-family: var(--font-serif);
  font-size: 1.125rem;
  font-weight: 700;
  line-height: 1.3;
}

.story-body {
  margin-bottom: 8px;
  font-size: 0.875rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--text-secondary);
}

.story-thumb {
  align-self: center;
  justify-self: center;
  width: 100px;
  height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
  background: transparent;
  border: none;
  box-shadow: none;
  transition:
    opacity 420ms cubic-bezier(0.16, 1, 0.3, 1),
    transform 520ms cubic-bezier(0.19, 1, 0.22, 1);
}

.story-card.is-expanded .story-thumb {
  opacity: 0;
  transform: translateY(-8px) scale(0.96);
  pointer-events: none;
}

.story-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  border-radius: 4px;
  border: none;
  box-shadow: 0 7px 16px rgba(0, 0, 0, 0.11);
}

.image-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f5f5f5;
  color: var(--text-secondary);
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 0.75rem;
  text-transform: uppercase;
  text-align: center;
  padding: 10px;
  border-radius: 4px;
  box-shadow: 0 7px 16px rgba(0, 0, 0, 0.08);
}

.empty-state {
  padding: 60px 20px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.9375rem;
}

.empty-state.compact {
  padding: 22px 20px;
}

/* Desktop Styles */
@media (min-width: 768px) {
  body {
    background: var(--bg-color);
    padding: 40px 0;
  }

  .paper-shell {
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    overflow: hidden;
    min-height: auto;
  }

  .category-rail {
    top: 0;
  }
}
