/* ============================================================
   Relink player portal — intro, masthead, gates, rail
   Only presentation. API contract untouched.
   ============================================================ */

html.intro-on { background: #080d0a; }
html.intro-on:not(.intro-done) body { overflow: hidden; }
html.intro-on .reveal { opacity: 0; transform: translateY(18px); }
html.intro-on.intro-done .reveal { opacity: 1; transform: none; }

.reveal {
  transition:
    opacity .9s cubic-bezier(.2, .7, .2, 1) var(--d, 0s),
    transform .9s cubic-bezier(.2, .7, .2, 1) var(--d, 0s);
}

/* ---------- intro ---------- */
.intro {
  position: fixed; inset: 0; z-index: 9999;
  display: grid; place-items: center;
  background:
    radial-gradient(620px 420px at 50% 44%, rgba(168, 216, 143, .075), transparent 70%),
    radial-gradient(900px 600px at 50% 120%, rgba(217, 187, 123, .035), transparent 60%),
    #080d0a;
  transition: opacity .65s ease, visibility .65s ease;
}
.intro.is-out { opacity: 0; visibility: hidden; }
.intro.is-gone { display: none; }
.intro-stage { display: flex; flex-direction: column; align-items: center; gap: 16px; transform: translateY(-2vh); }
.intro-mark { width: min(320px, 62vw); height: auto; color: var(--accent); overflow: visible; }
.intro-arc {
  stroke-dasharray: 330; stroke-dashoffset: 330;
  animation: introDraw 1.15s cubic-bezier(.55, 0, .2, 1) .12s forwards;
}
.intro-node {
  transform-box: fill-box; transform-origin: center;
  transform: scale(0); opacity: 0;
  animation: introPop .6s cubic-bezier(.2, 1.5, .35, 1) forwards;
}
.intro-node-a { animation-delay: .92s; }
.intro-node-b { animation-delay: 1.05s; }
.intro-joint {
  transform-box: fill-box; transform-origin: center;
  opacity: 0; transform: scale(.35) rotate(-30deg);
  animation: introJoint .65s cubic-bezier(.2, 1.25, .3, 1) 1.2s forwards;
}
.intro-ping {
  transform-box: fill-box; transform-origin: center;
  opacity: 0; animation: introPing 2.1s ease-out 1.45s infinite;
}
.intro-word {
  font: 700 clamp(26px, 4.6vw, 42px)/1 "Segoe UI", "Noto Sans SC", system-ui, sans-serif;
  letter-spacing: .34em; padding-left: .34em; color: var(--fg);
  opacity: 0; transform: translateY(12px);
  animation: introText .8s cubic-bezier(.2, .7, .2, 1) 1.28s forwards;
}
.intro-word em { font-style: normal; color: var(--accent); }
.intro-sub {
  color: var(--muted); font-size: 10px; letter-spacing: .34em; padding-left: .34em;
  opacity: 0; animation: introText .8s cubic-bezier(.2, .7, .2, 1) 1.52s forwards;
}
.intro-track { width: 168px; height: 1px; background: rgba(168, 216, 143, .16); overflow: hidden; margin-top: 4px; }
.intro-track i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, transparent, var(--accent)); animation: introTrack 1.95s cubic-bezier(.6, 0, .2, 1) .28s forwards; }
.intro-skip {
  position: absolute; right: 26px; bottom: 24px;
  appearance: none; background: none; border: 1px solid var(--line);
  border-radius: 999px; color: var(--muted); padding: 7px 15px;
  font: inherit; font-size: 11px; letter-spacing: .08em; cursor: pointer;
  transition: .2s ease;
}
.intro-skip:hover { color: var(--fg); border-color: var(--line-bright); }

@keyframes introDraw { to { stroke-dashoffset: 0; } }
@keyframes introPop { to { transform: scale(1); opacity: 1; } }
@keyframes introJoint { to { transform: scale(1) rotate(0deg); opacity: 1; } }
@keyframes introPing {
  0% { transform: scale(.5); opacity: .7; }
  70% { transform: scale(2.1); opacity: 0; }
  100% { transform: scale(2.1); opacity: 0; }
}
@keyframes introText { to { opacity: 1; transform: none; } }
@keyframes introTrack { to { width: 100%; } }

