/* ── Article Reader Expansion ──────────────────────────────────────────
   Overlay panel that expands from the clicked article card.
   Animation technique: CSS Custom Property FLIP
   Mobile (≤640px): bottom sheet slide-up instead of card morph.
   ─────────────────────────────────────────────────────────────────── */

/* ── New tokens ── */
:root {
  --reader-max-width: 760px;
  --overlay-blur:     blur(6px);
  --reader-easing:    cubic-bezier(0.22, 1, 0.36, 1);
  --reader-duration:  380ms;
}

/* ── Phase 1: Grid dims when reader is open ── */
.article-expand-active .lp-article-link--fading .lp-article-card {
  opacity: 0.18;
  transform: scale(0.97);
  pointer-events: none;
  transition:
    opacity 320ms var(--reader-easing),
    transform 320ms var(--reader-easing);
}

.article-expand-active .lp-article-link--origin .lp-article-card {
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

/* ── Phase 2: Backdrop ── */
.article-reader-backdrop {
  position: fixed;
  inset: 0;
  z-index: 400;
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  backdrop-filter: var(--overlay-blur);
  -webkit-backdrop-filter: var(--overlay-blur);
  opacity: 0;
  pointer-events: none;
  transition: opacity 280ms ease;
  cursor: default;
}

.article-reader-backdrop--visible {
  opacity: 1;
  pointer-events: auto;
}

/* ── Phase 3: Reader panel ── */
.article-reader {
  position: fixed;
  z-index: 500;
  border-radius: 12px;
  border: 1px solid var(--bd);
  background: var(--sf);
  overflow: hidden;
  top:    var(--card-top,    50%);
  left:   var(--card-left,   50%);
  width:  var(--card-width,  300px);
  height: var(--card-height, 200px);
  opacity: 0;
  pointer-events: none;
  transition:
    top    var(--reader-duration) var(--reader-easing),
    left   var(--reader-duration) var(--reader-easing),
    width  var(--reader-duration) var(--reader-easing),
    height var(--reader-duration) var(--reader-easing),
    border-radius var(--reader-duration) var(--reader-easing),
    opacity 200ms ease;
}

.article-reader--open {
  top:    50%;
  left:   50%;
  transform: translate(-50%, -50%);
  width:  min(var(--reader-max-width), calc(100vw - 32px));
  height: min(88vh, 860px);
  border-radius: 16px;
  border-color: var(--bd2);
  opacity: 1;
  pointer-events: auto;
  box-shadow:
    0 24px 80px rgba(0, 0, 0, .65),
    0 0 0 1px var(--bd2),
    0 0 0 6px rgba(0, 0, 0, .28);
}

.article-reader--closing {
  transition:
    top    260ms cubic-bezier(0.4, 0, 1, 1),
    left   260ms cubic-bezier(0.4, 0, 1, 1),
    width  260ms cubic-bezier(0.4, 0, 1, 1),
    height 260ms cubic-bezier(0.4, 0, 1, 1),
    border-radius 260ms cubic-bezier(0.4, 0, 1, 1),
    opacity 180ms ease-in;
}

/* ── Inner layout ── */
.article-reader__inner {
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* ── Progress bar ── */
.article-reader__progress {
  position: absolute;
  top: 0;
  left: 0;
  width: 0%;
  height: 2px;
  background: linear-gradient(90deg, var(--acc) 0%, var(--gold) 100%);
  transition: width 60ms linear;
  z-index: 1;
  border-radius: 0 2px 2px 0;
}

/* ── Sticky header ── */
.article-reader__header {
  flex-shrink: 0;
  height: 52px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  border-bottom: 1px solid var(--bd);
  background: var(--sf);
  opacity: 0;
  transition: opacity 160ms ease 240ms;
}

.article-reader--open .article-reader__header {
  opacity: 1;
}

.article-reader__meta-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.article-reader__icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--gold-d);
  border: 1px solid var(--gold-rim);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gold);
  flex-shrink: 0;
}

.article-reader__icon.gold {
  background: var(--gold-d);
  border-color: var(--gold-rim);
  color: var(--gold);
}

.article-reader__cat {
  font-size: 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--gold);
  opacity: 0.85;
  white-space: nowrap;
  font-family: var(--fb);
}

