/* Shared running rows from the approved P01/P02 reference. */
#main { --portfolio-row-height: 60px; }
@media screen and (max-width: 1200px) { #main { --portfolio-row-height: 48px; } }
@media screen and (max-width: 768px) { #main { --portfolio-row-height: 44px; } }

#main .unified-sheet > .portfolio-running {
  --u-edge: clamp(40px, calc(5vw - 16px), 80px);
  /* Replace legacy display rules on fixed boards without changing their artwork selectors. */
  display: grid !important;
  position: relative;
  z-index: 5;
  box-sizing: border-box;
  flex: none;
  height: var(--portfolio-row-height);
  min-height: var(--portfolio-row-height);
  margin: 0;
  padding: 0 var(--u-edge);
  align-items: center;
  border: 0;
  background: none;
  color: var(--public-color-199);
  white-space: nowrap;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  font: 400 clamp(12px, calc(1.25vw - 3px), 15px)/1 var(--u-latin);
  letter-spacing: 0;
  gap: 0;
}

#main .unified-sheet > .portfolio-running > * { min-width: 0; line-height: 1; }
#main .unified-sheet > .portfolio-running :where(span,a) { color: inherit; }
#main .unified-sheet > .portfolio-running-footer { margin-top: auto; }

#main :is(#home,#contact) > .portfolio-running { color: rgb(255 255 255 / .75); }

#main .unified-sheet > .portfolio-running::after {
  content: '';
  position: absolute;
  inset-inline: var(--u-edge);
  pointer-events: none;
  /* A single rasterized row preserves the .5px source rule's coverage. */
  height: 1px;
  background: rgb(var(--u-divider-rgb, 255 255 255));
  mask: url('../assets/running-divider-1805.svg') center / 1760px 1px no-repeat;
  opacity: .5;
  transform: none;
}

#main .unified-sheet > .portfolio-running-header::after { bottom: 0; }
#main .unified-sheet > .portfolio-running-footer::after { top: 0; }

#main .unified-sheet > .portfolio-running .u-icon {
  background-color: rgb(var(--u-divider-rgb, 255 255 255));
}

#main .unified-sheet > .portfolio-running-header {
  grid-template-columns: minmax(0, 1fr) max-content minmax(0, 1fr);
}
#main .unified-sheet > .portfolio-running-header .u-brand { gap: .933333em; }
#main .unified-sheet > .portfolio-running-header .u-lucky { gap: .333333em; }
#main .unified-sheet > .portfolio-running-header .u-brand-mark {
  --icon-source: url('../assets/cq-overview-1606/80dfa.svg');
  width: 1.933333em;
  height: .8em;
}
#main .unified-sheet > .portfolio-running-header .u-lucky > .u-copy { width: 7.05em; }
#main .unified-sheet > .portfolio-running-header .u-arrow {
  --icon-source: url('../assets/cq-overview-1606/cb7e3.svg');
  width: .71184em;
  height: .659039em;
}
#main .unified-sheet > .portfolio-running-header .u-identity {
  margin: 0;
  text-align: center;
  font-size: var(--portfolio-label-size, 1em);
}
#main .unified-sheet > .portfolio-running-header:not(.portfolio-cover-header) .u-identity {
  --portfolio-label-size: min(12px, 1em);
  font-weight: 700;
}
#main .unified-sheet > .portfolio-running-header .portfolio-tags {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: .8em;
  font-family: var(--u-body);
}
#main .unified-sheet > .portfolio-running-header .u-tag-divider {
  --icon-source: url('../assets/cq-overview-1606/55be7.svg');
  width: .320766em;
  height: .645137em;
}
#main .unified-sheet > .portfolio-running-header .portfolio-tags strong {
  font-family: var(--u-latin);
  font-weight: 500;
}
#main .unified-sheet > .portfolio-running-header .portfolio-tags b { font-weight: 600; }

#main .unified-sheet > .portfolio-running .u-since { gap: .533333em; }
#main .unified-sheet > .portfolio-running .u-dot {
  --icon-source: url('../assets/cq-overview-1606/03e0b.svg');
  width: .8em;
  height: .8em;
}
#main .unified-sheet > .portfolio-running .portfolio-role { text-align: right; }
#main .unified-sheet > .portfolio-running .portfolio-role strong { font-weight: 500; }

#main .unified-sheet > .portfolio-running-footer .u-page-number {
  --portfolio-label-size: min(12px, 1em);
  position: static;
  transform: none;
  justify-self: center;
  font-size: var(--portfolio-label-size);
  opacity: .6;
}

