/* ============================================================
   Zhongxin Energy - extras: opening sequence + certificate lightbox
   Loaded after style.css. Uses logical properties so RTL (ug) works.
   ============================================================ */

[hidden] { display: none !important; }
html.intro-skip .intro { display: none !important; }
html:not(.js) .intro { display: none !important; }
html.intro-playing body { overflow: hidden; }
/* fail-safe: never let the intro block the site if JS fails */
@keyframes introFailSafe { to { opacity: 0; visibility: hidden; pointer-events: none; } }
.intro { animation: introFailSafe .01s linear 9s forwards; }

/* ---------- clickable certificate cards ---------- */
.cert-item[data-cert] { cursor: pointer; position: relative; padding-inline-end: 46px; }
.cert-item[data-cert]:focus-visible {
  outline: 2px solid var(--gold-600);
  outline-offset: 2px;
}
.cert-item[data-cert] .cert-more {
  position: absolute;
  inset-inline-end: 16px;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0;
  color: var(--gold-700);
  white-space: nowrap;
  opacity: .7;
  transition: opacity .25s, transform .25s;
}
.cert-item[data-cert]:hover .cert-more { opacity: 1; transform: translateY(-50%) translateX(2px); }
html[dir="rtl"] .cert-item[data-cert]:hover .cert-more { transform: translateY(-50%) translateX(-2px); }
.cert-more svg { width: 12px; height: 12px; }
html[dir="rtl"] .cert-more svg { transform: scaleX(-1); }

