/* ============================================================
   news.html (Galeri): compact framed hero + restyle of the markup
   news.js generates (index grid, single gallery). Loaded after
   styles.css and hero-b.css; everything here overrides those rules.
   Shape rule: photos and surfaces 16px (--r-surface), rail thumbs 10px
   (inner, smaller elements), buttons pill.
   ============================================================ */

/* ---------- hero ---------- */
/* The home frame fades into its own tint for the SEMA photo; here it fades into the white page. */
/* single column, lined up with the content .wrap below */
.news-hero .hb-page {
  grid-template-columns: minmax(0, 1fr);
  width: 100%;
  max-width: var(--wrap);
  margin: 0 auto;
  padding: clamp(2rem, 5vw, 4.5rem) clamp(1.25rem, 4vw, 3rem) clamp(4rem, 8vw, 6.5rem);
}
.news-hero .hb-page-copy { gap: 0.9rem; }
.news-hero-title {
  font-family: var(--font-display);
  font-size: clamp(2.6rem, 6vw, 5rem);
  font-weight: 800;
  line-height: 1.02;
  letter-spacing: -0.035em;
  color: var(--text);
}
.news-hero .hb-page-lead { max-width: 44ch; text-wrap: pretty; }

/* one gallery open: the hero steps back to a slim band so the gallery title leads */
body:has(.news-article) .news-hero .hb-page { padding-top: clamp(1rem, 2.5vw, 1.75rem); padding-bottom: clamp(1.75rem, 3vw, 2.5rem); }
body:has(.news-article) .news-page.section { padding-top: 0; }
body:has(.news-article) .news-hero-title { font-size: clamp(1.6rem, 2.4vw, 2rem); letter-spacing: -0.025em; }
body:has(.news-article) .news-hero .hb-page-lead { display: none; }

/* ---------- page shell ---------- */
.news-page.section { padding-top: clamp(0.5rem, 2vw, 1.5rem); padding-bottom: clamp(4.5rem, 8vw, 7rem); }

/* index: the hero already names the page, so news.js's "Galeri terbaru" h1 stays for
   screen readers only (it is the page's one h1) */
#newsPage > h1:has(+ .news-grid) {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- index: editorial grid ----------
   First gallery leads across two rows on the left, the next two stack beside it,
   the rest pair up in alternating 5/7 and 7/5 rows. Works for any count: a lone
   last card takes the full row, a single gallery takes the full width. */
.news-grid {
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: clamp(2rem, 3.2vw, 3rem) var(--s3);
  margin-top: 0;
}
.news-card { grid-column: span 7; }
.news-card:first-child { grid-column: 1 / span 7; }
.news-card:first-child:nth-last-child(n+3) { grid-row: span 2; }
.news-card:nth-child(2),
.news-card:nth-child(3) { grid-column: 8 / -1; }
.news-card:nth-child(4n+4),
.news-card:nth-child(4n+7) { grid-column: span 5; }
.news-card:first-child:last-child,
.news-card:nth-child(n+4):nth-child(even):last-child { grid-column: 1 / -1; }

/* cards: photo, then caption below it. No box, no border, no text on the photo. */
.news-card {
  position: relative;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  border: 0;
  border-radius: var(--r-surface);
  background: none;
  overflow: visible;
  transition: none;
}
.news-card:hover { border-color: transparent; transform: none; }
.news-card:focus-visible { outline-offset: 6px; }

.news-card-shot {
  position: relative;
  aspect-ratio: 16 / 10;
  background: none;
  overflow: hidden;
  border-radius: var(--r-surface);
}
.news-card-shot img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--r-surface);
  background: var(--bg-3);
  outline: 1px solid rgba(15, 22, 56, 0.06); /* keeps the edge on pale skies */
  outline-offset: -1px;
  transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}
/* lead card: photo fills the two rows beside it (same move as the home mosaic) */
.news-card:first-child:nth-last-child(n+3) .news-card-shot { flex: 1; aspect-ratio: auto; min-height: 18rem; }
.news-card:first-child:nth-last-child(n+3) .news-card-shot img { position: absolute; inset: 0; }
/* paired rows: one photo height so a 5-col and a 7-col card line up */
.news-card:nth-child(n+4) .news-card-shot { aspect-ratio: auto; height: clamp(220px, 25vw, 360px); }