/* ---------- masthead ---------- */
.masthead {
  position: relative; overflow: hidden;
  min-height: min(82vh, 780px);
  display: flex; align-items: center;
  padding: 34px 0 80px;
}
.masthead::after {
  content: ""; position: absolute; inset: auto 0 0 0; height: 220px; z-index: 1;
  background: linear-gradient(180deg, transparent, var(--bg));
  pointer-events: none;
}
.masthead-bg { position: absolute; inset: 6% 0 4% 52%; opacity: .82; pointer-events: none; will-change: transform; }
.masthead-bg svg { width: 100%; height: 100%; }
.masthead-inner { position: relative; z-index: 2; }
.masthead h1 {
  margin: 0;
  font-size: clamp(46px, 7.2vw, 96px);
  line-height: 1.02;
  letter-spacing: -.055em;
  font-weight: 680;
}
.masthead h1 .accent { color: var(--accent); }
.masthead h1 .line { display: block; overflow: hidden; padding-bottom: .05em; }
html.intro-on .masthead h1 .line > span { transform: translateY(112%); }
.masthead h1 .line > span {
  display: block;
  transition: transform 1.15s cubic-bezier(.16, .84, .24, 1);
}
.masthead h1 .line:nth-child(1) > span { transition-delay: .18s; }
.masthead h1 .line:nth-child(2) > span { transition-delay: .32s; }
html.intro-on.intro-done .masthead h1 .line > span { transform: none; }
.masthead .lede { max-width: 470px; margin-top: 22px; font-size: 15px; line-height: 1.9; }
.masthead .eyebrow { display: flex; align-items: center; gap: 9px; }
.masthead .eyebrow::before { content: ""; width: 24px; height: 1px; background: var(--gold); opacity: .7; }