.article-reader__dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--t3);
  flex-shrink: 0;
}

.article-reader__read-time {
  font-size: 11px;
  color: var(--t3);
  font-family: var(--fm);
  white-space: nowrap;
}

/* ── Close button ── */
.article-reader__close {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--bd);
  background: var(--el);
  color: var(--t2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  margin: -6px -6px -6px 0;
  padding: 6px;
  transition:
    background var(--transition-fast),
    border-color var(--transition-fast),
    color var(--transition-fast);
}

.article-reader__close:hover {
  background: var(--acc-d);
  border-color: var(--acc-rim);
  color: var(--t1);
}

.article-reader__close:focus-visible {
  outline: 2px solid var(--acc);
  outline-offset: 2px;
}

/* ── Scrollable body ── */
.article-reader__body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--bd2) transparent;
  opacity: 0;
  transition: opacity 200ms ease 300ms;
}

.article-reader--open .article-reader__body {
  opacity: 1;
}

.article-reader__body::-webkit-scrollbar { width: 4px; }
.article-reader__body::-webkit-scrollbar-track { background: transparent; }
.article-reader__body::-webkit-scrollbar-thumb { background: var(--bd2); border-radius: 2px; }

/* ── Prose content ── */
.article-reader__prose {
  max-width: var(--reader-max-width);
  margin: 0 auto;
  padding: 40px 32px 64px;
}

/* ── Loading skeleton ── */
.article-reader__loading {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 40px 32px;
  opacity: 0;
  transition: opacity 120ms ease 180ms;
}

.article-reader__loading--visible {
  opacity: 1;
}

.skeleton {
  background: linear-gradient(
    90deg,
    var(--el) 0%,
    var(--bd) 40%,
    var(--el) 80%
  );
  background-size: 300% 100%;
  animation: skeleton-shimmer 1.4s ease-in-out infinite;
  border-radius: 4px;
}

@keyframes skeleton-shimmer {
  0%   { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

.skeleton--title  { height: 48px; width: 85%; }
.skeleton--text   { height: 16px; width: 100%; }
.skeleton--text-s { height: 16px; width: 72%; }

/* ── Error state ── */
.article-reader__error {
  display: none;
  padding: 48px 32px;
  text-align: center;
  color: var(--t2);
}

.article-reader__error svg { color: var(--t3); margin-bottom: 16px; }
.article-reader__error p { font-size: 14px; margin-bottom: 20px; }

/* ── Back button in reader ── */
.article-reader__back-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--t2);
  padding: 8px 12px;
  border: 1px solid var(--bd);
  border-radius: 8px;
  transition: border-color var(--transition-fast), color var(--transition-fast);
  margin-top: 48px;
  background: transparent;
  cursor: pointer;
  font-family: var(--fb);
}

.article-reader__back-btn:hover {
  border-color: var(--bd2);
  color: var(--t1);
}

/* ── Mobile: bottom sheet (≤640px) ── */
@media (max-width: 640px) {
  .article-reader {
    top: 100vh;
    left: 0;
    width: 100%;
    height: 90vh;
    border-radius: 20px 20px 0 0;
    transition:
      top var(--reader-duration) var(--reader-easing),
      opacity 200ms ease;
  }

  .article-reader--open {
    top: 10vh;
    left: 0;
    width: 100%;
    height: 90vh;
    border-radius: 20px 20px 0 0;
    transform: none;
    box-shadow: 0 -8px 40px rgba(0, 0, 0, .6);
  }

  .article-reader--closing {
    top: 100vh;
    transition:
      top 260ms cubic-bezier(0.4, 0, 1, 1),
      opacity 180ms ease-in;
  }

  .article-reader__prose {
    padding: 28px 20px 48px;
  }
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  .article-reader,
  .article-reader--closing,
  .article-reader__header,
  .article-reader__body,
  .article-reader__loading,
  .article-reader-backdrop,
  .article-expand-active .lp-article-link--fading .lp-article-card,
  .article-expand-active .lp-article-link--origin .lp-article-card {
    transition: opacity 150ms ease !important;
  }

  .article-reader--open {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(var(--reader-max-width), calc(100vw - 32px));
    height: min(88vh, 860px);
  }
}
