/* CV match, played as "pack the box". Every answer is an item that flies into its own compartment
   of the kit's wooden box. Then the lid closes, a laser engraves the DM KIT mark into it line by line,
   the bulb catches, and the box opens on the chosen CV. The wood is the one material outside the
   navy palette: it is the actual kit. Tungsten marks only the next compartment, the chosen item,
   the hot trace of the laser and the primary action. */

/* ------------------------------------------------------------------ layout */

.match__layout { display: grid; gap: var(--s-6); }
.match__note {
  margin-top: var(--s-4);
  font-size: var(--step-small);
  color: var(--ink-3);
}

.pack {
  width: 100%;
  max-width: 64rem;
  scroll-margin-top: 16px;
}
.pack__core {
  display: grid;
  gap: var(--s-2);
  padding: clamp(16px, 4vw, 32px);
}
.pack__scene { order: -1; } /* phones: the box first, the question under it */
@media (min-width: 900px) {
  .pack__core {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
    column-gap: clamp(32px, 4vw, 64px);
    align-items: center;
  }
  .pack__scene { order: 0; }
}

/* ------------------------------------------------------------------ the box */

.pack__scene {
  --wood: #6b5334;
  --wood-hi: #80653f;
  --wood-lo: #523f26;
  --wood-deep: #36281a;
  position: relative;
  display: grid;
  justify-items: center;
  padding: clamp(84px, 22vw, 112px) 4px 4px; /* room for the open lid above the tray */
  perspective: 1100px;
  perspective-origin: 50% -10%;
}
.pack__box {
  position: relative;
  width: min(100%, 400px);
  aspect-ratio: 400 / 150;
  transform-style: preserve-3d;
  transform: rotateX(30deg);
}

.pack__tray {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 3%;
  padding: 3.4%;
  border-radius: 16px;
  background:
    repeating-linear-gradient(91deg, rgba(20, 10, 2, 0.12) 0 1px, transparent 1px 7px, rgba(255, 230, 190, 0.04) 7px 8px, transparent 8px 13px),
    linear-gradient(180deg, var(--wood-lo), var(--wood-deep));
  box-shadow: inset 0 0 0 6px var(--wood), inset 0 0 0 7px rgba(20, 10, 2, 0.35), inset 0 16px 22px rgba(10, 5, 0, 0.55);
}
.pack__slot {
  position: relative;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: rgba(18, 10, 3, 0.42);
  box-shadow: inset 0 3px 7px rgba(8, 4, 0, 0.6), inset 0 -1px 0 rgba(255, 230, 190, 0.07);
  color: var(--paper);
  transition: box-shadow var(--t-micro) var(--ease-out);
}
.pack__slot .pack__ico { width: 56%; height: auto; }
/* the compartment the next answer goes into */
.pack__slot.is-next { box-shadow: inset 0 0 0 1.5px rgba(255, 201, 120, 0.7), inset 0 3px 7px rgba(8, 4, 0, 0.6); }
.js-motion .pack__slot.is-filled .pack__ico { animation: pack-drop 460ms var(--ease-spring) both; }
@keyframes pack-drop {
  from { transform: translateY(-16%) scale(1.18); }
  to { transform: none; }
}

/* the front wall, turned down from the tray's near edge, gives the box its depth */
.pack__front {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  height: 30%;
  transform-origin: 50% 0;
  transform: rotateX(-90deg);
  border-radius: 0 0 14px 14px;
  background:
    repeating-linear-gradient(90deg, rgba(20, 10, 2, 0.1) 0 1px, transparent 1px 9px),
    linear-gradient(180deg, var(--wood), var(--wood-lo));
}
/* the box stands on something */
.pack__scene::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -6px;
  width: min(92%, 380px);
  height: 28px;
  transform: translateX(-50%);
  background: radial-gradient(closest-side, rgba(2, 5, 14, 0.7), rgba(2, 5, 14, 0));
  pointer-events: none;
}

/* The lid, hinged at the far edge. Open, it leans back past upright; closed, it lies on the tray. */
.pack__lid {
  position: absolute;
  inset: 0;
  transform-origin: 50% 0;
  transform-style: preserve-3d;
  transform: rotateX(114deg);
  transition: transform 760ms var(--ease-spring);
}
.pack__box.is-closed .pack__lid { transform: rotateX(0deg) translateZ(1px); }
.pack__lid-face {
  position: absolute;
  inset: 0;
  border-radius: 16px;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}
