/* Frosted portfolio glass on the original vertical cards; metallic controls stay unchanged. */
#case-portfolio {
  --case-card-width: 360px;
  --case-card-min-height: 560px;
  position: relative;
  width: 100vw;
  margin-left: calc(50% - 50vw);
  padding: 12px 0 16px;
  overflow: clip;
  scroll-margin-top: 80px;
  color: #2d2420;
  font-family: 'Noto Sans JP', sans-serif;
}

#case-portfolio .case-bento-stage {
  position: relative;
  width: 100%;
  height: auto;
  min-height: 0;
  margin: 0;
  padding: 16px 0 24px;
  overflow: visible;
  touch-action: pan-y pinch-zoom;
}

/* Every card contributes to the same grid row, including hidden cards.
   The tallest case sets a stable stage height without clipping its copy. */
#case-portfolio .case-bento-pivot {
  position: relative;
  inset: auto;
  display: grid;
  grid-template-columns: minmax(0, var(--case-card-width));
  justify-content: center;
  align-items: stretch;
  width: 100%;
  perspective: 1100px;
  perspective-origin: 50% 50%;
  transform-style: preserve-3d;
  animation: none;
}

#case-portfolio .case-bento-card {
  --case-accent: #2d2420;
  position: relative;
  inset: auto;
  grid-area: 1 / 1;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  width: 100%;
  height: auto;
  min-width: 0;
  min-height: var(--case-card-min-height);
  margin: 0;
  padding: 34px 28px 30px;
  border: 1px solid rgba(255, 255, 255, 0.88);
  border-radius: 16px;
  /* The section is already softly blurred. Static translucent layers give the
     glass its reflections without re-sampling a backdrop during each swipe. */
  background:
    linear-gradient(125deg, #ffffff70, #ffffff00 32% 72%, #ffe1a826),
    linear-gradient(140deg, #fff5dac2, #ffbc8166 48%, #ffe6dfe0);
  box-shadow:
    inset 0 1px 1px #fffffff2,
    inset 0 -1px 1px #88582724,
    inset 1px 0 1px #ffffffa6,
    0 16px 38px #603f1c17,
    0 2px 6px #77491e0d;
  color: #2d2420;
  text-align: left;
  text-decoration: none;
  overflow: visible;
  overflow-wrap: break-word;
  word-break: normal;
  line-break: strict;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transform-origin: 50% 50%;
  transform: translateX(0) translateZ(-100px) scale(0.9);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  z-index: 0;
  transition: transform 0.42s cubic-bezier(0.22, 0.61, 0.36, 1), opacity 0.32s ease;
}

#case-portfolio .case-bento-card::after { content: none; }
#case-portfolio .case-bento-card::before {
  content: '';
  position: absolute;
  inset: 3px;
  z-index: -1;
  border: 1px solid #ffffff52;
  border-radius: 12px;
  /* A frosted reading surface stops the rear cards' text showing through on
     narrow screens; only the glass rim needs to transmit the backdrop. */
  background:
    linear-gradient(125deg, #ffffff70, #ffffff00 32% 72%, #ffe1a826),
    linear-gradient(140deg, #fffaf3, #fff8f0 48%, #ffeddf);
  box-shadow: inset 0 1px 0 #ffffffcc;
  pointer-events: none;
}
#case-portfolio .case-bento-card > * { flex-shrink: 0; }
#case-portfolio .case-bento-card .text-unit {
  display: inline-block;
  max-width: 100%;
  white-space: normal;
}
#case-portfolio .case-bento-card.is-active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  z-index: 3;
  transform: translateX(0) translateZ(0) rotateY(0deg) scale(1);
}
#case-portfolio .case-bento-card.is-prev {
  pointer-events: auto;
  opacity: 0.88;
  visibility: visible;
  z-index: 2;
  transform: translateX(-105%) translateZ(-48px) rotateY(34deg) scale(0.94);
}
#case-portfolio .case-bento-card.is-next {
  pointer-events: auto;
  opacity: 0.88;
  visibility: visible;
  z-index: 2;
  transform: translateX(105%) translateZ(-48px) rotateY(-34deg) scale(0.94);
}
#case-portfolio .case-bento-card.is-rest {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