#main #home > .portfolio-cover-footer { grid-template-columns: repeat(4, minmax(0, 1fr)); }
#main #home > .portfolio-cover-footer .portfolio-contact { text-align: center; white-space: pre; }
#main #home > .portfolio-cover-footer .portfolio-contact strong { font-weight: 900; }
#main #home > .portfolio-cover-footer .portfolio-contact a { text-decoration: none; }
#main #home > .portfolio-cover-footer .portfolio-contact a:is(:hover,:focus-visible) { text-decoration: underline; }

@media screen and (max-width: 1024px) {
  body:not(.canvas-mode) #main .unified-sheet > .portfolio-running {
    --u-edge: clamp(24px, 3.5vw, 36px);
    font-size: clamp(11px, 1.172vw, 12px);
  }
  body:not(.canvas-mode) #main .unified-sheet > .portfolio-running-header .portfolio-tags { gap: .42em; }
  /* These running labels have their own width-based sizing below the reader's body-text floor. */
  body:not(.canvas-mode) #main .unified-sheet > .portfolio-running [data-font-floor] {
    font-size: var(--portfolio-label-size, inherit) !important;
  }
}
@media screen and (min-width: 769px) and (max-width: 1000px) {
  body:not(.canvas-mode) #main .unified-sheet > .portfolio-running-header {
    grid-template-columns: max-content minmax(0, 1fr) max-content;
    column-gap: 8px;
  }
}
@media screen and (min-width: 729px) and (max-width: 900px) {
  body:not(.canvas-mode) #main #home > .portfolio-cover-footer {
    grid-template-columns: max-content minmax(0, 1fr) max-content max-content;
    column-gap: 8px;
  }
}

@media screen and (max-width: 768px) {
  body:not(.canvas-mode) #main .unified-sheet > .portfolio-running {
    --u-edge: clamp(8px, calc(8vw - 17.6px), 16px);
    column-gap: 6px;
    font-size: clamp(9px, 2.75vw, 11px);
  }
  body:not(.canvas-mode) #main .unified-sheet > .portfolio-running-header {
    grid-template-columns: minmax(0, 1fr) max-content;
  }
  body:not(.canvas-mode) #main .unified-sheet > .portfolio-running-header > .u-identity {
    --portfolio-label-size: clamp(8.75px, 2.48vw, 11px);
    display: block;
    text-align: right;
  }
  body:not(.canvas-mode) #main .unified-sheet > .portfolio-running-header .u-brand { gap: .45em; }
  body:not(.canvas-mode) #main .unified-sheet > .portfolio-running-header .u-brand-mark {
    width: 1.65em;
  }
  body:not(.canvas-mode) #main .unified-sheet > .portfolio-running-header .u-lucky > .u-copy { width: auto; }
  body:not(.canvas-mode) #main .unified-sheet > .portfolio-running-header :is(.portfolio-tags,.u-arrow) { display: none; }

  body:not(.canvas-mode) #main .unified-sheet > .portfolio-running-footer {
    grid-template-columns: minmax(0, 1fr) max-content minmax(0, 1fr);
  }
  body:not(.canvas-mode) #main .unified-sheet > .portfolio-running > .u-since { display: flex; }
  body:not(.canvas-mode) #main .unified-sheet > .portfolio-running-footer .u-page-number { opacity: 1; }

  body:not(.canvas-mode) #main #home.u-fixed {
    height: calc(1080px * var(--u-scale, 1) + 90px);
  }

}
@media screen and (max-width: 728px) {
  body:not(.canvas-mode) #main #home > .portfolio-cover-footer {
    grid-template-columns: max-content minmax(0, 1fr) max-content;
  }
  body:not(.canvas-mode) #main #home > .portfolio-cover-footer > .portfolio-phone { display: none; }
}
@media screen and (max-width: 570px) {
  body:not(.canvas-mode) #main #home > .portfolio-cover-footer {
    grid-template-columns: minmax(0, 1fr) max-content;
  }
  body:not(.canvas-mode) #main #home > .portfolio-cover-footer > .u-since { display: none; }
  body:not(.canvas-mode) #main #home > .portfolio-cover-footer .portfolio-email { text-align: left; }
}
@media screen and (max-width: 360px) {
  body:not(.canvas-mode) #main .unified-sheet > .portfolio-running-header .u-brand-mark { display: none; }
}

/* Fixed artwork keeps its own scale and clipping. Only its shared running rows sit outside the transform. */
#main :is(#home,#contact,.chapter-divider) > .portfolio-running,
html[data-theme='dark'] #main :is(
  #cq,#cq-context,#cq-pc,#cq-mobile,#cq-coding,#cq-architecture,#cq-skill,#cq-map,
  #cq-map-flow,#cq-quality,#cq-engineering,#cq-reuse,#zhike,#zhike-problem,#zhike-comparison,
  #zhike-before-after,#zhike-config-overview,#zhike-config-details,#zhike-config-workflow,
  #zhike-ai,#zhike-ai-flow,#zhike-ai-interaction,#zhike-review
) > .portfolio-running {
  position: absolute;
  inset-inline: 0;
}
#main .portfolio-running-header { top: 0; }
#main .portfolio-running-footer { bottom: 0; }
#main #about > .portfolio-running-header {
  position: absolute;
  inset-inline: 0;
}