.pack__lid-top {
  display: grid;
  place-items: center;
  background:
    repeating-linear-gradient(88deg, rgba(20, 10, 2, 0.1) 0 1px, transparent 1px 6px, rgba(255, 230, 190, 0.05) 6px 7px, transparent 7px 12px),
    linear-gradient(165deg, var(--wood-hi), var(--wood) 52%, var(--wood-lo));
  box-shadow: inset 0 1px 0 rgba(255, 236, 200, 0.2), inset 0 0 0 1px rgba(20, 10, 2, 0.3);
}
.pack__lid-under {
  transform: rotateX(180deg);
  background: linear-gradient(0deg, var(--wood-lo), var(--wood-deep));
  box-shadow: inset 0 0 0 6px var(--wood), inset 0 0 0 7px rgba(20, 10, 2, 0.35);
}

/* The engraving: the real mark, burnt in by a laser that scans the lid top to bottom.
   It burns hot (tungsten) and cools to charred wood; a hairline of light keeps the edge. */
.pack__engrave {
  position: relative;
  height: 80%;
  aspect-ratio: 720 / 838;
}
.pack__burn {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  clip-path: inset(0 0 100% 0);
  filter: sepia(1) saturate(5) hue-rotate(-12deg) brightness(1.08);
  transition: filter 1100ms var(--ease-out);
  -webkit-user-drag: none;
  user-select: none;
}
.pack__box.is-engraving .pack__burn { animation: pack-burn var(--engrave, 1700ms) linear forwards; }
.pack__box.is-engraved .pack__burn {
  clip-path: inset(0);
  filter: brightness(0.2) sepia(1) saturate(1.8) drop-shadow(0 1px 0 rgba(255, 228, 188, 0.28));
}
@keyframes pack-burn {
  from { clip-path: inset(0 0 100% 0); }
  to { clip-path: inset(0); }
}
/* the beam: the bottom edge of a box that slides down the engraving */
.pack__scan {
  position: absolute;
  left: -14%;
  right: -14%;
  top: 0;
  height: 100%;
  opacity: 0;
  transform: translateY(-100%);
  pointer-events: none;
}
.pack__scan::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, rgba(255, 201, 120, 0), rgba(255, 201, 120, 0.9) 22%, #fff6e8 50%, rgba(255, 201, 120, 0.9) 78%, rgba(255, 201, 120, 0));
}
.pack__box.is-engraving .pack__scan { animation: pack-scan var(--engrave, 1700ms) linear forwards; }
@keyframes pack-scan {
  0% { opacity: 1; transform: translateY(-100%); }
  96% { opacity: 1; }
  100% { opacity: 0; transform: translateY(0); }
}
/* the bulb inside the mark catches once the engraving is done */
.pack__bulb {
  position: absolute;
  left: 50.3%;
  top: 49.6%;
  width: 34%;
  aspect-ratio: 1;
  translate: -50% -50%;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(255, 244, 224, 0.95), rgba(255, 201, 120, 0.55) 34%, rgba(255, 201, 120, 0) 72%);
  mix-blend-mode: screen;
  opacity: 0;
  pointer-events: none;
}
.pack__box.is-lit .pack__bulb { opacity: 1; }
.js-motion .pack__box.is-lit .pack__bulb { animation: pack-bulb 900ms var(--ease-out) both; }
@keyframes pack-bulb {
  0% { opacity: 0; transform: scale(0.4); }
  24% { opacity: 0.9; transform: scale(1); }
  38% { opacity: 0.4; }
  60%, 100% { opacity: 1; transform: scale(1); }
}

