/* Only on terryhu.cn, over Homecraft's engine/style.css. */

/* All three works share one frame, sized for three 400x869 image slots.
   Portrait images fill their slots; the landscape film keeps its proportions. */
#panel .work-deck {
  --work-ratio: calc(1200 / 869);
  --pad: 28px; --gap: 16px; --work-content-gap: 24px;
}
#panel .work-deck > li {
  --mh: var(--work-media-height, min(calc(100cqh - var(--head) - 16px - var(--work-content-gap) - 2 * var(--pad)),
    calc((100cqw - 2 * var(--peek) - 2 * var(--pad) - 16px - 2 * var(--gap)) / var(--work-ratio))));
  width: var(--work-card-width, calc(var(--mh) * var(--work-ratio) + 2 * var(--gap) + 2 * var(--pad) + 16px));
  max-height: 100%;
}
#panel .work-content {
  grid-template-rows: var(--head) var(--mh); gap: var(--work-content-gap);
  max-height: calc(100cqh - 16px); overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain;
  container: work-card / inline-size;
}
#panel .listing { align-content: center; }
#panel .listing > div { min-width: 0; }
#panel .listing h3 { font-size: 20px; line-height: 1.25; margin-bottom: 4px; }
#panel .listing p { color: var(--ink); font-size: 16px; font-weight: 500; line-height: 1.4; text-wrap: pretty; overflow-wrap: break-word; }
#panel .work-deck .shots a { width: calc(var(--mh) * 400 / 869); }
#panel .work-deck .shots img { width: 100%; height: 100%; object-fit: cover; background: #14262a; }
/* Homecraft images already include one consistently proportioned browser bar. */
#panel [data-work="homecraft"] .shots img { object-position: center; }
#panel [data-work="homecraft"] .shots a { overflow: hidden; border-radius: 10px; }

/* With three projects, the nearest card stays above the farther card on
   the same side, so clicking the visible edge selects the adjacent work. */
#panel [data-work="homecraft"].is-before,
#panel [data-work="sfsymbols"].is-after { z-index: 0; }

/* The shared header height is measured from all three actual listings. */
@media (max-width: 720px), (max-height: 620px) {
  #panel .work-deck { --pad: 14px; --gap: 8px; --work-content-gap: 12px; }
  #panel .listing { grid-template-columns: 44px minmax(0, 1fr) auto; gap: 10px; }
  #panel .listing > img { width: 44px; height: 44px; }
  #panel .listing h3 { font-size: 18px; line-height: 1.2; }
  #panel .listing p { font-size: 15px; }
}
@media (max-height: 620px) {
  #panel .work-deck { --work-content-gap: 12px; }
}
@media (max-width: 720px) {
  #panel[data-station="works"] { width: calc(100vw - 28px); max-width: none; }
  #panel .work-deck { --peek: 18px; }
}
@container work-card (max-width: 480px) {
  #panel .listing { grid-template-columns: 44px minmax(0, 1fr) auto; gap: 10px; }
  #panel .listing > img { width: 44px; height: 44px; }
  #panel .listing h3 { font-size: 18px; line-height: 1.2; }
  #panel .listing p { font-size: 15px; }
}
@container work-card (max-width: 360px) {
  #panel .listing { grid-template-columns: 56px minmax(0, 1fr) auto; gap: 8px; }
  #panel .listing > div { display: flex; flex-direction: column; gap: 4px; }
  #panel .listing > img { width: 56px; height: 56px; }
  #panel .listing h3 { margin: 0; font-size: 16px; overflow-wrap: anywhere; }
  #panel .listing .get { font-size: 12px; min-width: 52px; padding-inline: 8px; }
  #panel .listing p { margin: 0; font-size: 12px; }
}
@container work-card (max-width: 240px) {
  #panel .listing { grid-template-columns: 48px minmax(0, 1fr) auto; gap: 8px; }
  #panel .listing > img { width: 48px; height: 48px; }
  #panel .listing h3 { font-size: 15px; }
  #panel .listing p { font-size: 12px; }
}
body.reading #portalButton { visibility: hidden; }

/* Filing numbers required on the terryhu.cn homepage. */
#beian {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: max(3px, env(safe-area-inset-bottom));
  z-index: 4;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
  font: 8px/1.2 system-ui, -apple-system, sans-serif;
  pointer-events: none;
  opacity: 0.14;
  transition: opacity .3s ease;
}
#beian:hover, #beian:focus-within {
  opacity: 0.7;
}
#beian a {
  color: #ffffff;
  text-decoration: none;
  pointer-events: auto;
  white-space: nowrap;
  flex-shrink: 0;
}
#beian a:hover {
  text-decoration: underline;
}
body.photo-mode #beian { display: none !important; }
body.plain #beian {
  position: static;
  transform: none;
  justify-content: center;
  padding: 0 0 24px;
  opacity: 1;
}
body.plain #beian a { color: #888; }
body.plain #beian a:hover { color: #333; }
@media (max-width: 480px), (max-height: 520px) {
  #beian { font-size: 7.5px; gap: 8px; bottom: max(2px, env(safe-area-inset-bottom)); }
}

/* WeChat app icon in phone on terryhu.cn */
#phone .tile[style*="#07c160"] {
  background: #07c160 url('../assets/wechat.webp') center / cover no-repeat !important;
}
#phone .tile[style*="#07c160"] > * {
  display: none !important;
}

/* Directly display WeChat QR code inside phone card */
#phone .card:has(.tile[style*="#07c160"]) {
  padding: 0 !important;
  background: #191919 !important;
  justify-content: center !important;
  align-items: center !important;
  overflow: hidden !important;
}
#phone .card:has(.tile[style*="#07c160"]) > :not(.back, .wechat-qr-img) {
  display: none !important;
}
#phone .card:has(.tile[style*="#07c160"]) .back {
  z-index: 10;
  background: rgba(255, 255, 255, .22);
  color: #fff;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
#phone .card .wechat-qr-img {
  display: none;
  width: 100%;
  height: 100%;
  padding: 44px 8px 24px;
  box-sizing: border-box;
  object-fit: contain;
  pointer-events: auto;
  border-radius: 36px;
}
#phone .card:has(.tile[style*="#07c160"]) .wechat-qr-img {
  display: block;
}


