/* Unique motion: intercept / lock-on / unredact. Not generic fade-up. */

.top-nav {
  position: relative;
}

.nav-lock,
.cat-lock {
  position: absolute;
  pointer-events: none;
  z-index: 0;
  transition: transform 0.38s cubic-bezier(0.22, 1, 0.36, 1),
    width 0.38s cubic-bezier(0.22, 1, 0.36, 1),
    height 0.28s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.2s ease;
  opacity: 0;
}

.nav-lock.is-on,
.cat-lock.is-on {
  opacity: 1;
}

html:not(.is-mobile) .nav-lock {
  left: 0;
  bottom: 0;
  height: 2px;
  background: var(--accent);
}

html:not(.is-mobile) .nav-link {
  position: relative;
  z-index: 1;
}

.cat-lock {
  left: 0;
  top: auto;
  bottom: 0.35rem;
  height: 2px !important;
  border: 0;
  background: var(--accent);
  box-shadow: 0 0 10px rgba(var(--accent-rgb), 0.55);
  border-radius: 1px;
}

.cat-lock::before,
.cat-lock::after {
  display: none;
}

.query-field::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 2px;
  height: 0;
  background: var(--accent);
  transform: translateY(-50%);
  transition: height 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.query-field:focus-within::before {
  height: 100%;
}

.query-count .count-flip {
  display: inline-block;
  font-variant-numeric: tabular-nums;
  color: var(--text-bright);
  font-weight: 750;
  animation: count-tick 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes count-tick {
  from { transform: translateY(0.45em); opacity: 0.2; }
  to { transform: none; opacity: 1; }
}

/* Lead: crop marks + one-shot scan */
.news-lead-media {
  position: relative;
}

.news-lead-media::before {
  content: "";
  position: absolute;
  inset: 8px;
  border: 1px solid rgba(255, 255, 255, 0.55);
  clip-path: polygon(
    0 0, 14px 0, 14px 1px, 1px 1px, 1px 14px, 0 14px,
    0 100%, 0 calc(100% - 14px), 1px calc(100% - 14px), 1px calc(100% - 1px), 14px calc(100% - 1px), 14px 100%,
    100% 100%, 100% calc(100% - 14px), calc(100% - 14px) calc(100% - 14px), calc(100% - 14px) calc(100% - 1px), calc(100% - 1px) calc(100% - 1px), calc(100% - 1px) calc(100% - 14px), 100% calc(100% - 14px),
    100% 0, calc(100% - 14px) 0, calc(100% - 14px) 1px, calc(100% - 1px) 1px, calc(100% - 1px) 14px, 100% 14px
  );
  pointer-events: none;
  z-index: 2;
  opacity: 0.85;
}

.news-lead-media::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -20%;
  height: 28%;
  background: linear-gradient(
    180deg,
    transparent,
    color-mix(in srgb, var(--accent) 45%, #fff) 40%,
    transparent
  );
  mix-blend-mode: overlay;
  opacity: 0;
  pointer-events: none;
  z-index: 3;
}

html.has-feed-motion .news-lead.is-scanning .news-lead-media::after {
  animation: lead-scan 1.05s cubic-bezier(0.22, 1, 0.36, 1) 0.08s both;
}

html.has-feed-motion .news-lead.is-scanning .news-lead-media img {
  animation: lead-expose 0.9s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes lead-scan {
  0% { transform: translateY(0); opacity: 0; }
  12% { opacity: 0.95; }
  100% { transform: translateY(420%); opacity: 0; }
}

@keyframes lead-expose {
  from { clip-path: inset(0 0 100% 0); filter: saturate(0.4) contrast(1.15); }
  to { clip-path: inset(0 0 0 0); filter: none; }
}

/* Titles un-redact as they enter the frame */
.post-row {
  position: relative;
  --aim-y: 50%;
}

.post-row .post-row-title-btn,
.news-lead-title {
  display: inline;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

html.has-feed-motion .post-row:not(.is-live) .post-row-title,
html.has-feed-motion .news-lead:not(.is-live) .news-lead-title {
  clip-path: inset(0 100% 0 0);
  filter: contrast(1.4);
}

html.has-feed-motion .post-row.is-live .post-row-title,
html.has-feed-motion .news-lead.is-live .news-lead-title {
  animation: unredact 0.62s cubic-bezier(0.16, 1, 0.3, 1) both;
}

html.has-feed-motion .post-row:not(.is-live) .post-row-excerpt,
html.has-feed-motion .news-lead:not(.is-live) .news-lead-excerpt {
  opacity: 0;
}

html.has-feed-motion .post-row.is-live .post-row-excerpt,
html.has-feed-motion .news-lead.is-live .news-lead-excerpt {
  animation: excerpt-open 0.5s ease 0.12s both;
}

@keyframes unredact {
  from { clip-path: inset(0 100% 0 0); }
  to { clip-path: inset(0 0 0 0); }
}

@keyframes excerpt-open {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* Rangefinder: a hairline that tracks the cursor inside a row */
.post-row::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: var(--aim-y);
  height: 1px;
  background: var(--accent);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  z-index: 2;
}

.post-row:hover::after {
  opacity: 0.45;
}

.post-row-cover img {
  transform: scale(1.04);
  filter: saturate(0.85);
  transition: transform 0.55s cubic-bezier(0.22, 1, 0.36, 1), filter 0.4s ease;
}

.post-row.is-live .post-row-cover img,
.news-lead.is-live .news-lead-media img {
  transform: none;
}

.post-row:hover .post-row-cover img {
  transform: scale(1.06);
  filter: saturate(1);
}

.category-chip {
  will-change: auto;
  transition: color 0.15s ease;
}

html.is-mobile .query-rail {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "field field"
    "count sort";
}

html.is-mobile .query-field { grid-area: field; }
html.is-mobile .query-count { grid-area: count; }
html.is-mobile .sort-row { grid-area: sort; justify-self: end; }
html.is-mobile .query-hotkey { display: none; }

html.is-mobile .nav-lock {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  .nav-lock,
  .cat-lock,
  .query-field::before,
  .count-flip,
  .post-row-title,
  .news-lead-title,
  .post-row-excerpt,
  .news-lead-excerpt,
  .post-row-cover img,
  .news-lead-media img,
  .news-lead-media::after,
  .category-chip {
    animation: none !important;
    transition: none !important;
    clip-path: none !important;
    transform: none !important;
    filter: none !important;
    opacity: 1 !important;
  }

  .post-row::after {
    display: none;
  }
}