/* meta row under the photo: date line left, photo count right (news.js renders both here) */
.news-card-meta { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.news-card-meta .news-count {
  position: static;
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  padding: 0;
  border-radius: 0;
  background: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  font-size: 0.88rem;
  line-height: 1.6;
  letter-spacing: 0;
  color: var(--text-dim);
  white-space: nowrap;
}

.news-card-body { padding: 0; }

/* meta: plain sentence-case line, not an uppercase eyebrow */
.news-page .news-meta {
  font-size: 0.88rem;
  line-height: 1.6;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text-dim);
}
.news-card-body .h-item {
  margin-top: 0.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.12;
  text-wrap: balance;
  transition: color 0.25s;
}
.news-card:first-child:nth-last-child(n+3) .h-item { font-size: clamp(1.6rem, 2.6vw, 2.25rem); max-width: 22ch; }
.news-card-body .news-excerpt { margin-top: 0.45rem; font-size: 0.97rem; max-width: 50ch; text-wrap: pretty; }

@media (hover: hover) {
  .news-card:hover .news-card-shot img { transform: scale(1.04); }
  .news-card:hover .h-item { color: var(--accent); }
}
.news-card:active .news-card-shot img { transform: scale(0.99); }

/* cards arrive in sequence once news.js has rendered them (state change: loaded) */
@media (prefers-reduced-motion: no-preference) {
  .news-card { animation: news-in 0.6s cubic-bezier(0.16, 1, 0.3, 1) both; }
  .news-card:nth-child(2) { animation-delay: 0.06s; }
  .news-card:nth-child(3) { animation-delay: 0.12s; }
  .news-card:nth-child(4) { animation-delay: 0.18s; }
  .news-card:nth-child(n+5) { animation-delay: 0.24s; }
  .news-article { animation: news-in 0.5s cubic-bezier(0.16, 1, 0.3, 1) both; }
}
@keyframes news-in {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: none; }
}

/* ---------- single gallery ---------- */
#newsPage > h1 + .news-back { margin-top: 1.25rem; } /* gallery not found */
.news-back {
  display: inline-flex;
  align-items: center;
  margin-bottom: clamp(1.5rem, 3vw, 2.25rem);
  padding: 0.55em 1.15em;
  border: 1px solid rgba(15, 22, 56, 0.2);
  border-radius: var(--r-pill);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  transition: background 0.2s, border-color 0.2s, transform 0.15s;
}
@media (hover: hover) {
  .news-back:hover { background: var(--bg-2); border-color: var(--text); }
}
.news-back:active { transform: scale(0.98); }

/* Title first, then the photos, then the text. news.js appends the gallery before the
   prose; the prose box is flattened so its parts can be ordered around the gallery.
   Tab order is unchanged (thumbnails, then body links, then pager). */
.news-article { display: flex; flex-direction: column; max-width: none; }
.news-prose { display: contents; }
.news-article .news-meta { order: 1; }
.news-article > .h-sec,
.news-prose > .h-sec { order: 2; margin-top: 0.4rem; max-width: 24ch; text-wrap: balance; font-size: clamp(2rem, 4vw, 3.25rem); }
.news-prose > .lead { order: 3; margin-top: 0.9rem; max-width: 46ch; text-wrap: pretty; }
.gallery-head { order: 4; margin-top: clamp(1.75rem, 3.5vw, 2.75rem); gap: var(--s2); }
.gallery-caption { order: 5; }
.news-body { order: 6; max-width: 46rem; margin-top: clamp(2rem, 4vw, 3rem); }
.news-pager { order: 7; max-width: 46rem; width: 100%; }

.gallery-stage { border-radius: var(--r-surface); }
/* the rail's highlighted thumbnail already says which photo is showing; no "1 / 4" on the photo */
.gallery-stage .news-count { display: none; }