#case-portfolio .case-bento-card--fujitsu { --case-accent: #8a2b00; }
#case-portfolio .case-bento-card--senn { --case-accent: #7d2424; }
#case-portfolio .case-bento-card--arth { --case-accent: #1a5d42; }
#case-portfolio .case-bento-card--pebble { --case-accent: #2c3e66; }
#case-portfolio .case-bento-card--spintegrate { --case-accent: #574a80; }
#case-portfolio .case-bento-card--satobiz { --case-accent: #c2361f; }

#case-portfolio .case-bento-logo {
  display: block;
  width: 132px;
  height: 72px;
  max-width: 100%;
  margin: 0 0 24px;
  object-fit: contain;
  object-position: left center;
  opacity: 1;
  filter: none;
}
#case-portfolio .case-bento-card--senn .case-bento-logo { width: 66px; }
#case-portfolio .case-bento-card--satobiz .case-bento-logo { width: 92px; }
#case-portfolio .case-bento-logo-text {
  display: flex;
  align-items: center;
  width: auto;
  font-family: 'Noto Serif JP', serif;
  font-size: 25px;
  font-weight: 900;
  line-height: 1.3;
  letter-spacing: 0.02em;
  color: var(--case-accent);
}
#case-portfolio .case-bento-meta {
  margin: 0 0 20px;
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.65;
  letter-spacing: 0.02em;
  color: #5e5651;
}
#case-portfolio .case-bento-keyword {
  margin: 0 0 12px;
  font-family: 'Noto Serif JP', serif;
  font-size: 54px;
  font-weight: 700;
  line-height: 1.18;
  letter-spacing: -0.025em;
  white-space: nowrap;
  color: var(--case-accent);
}
#case-portfolio .case-bento-unit {
  margin-left: 0.12em;
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 0.4em;
  font-weight: 600;
  letter-spacing: 0;
  color: #655b55;
}
#case-portfolio .case-bento-arrow-inline {
  margin: 0 0.12em;
  font-family: 'Inter', sans-serif;
  font-size: 0.55em;
  font-weight: 300;
  color: var(--case-accent);
}
#case-portfolio .case-bento-keyword-sub,
#case-portfolio .case-bento-substat {
  margin: 0 0 10px;
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.65;
  letter-spacing: 0.01em;
  color: #5e5651;
}
#case-portfolio .case-bento-substat b { font-weight: 800; color: var(--case-accent); }
#case-portfolio .case-bento-quote {
  margin: 22px 0 10px;
  padding: 0;
  font-family: 'Noto Serif JP', serif;
  font-size: 21px;
  font-weight: 600;
  line-height: 1.7;
  letter-spacing: 0.02em;
  color: var(--case-accent);
}
#case-portfolio .case-bento-attribution {
  margin: 0 0 16px;
  padding: 0;
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.65;
  letter-spacing: 0.01em;
  color: #655b55;
}
#case-portfolio .case-bento-arrow {
  align-self: flex-end;
  margin-top: auto;
  font-family: 'Inter', sans-serif;
  font-size: 22px;
  font-weight: 300;
  line-height: 1.2;
  color: #655b55;
}

/* Keep the existing 58 × 64 controls and their exact metallic SVG treatment. */
#case-portfolio .portfolio-controls,
#case-portfolio .case-bento-controls {
  position: relative;
  z-index: 3;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 26px;
  min-height: 64px;
  margin: 0 auto;
  padding: 6px 0;
}
#case-portfolio .portfolio-bracket {
  position: relative;
  display: inline-grid;
  place-content: center;
  flex: none;
  width: 58px;
  height: 64px;
  min-width: 44px;
  min-height: 44px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: 0 0;
  color: #392d23;
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
}
#case-portfolio .portfolio-bracket::before {
  content: '';
  position: absolute;
  inset: 13px 3px 6px;
  border-radius: 50%;
  background: radial-gradient(#ff9b4a59, #ffe1691f 40%, #0000 70%);
  opacity: 0.4;
  filter: blur(5px);
  pointer-events: none;
  transition: opacity 0.35s, transform 0.35s;
}
#case-portfolio .portfolio-bracket-mark {
  display: block;
  width: 42px;
  height: 54px;
  filter: drop-shadow(1px 5px 4px #7e301826);
  transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}
