/* css/modes/rigging.css — rig / unrig mini-game (js/modes/rigging.js) */
.rigging-root {
  position: absolute; inset: 0; display: grid; grid-template-rows: 1fr auto; grid-template-columns: 100%;
  touch-action: none; -webkit-user-select: none; user-select: none;
}
.rigging-scene { position: relative; overflow: hidden; min-height: 0; background: #a98dc4; }
.rigging-svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; overflow: hidden; }

/* HUD: top centre (the pause button sits top-right in dom modes) */
.play-layer.mode-rigging .hud.rigging-hud { top: calc(var(--safe-t) + 10px); max-width: calc(100% - 84px - var(--safe-l) - var(--safe-r)); }
@media (max-width: 520px) {
  .play-layer.mode-rigging .hud.rigging-hud { top: calc(var(--safe-t) + 10px); left: calc(50% - 26px); }
}

/* ------------------------------------------------------------------ boat parts */
.rig-part { transform-box: fill-box; transform-origin: 50% 50%; }
.rig-part.grow { transform-origin: 50% 100%; }
.rig-part.pop { animation: rigPop .5s cubic-bezier(.34, 1.56, .64, 1) both; }
.rig-part.grow.pop { animation: rigGrow .6s cubic-bezier(.34, 1.4, .64, 1) both; }
.rig-part.off { animation: rigOff .45s ease-in forwards; pointer-events: none; }
.rig-part.rig-ghost { opacity: .5; pointer-events: none; animation: rigGhost 1.4s ease-in-out infinite; }
.rig-part.rig-ghost * { fill: rgba(255, 255, 255, .14) !important; stroke: #fff !important; stroke-dasharray: 5 4; stroke-width: 1.6px !important; }
.rig-part.rig-ghost text { display: none; }
.rig-part.rig-avail { filter: drop-shadow(0 0 4px #ffd25e) drop-shadow(0 0 8px rgba(255, 210, 94, .8)); animation: rigAvail 1.2s ease-in-out infinite; }
.rig-part { cursor: help; }
.rig-flag { transform-box: fill-box; transform-origin: 100% 50%; animation: rigFlag 1.1s ease-in-out infinite; }
@keyframes rigPop { 0% { opacity: 0; transform: translateY(-18px) scale(.6); } 60% { opacity: 1; } 100% { opacity: 1; transform: none; } }
@keyframes rigGrow { 0% { opacity: 0; transform: scaleY(.05); } 30% { opacity: 1; } 100% { transform: none; } }
@keyframes rigOff { 0% { opacity: 1; transform: none; } 100% { opacity: 0; transform: translateY(40px) scale(.7) rotate(-8deg); } }
@keyframes rigGhost { 50% { opacity: .85; } }
@keyframes rigAvail { 50% { filter: drop-shadow(0 0 6px #ffd25e) drop-shadow(0 0 14px rgba(255, 210, 94, 1)); } }
@keyframes rigFlag { 50% { transform: scaleX(.75) skewY(4deg); } }
.rg-boat.shine .rig-hull { animation: rigShine 1.6s ease-out 1; }
@keyframes rigShine { 30% { filter: brightness(1.25) drop-shadow(0 0 10px rgba(191, 234, 255, .9)); } }
.rg-boat.wet .rig-hull { filter: saturate(.9) brightness(.96); }
.rg-waves { animation: rigWaves 3s ease-in-out infinite alternate; }
@keyframes rigWaves { to { transform: translateX(14px); } }

/* ------------------------------------------------------------------ snap zones */
.rig-zone { opacity: 0; transition: opacity .2s; pointer-events: none; }
.rig-zone.show { opacity: 1; }
.rig-zone.rg-dim { opacity: .45; }
.rig-zone .rgz-glow { fill: rgba(255, 210, 94, .22); stroke: none; transform-box: fill-box; transform-origin: center; animation: rgzPulse 1.1s ease-in-out infinite; }
.rig-zone .rgz-ring { fill: none; stroke: #ffd25e; stroke-width: 2.5px; vector-effect: non-scaling-stroke; stroke-dasharray: 6 5; transform-box: fill-box; transform-origin: center; animation: rgzSpin 4s linear infinite; }
.rig-zone .rgz-dot { fill: #fff; }
.rig-zone.hot .rgz-glow { fill: rgba(62, 224, 143, .4); animation-duration: .5s; }
.rig-zone.hot .rgz-ring { stroke: var(--good); stroke-dasharray: none; stroke-width: 4px; }
@keyframes rgzPulse { 50% { transform: scale(1.25); opacity: .6; } }
@keyframes rgzSpin { to { transform: rotate(360deg); } }

/* sparkles / rinse */
.rig-sparkle .rgs-p { animation: rgsFly .8s ease-out both; }
.rig-sparkle .rgs-ring { transform-box: fill-box; transform-origin: center; animation: rgsRing .6s ease-out both; }
@keyframes rgsFly { 0% { transform: translate(0, 0) scale(.4); opacity: 1; } 100% { transform: translate(var(--dx), var(--dy)) scale(1.1) rotate(90deg); opacity: 0; } }
@keyframes rgsRing { 0% { transform: scale(.3); opacity: 1; } 100% { transform: scale(4); opacity: 0; } }
.rig-rinse circle { animation: rinseDrop .9s ease-in both; }
@keyframes rinseDrop { 0% { opacity: 0; transform: translateY(-20px); } 20% { opacity: 1; } 100% { opacity: 0; transform: translateY(46px); } }

/* ------------------------------------------------------------------ the tray ("the ground") */
.rigging-tray {
  position: relative; z-index: 5; display: flex; flex-direction: column; gap: 6px;
  padding: 8px calc(var(--safe-r) + 10px) calc(var(--safe-b) + 10px) calc(var(--safe-l) + 10px);
  background:
    repeating-linear-gradient(90deg, rgba(0,0,0,.07) 0 2px, transparent 2px 64px),
    linear-gradient(180deg, #6f5a45 0%, #5a4836 100%);
  border-top: 3px solid #a2825f;
  box-shadow: 0 -8px 24px rgba(0, 0, 0, .35) inset, 0 -4px 16px rgba(0,0,0,.25);
}
.rigging-tray-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; color: rgba(255, 240, 220, .85); font-weight: 900; font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; padding: 0 4px; }
.rigging-keys { font-size: .72rem; font-weight: 700; text-transform: none; letter-spacing: 0; color: rgba(255, 240, 220, .6); text-align: right; }
@media (hover: none), (max-width: 700px) { .rigging-keys { display: none; } }
.rigging-cards {
  display: flex; gap: 8px; overflow-x: auto; overflow-y: hidden; padding: 4px 2px 6px; scroll-snap-type: x proximity;
  scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.3) transparent; -webkit-overflow-scrolling: touch;
}
@media (min-width: 900px) and (min-height: 600px) {
  .rigging-cards { flex-wrap: wrap; justify-content: center; overflow: visible; }
}
.rigging-card {
  position: relative; flex: none; width: 92px; min-height: 104px; padding: 6px 4px 6px; border-radius: 16px;
  display: flex; flex-direction: column; align-items: center; gap: 1px; scroll-snap-align: start;
  background: linear-gradient(180deg, rgba(255,255,255,.2), rgba(255,255,255,.07)); border: 1.5px solid rgba(255,255,255,.22);
  box-shadow: 0 4px 0 rgba(0,0,0,.25), 0 8px 16px rgba(0,0,0,.25); color: #fff; touch-action: pan-x;
  transition: transform .18s cubic-bezier(.34, 1.56, .64, 1), opacity .3s, background .2s, border-color .2s;
}
.rigging-card:hover { transform: translateY(-3px); background: linear-gradient(180deg, rgba(255,255,255,.28), rgba(255,255,255,.1)); }
.rigging-card:active { transform: translateY(1px) scale(.97); }
.rgc-ico { width: 52px; height: 52px; display: grid; place-items: center; filter: drop-shadow(0 3px 2px rgba(0,0,0,.35)); }
.rgc-ico svg { width: 100%; height: 100%; }
.rgc-name { font-size: .8rem; font-weight: 900; line-height: 1.05; text-align: center; text-shadow: 0 1px 0 rgba(0,0,0,.4); }
.rgc-en { font-size: .64rem; font-weight: 700; color: rgba(255, 240, 220, .7); line-height: 1.05; text-align: center; }
.rgc-badge { position: absolute; top: 5px; right: 5px; font-size: .58rem; font-weight: 900; padding: 1px 5px; border-radius: 6px; background: var(--good); color: #0b2a18; letter-spacing: .04em; }
.rgc-badge.off { background: var(--primary); color: #3a1d06; }
.rigging-card.is-sel { border-color: var(--blue); background: linear-gradient(180deg, rgba(73,198,242,.35), rgba(73,198,242,.12)); transform: translateY(-4px); }
.rigging-card.is-next { border-color: #ffd25e; animation: rgcNext 1.3s ease-in-out infinite; }
.rigging-card.is-dragging { opacity: .35; transform: scale(.94); }
.rigging-card.gone { opacity: 0; transform: translateY(-40px) scale(.5); pointer-events: none; }
.rigging-card.rg-shake { animation: rgcShake .45s ease; }
.rigging-card.rg-hint { animation: rgcHint .5s ease 3; border-color: var(--good); }
@keyframes rgcNext { 50% { box-shadow: 0 4px 0 rgba(0,0,0,.25), 0 0 0 4px rgba(255,210,94,.45), 0 8px 18px rgba(255,210,94,.35); transform: translateY(-3px); } }
@keyframes rgcShake { 20% { transform: translateX(-7px) rotate(-3deg); } 40% { transform: translateX(6px) rotate(3deg); } 60% { transform: translateX(-4px); } 80% { transform: translateX(3px); } }
@keyframes rgcHint { 50% { transform: translateY(-8px) scale(1.06); } }

/* the dragged part */
.rigging-ghost {
  position: absolute; left: 0; top: 0; z-index: 35; pointer-events: none; width: 84px; display: flex; flex-direction: column; align-items: center;
  filter: drop-shadow(0 10px 12px rgba(0,0,0,.45)); will-change: transform;
}
.rigging-ghost svg { width: 74px; height: 74px; transition: transform .15s; }
.rigging-ghost span { font-size: .78rem; font-weight: 900; background: rgba(13,19,33,.8); padding: 2px 8px; border-radius: 9px; white-space: nowrap; }
.rigging-ghost.hot svg { transform: scale(1.2) rotate(-6deg); }
.rigging-ghost.hot span { background: var(--good); color: #0b2a18; }
.rigging-ghost.back { transition: transform .28s ease-in, opacity .28s; opacity: 0; }
.rigging-ghost.snap { transition: transform .22s ease-in, opacity .22s ease-in; opacity: 0; }

/* info panel (tap a part to learn it) */
.rigging-info {
  position: relative; margin: 0 auto 2px; width: min(100%, 640px);
  display: flex; align-items: center; gap: 10px; padding: 8px 40px 8px 10px; border-radius: 14px;
  background: rgba(13, 19, 33, .78); border: 1px solid var(--glass-border); box-shadow: 0 6px 16px rgba(0,0,0,.3);
}
.rigging-info.in { animation: rgiIn .3s cubic-bezier(.34, 1.56, .64, 1); }
@keyframes rgiIn { from { transform: translateY(12px) scale(.97); opacity: 0; } }
.rgi-ico { width: 46px; height: 46px; flex: none; background: rgba(255,255,255,.08); border-radius: 12px; padding: 4px; }
.rgi-ico svg { width: 100%; height: 100%; }
.rgi-txt { flex: 1; min-width: 0; }
.rgi-name { font-weight: 900; font-size: 1rem; line-height: 1.1; }
.rgi-name small { font-weight: 700; color: var(--text-dim); font-size: .78rem; }
.rgi-desc { font-size: .8rem; font-weight: 600; color: rgba(240,244,255,.85); line-height: 1.22; margin-top: 2px; }
.rigging-do { flex: none; min-height: 44px; padding: 0 14px; white-space: nowrap; font-size: .92rem; }
.rgi-close { position: absolute; top: 4px; right: 4px; width: 32px; height: 32px; min-width: 0; min-height: 0; padding: 0; display: grid; place-items: center; background: rgba(255,255,255,.08); border: 0; border-radius: 10px; }
.rgi-close .ico { width: 16px; height: 16px; }
@media (max-width: 520px) {
  .rigging-info { gap: 8px; padding: 6px 38px 6px 8px; flex-wrap: wrap; }
  .rgi-ico { width: 38px; height: 38px; }
  .rgi-txt { flex: 1 1 calc(100% - 50px); }
  .rgi-desc { font-size: .74rem; }
  .rigging-do { flex: 1 1 100%; min-height: 40px; }
}

/* PACKED stamp */
.rigging-stamp {
  position: absolute; z-index: 9; left: 50%; top: 46%; transform: translate(-50%, -50%) rotate(-12deg) scale(2.4); opacity: 0;
  padding: 6px 22px; border: 6px solid var(--good); border-radius: 14px; color: var(--good); font-size: clamp(2rem, 9vw, 4rem); font-weight: 900;
  letter-spacing: .1em; text-shadow: 0 3px 0 rgba(0,0,0,.3); background: rgba(13, 19, 33, .35); transition: transform .35s cubic-bezier(.34, 1.56, .64, 1), opacity .2s;
}
.rigging-stamp.in { opacity: 1; transform: translate(-50%, -50%) rotate(-12deg) scale(1); }

/* floating feedback text */
.rigging-float {
  position: absolute; z-index: 36; pointer-events: none; transform: translate(-50%, -50%); font-weight: 900; font-size: 1.25rem; white-space: nowrap;
  color: #fff; text-shadow: 0 2px 0 rgba(0,0,0,.45), 0 0 12px rgba(0,0,0,.3); animation: rgfUp 1.15s ease-out forwards;
}
.rigging-float.good { color: #b6ffd6; }
.rigging-float.bad { color: #ffb3ba; }
@keyframes rgfUp { 0% { opacity: 0; transform: translate(-50%, -30%) scale(.6); } 15% { opacity: 1; transform: translate(-50%, -60%) scale(1.15); } 100% { opacity: 0; transform: translate(-50%, -180%) scale(1); } }

.rigging-root.is-done .rigging-tray { pointer-events: none; }
.rigging-root.is-done .rigging-cards, .rigging-root.is-done .rigging-tray-head { opacity: .35; filter: grayscale(.6); transition: opacity .4s; }

/* ------------------------------------------------------------------ landscape phones: tray on the right */
.rigging-root.tray-side { grid-template-rows: 100%; grid-template-columns: 1fr 228px; }
.rigging-root.tray-side .rigging-tray { border-top: 0; border-left: 3px solid #a2825f; padding: calc(var(--safe-t) + 60px) calc(var(--safe-r) + 8px) calc(var(--safe-b) + 8px) 8px; }
.rigging-root.tray-side .rigging-cards { flex-wrap: wrap; overflow-x: hidden; overflow-y: auto; align-content: flex-start; justify-content: center; scroll-snap-type: y proximity; min-height: 0; flex: 1; }
.rigging-root.tray-side .rigging-card { width: 98px; min-height: 92px; touch-action: pan-y; }
.rigging-root.tray-side .rgc-ico { width: 42px; height: 42px; }
.rigging-root.tray-side .rigging-info { width: 100%; flex-wrap: wrap; margin-bottom: 4px; }
.rigging-root.tray-side .rgi-txt { flex: 1 1 calc(100% - 50px); }
.rigging-root.tray-side .rgi-desc { font-size: .72rem; }
.rigging-root.tray-side .rigging-do { flex: 1 1 100%; min-height: 40px; }
.rigging-root.tray-side ~ .hud.rigging-hud, .play-layer.mode-rigging .rigging-root.tray-side + .hud { left: calc(50% - 114px); }

@media (prefers-reduced-motion: reduce) {
  .rig-part.pop, .rig-part.grow.pop, .rig-flag, .rg-waves, .rigging-card.is-next, .rig-zone .rgz-ring, .rig-zone .rgz-glow { animation: none; }
}

/* landscape phones: keep Coach Søs over the boat scene, not over the side tray */
#screen-play:has(.rigging-root.tray-side) .coach { left: calc((100% - 228px) / 2); width: min(calc(100% - 252px), 460px); min-width: 0; top: calc(var(--safe-t) + 62px); bottom: auto; }
#screen-play:has(.rigging-root.tray-side) .coach-avatar { width: 46px; height: 46px; }
#screen-play:has(.rigging-root.tray-side) .coach-bubble { margin-bottom: 4px; padding: 6px 10px 7px; }
#screen-play:has(.rigging-root.tray-side) .coach-text { font-size: .84rem; }