.gallery-rail { gap: 0.6rem; }
.gallery-thumb {
  border-radius: 10px;
  opacity: 0.55;
  transition: opacity 0.2s, transform 0.15s;
}
@media (hover: hover) {
  .gallery-thumb:hover { opacity: 0.85; }
}
.gallery-thumb:active { transform: scale(0.98); }
.gallery-thumb[aria-current="true"] { opacity: 1; outline: 2px solid var(--accent); outline-offset: -2px; }

/* desktop rail: exactly three rows fit the stage height; a longer set scrolls, and a soft
   fade at the foot of the rail (padding lets the last row clear it) says there is more */
@media (min-width: 901px) {
  .gallery-rail:not(.is-narrow) { grid-auto-rows: calc((100% - 1.2rem) / 3); }
  .gallery-rail:not(.is-narrow) .gallery-thumb { aspect-ratio: auto; }
  .gallery-rail:has(.gallery-thumb:nth-child(7)) {
    padding-bottom: 3rem;
    -webkit-mask-image: linear-gradient(180deg, #000 82%, transparent);
    mask-image: linear-gradient(180deg, #000 82%, transparent);
  }
}

.gallery-caption { font-size: 0.9rem; margin-top: 0.8rem; max-width: 60ch; }

.news-pager-link {
  display: inline-flex;
  padding: 0.55em 1.15em;
  border: 1px solid rgba(15, 22, 56, 0.2);
  border-radius: var(--r-pill);
  font-weight: 600;
  color: var(--text);
  transition: background 0.2s, border-color 0.2s, transform 0.15s;
}
@media (hover: hover) {
  .news-pager-link:hover { background: var(--bg-2); border-color: var(--text); }
}
.news-pager-link:active { transform: scale(0.98); }

/* ---------- tablet: lead card full width, the rest in pairs ---------- */
@media (max-width: 900px) {
  .news-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s4) var(--s2); }
  .news-card,
  .news-card:nth-child(2),
  .news-card:nth-child(3),
  .news-card:nth-child(4n+4),
  .news-card:nth-child(4n+7),
  .news-card:nth-child(n+4):nth-child(even):last-child { grid-column: span 1; grid-row: auto; }
  .news-card:first-child,
  .news-card:first-child:nth-last-child(n+3),
  .news-card:nth-child(even):last-child { grid-column: 1 / -1; grid-row: auto; }
  .news-card:first-child:nth-last-child(n+3) .news-card-shot { flex: none; aspect-ratio: 16 / 10; min-height: 0; }
  .news-card:first-child:nth-last-child(n+3) .news-card-shot img { position: static; }
  .news-card:nth-child(n+4) .news-card-shot { height: auto; aspect-ratio: 16 / 10; }
  .news-card:nth-child(even):last-child:not(:first-child) .news-card-shot { aspect-ratio: 16 / 9; }
}

/* ---------- phone: one column ---------- */
@media (max-width: 600px) {
  .news-hero .hb-page { padding-top: 1.25rem; padding-bottom: 3.5rem; }
  .news-grid { grid-template-columns: minmax(0, 1fr); gap: var(--s4); }
  .news-card,
  .news-card:first-child,
  .news-card:nth-child(even):last-child { grid-column: 1 / -1; }
  .news-card-shot,
  .news-card:nth-child(even):last-child:not(:first-child) .news-card-shot { aspect-ratio: 4 / 3; }
  .news-card:first-child:nth-last-child(n+3) .news-card-shot { aspect-ratio: 4 / 3; }
  .news-card:nth-child(n+4) .news-card-shot { aspect-ratio: 4 / 3; }
  .news-card:first-child:nth-last-child(n+3) .h-item { font-size: 1.6rem; }
  .news-card { gap: 0.75rem; }
  .news-card-shot .news-count { top: calc(100% + 0.75rem); }
  .gallery-stage { aspect-ratio: 4 / 3; }
  .gallery-thumb { flex-basis: 88px; }
}

@media (prefers-reduced-motion: reduce) {
  .news-card-shot img, .news-back, .news-pager-link, .gallery-thumb { transition: none; }
  .news-card:hover .news-card-shot img, .news-card:active .news-card-shot img { transform: none; }
}

/* back and pager links carry Phosphor arrows from news.js */
.news-back, .news-pager-link { display: inline-flex; align-items: center; gap: 0.5em; }
