/* ABOUT: party screen / character sheet (SPEC §4.2). Scoped under html.is-game; the plain CV keeps site.css. */

html.is-game .card--about { --card-w: 780px; }
html.is-game .card--about .sheet { grid-template-columns: minmax(0, 1fr) 200px; gap: 30px; }
html.is-game .card--about .prose .aside { padding-right: 56px; }

/* ---------------------------------------------------------------- side: portrait, nameplate, stat plate */
html.is-game .card--about .sheet__side { width: 200px; gap: 0; justify-items: stretch; }
html.is-game .card--about .portrait {
  position: relative; justify-self: center; width: 160px; height: 160px; margin: 8px 0 14px; border-radius: 0; overflow: visible;
  background: var(--ucsd-navy-3);
  box-shadow: 0 0 0 2px var(--ucsd-navy-3), 0 0 0 4px var(--gold), 0 0 0 6px var(--ucsd-navy-3), 0 0 0 7px var(--gold-a45), 0 18px 40px rgba(0, 0, 0, 0.5);
  clip-path: polygon(-3px -7px, calc(100% + 3px) -7px, calc(100% + 3px) -3px, calc(100% + 7px) -3px, calc(100% + 7px) calc(100% + 3px), calc(100% + 3px) calc(100% + 3px), calc(100% + 3px) calc(100% + 7px), -3px calc(100% + 7px), -3px calc(100% + 3px), -7px calc(100% + 3px), -7px -3px, -3px -3px);
}
html.is-game .card--about .portrait:hover { transform: none; }
html.is-game .card--about .portrait img { display: block; width: 100%; height: 100%; object-fit: cover; }
.portrait__px { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; opacity: 0; transition: opacity 300ms var(--ease); pointer-events: none; }
html.is-game .portrait__px { display: block; }
html.is-game .portrait.has-px .portrait__px { opacity: 1; }
html.is-game .portrait.has-px.is-photo .portrait__px,
html.is-game .portrait.is-voxel .portrait__px { opacity: 0; }
/* a scanline sheen over the sprite version, gone on the photo */
html.is-game .card--about .portrait::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.12) 0 1px, transparent 1px 3px);
  transition: opacity 300ms;
}
html.is-game .card--about .portrait.is-photo::after, html.is-game .card--about .portrait:not(.has-px)::after { opacity: 0; }
html.rm .portrait__px { transition: none; }

.sheet__plate { display: grid; justify-items: center; gap: 2px; margin: 4px 0 12px; text-align: center; }
.sheet__plate b { font: 600 18px/1.1 var(--px-title); letter-spacing: 0.08em; text-transform: uppercase; color: var(--gold); text-shadow: 0 2px 0 rgba(0, 0, 0, 0.5); }
.sheet__plate > span:not(.sheet__party) { font: 400 10px/1.3 var(--px); letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-3); }
.sheet__party { display: flex; justify-content: center; align-items: flex-end; gap: 6px; height: 36px; margin-top: 6px; }
.sheet__member { display: grid; place-items: end center; width: 32px; height: 36px; border-bottom: 2px solid var(--gold-a45); }
.sheet__member img { width: 24px; height: auto; image-rendering: pixelated; }
.sheet__member--me img { animation: member-bob 1.6s steps(2) infinite; }
.sheet__member--zhuo img { animation: member-bob 1.6s steps(2) 0.8s infinite; }
.sheet__member.is-join { animation: member-join 560ms var(--ease) both; }
@keyframes member-bob { 50% { transform: translateY(-1px); } }
@keyframes member-join { 0% { transform: translate(-60px, -30px) scale(0.6); opacity: 0; } 55% { transform: translate(-10px, -18px); opacity: 1; } 80% { transform: translateY(2px); } 100% { transform: none; } }
section:not(.is-live) .sheet__member img { animation-play-state: paused; }
html.rm .sheet__member img, html.rm .sheet__member.is-join { animation: none; }