/* The chosen CV waits inside the box and rises out of it when the lid opens */
.pack__doc {
  position: absolute;
  left: 50%;
  bottom: 12%;
  z-index: 1;
  width: 30%;
  aspect-ratio: 210 / 297;
  display: flex;
  flex-direction: column;
  gap: 5%;
  padding: 7%;
  border-radius: 3px;
  background: var(--paper);
  color: var(--navy-800);
  box-shadow: 0 12px 26px -10px rgba(2, 5, 14, 0.8), inset 0 0 0 1px rgba(5, 9, 20, 0.08);
  opacity: 0;
  transform: translateX(-50%) translateZ(-24px) scale(0.86);
  transition: transform 900ms var(--ease-spring), opacity 260ms var(--ease-out);
  pointer-events: none;
}
/* forward of the open lid's plane, so no part of the sheet ever passes behind it */
.pack__box.is-revealed .pack__doc {
  opacity: 1;
  transform: translateX(-50%) translateY(-12%) translateZ(120px) rotateX(-30deg) scale(0.94);
  transition-delay: 180ms;
}
.pack__doc-mark { width: 22%; height: auto; }
.pack__doc-title {
  font-family: var(--font-ui);
  font-weight: 500;
  font-size: clamp(6px, 1.9vw, 8.5px);
  line-height: 1.2;
}
.pack__doc-lines {
  flex: 1;
  background: repeating-linear-gradient(180deg, rgba(19, 34, 74, 0.2) 0 1px, transparent 1px 5px);
}
.pack__doc-lang {
  align-self: flex-start;
  padding: 1px 4px;
  border-radius: var(--r-pill);
  box-shadow: inset 0 0 0 1px rgba(19, 34, 74, 0.3);
  font-size: clamp(5px, 1.6vw, 7px);
}

.pack__tally {
  margin-top: clamp(36px, 7vw, 48px);
  font-size: var(--step-small);
  color: var(--ink-3);
}
.pack__tally .num { color: var(--ink-2); }

/* the item on its way from the answer to the box */
.pack__ghost {
  position: fixed;
  z-index: var(--z-toast);
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--paper);
  pointer-events: none;
  will-change: transform;
}
.pack__ghost .pack__ico { width: 24px; height: 24px; }

/* ------------------------------------------------------------------ the play: bar, questions, items */

.pack__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  min-height: 44px;
}
.pack__back[disabled] { visibility: hidden; }
.pack__count { font-size: var(--step-small); line-height: 1; color: var(--ink-2); }
.pack__count .num { font-size: 0.9375rem; color: var(--paper); }

.pack__stage { margin-top: var(--s-3); }
.pack__pane:not(.is-active) { display: none; }
.js-motion .pack__pane.is-active { animation: pack-in 520ms var(--ease-out) both; }
@keyframes pack-in {
  from { opacity: 0; transform: translateY(10px); filter: blur(4px); }
  to { opacity: 1; transform: none; filter: none; }
}

.pack__q {
  font-size: var(--step-display-m);
  line-height: 1.12;
  outline: none;
}
/* one column on phones, so every name reads on one or two lines; two once there is room */
.pack__items {
  display: grid;
  gap: 8px;
  margin-top: var(--s-5);
}
@media (min-width: 560px) {
  .pack__items { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  /* an odd last answer keeps the size of the others and sits in the middle of the row */
  .pack__items--odd > :last-child { grid-column: 1 / -1; justify-self: center; width: calc((100% - 10px) / 2); }
}

/* Each answer is an item in a capsule: its icon in a round well, its name beside it */
.pack__item {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding-block: 5px;
  padding-inline: 8px 18px;
  border-radius: var(--r-pill);
  background: rgba(242, 238, 230, 0.04);
  box-shadow: inset 0 0 0 1px var(--line-strong);
  color: var(--paper);
  text-align: start;
  transition: box-shadow var(--t-micro) var(--ease-out), background-color var(--t-micro) var(--ease-out), transform 160ms var(--ease-out);
}
.pack__well {
  flex: none;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(242, 238, 230, 0.07);
  color: var(--paper);
  transition: background-color var(--t-micro) var(--ease-out), color var(--t-micro) var(--ease-out), transform var(--t-micro) var(--ease-spring);
}
.pack__well .pack__ico { width: 24px; height: 24px; }
.pack__label { min-width: 0; font-size: 0.975rem; line-height: 1.3; }
.pack__term {
  display: block;
  margin-top: 2px;
  font-family: var(--font-slate);
  font-weight: 500;
  font-size: var(--step-micro);
  letter-spacing: 0.06em;
  color: var(--ink-3);
}
.pack__item:focus-visible .pack__well { background: rgba(255, 201, 120, 0.16); color: var(--tungsten); transform: scale(1.06); }
@media (hover: hover) and (pointer: fine) {
  .pack__item:hover { background: rgba(242, 238, 230, 0.07); box-shadow: inset 0 0 0 1px rgba(242, 238, 230, 0.34); }
  .pack__item:hover .pack__well { background: rgba(255, 201, 120, 0.16); color: var(--tungsten); transform: scale(1.06); }
}
.pack__item:active { transform: scale(0.97); }
.pack__item[aria-pressed="true"] { box-shadow: inset 0 0 0 1.5px var(--tungsten); }
.pack__item[aria-pressed="true"] .pack__well { background: var(--tungsten); color: var(--abyss); }
.pack__item:focus-visible { outline-offset: 3px; border-radius: var(--r-pill); }

/* letters inside the language tiles */
.ico .ico-type {
  fill: currentColor;
  stroke: none;
  font-family: var(--font-ui);
  font-weight: 500;
}
.ico .ico-type--latin { font-family: var(--font-slate); font-weight: 500; letter-spacing: 0.02em; }

/* ------------------------------------------------------------------ packing */

.pack__pane--packing { padding-block: var(--s-6) var(--s-4); }
.pack__status {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--step-display-m);
  line-height: 1.15;
  min-height: 2.4em;
  outline: none;
}
.js-motion .pack__status.is-new { animation: pack-in 520ms var(--ease-out) both; }
.pack__skip {
  margin-top: var(--s-6);
  font-size: var(--step-small);
  color: var(--ink-2);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.3em;
}
.pack__skip:hover { color: var(--paper); text-decoration-color: var(--tungsten); }