.masthead-stats { display: flex; gap: clamp(24px, 3.6vw, 46px); margin-top: 34px; flex-wrap: wrap; }
.masthead-stats span { display: flex; flex-direction: column; gap: 3px; }
.masthead-stats b { font-size: clamp(26px, 3vw, 36px); font-weight: 640; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.masthead-stats em { font-style: normal; color: var(--muted); font-size: 10px; letter-spacing: .14em; }

.masthead-actions { display: flex; gap: 12px; margin-top: 32px; flex-wrap: wrap; }
.btn-primary {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 12px 21px; border-radius: 999px;
  background: var(--accent); color: #0c1210;
  font-size: 13px; font-weight: 600; letter-spacing: .03em;
  transition: background .25s ease, transform .25s ease;
}
.btn-primary:hover { background: #bce8a5; transform: translateY(-1px); }
.btn-primary span { transition: transform .25s ease; }
.btn-primary:hover span { transform: translateX(3px); }
.btn-ghost {
  display: inline-flex; align-items: center; padding: 12px 19px;
  border: 1px solid var(--line-bright); border-radius: 999px;
  color: var(--fg); font-size: 13px; transition: .25s ease;
}
.btn-ghost:hover { border-color: rgba(168, 216, 143, .42); background: rgba(168, 216, 143, .05); }

.masthead-scroll {
  position: absolute; left: 50%; bottom: 20px; z-index: 2;
  transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  color: var(--muted); font-size: 9px; letter-spacing: .3em;
}
.masthead-scroll i { width: 1px; height: 34px; background: linear-gradient(180deg, transparent, var(--accent)); animation: scrollHint 2.2s ease-in-out infinite; }
@keyframes scrollHint {
  0%, 100% { opacity: .3; transform: scaleY(.55); transform-origin: top; }
  50% { opacity: 1; transform: scaleY(1); }
}

/* ---------- link map ---------- */
.link-arc {
  fill: none; stroke: url(#linkGrad); stroke-width: 1.5;
  stroke-dasharray: 3 8; opacity: .85;
  animation: arcFlow 14s linear infinite;
}
.link-arc--2 { stroke-width: 1; opacity: .45; animation-duration: 19s; }
@keyframes arcFlow { to { stroke-dashoffset: -220; } }
.link-node {
  fill: var(--accent); filter: url(#softGlow);
  transform-box: fill-box; transform-origin: center;
  animation: nodeBreath 3.6s ease-in-out infinite;
}
@keyframes nodeBreath {
  0%, 100% { transform: scale(1); opacity: .9; }
  50% { transform: scale(1.14); opacity: 1; }
}
.link-halo { fill: none; stroke: rgba(168, 216, 143, .28); stroke-width: 1; }
.link-joint { fill: #0c1210; stroke: var(--accent); stroke-width: 1.6; }
.link-core {
  fill: #0c1210; stroke: var(--accent); stroke-width: 1.8;
  transform-box: fill-box; transform-origin: center;
  animation: coreBeat var(--beat-dur, 1.9s) cubic-bezier(.2, .8, .2, 1) infinite;
}
.link-core.is-degraded { stroke: var(--gold); }
.link-core.is-offline { stroke: var(--danger); }
@keyframes coreBeat {
  0% { transform: scale(1); opacity: .92; }
  14% { transform: scale(var(--beat-scale, 1.1)); opacity: 1; }
  28% { transform: scale(1.02); }
  42% { transform: scale(calc(1 + (var(--beat-scale, 1.1) - 1) * .35)); }
  58%, 100% { transform: scale(1); opacity: .92; }
}
.link-ping {
  fill: none; stroke: rgba(168, 216, 143, .55); stroke-width: 1;
  transform-box: fill-box; transform-origin: center;
  animation: canvasPing var(--beat-dur, 1.9s) ease-out infinite;
}
@keyframes canvasPing {
  0% { transform: scale(.62); opacity: .85; }
  70% { transform: scale(2.6); opacity: 0; }
  100% { transform: scale(2.6); opacity: 0; }
}
.flow-dot { fill: var(--accent); opacity: .95; }
.flow-dot--2 { fill: var(--gold); opacity: .85; }

/* ---------- gates ---------- */
.portal { padding: clamp(42px, 6vw, 84px) 0 26px; }
.portal-head { max-width: 640px; }
.portal-head h2 { margin: 0; font-size: clamp(30px, 4.2vw, 52px); letter-spacing: -.045em; font-weight: 660; }
.portal-head p:last-child { margin: 10px 0 0; color: var(--muted); font-size: 13px; }
.portal-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-top: 30px; }
.portal-card {
  position: relative; display: flex; flex-direction: column;
  min-height: 272px; padding: 26px 24px 22px;
  border: 1px solid var(--line); border-radius: 20px;
  background: linear-gradient(158deg, rgba(26, 42, 33, .92), rgba(10, 16, 13, .97));
  overflow: hidden;
  transition: transform .35s cubic-bezier(.2, .7, .2, 1), border-color .35s ease, box-shadow .35s ease;
}
.portal-card::before {
  content: ""; position: absolute; inset: -40% -20% auto -20%; height: 90%;
  background: radial-gradient(closest-side, rgba(168, 216, 143, .16), transparent);
  opacity: 0; transition: opacity .35s ease; pointer-events: none;
}
.portal-card:hover { transform: translateY(-6px); border-color: rgba(168, 216, 143, .34); box-shadow: 0 30px 60px rgba(0, 0, 0, .38); }
.portal-card:hover::before { opacity: 1; }
.portal-card::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(260px circle at var(--mx, 50%) var(--my, 50%), rgba(168, 216, 143, .10), transparent 62%);
  opacity: 0; transition: opacity .3s ease;
}
.portal-card:hover::after { opacity: 1; }
.portal-wm {
  position: absolute; right: 16px; bottom: -28px;
  font: 800 132px/1 "Segoe UI", system-ui, sans-serif;
  letter-spacing: -.07em; color: rgba(168, 216, 143, .045);
  pointer-events: none;
}
.portal-icon {
  width: 46px; height: 46px; display: grid; place-items: center;
  border-radius: 13px; border: 1px solid rgba(168, 216, 143, .28);
  background: rgba(168, 216, 143, .06);
  color: var(--accent); font: 700 13px/1 "Segoe UI", system-ui, sans-serif;
  letter-spacing: .05em;
  transition: transform .35s cubic-bezier(.2, .8, .2, 1), border-color .35s ease;
}
.portal-name { margin-top: 22px; font-size: 25px; font-weight: 650; letter-spacing: -.03em; }
.portal-sub { margin-top: 5px; color: var(--muted); font-size: 12px; }
.portal-desc { margin-top: 15px; color: var(--muted); font-size: 11px; line-height: 1.75; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.portal-addr {
  align-self: flex-start;
  display: inline-flex; align-items: center; gap: 8px;
  margin-top: 12px; padding: 7px 10px;
  border: 1px dashed rgba(168, 216, 143, .3); border-radius: 8px;
  color: var(--accent); font-size: 11px; letter-spacing: .03em;
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  cursor: pointer; transition: background .2s ease, border-color .2s ease;
}
.portal-addr i { font-style: normal; color: var(--muted); font-size: 10px; }
.portal-addr:hover { background: rgba(168, 216, 143, .07); border-color: rgba(168, 216, 143, .55); }
.portal-meta { margin-top: auto; display: flex; align-items: center; justify-content: space-between; padding-top: 20px; }
.portal-stat { color: var(--fg); font-size: 11px; letter-spacing: .02em; margin-left: 2px; }
.portal-lat { margin-left: auto; color: var(--muted); font-size: 10px; letter-spacing: .06em; font-variant-numeric: tabular-nums; }
.portal-go {
  position: absolute; right: 24px; top: 27px;
  display: flex; align-items: center; gap: 6px;
  color: var(--muted); font-size: 11px; letter-spacing: .08em;
  opacity: .72; transition: .3s ease;
}
.portal-go i { font-style: normal; transition: transform .3s ease; }
.portal-card:hover .portal-go { color: var(--accent); opacity: 1; }
.portal-card:hover .portal-go i { transform: translateX(4px); }
.portal-card:hover .portal-icon { transform: rotate(-4deg) scale(1.07); border-color: rgba(168, 216, 143, .5); }

/* ---------- rail ---------- */
.rail { margin-top: clamp(36px, 5vw, 62px); }
.rail-title span { margin-left: 10px; color: rgba(168, 216, 143, .5); font-size: 9px; letter-spacing: .16em; }
.rail-title {
  color: var(--muted); font-size: 10px; letter-spacing: .26em;
  padding-bottom: 10px; border-bottom: 1px solid var(--line);
}
.rail-row {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 6px; border-bottom: 1px solid var(--line);
  transition: background .2s ease, padding .2s ease;
}
.rail-row:hover { background: rgba(168, 216, 143, .035); padding-left: 12px; }
.rail-row { text-decoration: none; }
.rail-dot { width: 6px; height: 6px; border-radius: 50%; flex: 0 0 6px; background: var(--accent); }
.rail-dot.status-degraded { background: var(--warn); }
.rail-dot.status-offline { background: var(--danger); }
.rail-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.rail-desc { color: var(--muted); font-size: 11px; line-height: 1.7; margin-top: 2px; max-width: 640px; }
.rail-name { font-size: 14px; font-weight: 550; }
.rail-addr {
  display: inline-flex; align-items: center; gap: 7px;
  margin-top: 3px; color: var(--accent); font-size: 10px;
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  letter-spacing: .02em; cursor: pointer; transition: color .2s ease;
}
.rail-addr i { font-style: normal; color: var(--muted); font-size: 9px; }
.rail-addr:hover { color: #c4ecad; }
.rail-sub { color: var(--muted); font-size: 11px; }
.rail-lat { margin-left: auto; color: var(--muted); font-size: 10px; font-variant-numeric: tabular-nums; }
.rail-arrow { color: var(--muted); font-size: 12px; opacity: .45; transition: .2s ease; }
.rail-row:hover .rail-arrow { color: var(--accent); opacity: 1; transform: translate(2px, -2px); }

/* ---------- responsive ---------- */
@media (max-width: 980px) {
  .portal-grid { grid-template-columns: 1fr 1fr; }
  .portal-card:last-child { grid-column: 1 / -1; }
}
@media (max-width: 700px) {
  .masthead { min-height: auto; padding: 48px 0 72px; }
  .masthead h1 { font-size: clamp(40px, 12vw, 58px); }
  .masthead-bg { display: none; }
  .portal-grid { grid-template-columns: 1fr; }
  .portal-card:last-child { grid-column: auto; }
  .rail-row { align-items: flex-start; gap: 10px; padding: 14px 4px; }
  .rail-main { flex: 1; }
  .rail-lat { display: none; }
  .rail-arrow { align-self: flex-start; margin-top: 3px; }
  .intro-skip { right: 16px; bottom: 16px; }
  .topbar { flex-wrap: wrap; row-gap: 12px; }
  .top-actions { width: 100%; justify-content: space-between; gap: 8px; }
  .top-actions .live { flex: 1 1 100%; order: -1; }
  .top-actions .refresh, .top-actions .sponsor-trigger { padding: 7px 12px; font-size: 11px; }
}


/* ---------- quiet texture ---------- */
.ambient {
  background-image:
    linear-gradient(rgba(255, 255, 255, .016) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .016) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(circle at 50% 18%, #000, transparent 82%);
  opacity: .7;
}
.ambient::after {
  content: ""; position: absolute; inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='.55'/%3E%3C/svg%3E");
  opacity: .035; mix-blend-mode: soft-light;
}

.masthead::before {
  content: "RELINK";
  position: absolute; right: -2%; bottom: -2%; z-index: 2;
  font: 800 clamp(120px, 24vw, 360px)/.78 "Segoe UI", "Noto Sans SC", system-ui, sans-serif;
  letter-spacing: -.075em;
  color: rgba(168, 216, 143, .032);
  pointer-events: none; user-select: none;
  white-space: nowrap;
}
.masthead-inner::before {
  content: ""; position: absolute; left: -30px; top: 4%; bottom: 4%; width: 1px;
  background: linear-gradient(180deg, transparent, rgba(168, 216, 143, .16) 22%, rgba(168, 216, 143, .16) 78%, transparent);
  pointer-events: none;
}
.masthead-inner::after {
  content: ""; position: absolute; left: -34px; top: 4%; bottom: 4%; width: 7px;
  background: repeating-linear-gradient(180deg, rgba(168, 216, 143, .2) 0 1px, transparent 1px 32px);
  pointer-events: none;
}
@media (max-width: 700px) {
  .masthead::before { font-size: 34vw; opacity: .7; }
  .masthead-inner::before, .masthead-inner::after { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .intro { display: none; }
  .reveal { opacity: 1 !important; transform: none !important; }
  .link-arc, .link-ping, .flow-dot, .intro-arc, .intro-node, .intro-joint { animation: none !important; }
  .masthead-scroll i { animation: none; }
}
