/* ==========================================================================
   Projects — cartridge shelf + console
   ========================================================================== */

.proj-head { margin: 6px 0 26px; }
.proj-title {
  font-family: var(--font-pixel);
  font-weight: 400;
  font-size: 24px;
  line-height: 1.3;
  -webkit-font-smoothing: none;
}
.proj-intro {
  margin-top: 10px;
  font-size: 14px;
  line-height: 1.8;
  color: var(--muted);
}

/* ---------- console ---------- */
.console {
  --cart: var(--accent);
  --phosphor: #c9f59a;
  --phosphor-dim: #7fae5a;
  --crt: #10170f;
  --crt-2: #1d2b1c;
  margin: 0 3px;
  padding: 14px 14px 12px;
  background: var(--surface-2);
}
.console-screen [hidden] { display: none !important; }
.console { scroll-margin-top: 96px; }
.console-screen {
  position: relative;
  min-height: 312px;
  padding: 20px 22px;
  overflow: hidden;
  color: var(--phosphor);
  background: var(--crt);
  font-family: var(--font-pixel);
  font-size: 12px;
  line-height: 1.6;
  -webkit-font-smoothing: none;
  box-shadow:
    inset 0 0 0 3px #050805,
    inset 0 0 0 6px var(--crt-2),
    inset 0 0 48px rgba(0, 0, 0, 0.65);
}
.console-screen::after {
  /* scanlines */
  content: '';
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  background: repeating-linear-gradient(to bottom, rgba(0, 0, 0, 0.22) 0 1px, transparent 1px 3px);
}
.console-screen.is-booting { animation: crt-roll 140ms steps(2, end) infinite; }
.console-screen.is-booting::before {
  /* static noise */
  content: '';
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  opacity: 0.18;
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.4) 0 2px, transparent 2px 5px),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.3) 0 1px, transparent 1px 4px);
  animation: noise 90ms steps(3, end) infinite;
}
@keyframes crt-roll { 50% { transform: translateY(1px); filter: brightness(1.2); } }
@keyframes noise {
  33% { background-position: 3px 1px, 0 2px; }
  66% { background-position: -2px 2px, 0 -1px; }
}
.console-screen.is-pulse { animation: pulse 300ms steps(3, end); }
@keyframes pulse { 50% { filter: brightness(1.5); } }

/* idle */
.screen-idle {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
  color: var(--phosphor-dim);
}
.idle-big {
  font-size: 24px;
  line-height: 1.2;
  letter-spacing: 0.06em;
  color: var(--phosphor);
}
.idle-arrow { animation: bob 800ms steps(2, end) infinite; }
@keyframes bob { 50% { transform: translateY(6px); } }