#case-portfolio .portfolio-bracket-mark svg { display: block; width: 100%; height: 100%; }
#case-portfolio .portfolio-bracket[data-direction='previous'] svg { transform: scaleX(-1); }
#case-portfolio .portfolio-bracket:focus-visible .portfolio-bracket-mark { transform: translateY(-3px) scale(1.05); }
#case-portfolio .portfolio-bracket:active .portfolio-bracket-mark { transform: translateY(1px) scale(0.96); }
#case-portfolio :where(a, button):focus-visible { outline: 2px solid #9d3d13; outline-offset: 5px; }
#case-portfolio .case-bento-stage:focus-visible { outline: 2px solid #9d3d13; outline-offset: -3px; }
#case-portfolio .portfolio-sr-only,
#case-portfolio .case-bento-status {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  clip-path: inset(50%);
  white-space: nowrap;
  overflow: hidden;
}
@media (hover: hover) {
  #case-portfolio .portfolio-bracket:hover .portfolio-bracket-mark {
    filter: drop-shadow(1px 7px 7px #7e30183d);
    transform: translateY(-3px) scale(1.05);
  }
  #case-portfolio .portfolio-bracket:hover::before { opacity: 1; transform: scale(1.2); }
}
@media (max-width: 767px) {
  #case-portfolio { --case-card-width: min(340px, calc(100vw - 56px)); --case-card-min-height: 520px; }
  #case-portfolio .case-bento-stage { padding-top: 12px; }
  #case-portfolio .case-bento-pivot { perspective: 850px; }
  #case-portfolio .case-bento-card { padding: 26px 22px 24px; }
  #case-portfolio .case-bento-card.is-prev { transform: translateX(-79%) translateZ(-90px) rotateY(34deg) scale(0.9); }
  #case-portfolio .case-bento-card.is-next { transform: translateX(79%) translateZ(-90px) rotateY(-34deg) scale(0.9); }
  #case-portfolio .case-bento-logo { height: 62px; width: 116px; margin-bottom: 18px; }
  #case-portfolio .case-bento-card--senn .case-bento-logo { width: 54px; }
  #case-portfolio .case-bento-card--satobiz .case-bento-logo { width: 76px; }
  #case-portfolio .case-bento-logo-text { width: auto; font-size: 23px; }
  #case-portfolio .case-bento-meta { font-size: 13px; margin-bottom: 16px; }
  #case-portfolio .case-bento-keyword { font-size: 46px; }
  #case-portfolio .case-bento-keyword-sub,
  #case-portfolio .case-bento-substat,
  #case-portfolio .case-bento-attribution { font-size: 13px; }
  #case-portfolio .case-bento-quote { margin-top: 18px; font-size: 19px; }
  #case-portfolio .portfolio-controls,
  #case-portfolio .case-bento-controls { gap: 22px; }
}
@media (prefers-reduced-motion: reduce) {
  #case-portfolio .case-bento-card,
  #case-portfolio .portfolio-bracket-mark,
  #case-portfolio .portfolio-bracket::before { transition: none; }
}

@media (prefers-reduced-transparency: reduce), (prefers-contrast: more) {
  #case-portfolio .case-bento-card { background: #fffaf4; }
  #case-portfolio .case-bento-card::before { background: #fffaf4; }
  #case-portfolio .case-bento-card.is-prev,
  #case-portfolio .case-bento-card.is-next { opacity: 1; }
}

/* If script loading fails, all cases remain readable in document order. */
#case-portfolio.is-fallback .case-bento-stage {
  height: auto;
  padding: 0;
  perspective: none;
}
#case-portfolio.is-fallback .case-bento-pivot {
  perspective: none;
  display: grid;
  grid-template-columns: minmax(0, var(--case-card-width));
  gap: 24px;
  transform-style: flat;
}
#case-portfolio.is-fallback .case-bento-card {
  grid-area: auto;
  width: 100%;
  min-height: 0;
  margin: 0 auto;
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: none;
  transition: none;
}
#case-portfolio.is-fallback .portfolio-controls,
#case-portfolio.is-fallback .case-bento-controls { display: none; }