/* ---------- certificate lightbox ---------- */
.cert-modal {
  position: fixed; inset: 0; z-index: 10000;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.cert-modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(6, 23, 38, .72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.cert-modal-panel {
  position: relative;
  width: min(920px, 100%);
  max-height: min(88vh, 900px);
  overflow-y: auto;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 40px 90px -30px rgba(0, 0, 0, .6);
  padding: 30px 32px 28px;
  animation: certPanelIn .3s ease both;
}
@keyframes certPanelIn {
  from { opacity: 0; transform: translateY(16px) scale(.98); }
  to   { opacity: 1; transform: none; }
}
.cert-modal-close {
  position: absolute; inset-inline-end: 16px; top: 14px;
  width: 38px; height: 38px; border: 0; border-radius: 50%;
  background: var(--soft); color: var(--ink);
  font-size: 25px; line-height: 1; cursor: pointer;
  display: grid; place-items: center;
  transition: background .2s, transform .2s;
}
.cert-modal-close:hover { background: var(--line); transform: rotate(90deg); }
.cert-modal-eyebrow {
  margin: 0 0 6px;
  font-size: 12px; font-weight: 700; letter-spacing: .14em;
  text-transform: uppercase; color: var(--gold-700);
}
.cert-modal-title {
  margin: 0 0 18px;
  font-size: clamp(19px, 2.3vw, 25px);
  font-weight: 700; line-height: 1.35; color: var(--navy-700);
  padding-inline-end: 44px;
}
html[dir="rtl"] .cert-modal-title { line-height: 1.6; font-size: 20px; }
.cert-modal-tabs { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.cert-modal-tab {
  border: 1px solid var(--line); background: var(--soft);
  color: var(--body); font: inherit; font-size: 13px; font-weight: 600;
  padding: 8px 18px; border-radius: 999px; cursor: pointer;
  transition: all .2s;
}
.cert-modal-tab.is-active {
  background: var(--navy-700); border-color: var(--navy-700); color: #fff;
}
.cert-modal-media {
  background: var(--soft-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  text-align: center;
}
.cert-modal-media img {
  display: block; width: 100%; height: auto;
  max-height: 62vh; object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 4px 18px rgba(13, 26, 41, .12);
}
.cert-modal-note {
  margin: 14px 0 0;
  font-size: 12.5px; line-height: 1.7; color: var(--muted);
  text-align: center;
}
.cert-modal-pending {
  padding: 30px 18px 24px;
  text-align: center;
}
.cert-modal-pending .pending-ico {
  width: 62px; height: 62px; margin: 0 auto 16px;
  border-radius: 50%; display: grid; place-items: center;
  background: rgba(27, 94, 67, .1); color: var(--green-700);
}
.cert-modal-pending .pending-ico svg { width: 30px; height: 30px; }
.cert-modal-pending p {
  margin: 0 0 18px;
  font-size: 15px; line-height: 1.8; color: var(--body);
  text-wrap: balance;
}
.cert-modal-pending a {
  display: inline-block;
  padding: 11px 26px; border-radius: 999px;
  background: var(--navy-700); color: #fff;
  text-decoration: none; font-size: 14px; font-weight: 600;
  transition: background .2s;
}
.cert-modal-pending a:hover { background: var(--navy-600); }
body.cert-modal-open { overflow: hidden; }

/* ---------- opening sequence ---------- */
.intro {
  position: fixed; inset: 0; z-index: 9999;
  background: var(--navy-900);
  color: #fff;
  overflow: hidden;
  opacity: 1;
  transition: opacity .6s ease, visibility .6s;
}
.intro.is-done { opacity: 0; visibility: hidden; pointer-events: none; }
.intro-frame {
  position: absolute; inset: 0;
  opacity: 0; visibility: hidden;
  background-size: cover; background-position: center;
  display: flex; align-items: center;
  transition: opacity .8s ease, visibility .8s;
}
.intro-frame::after {
  content: ""; position: absolute; inset: 0;
  background:
    linear-gradient(90deg, rgba(6,23,38,.86) 0%, rgba(6,23,38,.58) 48%, rgba(6,23,38,.22) 100%),
    linear-gradient(0deg, rgba(6,23,38,.55) 0%, rgba(6,23,38,0) 60%);
}
html[dir="rtl"] .intro-frame::after {
  background:
    linear-gradient(270deg, rgba(6,23,38,.86) 0%, rgba(6,23,38,.58) 48%, rgba(6,23,38,.22) 100%),
    linear-gradient(0deg, rgba(6,23,38,.55) 0%, rgba(6,23,38,0) 60%);
}
.intro-frame.is-brand {
  background:
    radial-gradient(900px 520px at 78% 40%, rgba(30,69,116,.55), transparent 70%),
    linear-gradient(135deg, #061726 0%, #0A2140 58%, #123A63 100%);
}
.intro-frame.is-brand::after { display: none; }
.intro-frame.is-active { opacity: 1; visibility: visible; }
.intro-frame.is-active .intro-bg { animation: introKen 6s ease-out both; }
.intro-bg { position: absolute; inset: 0; background-size: cover; background-position: center; }
@keyframes introKen { from { transform: scale(1.02); } to { transform: scale(1.12); } }

.intro-brand {
  position: absolute; top: 28px; inset-inline-start: 34px; z-index: 3;
  display: flex; align-items: center; gap: 11px;
  font-size: 14px; font-weight: 700; letter-spacing: .16em;
  color: rgba(255,255,255,.9);
}
.intro-brand img { width: 34px; height: 34px; }
.intro-copy {
  position: relative; z-index: 2;
  width: 100%; max-width: 1200px; margin: 0 auto;
  padding: 0 clamp(28px, 6vw, 84px);
  text-align: start;
}
.intro-tag {
  margin: 0 0 18px;
  font-size: 12px; font-weight: 700; letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--gold-300);
  display: flex; align-items: center; gap: 12px;
}
.intro-tag::before { content: ""; width: 34px; height: 2px; background: var(--gold-500); flex: 0 0 34px; }
html[dir="rtl"] .intro-tag { letter-spacing: 0; }
.intro-title {
  margin: 0 0 18px;
  font-size: clamp(30px, 5vw, 62px);
  font-weight: 700; line-height: 1.2; letter-spacing: .01em;
  color: #fff;
  text-wrap: balance;
  text-shadow: 0 2px 24px rgba(0,0,0,.3);
}
.intro-sub {
  margin: 0; max-width: 620px;
  font-size: clamp(14px, 1.6vw, 18px); line-height: 1.8;
  color: rgba(255,255,255,.82);
  text-wrap: balance;
}
html[dir="rtl"] .intro-title { font-size: clamp(24px, 3.6vw, 42px); line-height: 1.6; }
html[dir="rtl"] .intro-sub { line-height: 2; }
.intro-frame.is-active .intro-tag,
.intro-frame.is-active .intro-title,
.intro-frame.is-active .intro-sub {
  animation: introCopyIn .8s cubic-bezier(.2,.7,.2,1) both;
}
.intro-frame.is-active .intro-title { animation-delay: .1s; }
.intro-frame.is-active .intro-sub   { animation-delay: .22s; }
@keyframes introCopyIn {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: none; }
}

.intro-ui {
  position: absolute; z-index: 4; bottom: 34px;
  inset-inline-start: clamp(28px, 6vw, 84px);
  inset-inline-end: clamp(28px, 6vw, 84px);
  display: flex; align-items: center; justify-content: space-between;
  gap: 18px; flex-wrap: wrap;
}
.intro-dots { display: flex; gap: 8px; }
.intro-dot {
  width: 30px; height: 3px; border-radius: 2px;
  background: rgba(255,255,255,.25);
  overflow: hidden;
}
.intro-dot span {
  display: block; width: 0; height: 100%; background: var(--gold-500);
}
.intro-dot.is-past span { width: 100%; }
.intro-dot.is-on span { animation: introDotFill var(--frame-ms, 1350ms) linear both; }
@keyframes introDotFill { from { width: 0; } to { width: 100%; } }
.intro-actions { display: flex; align-items: center; gap: 12px; }
.intro-btn {
  border: 1px solid rgba(255,255,255,.35);
  background: rgba(255,255,255,.06);
  color: rgba(255,255,255,.9);
  font: inherit; font-size: 13px; font-weight: 600;
  padding: 10px 22px; border-radius: 999px; cursor: pointer;
  transition: background .2s, border-color .2s, transform .2s;
  backdrop-filter: blur(4px);
}
.intro-btn:hover { background: rgba(255,255,255,.16); border-color: rgba(255,255,255,.6); transform: translateY(-2px); }
.intro-btn.is-primary { background: var(--gold-600); border-color: var(--gold-600); color: #14283F; }
.intro-btn.is-primary:hover { background: var(--gold-500); }
html[dir="rtl"] .intro-btn { font-size: 12.5px; }
.intro-progress {
  position: absolute; bottom: 0; left: 0; right: 0; height: 3px;
  background: rgba(255,255,255,.12); z-index: 5;
}
.intro-progress span {
  display: block; width: 0; height: 100%;
  background: linear-gradient(90deg, var(--gold-700), var(--gold-300));
}
body.intro-open { overflow: hidden; }

@media (max-width: 640px) {
  .intro-brand { top: 20px; inset-inline-start: 22px; font-size: 12px; }
  .intro-copy { padding: 0 26px; }
  .intro-tag { margin-bottom: 14px; font-size: 11px; }
  .intro-title { font-size: clamp(26px, 8vw, 36px); margin-bottom: 14px; }
  .intro-sub { font-size: 13.5px; line-height: 1.7; }
  .intro-ui { bottom: 24px; inset-inline-start: 26px; inset-inline-end: 26px; }
  .intro-dot { width: 22px; }
  .intro-btn { padding: 9px 16px; font-size: 12px; }
  .cert-modal { padding: 14px; }
  .cert-modal-panel { padding: 24px 18px 22px; max-height: 90vh; }
  .cert-modal-media { padding: 8px; }
  .cert-item[data-cert] { padding-inline-end: 40px; }
}
@media (prefers-reduced-motion: reduce) {
  .intro-frame.is-active .intro-bg,
  .intro-frame.is-active .intro-tag,
  .intro-frame.is-active .intro-title,
  .intro-frame.is-active .intro-sub,
  .intro-dot.is-on span { animation: none; }
  .intro-dot.is-on span { width: 100%; }
}
