/* The capsule case, shared by every page: the mint box, the Hoi-Poi capsules, the puff when one pops, the smoke
   that turns a page into the feature inside a capsule, and the case that drops down from the bar on a feature's
   page. It uses each page's own colour and font tokens (--outline, --shadow, --ink, --gold, --f-display, ...). */

/* Arriving through a capsule: the page starts covered in smoke, which case.js then clears. */
html.arriving body::after { content: ""; position: fixed; inset: 0; z-index: 1001; background: #F4F7FF; }

/* ---------- the capsule box: mint, lid hinged at the top, a pocket per capsule ---------- */
.box { --mint: #A6DCCB; --mint-deep: #7CC3AE; --pocket: #86CDB8; position: relative; background: var(--mint); color: var(--ink); border: 3px solid var(--outline); border-radius: 22px; box-shadow: 8px 8px 0 var(--shadow); padding: 0 18px 18px; display: grid; gap: 14px; }
.box-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-inline: -18px; padding: 10px 18px; background: var(--mint-deep); border-bottom: 3px solid var(--outline); border-radius: 19px 19px 0 0; position: relative; }
.box-top::before, .box-top::after { content: ""; position: absolute; bottom: -10px; width: 40px; height: 16px; background: var(--mint); border: 3px solid var(--outline); border-radius: 6px; }
.box-top::before { left: 16%; } .box-top::after { right: 16%; }
.box-top h2 { margin: 0; font-family: var(--f-display); font-weight: 700; font-size: 1.02rem; line-height: 1.05; letter-spacing: 0.12em; color: var(--ink); }
.box-top .all { font-family: var(--f-display); font-weight: 600; font-size: 0.85rem; color: var(--ink); white-space: nowrap; }
.slots { margin-top: 8px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.slot { background: var(--pocket); border-radius: 999px; padding: 6px 36px 6px 10px; box-shadow: inset 4px 4px 0 rgba(10, 15, 36, 0.22), inset -2px -2px 0 rgba(255, 255, 255, 0.35); }
/* an odd last capsule sits in the middle of its row */
.slots > .slot:last-child:nth-child(odd) { grid-column: 1 / -1; justify-self: center; width: calc(50% - 6px); }
.box.small .slots > .slot:last-child:nth-child(odd) { width: calc(50% - 5px); }

/* ---------- a Hoi-Poi capsule on its side: white rounded ends, a coloured label with its number, the neck and the ribbed knob ---------- */
.capsule { position: relative; width: 100%; height: 86px; display: grid; grid-template-columns: 20px minmax(0, 1fr) 22px; padding: 0; text-align: left; cursor: pointer; font: inherit; color: inherit;
  background: linear-gradient(#FFFFFF 0%, #F1F4F8 55%, #D9DFE9 100%); border: 3px solid var(--outline); border-radius: 43px 34px 34px 43px; box-shadow: 3px 3px 0 var(--shadow); transition: transform 0.15s; }
.capsule:hover { transform: translate(-1px, -2px); }
.capsule[aria-current="page"] { box-shadow: 0 0 0 3px var(--gold), 3px 3px 0 var(--shadow); }
.capsule .label { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 6px; padding: 4px 8px 4px 10px; min-width: 0;
  background: linear-gradient(rgba(255, 255, 255, 0.22), transparent 45%, rgba(10, 15, 36, 0.12)), var(--c); border-inline: 3px solid var(--outline); }
/* The label starts inside the capsule's rounded ends, so it is cut along their curve instead of sticking out square:
   the left end's inner circle (40 px, its centre 20 px into the label), the right end's two (31 px, 9 px in), and the
   straight middle between them. Each cut fades out over the outline's inner pixel, so no white seam shows, and the
   layers overlap by a pixel; the top and bottom stay uncut. */
.capsule .label {
  --cut: radial-gradient(circle 40px at 20px 40px, #000 40px, #0000 41px) 0 0 / 21px 100% no-repeat,
    linear-gradient(#000 0 0) 19px 0 / calc(100% - 27px) 100% no-repeat,
    radial-gradient(circle 31px at 1px 31px, #000 31px, #0000 32px) 100% 0 / 10px 100% no-repeat,
    radial-gradient(circle 31px at 1px 49px, #000 31px, #0000 32px) 100% 0 / 10px 100% no-repeat;
  -webkit-mask: var(--cut); mask: var(--cut);
}
.capsule .txt { display: grid; gap: 1px; min-width: 0; }
.capsule .num { font-family: var(--f-display); font-weight: 700; font-size: 1.45rem; line-height: 1; letter-spacing: 0.02em; color: var(--ink); }
.capsule .name { font-family: var(--f-display); font-weight: 700; font-size: 0.9rem; line-height: 1.1; color: var(--ink); overflow-wrap: anywhere; }
.capsule .st { font-family: var(--f-screen); font-size: 0.56rem; color: rgba(10, 15, 36, 0.7); margin-top: 1px; }
.capsule .label img { width: 36px; height: 36px; image-rendering: pixelated; }
.capsule .neck { position: absolute; right: -14px; top: calc(50% - 11px); width: 14px; height: 22px; background: linear-gradient(#FFFFFF, #CDD3DF); border: 3px solid var(--outline); border-left: 0; }
.capsule .knob { position: absolute; right: -33px; top: calc(50% - 18px); width: 21px; height: 36px; border: 3px solid var(--outline); border-radius: 6px;
  background: repeating-linear-gradient(#F4F6FA 0 3px, #AEB5C4 3px 5px); }
.capsule.sealed .label { filter: saturate(0.8); }
/* a padlock hung on the neck, over the button that opens the capsule */
.capsule .lock { position: absolute; right: -22px; top: calc(50% - 12px); width: 22px; height: 30px; image-rendering: pixelated; pointer-events: none; z-index: 1; }

/* the smaller case and capsules that drop down from the bar */
.box.small { padding: 0 14px 14px; box-shadow: 6px 6px 0 var(--shadow); }
.box.small .box-top { margin-inline: -14px; padding: 8px 14px; }
.box.small .slots { gap: 10px; }
.box.small .slot { padding: 6px 28px 6px 8px; }
.capsule.small { height: 62px; grid-template-columns: 14px minmax(0, 1fr) 16px; border-radius: 31px 24px 24px 31px; }
/* the same cut for the small capsule: the left end's 28 px circle 14 px in, the right end's 21 px circles 5 px in */
.capsule.small .label {
  --cut: radial-gradient(circle 28px at 14px 28px, #000 28px, #0000 29px) 0 0 / 15px 100% no-repeat,
    linear-gradient(#000 0 0) 13px 0 / calc(100% - 17px) 100% no-repeat,
    radial-gradient(circle 21px at 1px 21px, #000 21px, #0000 22px) 100% 0 / 6px 100% no-repeat,
    radial-gradient(circle 21px at 1px 35px, #000 21px, #0000 22px) 100% 0 / 6px 100% no-repeat;
}
.capsule.small .num { font-size: 1.05rem; }
.capsule.small .name { font-size: 0.78rem; }
.capsule.small .st { font-size: 0.5rem; }
.capsule.small .label img { width: 26px; height: 26px; }
.capsule.small .neck { right: -11px; top: calc(50% - 8px); width: 11px; height: 16px; }
.capsule.small .knob { right: -26px; top: calc(50% - 13px); width: 16px; height: 26px; border-radius: 5px; }
.capsule.small .lock { right: -18px; top: calc(50% - 9px); width: 16.5px; height: 22.5px; }

/* ---------- the puff when a capsule pops ---------- */
.poof { position: absolute; left: 50%; top: 50%; width: 120px; height: 80px; margin: -40px 0 0 -60px; image-rendering: pixelated; pointer-events: none; z-index: 3; animation: poof 0.65s ease-out forwards; }
@keyframes poof { 0% { transform: scale(0.3); opacity: 1; } 70% { opacity: 0.9; } 100% { transform: scale(1.7); opacity: 0; } }
.capsule.popping { animation: shake 0.3s steps(3, end); }
@keyframes shake { 0% { transform: translateX(0); } 33% { transform: translateX(-3px) rotate(-1deg); } 66% { transform: translateX(3px) rotate(1deg); } 100% { transform: translateX(0); } }

/* ---------- a capsule thrown, as in the anime: it leaves its pocket, flies, lands on its shadow and bursts ---------- */
.capsule.thrown { position: fixed; z-index: 1001; margin: 0; pointer-events: none; transition: none; }
.capsule.gone { visibility: hidden; }
.landing { position: fixed; z-index: 1000; width: 70px; height: 14px; border-radius: 50%; background: rgba(10, 15, 36, 0.55); pointer-events: none; opacity: 0; transform: translate(-50%, -50%); }
.poof.landed { position: fixed; z-index: 1002; width: 240px; height: 160px; margin: -80px 0 0 -120px; }

/* ---------- the smoke between pages: it bursts out of the capsule, fills the screen, then clears on the feature's page ---------- */
.smoke { position: fixed; inset: 0; z-index: 1000; pointer-events: none; overflow: hidden; }
.smoke::before { content: ""; position: absolute; inset: 0; background: #F4F7FF; clip-path: circle(0 at var(--x) var(--y)); animation: smoke-fill 0.6s ease-in forwards; }
.smoke-puff { position: absolute; width: 180px; height: 120px; margin: -60px 0 0 -90px; image-rendering: pixelated; animation: smoke-out 0.6s ease-out forwards; }
@keyframes smoke-fill { to { clip-path: circle(150vmax at var(--x) var(--y)); } }
@keyframes smoke-out { from { transform: translate(0, 0) scale(0.3); } to { transform: translate(var(--dx), var(--dy)) scale(2.6); } }
.smoke.clearing::before { clip-path: none; animation: smoke-clear 0.75s ease-out forwards; }
.smoke.clearing .smoke-puff { animation: smoke-away 0.75s ease-out forwards; }
@keyframes smoke-clear { from { opacity: 1; } to { opacity: 0; } }
@keyframes smoke-away { from { transform: scale(2.6); opacity: 1; } to { transform: translate(var(--dx), var(--dy)) scale(3.4); opacity: 0; } }

/* ---------- the case in the bar, on a feature's own page ---------- */
.bar-outer > nav { position: relative; }
.case-btn { display: inline-flex; align-items: center; gap: 8px; font-family: var(--f-display); font-weight: 600; font-size: 0.95rem; padding: 5px 12px; border: 0; border-radius: 999px; background: none; color: var(--ink); cursor: pointer; }
.case-btn[aria-expanded="true"] { background: #A6DCCB; box-shadow: inset 0 0 0 2px var(--outline); }
.case-ico { width: 20px; height: 15px; border: 2px solid var(--outline); border-radius: 4px; background: linear-gradient(#7CC3AE 0 5px, var(--outline) 5px 7px, #A6DCCB 7px); }
.case-panel { position: absolute; right: var(--gutter-r, 16px); top: calc(100% + 12px); width: min(560px, calc(100vw - 32px)); z-index: 20; }

@media (max-width: 560px) {
  .slots { grid-template-columns: minmax(0, 1fr); }
  .slots > .slot:last-child:nth-child(odd), .box.small .slots > .slot:last-child:nth-child(odd) { width: auto; justify-self: stretch; }
}
@media (prefers-reduced-motion: reduce) {
  .poof, .smoke, .capsule.popping { animation: none; }
  .poof, .smoke { display: none; }
  .capsule { transition: none; }
  html.arriving body::after { display: none; }
}

/* ---------- the legal links on the full-screen feature pages, which have no footer: small, bottom left ---------- */
.legal-corner { position: fixed; left: max(10px, env(safe-area-inset-left, 0px)); bottom: calc(10px + env(safe-area-inset-bottom, 0px)); z-index: 6; margin: 0; display: grid; gap: 2px; font-family: var(--f-display); font-weight: 600; font-size: 0.7rem; line-height: 1.2; }
.legal-corner a { color: var(--fg); text-decoration: none; text-shadow: 1px 1px 0 var(--shadow); opacity: 0.8; }
.legal-corner a:hover, .legal-corner a:focus-visible { text-decoration: underline; opacity: 1; }