html.is-game .card--about .sheet__stats {
  gap: 0; padding: 6px 10px; border-radius: 4px; font-size: 14px;
  background: rgba(8, 12, 24, 0.55); border: 1px solid rgba(255, 205, 0, 0.14);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
html.is-game .card--about .sheet__stats div { grid-template-columns: 1fr; gap: 1px; padding: 6px 0; border-bottom: 1px dashed rgba(233, 236, 241, 0.1); }
html.is-game .card--about .sheet__stats div:last-child { border-bottom: 0; }
html.is-game .card--about .sheet__stats dt { font: 400 10px/1.2 var(--px); letter-spacing: 0.12em; color: var(--gold); opacity: 0.8; }
html.is-game .card--about .sheet__stats dd { font: 400 14px/1.35 var(--sans); color: var(--ink); }
html.is-game .card--about .sheet__stats a { text-decoration-color: var(--gold-a45); }

/* ---------------------------------------------------------------- affinity chips */
.affinities { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 20px 0 0; padding: 0; list-style: none; }
.affinities::before { content: 'Interests'; margin-right: 4px; font: 400 10px/1 var(--px); letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-3); }
html.is-game .affinity {
  display: inline-flex; align-items: center; gap: 7px; height: 28px; padding: 0 10px 0 8px; border-radius: 4px;
  font: 400 10px/1 var(--px); letter-spacing: 0.08em; color: var(--ink-2);
  background: rgba(24, 43, 73, 0.55); border: 1px solid var(--line-2);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.25);
}
.affinity::before { content: ''; width: 7px; height: 7px; background: var(--ink-3); transform: rotate(45deg); transition: background-color var(--t-ui), box-shadow var(--t-ui); }
html.is-game .affinity:hover { color: var(--ink); border-color: var(--gold-a45); transform: translateY(-1px); }
html.is-game .affinity:hover::before { background: var(--gold); }
html.is-game .affinity[aria-pressed='true'] { color: var(--teal); border-color: var(--teal); background: rgba(0, 198, 215, 0.1); box-shadow: 0 0 14px var(--teal-a30), inset 0 -2px 0 rgba(0, 0, 0, 0.25); }
html.is-game .affinity[aria-pressed='true']::before { background: var(--teal); box-shadow: 0 0 6px var(--teal); }
@media (pointer: coarse) { html.is-game .affinity { min-height: 44px; } }
.affinities__out { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; min-height: 22px; margin-top: 8px; font-size: 13px; color: var(--ink-3); }
.affinities__out:empty { min-height: 0; margin-top: 0; }
.affinities__k { font: 400 10px/1 var(--px); letter-spacing: 0.1em; text-transform: uppercase; color: var(--teal); }
.affinities__link {
  padding: 2px 0; border: 0; background: none; font: 500 13px/1.3 var(--sans); color: var(--ink);
  text-decoration: underline; text-decoration-color: var(--teal); text-underline-offset: 3px; cursor: pointer;
}
.affinities__link:hover { color: var(--teal); }
.affinities__link::after { content: ' ↓'; color: var(--teal); }

/* ---------------------------------------------------------------- party member: Chef Zhuo */
.party {
  position: relative; display: grid; grid-template-columns: 76px auto auto 1fr; align-items: center; gap: 8px 10px;
  margin-top: 18px; padding: 12px 14px 12px 12px; border-radius: 6px;
  background: linear-gradient(90deg, rgba(24, 43, 73, 0.55), rgba(12, 18, 34, 0.4));
  border: 1px solid rgba(255, 205, 0, 0.16); box-shadow: inset 3px 0 0 var(--gold-a45);
}
.party.is-joined { box-shadow: inset 3px 0 0 var(--hp); }
.party__k { grid-column: 2 / -1; grid-row: 1; font: 400 9px/1 var(--px); letter-spacing: 0.14em; text-transform: uppercase; color: var(--gold); opacity: 0.85; }
.party.is-joined .party__k { color: var(--hp); }
.party__sprite {
  grid-column: 1; grid-row: 1 / span 3; align-self: stretch; display: grid; place-items: end center; padding-bottom: 6px;
  background: radial-gradient(ellipse at 50% 88%, rgba(255, 205, 0, 0.16), transparent 60%), rgba(8, 12, 24, 0.6);
  border-radius: 4px; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}