/* ------------------------------------------------------------------ the result */

.pack__pane--result > * { position: relative; }
.js-motion .pack__pane--result.is-active > * { animation: pack-in 640ms var(--ease-out) both; animation-delay: calc(var(--i, 0) * 90ms); }
.pack__chosen { font-size: var(--step-small); color: var(--ink-2); }
.pack__title {
  margin-top: var(--s-2);
  font-size: var(--step-display-m);
  line-height: 1.12;
  outline: none;
}
.pack__why {
  margin-top: var(--s-4);
  font-size: var(--step-body-l);
  line-height: 1.65;
  color: var(--ink-2);
  max-width: 52ch;
}
.pack__file {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  margin-top: var(--s-5);
}
.pack__file-type {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--step-small);
  color: var(--ink-3);
}
.pack__file-type svg { width: 18px; height: 18px; }
.pack__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-3) var(--s-5);
  margin-top: var(--s-8);
}
.pack__restart {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  font-size: var(--step-small);
  color: var(--ink-2);
  transition: color var(--t-micro) var(--ease-out);
}
.pack__restart svg { width: 18px; height: 18px; transition: transform 520ms var(--ease-spring); }
.pack__restart:hover { color: var(--paper); }
@media (hover: hover) and (pointer: fine) {
  .pack__restart:hover svg { transform: rotate(-40deg); }
}
.pack__alt {
  margin-top: var(--s-6);
  padding-top: var(--s-5);
  border-top: 1px solid var(--line);
  display: grid;
  gap: var(--s-3);
  justify-items: start;
}
.pack__alt-line { font-size: var(--step-small); color: var(--ink-2); max-width: 52ch; }
.pack__alt-title { color: var(--paper); font-weight: 500; }

/* ------------------------------------------------------------------ preferences */

@media (prefers-reduced-motion: reduce) {
  .pack__lid, .pack__doc { transition: none; }
}
@media (forced-colors: active) {
  .pack__item[aria-pressed="true"] { outline: 2px solid Highlight; }
  .pack__scene { display: none; }
}

/* The chapter title runs to two lines, the second one whole on wide screens (it breaks after the comma) */
#match-title { max-width: 24ch; text-wrap: balance; }

/* The title shares its row with a small shortcut: a CV straight away, without the five questions.
   It sits beside the title's last line, and drops under the title where the row is too narrow. */
.match__titlebar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--s-3) var(--s-6);
}
.match__direct {
  min-height: 40px;
  padding-inline: 16px 4px;
  gap: 10px;
  margin-bottom: 4px;
  font-size: 0.875rem;
}
.match__direct .btn__icon { width: 32px; height: 32px; }