/* These two approved DARK pages remain numbered and keep their footer hidden. */
html[data-theme='dark'] #main :is(#cq-context,#zhike-before-after) > .portfolio-running-footer {
  display: none !important;
}

@media screen and (min-width: 769px) {
  html[data-theme='dark'] body:not(.canvas-mode) #main :is(
    #cq-coding,#cq-architecture,#cq-skill,#cq-map,#cq-map-flow,#cq-quality,#cq-engineering,#cq-reuse
  ).portfolio-sheet {
    /* Reserve the added height beneath the original matrix or image crop. */
    --portfolio-footer-extra: max(0px, calc(var(--portfolio-row-height) - 60px * var(--zk592-scale, 1)));
    height: calc(1400px * var(--zk592-scale, 1) + 4px + var(--portfolio-footer-extra));
  }
}

html[data-theme='dark'] #main :is(
  #zhike,#zhike-problem,#zhike-comparison,#zhike-before-after,
  #zhike-config-overview,#zhike-config-details,#zhike-config-workflow,
  #zhike-ai,#zhike-ai-flow,#zhike-ai-interaction,#zhike-review
).portfolio-sheet {
  --portfolio-canvas-height: 1600px;
  --portfolio-canvas-border: 0px;
  --portfolio-head-extra: max(0px, calc(var(--portfolio-row-height) - 60px * var(--zk592-scale, 1)));
  --portfolio-foot-extra: var(--portfolio-head-extra);
  --portfolio-artwork-top: calc(-1 * var(--portfolio-head-extra) / var(--zk592-scale, 1));
  --portfolio-canvas-end-color: #090517;
  height: calc(var(--portfolio-canvas-height) * var(--zk592-scale, 1)
    + var(--portfolio-canvas-border) + var(--portfolio-head-extra) + var(--portfolio-foot-extra));
  background-image: linear-gradient(to bottom,
    #060713 calc(100% - var(--portfolio-foot-extra)), var(--portfolio-canvas-end-color) 0);
}
html[data-theme='dark'] #main #zhike.portfolio-sheet { --portfolio-canvas-end-color: #21003c; }
html[data-theme='dark'] #main #zhike-comparison.portfolio-sheet {
  --portfolio-canvas-height: 1800px;
  --portfolio-canvas-border: 4px;
}
html[data-theme='dark'] #main #zhike-before-after.portfolio-sheet { --portfolio-foot-extra: 0px; }
html[data-theme='dark'] #main :is(#zhike-config-details,#zhike-config-workflow).portfolio-sheet {
  --portfolio-canvas-height: 1080px;
}
html[data-theme='dark'] #main :is(#zhike-ai,#zhike-ai-flow,#zhike-ai-interaction,#zhike-review).portfolio-sheet {
  --portfolio-canvas-border: 2px;
}
html[data-theme='dark'] #main .portfolio-sheet > :is(.zk592-wrap,.zkp22-wrap,.zkp24-wrap,.zkp25-wrap) {
  top: var(--portfolio-head-extra) !important;
  bottom: var(--portfolio-foot-extra) !important;
}
html[data-theme='dark'] #main .portfolio-sheet > :is(.zk1763-stage,.zk08-stage,.zk09-stage,.zk10-stage,.zk11-stage) {
  top: var(--portfolio-head-extra) !important;
}

/* Keep decorative bleed tied to the outer rounded artboard. Phone and card masks remain local. */
html[data-theme='dark'] #main .portfolio-sheet :is(
  .zk592-canvas,.zkp22-canvas,.zk1763-stage,.zkp24-canvas,.zkp25-canvas,.zkp26-canvas,.zkp27-canvas,
  .zk08-stage,.zk09-stage,.zk10-stage,.zk11-stage
) {
  overflow: visible !important;
}
html[data-theme='dark'] #main .portfolio-sheet :is(
  .zk592-number,.zkp22-number,.zk1763-number,.zkp24-number,.zkp25-number,.zkp26-number,.zkp27-number,
  .zk08-number,.zk09-number,.zk10-number,.zk11-number
) {
  translate: 0 var(--portfolio-artwork-top, 0px);
}
html[data-theme='dark'] #main .portfolio-sheet :is(
  .zk592-header,.zk592-footer,.zk1763-running,.zk08-top,.zk09-top,.zk10-top,.zk11-top,
  .zk08-stage > .u-footer,.zk09-stage > .u-footer,.zk10-stage > .u-footer,.zk11-stage > .u-footer
) {
  display: none !important;
}