/* boot */
.screen-boot p { margin: 0 0 6px; }
.screen-boot .ok { color: #ffd166; }
.boot-bar {
  width: 60%;
  max-width: 260px;
  height: 12px;
  margin: 14px 0;
  box-shadow: 0 0 0 3px var(--phosphor);
}
.boot-bar i {
  display: block;
  width: 0;
  height: 100%;
  background: repeating-linear-gradient(90deg, var(--phosphor) 0 9px, transparent 9px 12px);
}

/* body */
.screen-body {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr);
  gap: 16px 20px;
  align-items: start;
}
.screen-body[hidden] { display: none; }
.sc-art {
  width: 84px;
  height: 84px;
  background: var(--crt-2) center / 60px 60px no-repeat;
  image-rendering: pixelated;
  box-shadow: 0 0 0 3px var(--cart);
}
.sc-class {
  color: var(--cart);
  letter-spacing: 0.08em;
  filter: brightness(1.25);
}
.sc-name {
  margin: 4px 0 10px;
  font-size: 24px;
  line-height: 1.2;
  color: #f4ffe6;
  word-break: break-all;
}
.sc-desc {
  min-height: 5.4em;
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.8;
  color: var(--phosphor);
  -webkit-font-smoothing: antialiased;
}
.sc-desc.is-typing::after {
  content: '';
  display: inline-block;
  width: 9px;
  height: 3px;
  margin-left: 2px;
  background: var(--phosphor);
  animation: blink 0.6s steps(1, end) infinite;
}
.sc-stats {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
}
.sc-stats > div {
  padding: 8px 10px;
  box-shadow: inset 0 0 0 2px #2f4a2c;
}
.sc-stats dt { color: var(--phosphor-dim); }
.sc-stats dd {
  margin: 4px 0 0;
  font-family: var(--font-dots);
  font-size: 20px;
  line-height: 1.1;
  color: #f4ffe6;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sc-stats dd.sc-text { font-family: var(--font-pixel); font-size: 12px; line-height: 23px; }
.sc-tags {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.sc-tags li {
  padding: 3px 6px;
  background: var(--crt-2);
  color: var(--phosphor);
  animation: tag-in 240ms steps(3, end) both;
  animation-delay: var(--d, 0ms);
}
@keyframes tag-in { from { opacity: 0; transform: translateY(6px); } }
.sc-actions {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  padding: 2px 0 4px 3px;
}
.console-screen .px-btn {
  --line: #050805;
  --shadow: #2f4a2c;
  color: var(--crt);
  background: var(--phosphor);
}
.console-screen .px-btn:hover { background: #ffd166; color: var(--crt); }
.console-screen .px-btn[aria-disabled='true'] { background: var(--crt-2); color: var(--phosphor-dim); cursor: default; transform: none; }

/* bar */
.console-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  padding: 14px 3px 3px;
  font-family: var(--font-pixel);
  font-size: 12px;
  color: var(--muted);
}
.console-led {
  width: 9px;
  height: 9px;
  background: #5a4a3a;
  box-shadow: 0 0 0 2px var(--line);
}
.console-led.is-on {
  background: var(--cart);
  box-shadow: 0 0 0 2px var(--line), 0 0 10px var(--cart);
}
.console-brand { letter-spacing: 0.14em; color: var(--ink); }
.console-slot {
  flex: 1;
  min-width: 60px;
  max-width: 180px;
  height: 9px;
  margin: 0 auto;
  background: var(--line);
  box-shadow: inset 0 3px 0 rgba(0, 0, 0, 0.45);
}
.console-count b { font-weight: 400; color: var(--accent); }
.console-eject { min-height: 26px; padding: 5px 8px; }
.console-eject:disabled { opacity: 0.5; cursor: default; transform: none; }

/* ---------- shelf ---------- */
.shelf {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 24px 18px;
  margin: 36px 0 0;
  padding: 0 3px;
}
.cart { position: relative; min-width: 0; scroll-margin-top: 120px; }
.cart-shell {
  --rx: 0deg;
  --ry: 0deg;
  --lift: 0px;
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  aspect-ratio: 5 / 6;
  padding: 10px 12px 10px;
  text-align: left;
  color: #2b2118;
  background: var(--cart);
  cursor: pointer;
  box-shadow:
    0 calc(var(--px) * -1) 0 0 var(--line),
    0 var(--px) 0 0 var(--line),
    calc(var(--px) * -1) 0 0 0 var(--line),
    var(--px) 0 0 0 var(--line),
    var(--px) calc(var(--px) * 2) 0 0 var(--shadow),
    calc(var(--px) * 2) var(--px) 0 0 var(--shadow),
    inset 0 var(--px) 0 0 rgba(255, 255, 255, 0.35),
    inset 0 calc(var(--px) * -2) 0 0 rgba(0, 0, 0, 0.2);
  transform: perspective(700px) rotateX(var(--rx)) rotateY(var(--ry)) translateY(var(--lift));
  transition: transform 120ms steps(3, end);
}
.cart-shell:hover,
.cart-shell:focus-visible { --lift: -8px; }
.cart-shell:active { --lift: 2px; }
.cart-shell::before {
  /* notch, top-right */
  content: '';
  position: absolute;
  right: 0;
  top: 0;
  width: 15px;
  height: 15px;
  background: var(--bg);
  box-shadow: calc(var(--px) * -1) var(--px) 0 0 var(--line);
}
.cart-grip {
  height: 12px;
  margin: 2px 18px 10px 4px;
  background: repeating-linear-gradient(90deg, rgba(0, 0, 0, 0.3) 0 3px, transparent 3px 7px);
}
.cart-label {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 6px;
  background: #fff6e8;
  box-shadow: inset 0 0 0 3px rgba(0, 0, 0, 0.18);
}
.cart-art {
  width: 48px;
  height: 48px;
  background: center / contain no-repeat;
  image-rendering: pixelated;
}
.cart-name,
.cart-sub {
  font-family: var(--font-pixel);
  font-size: 12px;
  line-height: 1.3;
  text-align: center;
  word-break: break-all;
  -webkit-font-smoothing: none;
}
.cart-sub { color: #7a6650; }
.cart-foot {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  margin-top: 8px;
  font-family: var(--font-pixel);
  font-size: 12px;
  line-height: 1;
  color: rgba(43, 33, 24, 0.85);
  white-space: nowrap;
}

.cart-badge {
  padding: 2px 4px;
  color: #fff6e8;
  background: rgba(43, 33, 24, 0.75);
}
.sc-class .sc-closed {
  margin-left: 8px;
  padding: 1px 5px;
  color: var(--crt);
  background: var(--phosphor-dim);
}

/* collected sticker */
.cart.is-collected .cart-label::after {
  content: '★';
  position: absolute;
  right: -6px;
  top: -9px;
  width: 21px;
  height: 21px;
  font-size: 12px;
  line-height: 21px;
  text-align: center;
  color: #2b2118;
  background: #ffd166;
  box-shadow: 0 0 0 2px #2b2118;
  transform: rotate(12deg);
}

/* cartridge in console: leave a dashed slot behind */
.cart.is-loaded .cart-shell { visibility: hidden; }
.cart.is-loaded::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, var(--muted) 50%, transparent 50%) 0 0 / 9px 3px repeat-x,
    linear-gradient(90deg, var(--muted) 50%, transparent 50%) 0 100% / 9px 3px repeat-x,
    linear-gradient(var(--muted) 50%, transparent 50%) 0 0 / 3px 9px repeat-y,
    linear-gradient(var(--muted) 50%, transparent 50%) 100% 0 / 3px 9px repeat-y;
  opacity: 0.6;
}
.cart.is-loaded::after {
  content: 'IN CONSOLE ▲';
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  margin-top: -6px;
  font-family: var(--font-pixel);
  font-size: 12px;
  line-height: 1;
  text-align: center;
  color: var(--muted);
}

.cart.hint .cart-shell { animation: wiggle-cart 640ms steps(4, end) 2; }
@keyframes wiggle-cart {
  25% { transform: translateY(-6px) rotate(-3deg); }
  75% { transform: translateY(-6px) rotate(3deg); }
}

/* text card: visible without JS, used as data source with JS */
.cart-info {
  margin-top: 14px;
  font-size: 13px;
  line-height: 1.7;
}
html.js .cart-info {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}
.ci-name { font-size: 15px; }
.ci-name small { font-weight: 400; color: var(--muted); }
.ci-class { font-family: var(--font-pixel); font-size: 12px; color: var(--accent-2); }
.ci-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.ci-tags li { padding: 1px 6px; font-size: 12px; background: var(--surface-2); }
.ci-links a { color: var(--accent); }
html:not(.js) .console { display: none; }

/* ---------- confetti ---------- */
.px-confetti {
  position: fixed;
  z-index: 300;
  width: 6px;
  height: 6px;
  pointer-events: none;
  animation: px-confetti 1100ms steps(11, end) forwards;
}
@keyframes px-confetti {
  to { transform: translate(var(--dx), var(--dy)) rotate(180deg); opacity: 0; }
}

/* ---------- responsive ---------- */
@media screen and (max-width: 600px) {
  .console { padding: 10px 10px 10px; }
  .console-screen { min-height: 430px; padding: 16px; }
  .screen-body { grid-template-columns: 64px minmax(0, 1fr); gap: 14px; }
  .sc-art { grid-row: span 2; width: 64px; height: 64px; background-size: 46px 46px; }
  .sc-name { font-size: 24px; }
  .sc-desc { grid-column: 1 / -1; }
  .sc-main { display: contents; }
  .sc-class, .sc-name { grid-column: 2; }
  .sc-class { align-self: end; }
  .sc-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .console-slot { display: none; }
  .shelf { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 14px; margin-top: 28px; }
  .cart-shell { padding: 8px 8px 8px; }
  .cart-shell::before { width: 12px; height: 12px; }
  .cart-grip { height: 9px; margin: 2px 14px 8px 2px; }
  .cart-art { width: 36px; height: 36px; }
  .cart-foot span:first-child { display: none; }
  .cart-foot { justify-content: center; }
}