.party__sprite img { width: 48px; height: auto; image-rendering: pixelated; margin-right: 10px; }
.party__name { grid-column: 2 / -1; grid-row: 2; margin: 0; font: 600 16px/1.2 var(--px-title); color: var(--ink); letter-spacing: 0.02em; }
.party__role { display: block; margin-top: 3px; font: 400 13px/1.4 var(--sans); color: var(--ink-2); letter-spacing: 0; }
.party [data-act='pan'] { grid-column: 2; grid-row: 3; }
.party [data-act='invite'] { grid-column: 3; grid-row: 3; }
.party.is-joined [data-act='invite'] { color: var(--hp); border-color: rgba(74, 222, 128, 0.5); opacity: 1; }
.party .token { grid-column: 4; grid-row: 3; justify-self: start; margin: -10px 0; }
.party .token.is-pop { animation: token-pop 520ms var(--ease) both; }
@keyframes token-pop { 0% { transform: translate(-150px, 10px) scale(0.4); opacity: 0; } 50% { transform: translate(-70px, -34px); opacity: 1; } 100% { transform: none; } }

/* the pan: pixel art in CSS, held at the chef's hand */
.party__pan {
  grid-column: 1; grid-row: 1 / span 3; align-self: end; justify-self: end; position: relative; width: 30px; height: 12px; margin: 0 -2px 16px 0;
  transform-origin: 90% 50%; pointer-events: none;
}
.party__pan::before { /* pan body */
  content: ''; position: absolute; left: 0; bottom: 0; width: 20px; height: 6px;
  background: #2b2f3a; box-shadow: 0 -2px 0 #4b5263, inset 0 -2px 0 #15171d;
  clip-path: polygon(2px 0, 18px 0, 20px 2px, 20px 4px, 18px 6px, 2px 6px, 0 4px, 0 2px);
}
.party__pan::after { /* handle */
  content: ''; position: absolute; left: 19px; bottom: 2px; width: 11px; height: 3px; background: #7c4a1e; box-shadow: inset 0 -1px 0 #4a2a0e;
}
.party__food { /* tomato and egg */
  position: absolute; left: 4px; bottom: 5px; width: 12px; height: 4px;
  background:
    linear-gradient(#ef4444, #ef4444) 2px 0 / 4px 3px no-repeat,
    linear-gradient(#facc15, #facc15) 6px 1px / 5px 3px no-repeat,
    linear-gradient(#fde68a, #fde68a) 0 2px / 12px 2px no-repeat;
}
.party__steam { position: absolute; left: 4px; bottom: 10px; width: 14px; height: 16px; }
.party__steam i { position: absolute; bottom: 0; width: 3px; height: 3px; background: rgba(226, 232, 240, 0.7); opacity: 0; }
.party__steam i:nth-child(1) { left: 0; } .party__steam i:nth-child(2) { left: 5px; } .party__steam i:nth-child(3) { left: 10px; }
.party__pan.is-flip { animation: pan-flip 300ms steps(2) both; }
.party__pan.is-flip .party__food { animation: food-flip 620ms var(--ease) both; }
.party__pan.is-flip .party__steam i { animation: steam 900ms ease-out both; }
.party__pan.is-flip .party__steam i:nth-child(2) { animation-delay: 120ms; }
.party__pan.is-flip .party__steam i:nth-child(3) { animation-delay: 240ms; }
@keyframes pan-flip { 0% { transform: rotate(0); } 40% { transform: rotate(-30deg); } 100% { transform: rotate(0); } }
@keyframes food-flip { 0% { transform: none; } 45% { transform: translateY(-22px) rotate(180deg); } 80% { transform: translateY(0) rotate(360deg); } 90% { transform: translateY(-2px) rotate(360deg); } 100% { transform: rotate(360deg); } }
@keyframes steam { 0% { opacity: 0; transform: none; } 20% { opacity: 0.8; } 100% { opacity: 0; transform: translateY(-16px) scale(1.6); } }
html.rm .party__pan.is-flip, html.rm .party__pan.is-flip .party__food, html.rm .party__pan.is-flip .party__steam i, html.rm .party .token.is-pop { animation: none; }

/* ---------------------------------------------------------------- phones */
@media (max-width: 860px) {
  html.is-game .card--about .sheet { grid-template-columns: 1fr; gap: 18px; }
  html.is-game .card--about .sheet__side { order: -1; width: auto; grid-template-columns: 112px 1fr; column-gap: 18px; align-items: center; }
  html.is-game .card--about .portrait { width: 104px; height: 104px; margin: 8px 0 8px 6px; grid-row: 1; grid-column: 1; }
  html.is-game .card--about .sheet__plate { grid-row: 1; grid-column: 2; justify-items: start; text-align: left; margin: 0; }
  html.is-game .card--about .sheet__party { justify-content: flex-start; }
  html.is-game .card--about .sheet__stats { grid-column: 1 / -1; grid-template-columns: 1fr 1fr; column-gap: 14px; margin-top: 12px; }
  html.is-game .card--about .sheet__stats div:nth-last-child(2) { border-bottom: 0; }
  .party { grid-template-columns: 60px minmax(0, 1fr); }
  .party__sprite, .party__pan { grid-row: 1 / span 2; }
  .party [data-act='pan'], .party [data-act='invite'] { grid-column: 1 / -1; width: 100%; }
  .party [data-act='pan'] { grid-row: 3; }
  .party [data-act='invite'] { grid-row: 4; }
  .party .token { grid-column: 1 / -1; grid-row: 5; justify-self: center; margin: 0; }
  .affinities::before { flex-basis: 100%; }
}

/* ---------------------------------------------------------------- the portrait's back side (portrait-flip.js)
   A clean double-click flips the photo over like a card and plays assets/video/intro.*. The card lives in a
   fixed overlay on <body>; the portrait keeps its slot (hidden) while the card is out. Works in every mode. */
.portrait { touch-action: manipulation; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
.portrait.is-flipped { visibility: hidden; }
.pflip { position: fixed; inset: 0; z-index: 125; }
.pflip__backdrop {
  position: absolute; inset: 0; touch-action: none;
  background: radial-gradient(circle at 50% 50%, rgba(24, 43, 73, 0.42), rgba(4, 6, 12, 0.66) 70%);
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
}
.pflip__card { position: absolute; transform-style: preserve-3d; will-change: transform; touch-action: none; }
.pflip__face {
  position: absolute; inset: 0; overflow: hidden; border-radius: 14px; background: var(--ucsd-navy-3);
  -webkit-backface-visibility: hidden; backface-visibility: hidden;
  box-shadow: 0 0 0 1px var(--line-2), 0 24px 60px rgba(0, 0, 0, 0.55);
}
.pflip__back { transform: rotateY(180deg); }
.pflip__front img, .pflip__px, .pflip__video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.pflip__front img { filter: saturate(0.9); }
.pflip__front.is-voxel img { filter: none; image-rendering: pixelated; }
.pflip__px { display: none; image-rendering: pixelated; }
.pflip__front.has-px .pflip__px { display: block; }
.pflip__video { background: #000; }
/* the game look: the portrait's gold double ring with clipped corners */
html.is-game .pflip__face {
  border-radius: 0;
  box-shadow: 0 0 0 2px var(--ucsd-navy-3), 0 0 0 4px var(--gold), 0 0 0 6px var(--ucsd-navy-3), 0 0 0 7px var(--gold-a45), 0 24px 60px rgba(0, 0, 0, 0.55);
  clip-path: polygon(-3px -7px, calc(100% + 3px) -7px, calc(100% + 3px) -3px, calc(100% + 7px) -3px, calc(100% + 7px) calc(100% + 3px), calc(100% + 3px) calc(100% + 3px), calc(100% + 3px) calc(100% + 7px), -3px calc(100% + 7px), -3px calc(100% + 3px), -7px calc(100% + 3px), -7px -3px, -3px -3px);
}
html.is-game .pflip__back { background: #000; }
html.is-plain .pflip__face { border-radius: 12px; box-shadow: 0 0 0 1px var(--line-2), 0 18px 44px rgba(0, 0, 0, 0.5); }

.pflip__btns { position: absolute; top: 10px; right: 10px; display: flex; gap: 8px; }
.pflip__btn {
  display: grid; place-items: center; width: 36px; height: 36px; padding: 0; border: 1px solid rgba(255, 255, 255, 0.28); border-radius: 50%;
  background: rgba(8, 11, 22, 0.62); color: #fff; cursor: pointer; transition: background 0.2s, border-color 0.2s, transform 0.2s;
}
.pflip__btn:hover { background: rgba(8, 11, 22, 0.85); border-color: var(--accent); }
.pflip__btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.pflip__btn svg { display: block; }
html.is-game .pflip__btn { border-radius: 0; border: 2px solid var(--gold); background: rgba(15, 29, 51, 0.82); color: var(--gold); box-shadow: 0 2px 0 rgba(0, 0, 0, 0.5); }
html.is-game .pflip__btn:hover { background: var(--ucsd-navy-2); }
html.is-game .pflip__btn:focus-visible { outline-color: #fff; }
.pflip__bar { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(0, 0, 0, 0.35); pointer-events: none; }
.pflip__bar i { display: block; height: 100%; background: var(--accent); transform: scaleX(0); transform-origin: 0 50%; }
html.is-game .pflip__bar i { background: var(--gold); }
/* reduced motion: no flip at all, the back face simply fades in at the target size */
.pflip.is-rm .pflip__front { display: none; }
.pflip.is-rm .pflip__back { transform: none; }
.pflip.is-out { pointer-events: none; }
.pflip.is-out .pflip__btns { opacity: 0; transition: opacity 0.12s; }
@media (pointer: coarse) { .pflip__btn { width: 40px; height: 40px; } }
@media print { .pflip { display: none; } .portrait.is-flipped { visibility: visible; } }

/* ---------------------------------------------------------------- the portrait's minifigure face (portrait-swap.js)
   One click builds assets/img/portrait-lego.webp out of 5x5 bricks over the photo (bottom row first); the next click
   pops them off again. The bricks live inside the portrait (clipped by its frame). Works in every mode. */
.portrait { position: relative; }
.portrait__bricks {
  position: absolute; inset: 0; z-index: 2; display: grid; grid-template-columns: repeat(5, 1fr); grid-template-rows: repeat(5, 1fr);
  pointer-events: none; filter: saturate(0.9);
}
.portrait__bricks i {
  position: relative; display: block; background-repeat: no-repeat; will-change: transform, opacity;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), inset 0 0 0 1px rgba(255, 255, 255, 0.14), inset 0 -2px 0 rgba(0, 0, 0, 0.3);
  transition: box-shadow 220ms;
}
/* the stud on top of each brick */
.portrait__bricks i::before {
  content: ''; position: absolute; left: 28%; top: 28%; width: 44%; height: 44%; border-radius: 50%;
  background: radial-gradient(circle at 36% 30%, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0.1) 46%, rgba(0, 0, 0, 0.18) 76%);
  box-shadow: 0 1px 1.5px rgba(0, 0, 0, 0.4), inset 0 0 0 1px rgba(255, 255, 255, 0.16);
  transition: opacity 220ms;
}
.portrait__bricks.is-set i, .portrait__bricks.is-flat i { box-shadow: none; }
.portrait__bricks.is-set i::before, .portrait__bricks.is-flat i::before { opacity: 0; }
@media print { .portrait__bricks { display: none; } }
